diff --git a/src/vue-poc/components/router.js b/src/vue-poc/components/router.js index 3ecac73..4d6b0a2 100644 --- a/src/vue-poc/components/router.js +++ b/src/vue-poc/components/router.js @@ -19,7 +19,7 @@ const router = new VueRouter({ { path: '/server/users', component: Users,meta:{title:"Users"} }, { path: '/server/repo', component: Repo,meta:{title:"Repository"} }, { path: '/files', component: Files,meta:{title:"File system"},props:{protocol:"webfile"} }, - { path: '/database', component: Files,meta:{title:"Databases"},props:{protocol:"basexdb"} }, + { path: '/database', component: Files,meta:{title:"Databases"},props:{protocol:"xmldb"} }, { path: '/ping', component: Ping,meta:{title:"Ping"} }, { path: '/settings', component: Settings, meta:{title:"Settings"} }, { path: '/acesettings', component: Acesettings, meta:{title:"Editor settings"} }, diff --git a/src/vue-poc/features/collection/collections.xqm b/src/vue-poc/features/collection/collections.xqm index 4758f76..5dc933c 100644 --- a/src/vue-poc/features/collection/collections.xqm +++ b/src/vue-poc/features/collection/collections.xqm @@ -41,7 +41,7 @@ as element(json) { let $reader:=map{ "webfile":ufile:webfile#1, - "basexdb":ufile:basexdb#1 + "xmldb":ufile:xmldb#1 } let $items:=$reader($protocol)($url) return vue-api:items($items) @@ -53,32 +53,25 @@ declare function vue-api:items($items) as element(json) { - - {for $f in $items/c:directory + + {for $f in $items/* order by $f/@name/lower-case(.) return <_ type="object"> {vue-api:details($f,"folder")} } - - - {for $f in $items/c:file - order by $f/@name/lower-case(.) - return <_ type="object"> - {vue-api:details($f,"insert_drive_file")} - - } - + }; -declare function vue-api:details($f as element(*),$icon as xs:string) +declare function vue-api:details($f as element(*),$type as xs:string) as element(*)* { {$f/@name/string()} - ,{$icon} + ,{if(local-name($f)="file" )then "file" else "folder"} ,{$f/@last-modified/string()} ,{$f/@size/string()} + ,false ,unknown }; diff --git a/src/vue-poc/features/collection/files.vue b/src/vue-poc/features/collection/files.vue index a04be18..08d0e61 100644 --- a/src/vue-poc/features/collection/files.vue +++ b/src/vue-poc/features/collection/files.vue @@ -4,7 +4,7 @@ - + {{icon}} @@ -15,24 +15,27 @@ - + - - - Sel:{{selCount}} + + + + + - + - + more_vert @@ -49,20 +52,18 @@ + - - - - + - + - Folders ({{ folders.length }}) + Folders ({{ xfolders.length }}) - + - {{ item.icon }} + {{ itemIcon(item) }} {{ item.name }} @@ -77,11 +78,11 @@ - Files ({{ files.length }}) + Files ({{ xfiles.length }}) - - - {{ item.icon }} + + + {{ itemIcon(item) }} {{ item.name }} @@ -113,6 +114,7 @@ + @@ -122,18 +124,17 @@ data(){ return { url: "", - folders: [], - files: [], + items: [], q: "", busy: false, showInfo: false, - selected: null, + selected: [], buttons: [ {method: this.todo, icon: "view_quilt"}, {method: this.add, icon: "add"}, - {method: this.todo, icon: "refresh"}, + {method: this.load, icon: "refresh"}, {method: this.todo, icon: "sort"}, - {method: this.todo, icon: "select_all"} + {method: this.selectAll, icon: "select_all"} ], selopts: [ {method: this.todo, icon: "delete"}, @@ -153,12 +154,12 @@ selopts: [ folder (item) { this.url=this.url+item.name+"/" }, - load(url){ + load(){ + var url=this.url this.busy=true HTTP.get("collection",{params:{url:url,protocol:this.protocol}}) .then(r=>{ - this.folders=r.data.folders - this.files=r.data.files + this.items=r.data.items this.busy=false }) .catch(error=> { @@ -169,8 +170,7 @@ selopts: [ }, action(b){ - alert(b.icon) - b.method() + b.method(b.icon) }, add(){ alert("add") @@ -191,14 +191,29 @@ selopts: [ this.$router.push({ name: 'jobShow', params: {job:job }}) }) }, - todo(){ - alert("todo") + todo(icon){ + alert("todo: " + icon) + }, + itemIcon(item){ + return item.selected?"check_circle":"folder" + }, + selectAll(){ + this.items.forEach(item=>{item.selected=true}) + }, + selectNone(){ + this.items.forEach(item=>{item.selected=false}) } }, computed: { icon(){ - return (this.protocol=="basexdb")?"developer_mode":"folder" + return (this.protocol=="xmldb")?"developer_mode":"folder" }, + xfiles(){ + return this.items.filter(item=>{return item.type!="folder"}) + }, + xfolders(){ + return this.items.filter(item=>{return item.type=="folder"}) + }, // array of {name:"that", path:"/this/that/"} for url crumbs(){ var parts=this.url.split("/").filter((a)=>a.length>0) @@ -206,6 +221,9 @@ selopts: [ function(v,i,a){return {name:v, path:"/"+a.slice(0,i+1).join("/")+"/"}} ) return a + }, + selCount(){ + return this.items.reduce((acc,item)=>{return acc+(item.selected?1:0)},0) } }, watch:{ @@ -216,14 +234,14 @@ selopts: [ //console.log("ROUTE",vnew,vold) var url=this.$route.query.url this.url=url?url:"/"; - if(vnew.query.url != vold.query.url) this.load(this.url) + if(vnew.query.url != vold.query.url) this.load() } }, created:function(){ var url=this.$route.query.url this.url=url?url:"/"; this.q=this.$route.query.q || this.q - this.load(this.url) + this.load() } } diff --git a/src/vue-poc/features/edit/edit.vue b/src/vue-poc/features/edit/edit.vue index b383312..5f5af6f 100644 --- a/src/vue-poc/features/edit/edit.vue +++ b/src/vue-poc/features/edit/edit.vue @@ -221,7 +221,7 @@ v-on:annotation="annotation"> }) }, showfiles(){ - var target=this.protocol="basexdb"?"database":"files"; + var target=this.protocol="xmldb"?"database":"files"; router.push({ path: target, query: { url: this.path.join("/"),protocol:this.protocol }}) }, beautify(){ @@ -267,7 +267,7 @@ v-on:annotation="annotation"> }, computed:{ icon(){ - return (this.protocol=="basexdb")?"account_balance":"folder" + return (this.protocol=="xmldb")?"account_balance":"folder" } }, created(){ diff --git a/src/vue-poc/features/edit/edit.xqm b/src/vue-poc/features/edit/edit.xqm index 6a7b83c..5e5b79c 100644 --- a/src/vue-poc/features/edit/edit.xqm +++ b/src/vue-poc/features/edit/edit.xqm @@ -25,7 +25,7 @@ function vue-api:edit-get($url as xs:string,$protocol as xs:string) { let $reader := map{ "webfile":vue-api:get-webfile#1, - "basexdb":vue-api:get-basexdb#1 + "xmldb":vue-api:get-basexdb#1 } return $reader($protocol)($url) }; diff --git a/src/vue-poc/features/tasks/tasks.vue b/src/vue-poc/features/tasks/tasks.vue index 8661df9..e955c6f 100644 --- a/src/vue-poc/features/tasks/tasks.vue +++ b/src/vue-poc/features/tasks/tasks.vue @@ -2,6 +2,13 @@