@@ -33,15 +33,18 @@ function dba:jobs(
33
33
$error as xs:string?,
34
34
$info as xs:string?
35
35
) as element (html) {
36
- html:wrap (map { 'header' : $dba:CAT, 'info' : $info, 'error' : $error },
36
+ html:wrap (map {
37
+ 'header' : $dba:CAT, 'info' : $info, 'error' : $error,
38
+ 'css' : 'codemirror/lib/codemirror.css' ,
39
+ 'scripts' : ('codemirror/lib/codemirror.js' , 'codemirror/mode/xml/xml.js' )
40
+ },
37
41
<tr>{
38
42
<td>
39
43
<form action = '{ $dba:CAT } ' method = 'post' class = 'update' >
40
44
<h2>Jobs</h2>
41
45
{
42
46
let $headers := (
43
47
map { 'key' : 'id' , 'label' : 'ID' },
44
- map { 'key' : 'type' , 'label' : 'Type' },
45
48
map { 'key' : 'state' , 'label' : 'State' },
46
49
map { 'key' : 'duration' , 'label' : 'Dur.' , 'type' : 'number' , 'order' : 'desc' },
47
50
map { 'key' : 'user' , 'label' : 'User' },
@@ -62,7 +65,6 @@ function dba:jobs(
62
65
order by $sec descending , $start descending
63
66
return map {
64
67
'id' : $id,
65
- 'type' : $details/@type ,
66
68
'state' : $details/@state,
67
69
'duration' : html:duration ($sec),
68
70
'user' : $details/@user,
@@ -90,50 +92,72 @@ function dba:jobs(
90
92
let $cached := $details/@state = 'cached'
91
93
return (
92
94
<td class = 'vertical' />,
93
- <td>{
94
- <h2>Job: { $job }</h2>,
95
- if ($details) then (
96
- <form action = 'jobs' method = 'post' id = 'jobs' >
97
- <input type = 'hidden' name = 'id' value = '{ $job } ' />
98
- {
99
- html:button ('job-result' , 'Download' , false (),
100
- if ($cached) then () else map { 'disabled' : '' }), ' ' ,
101
- html:button ('job-remove' , 'Remove' , false ())
102
- }
103
- </form>,
104
- <h3>General Information</h3>,
105
- <table>{
106
- for $value in $details/@*
107
- for $name in name ($value)[. != 'id' ]
108
- return <tr>
109
- <td><b>{ util:capitalize ($name) }</b></td>
110
- <td>{ string ($value) }</td>
111
- </tr>
112
- }</table>,
113
- let $bindings := job:bindings ($job)
114
- where map:size ($bindings) > 0
115
- return (
116
- <h3>Query Bindings</h3>,
95
+ <td>
96
+ <form action = 'jobs' method = 'post' id = 'jobs' >{
97
+ <input type = 'hidden' name = 'id' value = '{ $job } ' />,
98
+ <h2>{
99
+ 'Job: ' , $job, '  ' ,
100
+ if ($details) then html:button ('job-remove' , 'Remove' , false ())
101
+ }</h2>,
102
+
103
+ if ($details) then (
104
+ <h3>General Information</h3>,
117
105
<table>{
118
- map:for-each ($bindings, function ($key, $value) {
119
- <tr>
120
- <td><b>{ $key ?? '$' || $key !! 'Context' }</b></td>
121
- <td><code>{
122
- util:chop (serialize ($value, map { 'method' : 'basex' }), 1000 )
123
- }</code></td>
124
- </tr>
106
+ for $value in $details/@*
107
+ for $name in name ($value)[. != 'id' ]
108
+ return <tr>
109
+ <td><b>{ util:capitalize ($name) }</b></td>
110
+ <td>{ string ($value) }</td>
111
+ </tr>
112
+ }</table>,
113
+
114
+ let $bindings := job:bindings ($job)
115
+ where map:size ($bindings) > 0
116
+ return (
117
+ <h3>Query Bindings</h3>,
118
+ <table>{
119
+ map:for-each ($bindings, function ($key, $value) {
120
+ <tr>
121
+ <td><b>{ $key ?? '$' || $key !! 'Context' }</b></td>
122
+ <td><code>{
123
+ util:chop (serialize ($value, map { 'method' : 'basex' }), 1000 )
124
+ }</code></td>
125
+ </tr>
126
+ })
127
+ }
128
+ </table>
129
+ ),
130
+
131
+ <h3>Query</h3>,
132
+ <textarea readonly = '' spellcheck = 'false' rows = '5' >{
133
+ string ($details)
134
+ }</textarea>,
135
+
136
+ if ($cached) then (
137
+ let $result := util:serialize (try {
138
+ job:result ($job, map { 'keep' : true () })
139
+ } catch * {
140
+ 'Stopped at ' || $err:module || ', ' || $err:line-number || '/' ||
141
+ $err:column-number || ':' || string:nl () || $err:description
125
142
})
126
- }
127
- </table>
128
- ),
129
- <h3>Job String</h3>,
130
- <textarea readonly = '' rows = '10' >{
131
- string ($details)
132
- }</textarea>
133
- ) else (
134
- 'Job is defunct.'
135
- )
136
- }</td>
143
+ where $result
144
+ return (
145
+ <h3>{
146
+ 'Result' , '  ' ,
147
+ html:button ('job-result' , 'Download' )
148
+ }
149
+ </h3>,
150
+ <textarea name = 'output' id = 'output' readonly = '' spellcheck = 'false' >{
151
+ $result
152
+ }</textarea>,
153
+ html:js ('loadCodeMirror("xml");' )
154
+ )
155
+ )
156
+ ) else (
157
+ 'Job has expired.'
158
+ )
159
+ }</form>
160
+ </td>
137
161
)
138
162
) else ()
139
163
}</tr>
0 commit comments