[mod] vuetify 2.3.16
This commit is contained in:
parent
a5f2c39987
commit
d28c1b94aa
12 changed files with 259 additions and 224 deletions
|
@ -22,7 +22,7 @@ const MimeTypes=new function(){
|
||||||
"image/svg+xml":{ mode:"svg"}
|
"image/svg+xml":{ mode:"svg"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// mode to {icon, format function}
|
||||||
this.mode={
|
this.mode={
|
||||||
"text": {
|
"text": {
|
||||||
"icon": "library_books"
|
"icon": "library_books"
|
||||||
|
@ -44,11 +44,29 @@ const MimeTypes=new function(){
|
||||||
"icon": "spa"
|
"icon": "spa"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.modeForMime=function(mimetype){
|
||||||
|
var r= this.contentType[mimetype] && this.contentType[mimetype].mode
|
||||||
|
return r || 'text'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.headers= [
|
||||||
|
{ text: 'Name', value: 'name'},
|
||||||
|
{ text: 'Ace Mode', value: 'mode' },
|
||||||
|
{ text: 'Icon', value: 'icon' },
|
||||||
|
{ text: 'Format', value: 'format' }
|
||||||
|
];
|
||||||
|
|
||||||
// return [{name:.. mode:..}..]
|
// return [{name:.. mode:..}..]
|
||||||
this.list=function(){
|
this.list=function(){
|
||||||
var that=this
|
var that=this
|
||||||
var h= Object.keys(this.contentType).map(
|
var h= Object.keys(this.contentType).map(
|
||||||
function(k){ return {name: k, mode: that.contentType[k].mode}}
|
function(k){ var mode=that.modeForMime(k)
|
||||||
|
return {name: k,
|
||||||
|
mode: mode,
|
||||||
|
icon: that.icon(mode),
|
||||||
|
format: !!that.mode[mode]
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return h
|
return h
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,10 +115,11 @@
|
||||||
noDataMsg:{ default: "No data found."},
|
noDataMsg:{ default: "No data found."},
|
||||||
title:{ default: "" },
|
title:{ default: "" },
|
||||||
entity:{ },
|
entity:{ },
|
||||||
|
initItems: { default: function(){return []}},
|
||||||
query: {default: function(){return {filter:null}}},
|
query: {default: function(){return {filter:null}}},
|
||||||
showSelect: { default: false },
|
showSelect: { default: false },
|
||||||
multiSort: { default: false },
|
multiSort: { default: false },
|
||||||
filter: { default: []},
|
filter: { default: function(){return []}},
|
||||||
customFilter: {default: function(value, search, item) {
|
customFilter: {default: function(value, search, item) {
|
||||||
return value != null &&
|
return value != null &&
|
||||||
search != null &&
|
search != null &&
|
||||||
|
@ -129,9 +130,9 @@
|
||||||
|
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
|
items: [],
|
||||||
selected: [],
|
selected: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
items: [],
|
|
||||||
showSelectL: this.showSelect,
|
showSelectL: this.showSelect,
|
||||||
multiSortL: this.multiSort,
|
multiSortL: this.multiSort,
|
||||||
autoRefreshL: false
|
autoRefreshL: false
|
||||||
|
@ -140,15 +141,18 @@
|
||||||
|
|
||||||
methods:{
|
methods:{
|
||||||
getItems(){
|
getItems(){
|
||||||
if(this.dataUri === null) return;
|
if(this.dataUri === null) {
|
||||||
this.loading=true;
|
this.items= this.initItems
|
||||||
HTTP.get(this.dataUri)
|
} else {
|
||||||
.then(r=>{
|
this.loading=true;
|
||||||
this.loading=false;
|
HTTP.get(this.dataUri)
|
||||||
console.log("qd-table items:",r.data.items,"headers ",this.headers);
|
.then(r=>{
|
||||||
this.items=r.data.items;
|
this.loading=false;
|
||||||
if(this.autoRefreshL) this.timer=setTimeout(()=>{ this.getItems() }, 10000);
|
console.log("qd-table items:",r.data.items,"headers ",this.headers);
|
||||||
})
|
this.items=r.data.items;
|
||||||
|
if(this.autoRefreshL) this.timer=setTimeout(()=>{ this.getItems() }, 10000);
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
copy(){
|
copy(){
|
||||||
|
|
|
@ -141,13 +141,12 @@
|
||||||
<v-progress-linear v-if="busy" v-bind:indeterminate="true" ></v-progress-linear>
|
<v-progress-linear v-if="busy" v-bind:indeterminate="true" ></v-progress-linear>
|
||||||
|
|
||||||
<v-card-text v-if="!busy">
|
<v-card-text v-if="!busy">
|
||||||
<v-flex xs12 style="height:70vh" fill-height>
|
<v-flex xs12 style="height:70vh" fill-height>
|
||||||
|
<vue-ace :content="contentA" :mode="mode" :wrap="wrap" :settings="aceSettings"
|
||||||
<vue-ace :content="contentA" :mode="mode" :wrap="wrap" :settings="aceSettings"
|
:events="events" v-resize="onResize" :completer="$aceExtras.basexCompleter" :snippets="$aceExtras.snippets"
|
||||||
:events="events" v-resize="onResize" :completer="$aceExtras.basexCompleter" :snippets="$aceExtras.snippets"
|
v-on:change-content="changeContentA"
|
||||||
v-on:change-content="changeContentA"
|
v-on:annotation="annotation"></vue-ace>
|
||||||
v-on:annotation="annotation"></vue-ace>
|
</v-flex>
|
||||||
</v-flex>
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
<qd-confirm v-model="clearDialog" @confirm="reset">Delete all edit text?</qd-confirm>
|
<qd-confirm v-model="clearDialog" @confirm="reset">Delete all edit text?</qd-confirm>
|
||||||
|
@ -162,7 +161,6 @@ v-on:annotation="annotation"></vue-ace>
|
||||||
};`,
|
};`,
|
||||||
mode: 'xquery',
|
mode: 'xquery',
|
||||||
url: '',
|
url: '',
|
||||||
protocol: 'webfile',
|
|
||||||
name: '',
|
name: '',
|
||||||
path: [],
|
path: [],
|
||||||
mimetype: "",
|
mimetype: "",
|
||||||
|
@ -199,10 +197,11 @@ v-on:annotation="annotation"></vue-ace>
|
||||||
this.url=url
|
this.url=url
|
||||||
this.name=a.pop()
|
this.name=a.pop()
|
||||||
this.path=a
|
this.path=a
|
||||||
HTTP.get("edit",{params: {url:url,protocol:this.protocol}})
|
HTTP.get("edit",{params: {url:url}})
|
||||||
.then(r=>{
|
.then(r=>{
|
||||||
//console.log(r)
|
//console.log(r)
|
||||||
this.setMode(r.data.mimetype)
|
this.mimetype=r.data.mimetype
|
||||||
|
this.mode= this.$MimeTypes.modeForMime(this.mimetype)
|
||||||
this.contentA=r.data.data
|
this.contentA=r.data.data
|
||||||
|
|
||||||
this.busy=false
|
this.busy=false
|
||||||
|
@ -230,7 +229,6 @@ v-on:annotation="annotation"></vue-ace>
|
||||||
save(){
|
save(){
|
||||||
alert("TODO save: "+this.url);
|
alert("TODO save: "+this.url);
|
||||||
var data= {
|
var data= {
|
||||||
protocol:this.protocol,
|
|
||||||
url: this.url, //gave the values directly for testing
|
url: this.url, //gave the values directly for testing
|
||||||
data: this.contentA
|
data: this.contentA
|
||||||
}
|
}
|
||||||
|
@ -288,6 +286,9 @@ v-on:annotation="annotation"></vue-ace>
|
||||||
},
|
},
|
||||||
|
|
||||||
computed:{
|
computed:{
|
||||||
|
protocol(){
|
||||||
|
return this.url.split(':').shift()
|
||||||
|
},
|
||||||
icon(){
|
icon(){
|
||||||
return (this.protocol=="xmldb")?"account_balance":"folder"
|
return (this.protocol=="xmldb")?"account_balance":"folder"
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,6 @@ v-on:annotation="annotation"></vue-ace>
|
||||||
created(){
|
created(){
|
||||||
//https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
|
//https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
|
||||||
document.addEventListener('beforeunload', this.leaving);
|
document.addEventListener('beforeunload', this.leaving);
|
||||||
this.protocol=this.$route.query.protocol?this.$route.query.protocol:this.protocol
|
|
||||||
var url=this.$route.query.url
|
var url=this.$route.query.url
|
||||||
if(url) this.fetch(url)
|
if(url) this.fetch(url)
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,6 +7,7 @@ module namespace vue-api = 'quodatum:vue.api';
|
||||||
import module namespace rest = "http://exquery.org/ns/restxq";
|
import module namespace rest = "http://exquery.org/ns/restxq";
|
||||||
import module namespace session = "http://basex.org/modules/session";
|
import module namespace session = "http://basex.org/modules/session";
|
||||||
import module namespace ufile = 'vue-poc/file' at "../../lib/file.xqm";
|
import module namespace ufile = 'vue-poc/file' at "../../lib/file.xqm";
|
||||||
|
import module namespace resolve = 'urn:quodatum:resolve' at "../../lib/resolve.xqm";
|
||||||
|
|
||||||
import module namespace mt = 'urn:quodatum:data:mimetype' at "../../lib/mimetype.xqm";
|
import module namespace mt = 'urn:quodatum:data:mimetype' at "../../lib/mimetype.xqm";
|
||||||
declare namespace c="http://www.w3.org/ns/xproc-step";
|
declare namespace c="http://www.w3.org/ns/xproc-step";
|
||||||
|
@ -18,19 +19,17 @@ declare namespace c="http://www.w3.org/ns/xproc-step";
|
||||||
declare
|
declare
|
||||||
%rest:GET %rest:path("/vue-poc/api/edit")
|
%rest:GET %rest:path("/vue-poc/api/edit")
|
||||||
%rest:query-param("url", "{ $url }")
|
%rest:query-param("url", "{ $url }")
|
||||||
%rest:query-param("protocol", "{ $protocol }")
|
|
||||||
%rest:produces("application/json")
|
%rest:produces("application/json")
|
||||||
%output:method("json")
|
%output:method("json")
|
||||||
function vue-api:edit-get($url as xs:string, $protocol as xs:string)
|
function vue-api:edit-get($url as xs:string)
|
||||||
{
|
{
|
||||||
|
let $u:=resolve:uri($url)
|
||||||
let $reader := map{
|
return <json type="object">{
|
||||||
"webfile": vue-api:get-webfile#1,
|
element protocol{ $u?protocol},
|
||||||
"xmldb": vue-api:get-basexdb#1
|
element uri { $u?uri },
|
||||||
}
|
element mimetype { fetch:content-type($u?uri) },
|
||||||
let $reader:=trace($reader)
|
element data { $u?fnGet() }
|
||||||
let $fn:=($reader($protocol),vue-api:get-webfile#1)[1]
|
}</json>
|
||||||
return $fn($url)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
|
|
|
@ -59,7 +59,9 @@
|
||||||
<template v-slot:item.start="{ item }">
|
<template v-slot:item.start="{ item }">
|
||||||
<span>{{ item.start | fromNow }}</span>
|
<span>{{ item.start | fromNow }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:item.writes="{ item }">
|
||||||
|
<span>*{{ item.writes }}</span>
|
||||||
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -12,11 +12,11 @@ declare variable $vue-login:SESSION-KEY := "id";
|
||||||
declare variable $vue-login:SESSION-VALUE := session:get($vue-login:SESSION-KEY);
|
declare variable $vue-login:SESSION-VALUE := session:get($vue-login:SESSION-KEY);
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
: Permission check: Area for logged-in users.
|
: Permission check:
|
||||||
: Checks if a session id exists for the current user; if not, redirects to the login page.
|
: @todo something useful
|
||||||
:)
|
:)
|
||||||
declare
|
declare
|
||||||
%perm:check('/vue-poc')
|
%perm:check('/vue-poc/api')
|
||||||
function vue-login:check-app() {
|
function vue-login:check-app() {
|
||||||
let $user := session:get('id')
|
let $user := session:get('id')
|
||||||
let $m:=``[path: `{ request:path() }`, user: `{ $user }`.]``
|
let $m:=``[path: `{ request:path() }`, user: `{ $user }`.]``
|
||||||
|
|
|
@ -36,14 +36,14 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:default="props">
|
<template v-slot:default="props">
|
||||||
<v-layout wrap >
|
<v-row align-content="start" >
|
||||||
<v-flex
|
<v-col
|
||||||
v-for="item in props.items"
|
v-for="item in props.items"
|
||||||
:key="item.name" >
|
:key="item.name" >
|
||||||
|
|
||||||
<v-card :hover="true" active-class="default-class qd-active" max-width="20em" min-width="20em">
|
<v-card :hover="true" active-class="default-class qd-active" max-width="20em" min-width="20em">
|
||||||
|
|
||||||
<v-toolbar color="blue lighten-3" >
|
<v-toolbar color="orange lighten-3" >
|
||||||
<v-toolbar-title>
|
<v-toolbar-title>
|
||||||
<router-link :to="{path:'entity/'+ item.name}">
|
<router-link :to="{path:'entity/'+ item.name}">
|
||||||
<v-avatar color="lime">
|
<v-avatar color="lime">
|
||||||
|
@ -59,8 +59,8 @@
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-card-text xs1 >{{ item.description }}</<v-card-text>
|
<v-card-text xs1 >{{ item.description }}</<v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-flex>
|
</v-col>
|
||||||
</v-layout>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
</v-data-iterator>
|
</v-data-iterator>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
|
|
@ -1,79 +1,27 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<template id="mimetype">
|
<template id="mimetype">
|
||||||
<v-container fluid grid-list-md>
|
<v-container fluid grid-list-md>
|
||||||
|
<qd-table :headers="$MimeTypes.headers" :init-items="items" item-key="name"
|
||||||
<v-data-iterator
|
:show-select="false" >
|
||||||
:items="items"
|
<template v-slot:item.name="{ item }">
|
||||||
:items-per-page.sync="itemsPerPage"
|
<span>{{ item.name }} </span>
|
||||||
:search="q"
|
</template>
|
||||||
hide-default-footer
|
<template v-slot:actions>
|
||||||
select-all
|
<v-list-item @click="remove">
|
||||||
:value="selected"
|
<v-list-item-avatar><v-icon>delete</v-icon></v-list-item-avatar>
|
||||||
>
|
<v-list-item-title>Delete todo</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
<template v-slot:header>
|
</template>
|
||||||
<v-toolbar >
|
</qd-table>
|
||||||
<v-toolbar-title>
|
|
||||||
mimetype TODO
|
|
||||||
<v-breadcrumbs :items="[{text:'Entities',to:'/entity'}]" >
|
|
||||||
<template slot="item" slot-scope="props">
|
|
||||||
<v-breadcrumbs-item :to="props.item.to" :disabled="props.item.disabled" :exact="true">
|
|
||||||
{{ props.item.text }}
|
|
||||||
</v-breadcrumbs-item>
|
|
||||||
</template>
|
|
||||||
</v-breadcrumbs>
|
|
||||||
</v-toolbar-title>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-text-field prepend-icon="filter_list" label="Filter..." v-model="q" type="search"
|
|
||||||
hide-details single-line @keyup.enter="setfilter"
|
|
||||||
clearable></v-text-field>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-btn @click="getItems" icon
|
|
||||||
:loading="loading"
|
|
||||||
:disabled="loading"
|
|
||||||
><v-icon>refresh</v-icon></v-btn>
|
|
||||||
<vp-entitylink entity="mimetype"></vp-entitylink>
|
|
||||||
</v-toolbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:default="props">
|
|
||||||
<v-layout wrap>
|
|
||||||
<v-flex
|
|
||||||
v-for="item in props.items"
|
|
||||||
:key="item.name"
|
|
||||||
xs12
|
|
||||||
sm6
|
|
||||||
md4
|
|
||||||
lg3
|
|
||||||
>
|
|
||||||
|
|
||||||
<v-card :hover="true" active-class="default-class qd-active" height="200px" max-height="200px">
|
|
||||||
|
|
||||||
<v-toolbar color="blue lighten-3" dense>
|
|
||||||
<v-toolbar-title>
|
|
||||||
<router-link :to="{path:'entity/'+ item.name}">
|
|
||||||
<v-avatar>
|
|
||||||
<v-icon>{{ item.iconclass }}</v-icon>
|
|
||||||
</v-avatar> {{ item.name }}
|
|
||||||
</v-toolbar-title>
|
|
||||||
</v-card-title>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-badge >
|
|
||||||
<span slot="badge">{{ item.nfields }}</span>
|
|
||||||
</v-badge>
|
|
||||||
</v-toolbar>
|
|
||||||
<v-card-text >{{ item.description }}</<v-card-text>
|
|
||||||
</v-card>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
</template>
|
|
||||||
</v-data-iterator>
|
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>{
|
<script>{
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
|
|
||||||
itemsPerPage: 100,
|
itemsPerPage: 100,
|
||||||
page: 1,
|
page: 1,
|
||||||
items:[],
|
items:[],
|
||||||
|
@ -86,15 +34,9 @@
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getItems(){
|
getItems(){
|
||||||
this.loading=true
|
this.items=this.$MimeTypes.list()
|
||||||
HTTP.get("data/entity",{params:{q:this.q}})
|
|
||||||
.then(r=>{
|
|
||||||
this.loading=false
|
|
||||||
//console.log(r.data)
|
|
||||||
//var items=r.data.items.filter(item=>{return item.text!="[GET] http://localhost:8984/vue-poc/api/log"})
|
|
||||||
this.items=r.data.items
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setfilter(){
|
setfilter(){
|
||||||
console.log("TODO",this.q);
|
console.log("TODO",this.q);
|
||||||
this.$router.push({ query: {url: this.url,
|
this.$router.push({ query: {url: this.url,
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
module namespace vue-rest = 'quodatum:vue.tasks';
|
module namespace vue-rest = 'quodatum:vue.tasks';
|
||||||
import module namespace query-a = 'vue-poc/query-a' at "../../lib/query-a.xqm";
|
import module namespace query-a = 'vue-poc/query-a' at "../../lib/query-a.xqm";
|
||||||
import module namespace hlog = 'quodatum.data.history' at '../../lib/history.xqm';
|
import module namespace hlog = 'quodatum.data.history' at '../../lib/history.xqm';
|
||||||
|
import module namespace resolve = 'urn:quodatum:resolve' at '../../lib/resolve.xqm';
|
||||||
|
|
||||||
declare namespace hist="urn:quodatum:vue-poc.history";
|
declare namespace hist="urn:quodatum:vue-poc.history";
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
|
@ -39,18 +41,19 @@ function vue-rest:task($task,$id)
|
||||||
{
|
{
|
||||||
let $taskdef:=doc("taskdef.xml")/tasks/task[@name=$task]
|
let $taskdef:=doc("taskdef.xml")/tasks/task[@name=$task]
|
||||||
let $url:=resolve-uri($taskdef/@url)
|
let $url:=resolve-uri($taskdef/@url)
|
||||||
let $info:=query-a:inspect($url)
|
|
||||||
|
|
||||||
let $h:=if($id) then hlog:get($id) else ()
|
let $h:=if($id) then hlog:get($id) else ()
|
||||||
return if($h) then (: use old values :)
|
let $info:= query-a:inspect($url)
|
||||||
|
let $info:= if($h) then (: use old values :)
|
||||||
let $v:=<values type="object">{
|
let $v:=<values type="object">{
|
||||||
$h/hist:task/hist:param!element{@name}{string(.)}
|
$h/hist:task/hist:param!element{@name}{string(.)}
|
||||||
}</values> =>trace("O/P")
|
}</values> =>trace("O/P")
|
||||||
return $info transform with {replace node ./values with $v}
|
return $info transform with {replace node ./values with $v}
|
||||||
else
|
else
|
||||||
$info
|
$info
|
||||||
|
return $info transform with { insert node <url2>{ resolve:special($url) }</url2> into . }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
: Run the named task and log history
|
: Run the named task and log history
|
||||||
:)
|
:)
|
||||||
|
|
|
@ -24,21 +24,21 @@ let $updating:=xquery:parse-uri($mod)/@updating/string()
|
||||||
let $d:=inspect:module($mod)
|
let $d:=inspect:module($mod)
|
||||||
let $vars:=$d/variable[@external="true"]
|
let $vars:=$d/variable[@external="true"]
|
||||||
return <json type="object">
|
return <json type="object">
|
||||||
<description>{ $d/description/string() }</description>
|
<description>{ $d/description/string() }</description>
|
||||||
<updating type="boolean" >{ $updating }</updating>
|
<updating type="boolean" >{ $updating }</updating>
|
||||||
<url >{ $mod }</url>
|
<url >{ $mod }</url>
|
||||||
<fields type="array">{
|
<fields type="array">{
|
||||||
$vars!
|
$vars!
|
||||||
<_ type="object">
|
<_ type="object">
|
||||||
<model>{ @name/string() }</model>
|
<model>{ @name/string() }</model>
|
||||||
<label>{ description/string() }</label>
|
<label>{ description/string() }</label>
|
||||||
<type>{ @type/string() }</type>
|
<type>{ @type/string() }</type>
|
||||||
</_>
|
</_>
|
||||||
}</fields>
|
}</fields>
|
||||||
<values type="object">{
|
<values type="object">{
|
||||||
$vars!element{@name}{default_tag/string()}
|
$vars!element{@name}{default_tag/string()}
|
||||||
}</values>
|
}</values>
|
||||||
</json>
|
</json>
|
||||||
};
|
};
|
||||||
|
|
||||||
(:~
|
(:~
|
||||||
|
|
83
src/vue-poc/lib/resolve.xqm
Normal file
83
src/vue-poc/lib/resolve.xqm
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
(:~
|
||||||
|
: resolve uri tools supports protocols: "xmldb" "webfile"
|
||||||
|
result map{
|
||||||
|
"protocol": one of "file", "xmldb"
|
||||||
|
"uri":
|
||||||
|
"fnGet": function#0 to get
|
||||||
|
}
|
||||||
|
@since Sept 2020
|
||||||
|
@author Andy Bunce
|
||||||
|
@copyright Quodatum Ltd
|
||||||
|
@version 0.0.4
|
||||||
|
:)
|
||||||
|
module namespace resolve = 'urn:quodatum:resolve';
|
||||||
|
import module namespace web = 'http://basex.org/modules/web';
|
||||||
|
|
||||||
|
(:~
|
||||||
|
:
|
||||||
|
:)
|
||||||
|
declare function resolve:uri($uri as xs:string)
|
||||||
|
as map(*){
|
||||||
|
let $t:=tokenize($uri,':')
|
||||||
|
let $protocol:= if(count($t) gt 1 ) then head($t) else ()
|
||||||
|
let $isDrive:= matches($protocol,"^[A-Za-z]$")
|
||||||
|
let $path:= tail($t)=>string-join(":")
|
||||||
|
let $uri:=switch ($protocol)
|
||||||
|
case "webfile"
|
||||||
|
return let $webroot:=db:system()/globaloptions/webpath/string()
|
||||||
|
return concat($webroot,$path)
|
||||||
|
case "xmldb"
|
||||||
|
return $path
|
||||||
|
|
||||||
|
case "file"
|
||||||
|
return web:decode-url($path)=>replace("^//*","")=>replace("/","\" || file:dir-separator())
|
||||||
|
default
|
||||||
|
return if ($isDrive) then $uri else $path
|
||||||
|
|
||||||
|
let $protocol:= switch (true())
|
||||||
|
case $isDrive
|
||||||
|
return "file"
|
||||||
|
|
||||||
|
case $protocol = "webfile"
|
||||||
|
return "file"
|
||||||
|
|
||||||
|
default
|
||||||
|
return $protocol
|
||||||
|
|
||||||
|
let $getfn:= switch ($protocol)
|
||||||
|
case "xmldb"
|
||||||
|
return function(){ doc($uri)}
|
||||||
|
|
||||||
|
default
|
||||||
|
return function(){ fetch:text($uri)}
|
||||||
|
|
||||||
|
return map{
|
||||||
|
"protocol": $protocol,
|
||||||
|
"uri": $uri,
|
||||||
|
"isDrive": $isDrive,
|
||||||
|
"fnGet": $getfn
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function resolve:meta($uri )
|
||||||
|
as map(*){
|
||||||
|
let $uri:=resolve:analyse($uri)
|
||||||
|
let $size:=50
|
||||||
|
return map:merge(($uri,map{"size": $size}))
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
declare function resolve:analyse($uri)
|
||||||
|
as map(*){
|
||||||
|
typeswitch($uri)
|
||||||
|
case map(*) return $uri
|
||||||
|
case xs:string return resolve:uri($uri)
|
||||||
|
default return error(xs:QName("resolve:analyse"),"type not supported")
|
||||||
|
};
|
||||||
|
|
||||||
|
declare function resolve:special($uri as xs:string)
|
||||||
|
as xs:string{
|
||||||
|
let $webroot:=db:system()/globaloptions/webpath/string()
|
||||||
|
let $_:=trace(($uri,$webroot),"special")
|
||||||
|
return $uri
|
||||||
|
};
|
|
@ -1,4 +1,4 @@
|
||||||
// generated 2020-11-01T22:01:41.739Z
|
// generated 2020-11-07T23:04:20.292Z
|
||||||
|
|
||||||
// src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/components/qd-autoheight.vue
|
// src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/components/qd-autoheight.vue
|
||||||
Vue.component('qd-autoheight',{template:`
|
Vue.component('qd-autoheight',{template:`
|
||||||
|
@ -617,10 +617,11 @@ Vue.component('qd-table',{template:`
|
||||||
noDataMsg:{ default: "No data found."},
|
noDataMsg:{ default: "No data found."},
|
||||||
title:{ default: "" },
|
title:{ default: "" },
|
||||||
entity:{ },
|
entity:{ },
|
||||||
|
initItems: { default: function(){return []}},
|
||||||
query: {default: function(){return {filter:null}}},
|
query: {default: function(){return {filter:null}}},
|
||||||
showSelect: { default: false },
|
showSelect: { default: false },
|
||||||
multiSort: { default: false },
|
multiSort: { default: false },
|
||||||
filter: { default: []},
|
filter: { default: function(){return []}},
|
||||||
customFilter: {default: function(value, search, item) {
|
customFilter: {default: function(value, search, item) {
|
||||||
return value != null &&
|
return value != null &&
|
||||||
search != null &&
|
search != null &&
|
||||||
|
@ -631,9 +632,9 @@ Vue.component('qd-table',{template:`
|
||||||
|
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
|
items: [],
|
||||||
selected: [],
|
selected: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
items: [],
|
|
||||||
showSelectL: this.showSelect,
|
showSelectL: this.showSelect,
|
||||||
multiSortL: this.multiSort,
|
multiSortL: this.multiSort,
|
||||||
autoRefreshL: false
|
autoRefreshL: false
|
||||||
|
@ -642,15 +643,18 @@ Vue.component('qd-table',{template:`
|
||||||
|
|
||||||
methods:{
|
methods:{
|
||||||
getItems(){
|
getItems(){
|
||||||
if(this.dataUri === null) return;
|
if(this.dataUri === null) {
|
||||||
this.loading=true;
|
this.items= this.initItems
|
||||||
HTTP.get(this.dataUri)
|
} else {
|
||||||
.then(r=>{
|
this.loading=true;
|
||||||
this.loading=false;
|
HTTP.get(this.dataUri)
|
||||||
console.log("qd-table items:",r.data.items,"headers ",this.headers);
|
.then(r=>{
|
||||||
this.items=r.data.items;
|
this.loading=false;
|
||||||
if(this.autoRefreshL) this.timer=setTimeout(()=>{ this.getItems() }, 10000);
|
console.log("qd-table items:",r.data.items,"headers ",this.headers);
|
||||||
})
|
this.items=r.data.items;
|
||||||
|
if(this.autoRefreshL) this.timer=setTimeout(()=>{ this.getItems() }, 10000);
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
copy(){
|
copy(){
|
||||||
|
@ -1683,7 +1687,7 @@ const MimeTypes=new function(){
|
||||||
"image/svg+xml":{ mode:"svg"}
|
"image/svg+xml":{ mode:"svg"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// mode to {icon, format function}
|
||||||
this.mode={
|
this.mode={
|
||||||
"text": {
|
"text": {
|
||||||
"icon": "library_books"
|
"icon": "library_books"
|
||||||
|
@ -1705,11 +1709,29 @@ const MimeTypes=new function(){
|
||||||
"icon": "spa"
|
"icon": "spa"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
this.modeForMime=function(mimetype){
|
||||||
|
var r= this.contentType[mimetype] && this.contentType[mimetype].mode
|
||||||
|
return r || 'text'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.headers= [
|
||||||
|
{ text: 'Name', value: 'name'},
|
||||||
|
{ text: 'Ace Mode', value: 'mode' },
|
||||||
|
{ text: 'Icon', value: 'icon' },
|
||||||
|
{ text: 'Format', value: 'format' }
|
||||||
|
];
|
||||||
|
|
||||||
// return [{name:.. mode:..}..]
|
// return [{name:.. mode:..}..]
|
||||||
this.list=function(){
|
this.list=function(){
|
||||||
var that=this
|
var that=this
|
||||||
var h= Object.keys(this.contentType).map(
|
var h= Object.keys(this.contentType).map(
|
||||||
function(k){ return {name: k, mode: that.contentType[k].mode}}
|
function(k){ var mode=that.modeForMime(k)
|
||||||
|
return {name: k,
|
||||||
|
mode: mode,
|
||||||
|
icon: that.icon(mode),
|
||||||
|
format: !!that.mode[mode]
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
return h
|
return h
|
||||||
};
|
};
|
||||||
|
@ -3615,10 +3637,9 @@ const Edit=Vue.extend({template:`
|
||||||
<v-progress-linear v-if="busy" v-bind:indeterminate="true"></v-progress-linear>
|
<v-progress-linear v-if="busy" v-bind:indeterminate="true"></v-progress-linear>
|
||||||
|
|
||||||
<v-card-text v-if="!busy">
|
<v-card-text v-if="!busy">
|
||||||
<v-flex xs12 style="height:70vh" fill-height>
|
<v-flex xs12 style="height:70vh" fill-height>
|
||||||
|
<vue-ace :content="contentA" :mode="mode" :wrap="wrap" :settings="aceSettings" :events="events" v-resize="onResize" :completer="$aceExtras.basexCompleter" :snippets="$aceExtras.snippets" v-on:change-content="changeContentA" v-on:annotation="annotation"></vue-ace>
|
||||||
<vue-ace :content="contentA" :mode="mode" :wrap="wrap" :settings="aceSettings" :events="events" v-resize="onResize" :completer="$aceExtras.basexCompleter" :snippets="$aceExtras.snippets" v-on:change-content="changeContentA" v-on:annotation="annotation"></vue-ace>
|
</v-flex>
|
||||||
</v-flex>
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
<qd-confirm v-model="clearDialog" @confirm="reset">Delete all edit text?</qd-confirm>
|
<qd-confirm v-model="clearDialog" @confirm="reset">Delete all edit text?</qd-confirm>
|
||||||
|
@ -3632,7 +3653,6 @@ const Edit=Vue.extend({template:`
|
||||||
};`,
|
};`,
|
||||||
mode: 'xquery',
|
mode: 'xquery',
|
||||||
url: '',
|
url: '',
|
||||||
protocol: 'webfile',
|
|
||||||
name: '',
|
name: '',
|
||||||
path: [],
|
path: [],
|
||||||
mimetype: "",
|
mimetype: "",
|
||||||
|
@ -3669,10 +3689,11 @@ const Edit=Vue.extend({template:`
|
||||||
this.url=url
|
this.url=url
|
||||||
this.name=a.pop()
|
this.name=a.pop()
|
||||||
this.path=a
|
this.path=a
|
||||||
HTTP.get("edit",{params: {url:url,protocol:this.protocol}})
|
HTTP.get("edit",{params: {url:url}})
|
||||||
.then(r=>{
|
.then(r=>{
|
||||||
//console.log(r)
|
//console.log(r)
|
||||||
this.setMode(r.data.mimetype)
|
this.mimetype=r.data.mimetype
|
||||||
|
this.mode= this.$MimeTypes.modeForMime(this.mimetype)
|
||||||
this.contentA=r.data.data
|
this.contentA=r.data.data
|
||||||
|
|
||||||
this.busy=false
|
this.busy=false
|
||||||
|
@ -3700,7 +3721,6 @@ const Edit=Vue.extend({template:`
|
||||||
save(){
|
save(){
|
||||||
alert("TODO save: "+this.url);
|
alert("TODO save: "+this.url);
|
||||||
var data= {
|
var data= {
|
||||||
protocol:this.protocol,
|
|
||||||
url: this.url, //gave the values directly for testing
|
url: this.url, //gave the values directly for testing
|
||||||
data: this.contentA
|
data: this.contentA
|
||||||
}
|
}
|
||||||
|
@ -3758,6 +3778,9 @@ const Edit=Vue.extend({template:`
|
||||||
},
|
},
|
||||||
|
|
||||||
computed:{
|
computed:{
|
||||||
|
protocol(){
|
||||||
|
return this.url.split(':').shift()
|
||||||
|
},
|
||||||
icon(){
|
icon(){
|
||||||
return (this.protocol=="xmldb")?"account_balance":"folder"
|
return (this.protocol=="xmldb")?"account_balance":"folder"
|
||||||
}
|
}
|
||||||
|
@ -3766,7 +3789,6 @@ const Edit=Vue.extend({template:`
|
||||||
created(){
|
created(){
|
||||||
//https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
|
//https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
|
||||||
document.addEventListener('beforeunload', this.leaving);
|
document.addEventListener('beforeunload', this.leaving);
|
||||||
this.protocol=this.$route.query.protocol?this.$route.query.protocol:this.protocol
|
|
||||||
var url=this.$route.query.url
|
var url=this.$route.query.url
|
||||||
if(url) this.fetch(url)
|
if(url) this.fetch(url)
|
||||||
},
|
},
|
||||||
|
@ -5482,7 +5504,9 @@ const Jobs=Vue.extend({template:`
|
||||||
<template v-slot:item.start="{ item }">
|
<template v-slot:item.start="{ item }">
|
||||||
<span>{{ item.start | fromNow }}</span>
|
<span>{{ item.start | fromNow }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:item.writes="{ item }">
|
||||||
|
<span>*{{ item.writes }}</span>
|
||||||
|
</template>
|
||||||
</v-data-table>
|
</v-data-table>
|
||||||
</v-card>
|
</v-card>
|
||||||
`,
|
`,
|
||||||
|
@ -5922,12 +5946,12 @@ const Entity=Vue.extend({template:`
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:default="props">
|
<template v-slot:default="props">
|
||||||
<v-layout wrap>
|
<v-row align-content="start">
|
||||||
<v-flex v-for="item in props.items" :key="item.name">
|
<v-col v-for="item in props.items" :key="item.name">
|
||||||
|
|
||||||
<v-card :hover="true" active-class="default-class qd-active" max-width="20em" min-width="20em">
|
<v-card :hover="true" active-class="default-class qd-active" max-width="20em" min-width="20em">
|
||||||
|
|
||||||
<v-toolbar color="blue lighten-3">
|
<v-toolbar color="orange lighten-3">
|
||||||
<v-toolbar-title>
|
<v-toolbar-title>
|
||||||
<router-link :to="{path:'entity/'+ item.name}">
|
<router-link :to="{path:'entity/'+ item.name}">
|
||||||
<v-avatar color="lime">
|
<v-avatar color="lime">
|
||||||
|
@ -5943,8 +5967,8 @@ const Entity=Vue.extend({template:`
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-card-text xs1>{{ item.description }}<!--<v-card-text-->
|
<v-card-text xs1>{{ item.description }}<!--<v-card-text-->
|
||||||
</v-card-text></v-card>
|
</v-card-text></v-card>
|
||||||
</v-flex>
|
</v-col>
|
||||||
</v-layout>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
</v-data-iterator>
|
</v-data-iterator>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
@ -6199,59 +6223,25 @@ const Entity1data=Vue.extend({template:`
|
||||||
// src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/features/model/mimetype.vue
|
// src: file:///C:/Users/andy/git/vue-poc/src/vue-poc/features/model/mimetype.vue
|
||||||
const Mimetype=Vue.extend({template:`
|
const Mimetype=Vue.extend({template:`
|
||||||
<v-container fluid grid-list-md>
|
<v-container fluid grid-list-md>
|
||||||
|
<qd-table :headers="$MimeTypes.headers" :init-items="items" item-key="name" :show-select="false">
|
||||||
<v-data-iterator :items="items" :items-per-page.sync="itemsPerPage" :search="q" hide-default-footer select-all :value="selected">
|
<template v-slot:item.name="{ item }">
|
||||||
|
<span>{{ item.name }} </span>
|
||||||
<template v-slot:header>
|
</template>
|
||||||
<v-toolbar>
|
<template v-slot:actions>
|
||||||
<v-toolbar-title>
|
<v-list-item @click="remove">
|
||||||
mimetype TODO
|
<v-list-item-avatar><v-icon>delete</v-icon></v-list-item-avatar>
|
||||||
<v-breadcrumbs :items="[{text:'Entities',to:'/entity'}]">
|
<v-list-item-title>Delete todo</v-list-item-title>
|
||||||
<template slot="item" slot-scope="props">
|
</v-list-item>
|
||||||
<v-breadcrumbs-item :to="props.item.to" :disabled="props.item.disabled" :exact="true">
|
</template>
|
||||||
{{ props.item.text }}
|
</qd-table>
|
||||||
</v-breadcrumbs-item>
|
|
||||||
</template>
|
|
||||||
</v-breadcrumbs>
|
|
||||||
</v-toolbar-title>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-text-field prepend-icon="filter_list" label="Filter..." v-model="q" type="search" hide-details single-line @keyup.enter="setfilter" clearable></v-text-field>
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-btn @click="getItems" icon :loading="loading" :disabled="loading"><v-icon>refresh</v-icon></v-btn>
|
|
||||||
<vp-entitylink entity="mimetype"></vp-entitylink>
|
|
||||||
</v-toolbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-slot:default="props">
|
|
||||||
<v-layout wrap>
|
|
||||||
<v-flex v-for="item in props.items" :key="item.name" xs12 sm6 md4 lg3>
|
|
||||||
|
|
||||||
<v-card :hover="true" active-class="default-class qd-active" height="200px" max-height="200px">
|
|
||||||
|
|
||||||
<v-toolbar color="blue lighten-3" dense>
|
|
||||||
<v-toolbar-title>
|
|
||||||
<router-link :to="{path:'entity/'+ item.name}">
|
|
||||||
<v-avatar>
|
|
||||||
<v-icon>{{ item.iconclass }}</v-icon>
|
|
||||||
</v-avatar> {{ item.name }}
|
|
||||||
</router-link></v-toolbar-title>
|
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
|
||||||
<v-badge>
|
|
||||||
<span slot="badge">{{ item.nfields }}</span>
|
|
||||||
</v-badge>
|
|
||||||
</v-toolbar>
|
|
||||||
<v-card-text>{{ item.description }}<!--<v-card-text-->
|
|
||||||
</v-card-text></v-card>
|
|
||||||
</v-flex>
|
|
||||||
</v-layout>
|
|
||||||
</template>
|
|
||||||
</v-data-iterator>
|
|
||||||
</v-container>
|
</v-container>
|
||||||
`,
|
`,
|
||||||
|
|
||||||
data: function(){
|
data: function(){
|
||||||
return {
|
return {
|
||||||
|
|
||||||
itemsPerPage: 100,
|
itemsPerPage: 100,
|
||||||
page: 1,
|
page: 1,
|
||||||
items:[],
|
items:[],
|
||||||
|
@ -6264,15 +6254,9 @@ const Mimetype=Vue.extend({template:`
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getItems(){
|
getItems(){
|
||||||
this.loading=true
|
this.items=this.$MimeTypes.list()
|
||||||
HTTP.get("data/entity",{params:{q:this.q}})
|
|
||||||
.then(r=>{
|
|
||||||
this.loading=false
|
|
||||||
//console.log(r.data)
|
|
||||||
//var items=r.data.items.filter(item=>{return item.text!="[GET] http://localhost:8984/vue-poc/api/log"})
|
|
||||||
this.items=r.data.items
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setfilter(){
|
setfilter(){
|
||||||
console.log("TODO",this.q);
|
console.log("TODO",this.q);
|
||||||
this.$router.push({ query: {url: this.url,
|
this.$router.push({ query: {url: this.url,
|
||||||
|
|
Loading…
Add table
Reference in a new issue