diff --git a/.settings/de.loskutov.FileSync.prefs b/.settings/de.loskutov.FileSync.prefs
index 14dc75c..6500af3 100644
--- a/.settings/de.loskutov.FileSync.prefs
+++ b/.settings/de.loskutov.FileSync.prefs
@@ -1,5 +1,5 @@
WARNING=DO NOT MODIFY THIS FILE IF YOU DON'T UNDERSTAND
-defaultDestination=C\:/Program Files (x86)/basex/webapp
+defaultDestination=C\:/Users/andy/Desktop/basex.865b/webapp
defaultVariables=
eclipse.preferences.version=1
includeTeamPrivateFiles=false
diff --git a/src/vue-poc/static/core.js b/src/vue-poc/components/core.js
similarity index 92%
rename from src/vue-poc/static/core.js
rename to src/vue-poc/components/core.js
index 4e299e3..b07943d 100644
--- a/src/vue-poc/static/core.js
+++ b/src/vue-poc/components/core.js
@@ -58,8 +58,8 @@ Vue.component('nav-list', {
-
-
+
+
{{ item.icon }}
@@ -74,12 +74,9 @@ Vue.component('nav-list', {
-
-
-
+
+
+
{{ child.icon }}
@@ -89,10 +86,10 @@ Vue.component('nav-list', {
-
+
-
-
+
+
{{ item.icon }}
@@ -102,7 +99,6 @@ Vue.component('nav-list', {
-
`,
created:function(){
@@ -178,16 +174,16 @@ const app = new Vue({
{href: 'files', text: 'File system',icon: 'folder' },
{href: 'edit',text: 'edit',icon: 'mode_edit'},
{href: 'history',text: 'history',icon: 'history'},
+ {href: 'logs',text: 'Server logs',icon: 'dns'}
]},
{
icon: 'directions_run',
text: 'Actions' ,
model: false,
children: [
- {href: 'eval',text: 'Evaluate',icon: 'cake'},
- {href: 'tasks',text: 'Tasks',icon: 'build'},
- {href: 'jobs',text: 'Jobs',icon: 'print'},
- {href: 'logs',text: 'Server logs',icon: 'dns'}
+ {href: 'eval',text: 'Evaluate',icon: 'play_circle_outline'},
+ {href: 'jobs',text: 'Jobs',icon: 'dashboard'},
+ {href: 'tasks',text: 'Tasks',icon: 'history'},
]},
{
icon: 'more_horiz',
diff --git a/src/vue-poc/static/filters.js b/src/vue-poc/components/filters.js
similarity index 100%
rename from src/vue-poc/static/filters.js
rename to src/vue-poc/components/filters.js
diff --git a/src/vue-poc/components/my-component.vue b/src/vue-poc/components/my-component.vue
new file mode 100644
index 0000000..60dd53f
--- /dev/null
+++ b/src/vue-poc/components/my-component.vue
@@ -0,0 +1,12 @@
+
+
+ {{href}}link
+
+
+
diff --git a/src/vue-poc/components/nav-list.vue b/src/vue-poc/components/nav-list.vue
new file mode 100644
index 0000000..5361d1a
--- /dev/null
+++ b/src/vue-poc/components/nav-list.vue
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+ {{ item.heading }}
+
+
+
+ EDIT
+
+
+
+
+
+
+ {{ item.icon }}
+
+
+ {{ item.text }}
+
+
+
+ {{ item.model ? 'keyboard_arrow_up' : 'keyboard_arrow_down' }}
+
+
+
+
+
+
+
+
+ {{ child.icon }}
+
+
+
+ {{ child.text }}
+
+
+
+
+
+
+
+
+ {{ item.icon }}
+
+
+
+ {{ item.text }}
+
+
+
+
+
+
+
+
+
diff --git a/src/vue-poc/expath-pkg.xml b/src/vue-poc/expath-pkg.xml
index c6c567d..78e4fde 100644
--- a/src/vue-poc/expath-pkg.xml
+++ b/src/vue-poc/expath-pkg.xml
@@ -2,7 +2,7 @@
abbrev="vue-poc" version="0.0.3" spec="1.0">
vue-poc test of vue.js.
-
+
diff --git a/src/vue-poc/templates/404.vue b/src/vue-poc/features/404.vue
similarity index 100%
rename from src/vue-poc/templates/404.vue
rename to src/vue-poc/features/404.vue
diff --git a/src/vue-poc/features/collection/collections.xqm b/src/vue-poc/features/collection/collections.xqm
new file mode 100644
index 0000000..f61e534
--- /dev/null
+++ b/src/vue-poc/features/collection/collections.xqm
@@ -0,0 +1,85 @@
+(:~
+ : vue-poc collection api.
+ :
+ : @author Andy Bunce july-2017
+ :)
+module namespace vue-api = 'quodatum:vue.api.collection';
+import module namespace rest = "http://exquery.org/ns/restxq";
+import module namespace fw="quodatum:file.walker";
+import module namespace ufile = 'vue-poc/file' at "../../lib/file.xqm";
+declare namespace c="http://www.w3.org/ns/xproc-step";
+
+
+(:~
+ : history list
+ :)
+declare
+%rest:GET %rest:path("/vue-poc/api/history")
+%rest:produces("application/json")
+%output:method("json")
+function vue-api:history( )
+{
+ let $h:=(
+ '/vue-poc/vue-poc.xqm',
+ '/vue-poc/data/vue-poc/ch4d1.xml',
+ '/vue-poc/static/app-gen.js',
+ '/vue-poc/static/app.html',
+ '/vue-poc/static/app.css',
+ '/vue-poc/logo.svg',
+ '/vue-poc/static/resources/sparql.rq',
+ '/vue-poc/static/resources/turtle.ttl'
+ )
+
+ return
+
+ {$h!(<_ type="object">{.})}
+
+
+};
+
+
+(:~
+ : Returns folder info.
+ :)
+declare
+%rest:path("/vue-poc/api/file")
+%rest:query-param("url", "{$url}")
+%rest:produces("application/json")
+%output:method("json")
+function vue-api:file($url as xs:string)
+{
+ let $path := ufile:web( $url)=>trace("vue-api:web ")
+ return if( file:exists($path))then
+ let $items:=fw:directory-list($path,map{"max-depth":1,"include-info":true()})
+
+ return
+
+ {for $f in $items/c:directory
+ 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")}
+
+ }
+
+
+ else
+ error(xs:QName('vue-api:raw'),$path)
+};
+
+declare function vue-api:details($f as element(*),$icon as xs:string)
+as element(*)*
+{
+ {$f/@name/string()}
+ ,{$icon}
+ ,{$f/@last-modified/string()}
+ ,{$f/@size/string()}
+ ,unknown
+};
diff --git a/src/vue-poc/templates/files.vue b/src/vue-poc/features/collection/files.vue
similarity index 86%
rename from src/vue-poc/templates/files.vue
rename to src/vue-poc/features/collection/files.vue
index a084cc9..f711ac2 100644
--- a/src/vue-poc/templates/files.vue
+++ b/src/vue-poc/features/collection/files.vue
@@ -1,34 +1,33 @@
-
+
-
-
+
+
folder
-
-
+
+
{{ item }}
-
+
-
-
{{ url }}
view_module
-
+
+
Folders
-
-
+
+
{{ item.icon }}
@@ -42,11 +41,12 @@
-
+
+
Files
-
-
+
+
{{ item.icon }}
@@ -60,10 +60,12 @@
-
+
Some info here {{selected}}
+ >
+Some info here {{selected}} blah blah
+
diff --git a/src/vue-poc/templates/history.vue b/src/vue-poc/features/collection/history.vue
similarity index 77%
rename from src/vue-poc/templates/history.vue
rename to src/vue-poc/features/collection/history.vue
index 76bc513..64fd4d1 100644
--- a/src/vue-poc/templates/history.vue
+++ b/src/vue-poc/features/collection/history.vue
@@ -1,22 +1,19 @@
-
-
-
+
+
star
-
+
-
-
+
diff --git a/src/vue-poc/templates/edit.vue b/src/vue-poc/features/edit/edit.vue
similarity index 90%
rename from src/vue-poc/templates/edit.vue
rename to src/vue-poc/features/edit/edit.vue
index 5667cdd..51eac84 100644
--- a/src/vue-poc/templates/edit.vue
+++ b/src/vue-poc/features/edit/edit.vue
@@ -7,15 +7,13 @@
-
-
+
+
folder
-
-
- {{ item }}
+
+ {{ item }}
-
@@ -66,23 +64,19 @@
help
-
-
+
settings
Show settings
-
-
-
-
+
+
keyboard
Show keyboard commands
-
@@ -91,40 +85,34 @@
-
unused
-
-
-
+
+
-
Clear?
-
-
clear text.
-
-
+
Cancel
Ok
-
+
-
+
-
-
+
+
-
+
@@ -156,7 +144,8 @@ v-on:annotation="annotation">
"application/sparql-query":"sparql",
"text/html":"html",
"text/turtle":"turtle",
- "text/css":"css"
+ "text/css":"css",
+ "image/svg+xml":"svg"
}
}
},
@@ -225,6 +214,7 @@ v-on:annotation="annotation">
var a=this.contentA
switch(this.mode) {
case "html":
+ case "svg":
case "xml":
a=html_beautify(a, { indent_size: 3 ,indent_inner_html:true})
break;
diff --git a/src/vue-poc/features/edit/edit.xqm b/src/vue-poc/features/edit/edit.xqm
new file mode 100644
index 0000000..afebec6
--- /dev/null
+++ b/src/vue-poc/features/edit/edit.xqm
@@ -0,0 +1,62 @@
+(:~
+ : vue-poc api.
+ :
+ : @author Andy Bunce may-2017
+ :)
+module namespace vue-api = 'quodatum:vue.api';
+import module namespace rest = "http://exquery.org/ns/restxq";
+import module namespace session = "http://basex.org/modules/session";
+import module namespace ufile = 'vue-poc/file' at "../../lib/file.xqm";
+
+import module namespace mt = 'quodatum.data.mimetype' at "../../lib/mimetype.xqm";
+declare namespace c="http://www.w3.org/ns/xproc-step";
+
+
+(:~
+ : Returns a file content.
+ :)
+declare
+%rest:GET %rest:path("/vue-poc/api/edit")
+%rest:query-param("url", "{$url}")
+%rest:produces("application/json")
+%output:method("json")
+function vue-api:edit-get($url as xs:string)
+{
+ let $path := ufile:web( $url)=>trace("path ")
+ return if( file:exists($path))then
+ let $type:=mt:type($path)
+ let $fetch:=mt:fetch-fn($type("treat-as"))
+ return
+ {$url}
+ {$type?type}
+ {$fetch($path)}
+
+ else
+ error(xs:QName('vue-api:raw'),$path)
+};
+
+(:~
+ : Update a file content. @TODO
+ :)
+declare
+%rest:POST %rest:path("/vue-poc/api/edit")
+%rest:form-param("url", "{$url}")
+%rest:form-param("data", "{$data}")
+%rest:produces("application/json")
+%output:method("json")
+function vue-api:edit-post($url as xs:string,$data)
+{
+ let $path := ufile:web( $url)=>trace("path ")
+ let $data:=trace($data)
+ return if( file:exists($path))then
+ let $type:=mt:type($path)
+ let $fetch:=mt:fetch-fn($type("treat-as"))
+ return
+ {$url}
+ {$type?type}
+ {$fetch($path)}
+
+ else
+ error(xs:QName('vue-api:raw'),$path)
+};
+
diff --git a/src/vue-poc/features/eval/eval.vue b/src/vue-poc/features/eval/eval.vue
new file mode 100644
index 0000000..9446ea5
--- /dev/null
+++ b/src/vue-poc/features/eval/eval.vue
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+ Run
+
+ play_circle_outline
+ Submit
+
+
+
+
+
+
+
+
+
+
+ {{result}}
+
+
+
+ JobId:
+ {{jobId}}
+
+ Elapsed:
+ {{elapsed}}
+
+ @TODO
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/vue-poc/templates/eval/eval.xqm b/src/vue-poc/features/eval/eval.xqm
similarity index 64%
rename from src/vue-poc/templates/eval/eval.xqm
rename to src/vue-poc/features/eval/eval.xqm
index eada6e3..423643a 100644
--- a/src/vue-poc/templates/eval/eval.xqm
+++ b/src/vue-poc/features/eval/eval.xqm
@@ -41,3 +41,28 @@ function vue-api:submit($xq )
{$r}
};
+
+(:~
+ : imports
+ :)
+declare
+%rest:GET %rest:path("/vue-poc/api/eval/imports")
+%output:method("json")
+function vue-api:imports( )
+{
+let $n:='import module namespace fw="quodatum:file.walker";'
+ return
+ <_>{$n}
+
+};
+
+declare
+%rest:POST %rest:path('/vue-poc/api/eval/result/{$id}')
+%output:method("json")
+function vue-api:result($id)
+{
+ let $r:=jobs:result($id)
+ return
+ {util:display($r)}
+
+};
\ No newline at end of file
diff --git a/src/vue-poc/features/home.vue b/src/vue-poc/features/home.vue
new file mode 100644
index 0000000..31ef99f
--- /dev/null
+++ b/src/vue-poc/features/home.vue
@@ -0,0 +1,28 @@
+
+
+VUE-POC
+v0.0.2
+
+ This is a experiment in using
+ vue.js
+ .
+
+
+ add REPLACED
+
diff --git a/src/vue-poc/features/job/jobs.vue b/src/vue-poc/features/job/jobs.vue
new file mode 100644
index 0000000..6ffd002
--- /dev/null
+++ b/src/vue-poc/features/job/jobs.vue
@@ -0,0 +1,107 @@
+
+
+
+
+
+ refresh
+
+
+ Stop
+
+
+
+
+
+
+
+
+
+ |
+ {{ props.item.id }} |
+ {{ props.item.state }} |
+ {{ props.item.duration }} |
+ {{ props.item.type }} |
+ {{ props.item.user }} |
+ {{ props.item.text }} |
+
+
+
+
+
+
diff --git a/src/vue-poc/features/job/jobs.xqm b/src/vue-poc/features/job/jobs.xqm
new file mode 100644
index 0000000..03bcb73
--- /dev/null
+++ b/src/vue-poc/features/job/jobs.xqm
@@ -0,0 +1,46 @@
+module namespace j = 'quodatum.test.jobs';
+
+
+(:~
+ : job list
+ :)
+declare
+%rest:GET %rest:path("/vue-poc/api/job")
+%output:method("json")
+function j:list()
+as element(json)
+{
+ let $jlist:=jobs:list()[. != jobs:current()] !jobs:list-details(.)
+ return
+ {for $j in reverse($jlist)
+ return <_ type="object">
+ {j:job-json($j)}
+
+ }
+};
+
+(:~
+ : job info
+ :)
+declare
+%rest:GET %rest:path("/vue-poc/api/job/{$job}")
+%output:method("json")
+function j:job($job)
+as element(json)
+{
+ let $j:=jobs:list-details($job)
+ return
+ {j:job-json($j)}
+
+};
+
+declare function j:job-json($j)
+as element(*)*
+{
+ {$j/@id/string()}
+ ,{$j/@type/string()}
+ ,{$j/@state/string()}
+ ,{$j/@user/string()}
+ ,{$j/@duration/string()}
+ ,{$j/string()}
+};
\ No newline at end of file
diff --git a/src/vue-poc/templates/login.vue b/src/vue-poc/features/login/login.vue
similarity index 89%
rename from src/vue-poc/templates/login.vue
rename to src/vue-poc/features/login/login.vue
index 9f80b9c..dfa85e5 100644
--- a/src/vue-poc/templates/login.vue
+++ b/src/vue-poc/features/login/login.vue
@@ -2,15 +2,13 @@
-
-
+
Login
-
{{message}}
-
+
-
+
-
+
-
+
-
+
Continue
-
+
diff --git a/src/vue-poc/login.xqm b/src/vue-poc/features/login/login.xqm
similarity index 100%
rename from src/vue-poc/login.xqm
rename to src/vue-poc/features/login/login.xqm
diff --git a/src/vue-poc/templates/logs.vue b/src/vue-poc/features/logs.vue
similarity index 100%
rename from src/vue-poc/templates/logs.vue
rename to src/vue-poc/features/logs.vue
diff --git a/src/vue-poc/templates/options.vue b/src/vue-poc/features/options.vue
similarity index 87%
rename from src/vue-poc/templates/options.vue
rename to src/vue-poc/features/options.vue
index a362ff4..20273dd 100644
--- a/src/vue-poc/templates/options.vue
+++ b/src/vue-poc/features/options.vue
@@ -3,20 +3,18 @@
-
-
+
Featured Event:
May 24, 2016
7-11pm
-
-
+
Add to
Calendar
event
-
+
@@ -28,7 +26,7 @@
-
+
Show Snackbar
Snackbar?
diff --git a/src/vue-poc/templates/people.vue b/src/vue-poc/features/people.vue
similarity index 88%
rename from src/vue-poc/templates/people.vue
rename to src/vue-poc/features/people.vue
index 4a6e284..0eef1cc 100644
--- a/src/vue-poc/templates/people.vue
+++ b/src/vue-poc/features/people.vue
@@ -14,10 +14,10 @@
-
+
-
+
diff --git a/src/vue-poc/templates/ping/ping.vue b/src/vue-poc/features/ping/ping.vue
similarity index 100%
rename from src/vue-poc/templates/ping/ping.vue
rename to src/vue-poc/features/ping/ping.vue
diff --git a/src/vue-poc/templates/ping/ping.xqm b/src/vue-poc/features/ping/ping.xqm
similarity index 100%
rename from src/vue-poc/templates/ping/ping.xqm
rename to src/vue-poc/features/ping/ping.xqm
diff --git a/src/vue-poc/templates/puzzle.vue b/src/vue-poc/features/puzzle.vue
similarity index 100%
rename from src/vue-poc/templates/puzzle.vue
rename to src/vue-poc/features/puzzle.vue
diff --git a/src/vue-poc/templates/search.vue b/src/vue-poc/features/search.vue
similarity index 100%
rename from src/vue-poc/templates/search.vue
rename to src/vue-poc/features/search.vue
diff --git a/src/vue-poc/templates/select.vue b/src/vue-poc/features/select.vue
similarity index 95%
rename from src/vue-poc/templates/select.vue
rename to src/vue-poc/features/select.vue
index 6466e8b..34e2528 100644
--- a/src/vue-poc/templates/select.vue
+++ b/src/vue-poc/features/select.vue
@@ -2,12 +2,11 @@
-
-
+
+
Selection
-
diff --git a/src/vue-poc/templates/settings.vue b/src/vue-poc/features/settings.vue
similarity index 94%
rename from src/vue-poc/templates/settings.vue
rename to src/vue-poc/features/settings.vue
index ef8a989..b99d3b8 100644
--- a/src/vue-poc/templates/settings.vue
+++ b/src/vue-poc/features/settings.vue
@@ -6,7 +6,7 @@
Ace editor settings
-
+
@@ -16,8 +16,7 @@
Allow snippets
-
-
+
@@ -27,8 +26,7 @@
enableBasicAutocompletion
-
-
+
@@ -38,7 +36,6 @@
enableLiveAutocompletion
-
diff --git a/src/vue-poc/templates/tabs.vue b/src/vue-poc/features/tabs.vue
similarity index 94%
rename from src/vue-poc/templates/tabs.vue
rename to src/vue-poc/features/tabs.vue
index 805ed82..6a7e02c 100644
--- a/src/vue-poc/templates/tabs.vue
+++ b/src/vue-poc/features/tabs.vue
@@ -2,8 +2,7 @@
-
-
+
menu
@@ -14,8 +13,7 @@
more_vert
-
-
+
diff --git a/src/vue-poc/templates/tasks.vue b/src/vue-poc/features/tasks.vue
similarity index 100%
rename from src/vue-poc/templates/tasks.vue
rename to src/vue-poc/features/tasks.vue
diff --git a/src/vue-poc/templates/thumbnail/thumbnail.vue b/src/vue-poc/features/thumbnail/thumbnail.vue
similarity index 100%
rename from src/vue-poc/templates/thumbnail/thumbnail.vue
rename to src/vue-poc/features/thumbnail/thumbnail.vue
diff --git a/src/vue-poc/templates/thumbnail/thumbnail.xqm b/src/vue-poc/features/thumbnail/thumbnail.xqm
similarity index 100%
rename from src/vue-poc/templates/thumbnail/thumbnail.xqm
rename to src/vue-poc/features/thumbnail/thumbnail.xqm
diff --git a/src/vue-poc/lib/file.xqm b/src/vue-poc/lib/file.xqm
new file mode 100644
index 0000000..1b75a4c
--- /dev/null
+++ b/src/vue-poc/lib/file.xqm
@@ -0,0 +1,23 @@
+(:~
+ : file Utility functions.
+ :
+ : @author Andy Bunce, 2017
+ :)
+module namespace ufile = 'vue-poc/file';
+
+(:~
+ : resolve path relative to basex webpath
+ : file("/fred")=>C:\Program Files (x86)\BaseX\webapp\fred
+ :)
+declare function ufile:web($file as xs:string)
+as xs:string
+{
+ let $file:=if(starts-with($file,"/")) then
+ substring($file,2)
+ else
+ error(xs:QName('vue-api:badpath'),"leading slash")
+
+ let $webroot:=db:system()/globaloptions/webpath/concat(.,"/")
+ return file:resolve-path($file,$webroot)
+};
+
diff --git a/src/vue-poc/lib/util.xqm b/src/vue-poc/lib/util.xqm
index 3808c70..29f750a 100644
--- a/src/vue-poc/lib/util.xqm
+++ b/src/vue-poc/lib/util.xqm
@@ -15,14 +15,21 @@ import module namespace cons = 'vue-poc/cons' at 'cons.xqm';
:)
declare function util:query(
$query as xs:string?,
- $context as item()*
-) as xs:string {
- let $limit := $cons:OPTION($cons:K-MAXCHARS)
+ $context as item()*)
+as xs:string {
let $result := xquery:eval($query, map { '': $context }, util:query-options())
(: serialize more characters than requested, because limit represents number of bytes :)
+ return util:display($result)
+};
+
+declare function util:display(
+ $result as item()*)
+as xs:string
+{
+ let $limit := $cons:OPTION($cons:K-MAXCHARS)
+ (: serialize more characters than requested, because limit represents number of bytes :)
return util:chop(serialize($result, map { 'limit': $limit * 2 + 1, 'method': 'basex' }), $limit)
};
-
(:~
: Runs an updating query.
: @param $query query string
diff --git a/src/vue-poc/static/app-gen.js b/src/vue-poc/static/app-gen.js
index 4de9775..8108e78 100644
--- a/src/vue-poc/static/app-gen.js
+++ b/src/vue-poc/static/app-gen.js
@@ -1,4 +1,4 @@
-// generated 2017-06-26T17:16:36.47+01:00
+// generated 2017-07-05T23:03:36.134+01:00
/**
* vue filters
*/
@@ -42,7 +42,7 @@ Vue.filter('round', function(value, decimals) {
Not found
`,
-
+
data: function(){
return {
message: 'bad route!'
@@ -53,410 +53,35 @@ Vue.filter('round', function(value, decimals) {
}
}
-);
-const Edit=Vue.extend({template:`
-
-
- {{ message }}
- highlight_off
-
-
-
-
-
- folder
-
-
-
- {{ item }}
-
-
-
-
-
-
- {{ name }}
-
-
-
- *
-.
-
- {{ mode }}
-
- {{annotations && annotations.info}}
- {{annotations && annotations.warning}}
- {{annotations && annotations.error}}
-
- navigate_next
-
-
-
- star
-
-
-
-
- vertical_align_center
-
-
-
- wrap_text
-
-
-
- file_upload
-
-
-
- format_align_center
-
-
- delete
-
-
-
- help
-
-
-
-
-
- settings
-
- Show settings
-
-
-
-
-
-
- keyboard
-
- Show keyboard commands
-
-
-
-
-
-
- more_vert
-
-
-
-
-
- unused
-
-
-
-
-
-
-
-
-
- Clear?
-
-
- clear text.
-
-
- Cancel
- Ok
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- `,
-
- data () {
- return {
- contentA: `declare function local:query($q as xs:string)
-{
-};`,
- mode:'xquery',
- url:'',
- name:'',
- path:[],
- mimetype:"",
- wrap:false,
- busy:false,
- clearDialog:false,
- annotations:null,
- dirty:false,
- snackbar:false,
- message:"Cant do that",
- mimemap:{
- "text/xml":"xml",
- "application/xml":"xml",
- "application/xquery":"xquery",
- "text/ecmascript":"javascript",
- "application/sparql-query":"sparql",
- "text/html":"html",
- "text/turtle":"turtle",
- "text/css":"css"
- }
- }
- },
- methods: {
- reset (ok) {
- if(ok){
- this.contentA = 'reset content for Editor A'
- this.dirty=false
- }
- this.clearDialog=false
- },
- changeContentA (val) {
- if (this.contentA !== val) {
- this.contentA = val
- this.dirty=true
- }
- },
- // load from url
- fetch(url){
- this.busy=true
- HTTP.get("edit?url="+url,axios_json)
- .then(r=>{
- //console.log(r)
- this.mimetype=r.data.mimetype
- this.mode=this.acetype(r.data.mimetype)
- this.contentA=r.data.data
- var a=url.split("/")
- this.url=url
- this.name=a.pop()
- this.path=a
- this.busy=false
- this.dirty=false
- //alert(mode)
- })
- .catch(error=> {
- console.log(error);
- this.busy=false
- alert("Get query error:\n"+url)
- });
-
- },
- acecmd(cmd){
- Events.$emit('eventFired',cmd);
- },
- fold(){
- Events.$emit('eventFired',"foldall");
- },
- save(){
- alert("TODO save: "+this.url);
- var data=Qs.stringify(
- {
- url: this.url, //gave the values directly for testing
- data: this.contentA
- })
- HTTP.post("edit", data,{
- headers: { "Content-Type": "application/x-www-form-urlencoded"}
- }).then(r=>{
- alert("AAA")
- })
- },
- showfiles(){
- router.push({ path: 'files', query: { url: this.path.join("/") }})
- },
- beautify(){
- this.busy=true
- var a=this.contentA
- switch(this.mode) {
- case "html":
- case "xml":
- a=html_beautify(a, { indent_size: 3 ,indent_inner_html:true})
- break;
- case "javascript":
- a=js_beautify(a, { indent_size: 2 })
- break;
- case "css":
- a=css_beautify(a, { indent_size: 2 })
- break;
- default:
- this.message="No beautify yet for "+this.mode
- this.snackbar=true
- }
- this.contentA=a
- this.busy=false
- },
- annotation(counts){
- this.annotations=counts
- console.log("annotations: ",counts)
- },
- acetype(mime){
- var r=this.mimemap[mime]
- return r?r:"text"
- },
- leaving(event) {
- event.returnValue = "event seems to need to be set";
- //debugger;
- console.log("Leaving...");
- if(this.dirty)event.preventDefault();
- }
- },
- created(){
- //https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
- document.addEventListener('beforeunload', this.leaving);
- var url=this.$route.query.url
- console.log("Edit: ",url)
- if(url) this.fetch(url)
- },
- beforeRouteLeave (to, from, next) {
- // called when the route that renders this component is about to
- // be navigated away from.
- // has access to `this` component instance.
- if(this.dirty && confirm("unsaved changes will be lost"))this.dirty=false;
- next(!this.dirty);
- }
-}
-
-);
-const Eval=Vue.extend({template:`
+ );
+ const Files=Vue.extend({template:`
-
-
-
- Run
- Submit
-
-
-
-
-
-
-
-
-
- {{result}}
-
-
-
-
-
-
-
-
-
-
- {{elapsed}}
- Elapsed:
-
-
-
- {{jobId}}
- JobId:
-
-
-
- @TODO
-
-
-
-
- `,
-
- data: function(){
- return {
- xq: '(: type your XQuery :)\n',
- result:'',
- elapsed:null,
- show:false,
- showError:false,
- jobId:null
- }
- },
- methods:{
- onChange(val){
- if (this.xq !== val) {
- this.xq = val
- }
- },
-
- run(){
- var data={xq:this.xq}
- this.showError=this.show=false
- var _start = performance.now();
- HTTP.post("eval/execute",Qs.stringify(data))
- .then(r=>{
- this.elapsed=Math.floor(performance.now() - _start);
- this.result=r.data.result
- this.jobId=null
- this.show=true
- })
- .catch(r=> {
- console.log("error",r)
- this.result=r.response.data
- this.showError=true;
-
- });
- localforage.setItem('eval/xq', this.xq)
- },
- submit(){
- var data={xq:this.xq}
- this.showError=this.show=false
- var _start = performance.now();
- HTTP.post("eval/submit",Qs.stringify(data))
- .then(r=>{
- this.elapsed=Math.floor(performance.now() - _start);
- this.result=this.jobId=r.data.job
- this.show=true
- })
- .catch(r=> {
- console.log("error",r)
- this.jobId=r.response.job
- this.showError=true;
-
- });
- }
- },
-
- created:function(){
- localforage.getItem('eval/xq').then((value) => { this.xq=value || this.xq});
- }
-}
-
-);
-const Files=Vue.extend({template:`
-
-
+
-
-
+
+
folder
-
-
+
+
{{ item }}
-
+
-
-
{{ url }}
view_module
-
+
+
Folders
-
-
+
+
{{ item.icon }}
@@ -470,11 +95,12 @@ const Files=Vue.extend({template:`
-
+
+
Files
-
-
+
+
{{ item.icon }}
@@ -488,13 +114,15 @@ const Files=Vue.extend({template:`
-
+
- Some info here {{selected}}
+
+Some info here {{selected}} blah blah
+
`,
-
+
data: function(){
return {
crumbs:[],
@@ -572,27 +200,25 @@ const Files=Vue.extend({template:`
}
}
-);
-const History=Vue.extend({template:`
+ );
+ const History=Vue.extend({template:`
-
-
-
+
+
star
-
+
-
-
+
`,
-
+
data: function(){
return {
message: 'Hello Vue.js!',
@@ -618,55 +244,494 @@ const History=Vue.extend({template:`
}
}
-);
-const Home=Vue.extend({template:`
-
-
-
-
- VUE-POC
- v0.0.2
-
-
-
-
- This is a experiment in using vue.js.
-
-
-
- add
-
- REPLACED
-
- `,
+ );
+ const Edit=Vue.extend({template:`
+
+
+ {{ message }}
+ highlight_off
+
+
+
+
+ folder
+
+
+ {{ item }}
+
+
+
+
+
+ {{ name }}
+
+
+
+ *
+.
+
+ {{ mode }}
+
+ {{annotations && annotations.info}}
+ {{annotations && annotations.warning}}
+ {{annotations && annotations.error}}
+
+ navigate_next
+
+
+
+ star
+
+
+
+
+ vertical_align_center
+
+
+
+ wrap_text
+
+
+
+ file_upload
+
+
+
+ format_align_center
+
+
+ delete
+
+
+
+ help
+
+
+
+
+ settings
+
+ Show settings
+
+
+
+
+ keyboard
+
+ Show keyboard commands
+
+
+
+
+
+ more_vert
+
+
+
+
+ unused
+
+
+
+
+
+
+
+ Clear?
+ clear text.
+
+ Cancel
+ Ok
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ `,
+
+ data () {
+ return {
+ contentA: `declare function local:query($q as xs:string)
+{
+};`,
+ mode:'xquery',
+ url:'',
+ name:'',
+ path:[],
+ mimetype:"",
+ wrap:false,
+ busy:false,
+ clearDialog:false,
+ annotations:null,
+ dirty:false,
+ snackbar:false,
+ message:"Cant do that",
+ mimemap:{
+ "text/xml":"xml",
+ "application/xml":"xml",
+ "application/xquery":"xquery",
+ "text/ecmascript":"javascript",
+ "application/sparql-query":"sparql",
+ "text/html":"html",
+ "text/turtle":"turtle",
+ "text/css":"css",
+ "image/svg+xml":"svg"
+ }
+ }
+ },
+ methods: {
+ reset (ok) {
+ if(ok){
+ this.contentA = 'reset content for Editor A'
+ this.dirty=false
+ }
+ this.clearDialog=false
+ },
+ changeContentA (val) {
+ if (this.contentA !== val) {
+ this.contentA = val
+ this.dirty=true
+ }
+ },
+ // load from url
+ fetch(url){
+ this.busy=true
+ HTTP.get("edit?url="+url,axios_json)
+ .then(r=>{
+ //console.log(r)
+ this.mimetype=r.data.mimetype
+ this.mode=this.acetype(r.data.mimetype)
+ this.contentA=r.data.data
+ var a=url.split("/")
+ this.url=url
+ this.name=a.pop()
+ this.path=a
+ this.busy=false
+ this.dirty=false
+ //alert(mode)
+ })
+ .catch(error=> {
+ console.log(error);
+ this.busy=false
+ alert("Get query error:\n"+url)
+ });
+
+ },
+ acecmd(cmd){
+ Events.$emit('eventFired',cmd);
+ },
+ fold(){
+ Events.$emit('eventFired',"foldall");
+ },
+ save(){
+ alert("TODO save: "+this.url);
+ var data=Qs.stringify(
+ {
+ url: this.url, //gave the values directly for testing
+ data: this.contentA
+ })
+ HTTP.post("edit", data,{
+ headers: { "Content-Type": "application/x-www-form-urlencoded"}
+ }).then(r=>{
+ alert("AAA")
+ })
+ },
+ showfiles(){
+ router.push({ path: 'files', query: { url: this.path.join("/") }})
+ },
+ beautify(){
+ this.busy=true
+ var a=this.contentA
+ switch(this.mode) {
+ case "html":
+ case "svg":
+ case "xml":
+ a=html_beautify(a, { indent_size: 3 ,indent_inner_html:true})
+ break;
+ case "javascript":
+ a=js_beautify(a, { indent_size: 2 })
+ break;
+ case "css":
+ a=css_beautify(a, { indent_size: 2 })
+ break;
+ default:
+ this.message="No beautify yet for "+this.mode
+ this.snackbar=true
+ }
+ this.contentA=a
+ this.busy=false
+ },
+ annotation(counts){
+ this.annotations=counts
+ console.log("annotations: ",counts)
+ },
+ acetype(mime){
+ var r=this.mimemap[mime]
+ return r?r:"text"
+ },
+ leaving(event) {
+ event.returnValue = "event seems to need to be set";
+ //debugger;
+ console.log("Leaving...");
+ if(this.dirty)event.preventDefault();
+ }
+ },
+ created(){
+ //https://forum.vuejs.org/t/detect-browser-close/5001/3 @fixme
+ document.addEventListener('beforeunload', this.leaving);
+ var url=this.$route.query.url
+ console.log("Edit: ",url)
+ if(url) this.fetch(url)
+ },
+ beforeRouteLeave (to, from, next) {
+ // called when the route that renders this component is about to
+ // be navigated away from.
+ // has access to `this` component instance.
+ if(this.dirty && confirm("unsaved changes will be lost"))this.dirty=false;
+ next(!this.dirty);
+ }
}
-);
-const Job=Vue.extend({template:`
+ );
+ const Eval=Vue.extend({template:`
- JOBS
+
+
+
+
+
+ Run
+
+ play_circle_outline
+ Submit
+
+
+
+
+
+
+
+
+
+
+ {{result}}
+
+
+
+ JobId:
+ {{jobId}}
+
+ Elapsed:
+ {{elapsed}}
+
+ @TODO
+
+
+
+
+
+
+
`,
-
+
data: function(){
return {
- message: 'Hello Vue.js!',
- jobs:[]
+ xq: '(: type your XQuery :)\n',
+ result:'',
+ elapsed:null,
+ show:false,
+ showError:false,
+ jobId:null,
+ waiting:false,
+ start:null,
+ dropdown_font: [
+ { text: 'Arial' },
+ { text: 'Calibri' },
+ { text: 'Courier' },
+ { text: 'Verdana' }
+ ]
+ }
+ },
+ methods:{
+ onChange(val){
+ if (this.xq !== val) {
+ this.xq = val
+ }
+ },
+
+ run(){
+ var data={xq:this.xq}
+ this.showError=this.show=false
+ this.start = performance.now();
+ HTTP.post("eval/execute",Qs.stringify(data))
+ .then(r=>{
+ this.elapsed=Math.floor(performance.now() - this.start);
+ this.result=r.data.result
+ this.jobId=null
+ this.show=true
+ })
+ .catch(r=> {
+ console.log("error",r)
+ this.result=r.response.data
+ this.showError=true;
+
+ });
+ localforage.setItem('eval/xq', this.xq)
+ },
+ submit(){
+ var data={xq:this.xq}
+ this.showError=this.show=false
+ this.start = performance.now();
+ HTTP.post("eval/submit",Qs.stringify(data))
+ .then(r=>{
+ this.elapsed=Math.floor(performance.now() - this.start);
+ this.result=this.jobId=r.data.job
+ this.show=true
+ this.pollState()
+
+ })
+ .catch(r=> {
+ console.log("error",r)
+ this.jobId=r.response.job
+ this.showError=true;
+
+ });
+ },
+ pollState(){
+ this.waiting=true;
+ HTTP.get("job/"+this.jobId)
+ .then(r=>{
+ this.waiting=r.data.state!="cached";
+ this.elapsed=Math.floor(performance.now() - this.start);
+ if(this.waiting) {
+ setTimeout(()=>{ this.pollState() }, 5000);
+ }else{
+ this.getResult()
+ }
+ })
+ },
+ getResult(){
+ HTTP.post("eval/result/"+this.jobId)
+ .then(r=>{
+ this.result=r.data.result
+ this.jobId=null
+ this.show=true
+ })
+ }
+ },
+
+ created:function(){
+ localforage.getItem('eval/xq').then((value) => { this.xq=value || this.xq});
+ }
+}
+
+ );
+ const Home=Vue.extend({template:`
+VUE-POC
+v0.0.2
+
+ This is a experiment in using
+ vue.js
+ .
+
+
+ add REPLACED `,
+ }
+
+ );
+ const Job=Vue.extend({template:`
+
+
+
+ refresh
+
+
+ Stop
+
+
+
+
+
+
+
+
+
+ |
+ {{ props.item.id }} |
+ {{ props.item.state }} |
+ {{ props.item.duration }} |
+ {{ props.item.type }} |
+ {{ props.item.user }} |
+ {{ props.item.text }} |
+
+
+
+ `,
+
+ data: function(){
+ return {
+ headers: [
+ {
+ text: 'Job id',
+ left: true,
+ value: 'id'
+ },
+ { text: 'State', value: 'state' },
+ { text: 'Duration', value: 'duration' },
+ { text: 'Type', value: 'type' },
+ { text: 'User', value: 'user' },
+ { text: 'Query', value: 'text' }
+ ],
+ items:[
+ ],
+ selected:[],
+ search:"",
+ loading:false
}
},
methods:{
getJobs(){
- alert("get jobs")
+ this.loading=true;
+ HTTP.get("job")
+ .then(r=>{
+ this.loading=false
+ this.items=r.data
+ setTimeout(()=>{ this.getJobs() }, 10000);
+ })
+
+ },
+ stop(){
+ var s=this.selected.map((j)=>{return j.id}).join(",")
+ console.log("AAA",this.selected)
+ alert(s)
+ }
+ },
+ computed: {
+ // a computed getter
+ noSelection: function () {
+ // `this` points to the vm instance
+ return this.selected.length==0
}
},
created(){
@@ -674,34 +739,32 @@ const Job=Vue.extend({template:`
}
}
-);
-const Login=Vue.extend({template:`
+ );
+ const Login=Vue.extend({template:`
-
-
+
Login
-
{{message}}
-
+
-
+
-
+
-
+
-
+
Continue
-
+
`,
-
+
data () {
return {
hidepass: true,
@@ -740,12 +803,12 @@ const Login=Vue.extend({template:`
}
}
-);
-const Log=Vue.extend({template:`
+ );
+ const Log=Vue.extend({template:`
LOGS
`,
-
+
data: function(){
return {
message: 'Hello Vue.js!',
@@ -757,25 +820,23 @@ const Log=Vue.extend({template:`
}
}
-);
-const Options=Vue.extend({template:`
+ );
+ const Options=Vue.extend({template:`
-
-
+
Featured Event:
May 24, 2016
7-11pm
-
-
+
Add to
Calendar
event
-
+
@@ -784,7 +845,7 @@ const Options=Vue.extend({template:`
-
+
Show Snackbar
Snackbar?
@@ -796,7 +857,7 @@ const Options=Vue.extend({template:`
`,
-
+
data: function(){
return {
snackbar:false
@@ -804,8 +865,8 @@ const Options=Vue.extend({template:`
}
}
-);
-const People=Vue.extend({template:`
+ );
+ const People=Vue.extend({template:`
Look at all the people who work here!
Reverse Message
@@ -820,15 +881,15 @@ const People=Vue.extend({template:`
-
+
-
+
`,
-
+
data: function(){
return {
message: 'Hello Vue.js!',
@@ -846,8 +907,8 @@ const People=Vue.extend({template:`
}
-);
-const Ping=Vue.extend({template:`
+ );
+ const Ping=Vue.extend({template:`
Simple performance measure. Read or increment a database value.
Counter:{{counter}}
@@ -931,7 +992,7 @@ const Ping=Vue.extend({template:`
`,
-
+
data: function(){
return {
getValues: new perfStat(),
@@ -973,8 +1034,8 @@ const Ping=Vue.extend({template:`
}
}
-);
-const Puzzle=Vue.extend({template:`
+ );
+ const Puzzle=Vue.extend({template:`
demo
@@ -999,7 +1060,7 @@ const Puzzle=Vue.extend({template:`
`,
-
+
data: function(){
return {grid: [
[1,5,8,12],
@@ -1051,13 +1112,13 @@ const Puzzle=Vue.extend({template:`
}
-);
-const Search=Vue.extend({template:`
+ );
+ const Search=Vue.extend({template:`
`,
-
+
data: function(){
return {
message: 'Hello Vue.js!',
@@ -1069,16 +1130,15 @@ const Search=Vue.extend({template:`
}
}
-);
-const Select=Vue.extend({template:`
+ );
+ const Select=Vue.extend({template:`
-
-
+
+
Selection
-
@@ -1098,7 +1158,7 @@ const Select=Vue.extend({template:`
`,
-
+
components: { multiselect: VueMultiselect.Multiselect},
data: function(){
return {
@@ -1130,15 +1190,15 @@ const Select=Vue.extend({template:`
}
-);
-const Settings=Vue.extend({template:`
+ );
+ const Settings=Vue.extend({template:`
Ace editor settings
-
+
@@ -1148,8 +1208,7 @@ const Settings=Vue.extend({template:`
Allow snippets
-
-
+
@@ -1159,8 +1218,7 @@ const Settings=Vue.extend({template:`
enableBasicAutocompletion
-
-
+
@@ -1170,14 +1228,13 @@ const Settings=Vue.extend({template:`
enableLiveAutocompletion
-
`,
-
+
data () {
return {
ace: {
@@ -1214,12 +1271,11 @@ const Settings=Vue.extend({template:`
}
-);
-const Tabs=Vue.extend({template:`
+ );
+ const Tabs=Vue.extend({template:`
-
-
+
menu
@@ -1230,8 +1286,7 @@ const Tabs=Vue.extend({template:`
more_vert
-
-
+
@@ -1249,7 +1304,7 @@ const Tabs=Vue.extend({template:`
`,
-
+
data () {
return {
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.'
@@ -1257,13 +1312,13 @@ const Tabs=Vue.extend({template:`
}
}
-);
-const Task=Vue.extend({template:`
+ );
+ const Task=Vue.extend({template:`
Tasks
`,
-
+
data: function(){
return {
message: 'Hello Vue.js!',
@@ -1275,8 +1330,8 @@ const Task=Vue.extend({template:`
}
}
-);
-const Thumbnail=Vue.extend({template:`
+ );
+ const Thumbnail=Vue.extend({template:`
@@ -1315,7 +1370,7 @@ const Thumbnail=Vue.extend({template:`
`,
-
+
data(){
return {
image:"http://images.metmuseum.org/CRDImages/ep/original/DT46.jpg",
@@ -1344,8 +1399,8 @@ const Thumbnail=Vue.extend({template:`
}
-);
-// base -----------------------
+ );
+ // base -----------------------
localforage.config({
name: 'vuepoc'
});
@@ -1405,8 +1460,8 @@ Vue.component('nav-list', {
-
-
+
+
{{ item.icon }}
@@ -1421,12 +1476,9 @@ Vue.component('nav-list', {
-
-
-
+
+
+
{{ child.icon }}
@@ -1436,10 +1488,10 @@ Vue.component('nav-list', {
-
+
-
-
+
+
{{ item.icon }}
@@ -1449,7 +1501,6 @@ Vue.component('nav-list', {
-
`,
created:function(){
@@ -1525,16 +1576,16 @@ const app = new Vue({
{href: 'files', text: 'File system',icon: 'folder' },
{href: 'edit',text: 'edit',icon: 'mode_edit'},
{href: 'history',text: 'history',icon: 'history'},
+ {href: 'logs',text: 'Server logs',icon: 'dns'}
]},
{
icon: 'directions_run',
text: 'Actions' ,
model: false,
children: [
- {href: 'eval',text: 'Evaluate',icon: 'cake'},
- {href: 'tasks',text: 'Tasks',icon: 'build'},
- {href: 'jobs',text: 'Jobs',icon: 'print'},
- {href: 'logs',text: 'Server logs',icon: 'dns'}
+ {href: 'eval',text: 'Evaluate',icon: 'play_circle_outline'},
+ {href: 'jobs',text: 'Jobs',icon: 'dashboard'},
+ {href: 'tasks',text: 'Tasks',icon: 'history'},
]},
{
icon: 'more_horiz',
diff --git a/src/vue-poc/static/app.html b/src/vue-poc/static/app.html
index c8cedf4..2ad3afc 100644
--- a/src/vue-poc/static/app.html
+++ b/src/vue-poc/static/app.html
@@ -9,7 +9,7 @@
Vue Router Test
-
+
@@ -19,7 +19,7 @@
-
+
@@ -38,7 +38,7 @@
-
+
@@ -52,7 +52,7 @@
-
+
@@ -69,14 +69,13 @@
-
-
+
+
logout
permission: {{$auth.permission}}
-
diff --git a/src/vue-poc/tasks/createthumbs.xq b/src/vue-poc/tasks/createthumbs.xq
new file mode 100644
index 0000000..f70d7bb
--- /dev/null
+++ b/src/vue-poc/tasks/createthumbs.xq
@@ -0,0 +1 @@
+42
\ No newline at end of file
diff --git a/src/vue-poc/tasks/primes.xq b/src/vue-poc/tasks/primes.xq
new file mode 100644
index 0000000..fca9a77
--- /dev/null
+++ b/src/vue-poc/tasks/primes.xq
@@ -0,0 +1,2 @@
+declare variable $MAX:=100000;
+for $i in (2 to $MAX) return if (every $j in (2 to $i - 1) satisfies $i mod $j ne 0) then $i else ()
\ No newline at end of file
diff --git a/src/vue-poc/tasks/scanpics.xq b/src/vue-poc/tasks/scanpics.xq
new file mode 100644
index 0000000..03e0e60
--- /dev/null
+++ b/src/vue-poc/tasks/scanpics.xq
@@ -0,0 +1,8 @@
+(:~ create xml file list
+:)
+import module namespace fw="quodatum:file.walker";
+declare namespace c="http://www.w3.org/ns/xproc-step";
+let $opt:=map{"include-filter":".*\.xsd",
+ "max-depth":-1,
+ "include-info":true()}
+return fw:directory-list("/",$opt)
\ No newline at end of file
diff --git a/src/vue-poc/templates/eval/eval.vue b/src/vue-poc/templates/eval/eval.vue
deleted file mode 100644
index 02c283b..0000000
--- a/src/vue-poc/templates/eval/eval.vue
+++ /dev/null
@@ -1,109 +0,0 @@
-
-
-
-
-
-
- Run
- Submit
-
-
-
-
-
-
-
-
-
- {{result}}
-
-
-
-
-
-
-
-
-
-
- {{elapsed}}
- Elapsed:
-
-
-
- {{jobId}}
- JobId:
-
-
-
- @TODO
-
-
-
-
-
-
-
diff --git a/src/vue-poc/templates/home.vue b/src/vue-poc/templates/home.vue
deleted file mode 100644
index 2bc33ea..0000000
--- a/src/vue-poc/templates/home.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
- VUE-POC
- v0.0.2
-
-
-
-
- This is a experiment in using vue.js.
-
-
-
- add
-
- REPLACED
-
-
-
diff --git a/src/vue-poc/templates/job/jobs.vue b/src/vue-poc/templates/job/jobs.vue
deleted file mode 100644
index 1ad3a65..0000000
--- a/src/vue-poc/templates/job/jobs.vue
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
- JOBS
-
-
-
-
-
diff --git a/src/vue-poc/templates/job/jobs.xqm b/src/vue-poc/templates/job/jobs.xqm
deleted file mode 100644
index 8050746..0000000
--- a/src/vue-poc/templates/job/jobs.xqm
+++ /dev/null
@@ -1,25 +0,0 @@
-module namespace j = 'quodatum.test.jobs';
-
-
-(:~
- : job list
- :)
-declare
-%rest:GET %rest:path("/vue-poc/api/job")
-%output:method("json")
-function j:list()
-as element(json)
-{
- let $jlist:=jobs:list()[. != jobs:current()] !jobs:list-details(.)
- return
- {for $j in $jlist
- return <_ type="object">
- {$j/@id/string()}
- {$j/@type/string()}
- {$j/@state/string()}
- {$j/@user/string()}
- {$j/@duration/string()}
-
- }
-};
-
diff --git a/src/vue-poc/vue-api2.xqm b/src/vue-poc/vue-api2.xqm
index 3685173..7071d5a 100644
--- a/src/vue-poc/vue-api2.xqm
+++ b/src/vue-poc/vue-api2.xqm
@@ -6,8 +6,8 @@
module namespace vue-api = 'quodatum:vue.api';
import module namespace rest = "http://exquery.org/ns/restxq";
import module namespace session = "http://basex.org/modules/session";
-import module namespace fw="quodatum:file.walker";
-import module namespace mt = 'quodatum.data.mimetype' at "lib/mimetype.xqm";
+
+
declare namespace c="http://www.w3.org/ns/xproc-step";
declare namespace wadl="http://wadl.dev.java.net/2009/02";
@@ -51,32 +51,6 @@ return
};
-(:~
- : history list
- :)
-declare
-%rest:GET %rest:path("/vue-poc/api/history")
-%rest:produces("application/json")
-%output:method("json")
-function vue-api:history( )
-{
- let $h:=(
- '/vue-poc/vue-poc.xqm',
- '/vue-poc/data/vue-poc/ch4d1.xml',
- '/vue-poc/static/app-gen.js',
- '/vue-poc/static/app.html',
- '/vue-poc/static/app.css',
- '/vue-poc/logo.svg',
- '/vue-poc/static/resources/sparql.rq',
- '/vue-poc/static/resources/turtle.ttl'
- )
-
- return
-
- {$h!(<_ type="object">{.})}
-
-
-};
(:~
: Returns wadl.
@@ -88,109 +62,3 @@ function vue-api:wadl()
rest:wadl()
};
-(:~
- : Returns a file content.
- :)
-declare
-%rest:GET %rest:path("/vue-poc/api/edit")
-%rest:query-param("url", "{$url}")
-%rest:produces("application/json")
-%output:method("json")
-function vue-api:edit-get($url as xs:string)
-{
- let $path := vue-api:web( $url)=>trace("path ")
- return if( file:exists($path))then
- let $type:=mt:type($path)
- let $fetch:=mt:fetch-fn($type("treat-as"))
- return
- {$url}
- {$type?type}
- {$fetch($path)}
-
- else
- error(xs:QName('vue-api:raw'),$path)
-};
-
-(:~
- : Update a file content. @TODO
- :)
-declare
-%rest:POST %rest:path("/vue-poc/api/edit")
-%rest:form-param("url", "{$url}")
-%rest:form-param("data", "{$data}")
-%rest:produces("application/json")
-%output:method("json")
-function vue-api:edit-post($url as xs:string,$data)
-{
- let $path := vue-api:web( $url)=>trace("path ")
- let $data:=trace($data)
- return if( file:exists($path))then
- let $type:=mt:type($path)
- let $fetch:=mt:fetch-fn($type("treat-as"))
- return
- {$url}
- {$type?type}
- {$fetch($path)}
-
- else
- error(xs:QName('vue-api:raw'),$path)
-};
-
-(:~
- : Returns folder info.
- :)
-declare
-%rest:path("/vue-poc/api/file")
-%rest:query-param("url", "{$url}")
-%rest:produces("application/json")
-%output:method("json")
-function vue-api:file($url as xs:string)
-{
- let $path := vue-api:web( $url)=>trace("vue-api:web ")
- return if( file:exists($path))then
- let $items:=fw:directory-list($path,map{"max-depth":1,"include-info":true()})
-
- return
-
- {for $f in $items/c:directory
- order by $f/@name/lower-case(.)
- return <_ type="object">
- {$f/@name/string()}
- folder
- {$f/@last-modified/string()}
- {$f/@size/string()}
-
- }
-
-
- {for $f in $items/c:file
- order by $f/@name/lower-case(.)
- return <_ type="object">
- {$f/@name/string()}
- insert_drive_file
- {$f/@last-modified/string()}
- {$f/@size/string()}
-
- }
-
-
- else
- error(xs:QName('vue-api:raw'),$path)
-};
-
-(:~
- : resolve path relative to basex webpath
- : file("/fred")=>C:\Program Files (x86)\BaseX\webapp\fred
- :)
-declare function vue-api:web($file as xs:string)
-as xs:string
-{
- let $file:=if(starts-with($file,"/")) then
- substring($file,2)
- else
- error(xs:QName('vue-api:badpath'),"leading slash")
-
- let $webroot:=db:system()/globaloptions/webpath/concat(.,"/")
- return file:resolve-path($file,$webroot)
-};
-
diff --git a/tools/compile.xq b/tools/compile.xq
index c4b9ab9..6155126 100644
--- a/tools/compile.xq
+++ b/tools/compile.xq
@@ -9,28 +9,40 @@ declare namespace Element="java:ch.digitalfondue.jfiveparse.Element";
declare namespace Node="java:ch.digitalfondue.jfiveparse.Node";
declare namespace functx = "http://www.functx.com";
-declare variable $SRC:="C:/Users/andy/git/vue-poc/src/vue-poc/templates/";
-declare variable $CORE:="C:/Users/andy/git/vue-poc/src/vue-poc/static/core.js";
-declare variable $FILTERS:="C:/Users/andy/git/vue-poc/src/vue-poc/static/filters.js";
-declare variable $DEST:="C:/Users/andy/git/vue-poc/src/vue-poc/static/app-gen.js";
+declare variable $PROJ:="C:/Users/andy/git/vue-poc/src/vue-poc/";
+declare variable $FEATURES:="features/"=>file:resolve-path($PROJ);
+declare variable $COMPONENTS:="components/"=>file:resolve-path($PROJ);
+declare variable $CORE:="components/core.js"=>file:resolve-path($PROJ);
+declare variable $FILTERS:="components/filters.js"=>file:resolve-path($PROJ);
+declare variable $DEST:="static/app-gen.js"=>file:resolve-path($PROJ);
(:~
: generate javascript vue call from vue files in source folder and core.js
:)
-declare function local:process($doc)
+declare function local:feature($doc,$isComp as xs:boolean)
{
-let $tempNode:= html5:getElementFirstByTagName($doc,"template")
-let $template:= Node:getInnerHTML($tempNode)
-let $id := Element:getAttribute($tempNode,"id")
-let $name:=functx:capitalize-first($id)=>trace("ID")
+let $p:=local:vue-parse($doc)
+let $script:= $p?script=>substring-after("{")
-let $script:= html5:getElementFirstByTagName($doc,"script")
-let $script:= Node:getInnerHTML($script)=>substring-after("{")
-let $js:= ``[const `{$name}`=Vue.extend({template:` `{$template}` `,
-`{$script}`
-);
-]``
-return if(empty($id)) then () else $js
+return if(empty($p?id)) then
+ ()
+ else
+ ``[const `{functx:capitalize-first($p?id)}`=Vue.extend({template:` `{$p?template}` `,
+ `{$script}`
+ );
+ ]``
+};
+
+declare function local:vue-parse($doc)
+as map(*)
+{
+ let $tempNode:= html5:getElementFirstByTagName($doc,"template")
+ let $template:= Node:getInnerHTML($tempNode)
+ let $id := Element:getAttribute($tempNode,"id")=>trace("ID")
+
+ let $script:= html5:getElementFirstByTagName($doc,"script")
+ let $script:= Node:getInnerHTML($script)
+ return map{"id":$id,"template":$template,"script":$script}
};
declare function functx:capitalize-first
@@ -39,11 +51,16 @@ declare function functx:capitalize-first
concat(upper-case(substring($arg,1,1)), substring($arg,2))
};
-let $files:= fw:directory-list($SRC,map{"include-filter":".*\.vue"})
+let $files:= fw:directory-list($FEATURES,map{"include-filter":".*\.vue"})
//c:file/@name/resolve-uri(.,base-uri(.))
-let $docs:=$files!(fetch:text(.)=>html5:doc()=>local:process())
+let $feats:=$files!(fetch:text(.)=>html5:doc()=>local:feature(false()))
+
+let $files:= fw:directory-list($COMPONENTS,map{"include-filter":".*\.vue"})
+ //c:file/@name/resolve-uri(.,base-uri(.))
+let $comps:=$files!(fetch:text(.)=>html5:doc()=>local:feature(true()))
+
let $comment:="// generated " || current-dateTime() || "
"
return file:write-text($DEST,string-join(($comment,
fetch:text($FILTERS),
- $docs,
+ $feats,
fetch:text($CORE))))
\ No newline at end of file