Lines 3-56
Link Here
|
3 |
[% USE Asset %] |
3 |
[% USE Asset %] |
4 |
[% USE KohaDates %] |
4 |
[% USE KohaDates %] |
5 |
[% SET footerjs = 1 %] |
5 |
[% SET footerjs = 1 %] |
6 |
[% BLOCK show_job_status %] |
|
|
7 |
[% SWITCH job.status %] |
8 |
[% CASE "new" %] |
9 |
<span>New</span> |
10 |
[% CASE "cancelled" %] |
11 |
<span>Cancelled</span> |
12 |
[% CASE "finished" %] |
13 |
<span>Finished</span> |
14 |
[% CASE "started" %] |
15 |
<span>Started</span> |
16 |
[% CASE "running" %] |
17 |
<span>Running</span> |
18 |
[% CASE "failed" %] |
19 |
<span>Failed</span> |
20 |
[% CASE # Default case %] |
21 |
[% job.status | html %] |
22 |
[% END -%] |
23 |
[% END %] |
24 |
[% BLOCK show_job_type %] |
25 |
[% SWITCH job_type %] |
26 |
[% CASE 'batch_biblio_record_modification' %] |
27 |
<span>Batch bibliographic record modification</span> |
28 |
[% CASE 'batch_biblio_record_deletion' %] |
29 |
<span>Batch bibliographic record record deletion</span> |
30 |
[% CASE 'batch_authority_record_modification' %] |
31 |
<span>Batch authority record modification</span> |
32 |
[% CASE 'batch_authority_record_deletion' %] |
33 |
<span>Batch authority record deletion</span> |
34 |
[% CASE 'batch_item_record_modification' %] |
35 |
<span>Batch item record modification</span> |
36 |
[% CASE 'batch_item_record_deletion' %] |
37 |
<span>Batch item record deletion</span> |
38 |
[% CASE "batch_hold_cancel" %] |
39 |
<span>Batch hold cancellation</span> |
40 |
[% CASE 'update_elastic_index' %] |
41 |
<span>Update Elasticsearch index</span> |
42 |
[% CASE 'update_holds_queue_for_biblios' %] |
43 |
<span>Holds queue update</span> |
44 |
[% CASE %]<span>Unknown job type '[% job_type | html %]'</span> |
45 |
[% END %] |
46 |
|
47 |
[% END %] |
48 |
[% INCLUDE 'doc-head-open.inc' %] |
6 |
[% INCLUDE 'doc-head-open.inc' %] |
49 |
<title> |
7 |
<title> |
50 |
[% IF op == 'view' %] |
8 |
[% IF op == 'view' %] |
51 |
Details of job #[% job.id | html %] › |
9 |
Details of job #[% job.id | html %] › |
52 |
[% END %] |
10 |
[% END %] |
53 |
Background jobs › |
11 |
Jobs › |
54 |
Administration › Koha |
12 |
Administration › Koha |
55 |
</title> |
13 |
</title> |
56 |
|
14 |
|
Lines 73-86
Link Here
|
73 |
</li> |
31 |
</li> |
74 |
[% IF op == 'view' %] |
32 |
[% IF op == 'view' %] |
75 |
<li> |
33 |
<li> |
76 |
<a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a> |
34 |
<a href="/cgi-bin/koha/admin/background_jobs.pl">Jobs</a> |
77 |
</li> |
35 |
</li> |
78 |
<li> |
36 |
<li> |
79 |
<a href="#" aria-current="page">Details of job #[% job.id | html %]</a> |
37 |
<a href="#" aria-current="page">Details of job #[% job.id | html %]</a> |
80 |
</li> |
38 |
</li> |
81 |
[% ELSE %] |
39 |
[% ELSE %] |
82 |
<li> |
40 |
<li> |
83 |
<a href="#" aria-current="page">Background jobs</a> |
41 |
<a href="#" aria-current="page">Jobs</a> |
84 |
</li> |
42 |
</li> |
85 |
[% END %] |
43 |
[% END %] |
86 |
[% ELSE %] |
44 |
[% ELSE %] |
Lines 112-128
Link Here
|
112 |
|
70 |
|
113 |
[% PROCESS "background_jobs/${job.type}.inc" %] |
71 |
[% PROCESS "background_jobs/${job.type}.inc" %] |
114 |
|
72 |
|
115 |
<fieldset class="rows"> |
73 |
<fieldset class="rows" style="display:none;"> |
116 |
<ol> |
74 |
<ol> |
117 |
<li><span class="label">Job ID: </span>[% job.id | html %]</li> |
75 |
<li><span class="label">Job ID: </span>[% job.id | html %]</li> |
118 |
<li> |
76 |
<li> |
119 |
<label for="job_status">Status: </label> |
77 |
<label for="job_status">Status: </label> |
120 |
[% PROCESS show_job_status %] |
78 |
<span id="job_status_description"></span> |
121 |
</li> |
79 |
</li> |
122 |
<li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li> |
80 |
<li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li> |
123 |
<li> |
81 |
<li> |
124 |
<label for="job_type">Type: </label> |
82 |
<label for="job_type">Type: </label> |
125 |
[% PROCESS show_job_type job_type => job.type %] |
83 |
<span id="job_type_description"></span> |
126 |
</li> |
84 |
</li> |
127 |
<li> |
85 |
<li> |
128 |
<label for="job_enqueued_on">Queued: </label> |
86 |
<label for="job_enqueued_on">Queued: </label> |
Lines 154-261
Link Here
|
154 |
|
112 |
|
155 |
[% IF op == 'list' %] |
113 |
[% IF op == 'list' %] |
156 |
|
114 |
|
157 |
<h1>Background jobs</h1> |
115 |
<h1>Jobs</h1> |
158 |
|
116 |
|
159 |
<div id="taskstabs" class="toptabs"> |
117 |
<div> |
160 |
<ul class="nav nav-tabs" role="tablist"> |
118 |
<input type="checkbox" id="only_current" checked /> |
161 |
<li role="presentation" class="active"><a href="#queued" aria-controls="queued" role="tab" data-toggle="tab">Queued jobs</a></li> |
119 |
<label for="only_current">Current jobs only</label> |
162 |
<li role="presentation"><a href="#complete" aria-controls="complete" role="tab" data-toggle="tab">Completed jobs</a></li> |
120 |
</div> |
163 |
</ul> |
|
|
164 |
|
165 |
<div class="tab-content"> |
166 |
<div role="tabpanel" class="tab-pane active" id="queued"> |
167 |
[% IF queued.count %] |
168 |
<table id="table_queued_jobs"> |
169 |
<thead> |
170 |
<tr> |
171 |
<th>Job ID</th> |
172 |
<th>Status</th> |
173 |
<th>Progress</th> |
174 |
<th>Type</th> |
175 |
<th>Queued</th> |
176 |
<th>Started</th> |
177 |
<th class="noExport">Actions</th> |
178 |
</tr> |
179 |
</thead> |
180 |
<tbody> |
181 |
[% FOREACH job IN queued %] |
182 |
<tr> |
183 |
<td>[% job.id | html %]</td> |
184 |
<td> |
185 |
[% PROCESS show_job_status %] |
186 |
</td> |
187 |
<td>[% job.progress || 0 | html %] / [% job.size | html %]</td> |
188 |
<td> |
189 |
[% PROCESS show_job_type job_type => job.type %] |
190 |
</td> |
191 |
<td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td> |
192 |
<td>[% job.started_on| $KohaDates with_hours = 1 %]</td> |
193 |
<td class="actions"> |
194 |
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a> |
195 |
[% IF job.status == 'new' || job.status == 'started' %] |
196 |
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a> |
197 |
[% END %] |
198 |
</td> |
199 |
</tr> |
200 |
[% END %] |
201 |
</tbody> |
202 |
</table> |
203 |
[% ELSE %] |
204 |
<div class="dialog message"> |
205 |
There are no queued background jobs yet. |
206 |
</div> |
207 |
[% END %] |
208 |
</div> |
209 |
|
121 |
|
210 |
<div role="tabpanel" class="tab-pane" id="complete"> |
122 |
<div> |
211 |
[% IF complete.count %] |
123 |
<input type="checkbox" id="include_last_hour" checked /> |
212 |
<p>Jobs completed in the last 60 minutes.</p> |
124 |
<label for="include_last_hour">Only include jobs started in the last hour</label> |
213 |
<table id="table_complete_jobs"> |
|
|
214 |
<thead> |
215 |
<tr> |
216 |
<th>Job ID</th> |
217 |
<th>Status</th> |
218 |
<th>Progress</th> |
219 |
<th>Type</th> |
220 |
<th>Queued</th> |
221 |
<th>Started</th> |
222 |
<th>Ended</th> |
223 |
<th class="noExport">Actions</th> |
224 |
</tr> |
225 |
</thead> |
226 |
<tbody> |
227 |
[% FOREACH job IN complete %] |
228 |
<tr> |
229 |
<td>[% job.id | html %]</td> |
230 |
<td> |
231 |
[% PROCESS show_job_status %] |
232 |
</td> |
233 |
<td>[% job.progress || 0 | html %] / [% job.size | html %]</td> |
234 |
<td> |
235 |
[% PROCESS show_job_type job_type => job.type %] |
236 |
</td> |
237 |
<td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td> |
238 |
<td>[% job.started_on| $KohaDates with_hours = 1 %]</td> |
239 |
<td>[% job.ended_on| $KohaDates with_hours = 1 %]</td> |
240 |
<td class="actions"> |
241 |
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a> |
242 |
[% IF job.status == 'new' || job.status == 'started' %] |
243 |
<a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a> |
244 |
[% END %] |
245 |
</td> |
246 |
</tr> |
247 |
[% END %] |
248 |
</tbody> |
249 |
</table> |
250 |
[% ELSE %] |
251 |
<div class="dialog message"> |
252 |
There were no completed background jobs completed in the last 60 minutes. |
253 |
</div> |
254 |
[% END %] |
255 |
</div> |
256 |
</div> |
257 |
</div> |
125 |
</div> |
258 |
|
126 |
|
|
|
127 |
<table id="table_jobs"> |
128 |
<thead> |
129 |
<tr> |
130 |
<th>Job ID</th> |
131 |
<th data-filter="job_statuses">Status</th> |
132 |
<th>Progress</th> |
133 |
<th data-filter="job_types">Type</th> |
134 |
<th>Queued</th> |
135 |
<th>Started</th> |
136 |
<th>Ended</th> |
137 |
<th class="noExport">Actions</th> |
138 |
</tr> |
139 |
</thead> |
140 |
</table> |
259 |
[% END %] |
141 |
[% END %] |
260 |
|
142 |
|
261 |
</main> |
143 |
</main> |
Lines 270-295
Link Here
|
270 |
|
152 |
|
271 |
[% MACRO jsinclude BLOCK %] |
153 |
[% MACRO jsinclude BLOCK %] |
272 |
[% Asset.js("js/admin-menu.js") | $raw %] |
154 |
[% Asset.js("js/admin-menu.js") | $raw %] |
|
|
155 |
[% INCLUDE 'js-date-format.inc' %] |
273 |
[% INCLUDE 'datatables.inc' %] |
156 |
[% INCLUDE 'datatables.inc' %] |
274 |
<script> |
157 |
<script> |
|
|
158 |
const job_statuses = [ |
159 |
{'_id': 'new', '_str': _("New")}, |
160 |
{'_id': 'cancelled', '_str': _("Cancelled")}, |
161 |
{'_id': 'finished', '_str': _("Finished")}, |
162 |
{'_id': 'started', '_str': _("Started")}, |
163 |
{'_id': 'running', '_str': _("Running")}, |
164 |
{'_id': 'failed', '_str': _("Failed")}, |
165 |
]; |
166 |
function get_job_status (status) { |
167 |
let status_lib = job_statuses.find( s => s._id == status ); |
168 |
if (status_lib) { |
169 |
return status_lib._str; |
170 |
} |
171 |
return status; |
172 |
} |
173 |
|
174 |
const job_types = [ |
175 |
{ |
176 |
'_id': 'batch_biblio_record_modification', |
177 |
'_str': _("Batch bibliographic record modification") |
178 |
}, |
179 |
{ |
180 |
'_id': 'batch_biblio_record_deletion', |
181 |
'_str': _("Batch bibliographic record record deletion") |
182 |
}, |
183 |
{ |
184 |
'_id': 'batch_authority_record_modification', |
185 |
'_str': _("Batch authority record modification") |
186 |
}, |
187 |
{ |
188 |
'_id': 'batch_authority_record_deletion', |
189 |
'_str': _("Batch authority record deletion") |
190 |
}, |
191 |
{ |
192 |
'_id': 'batch_item_record_modification', |
193 |
'_str': _("Batch item record modification") |
194 |
}, |
195 |
{ |
196 |
'_id': 'batch_item_record_deletion', |
197 |
'_str': _("Batch item record deletion") |
198 |
}, |
199 |
{ |
200 |
'_id': 'batch_hold_cancel', |
201 |
'_str': _("Batch hold cancellation") |
202 |
}, |
203 |
{ |
204 |
'_id': 'update_elastic_index', |
205 |
'_str': _("Update Elasticsearch index") |
206 |
}, |
207 |
{ |
208 |
'_id': 'update_holds_queue_for_biblios', |
209 |
'_str': _("Holds queue update") |
210 |
}, |
211 |
{ |
212 |
'_id': 'stage_marc_for_import', |
213 |
'_str': _("Staged MARC records for import") |
214 |
}, |
215 |
{ |
216 |
'_id': 'marc_import_commit_batch', |
217 |
'_str': _("Import MARC records") |
218 |
}, |
219 |
{ |
220 |
'_id': 'marc_import_revert_batch', |
221 |
'_str': _("Revert import MARC records") |
222 |
}, |
223 |
]; |
224 |
|
225 |
function get_job_type (job_type) { |
226 |
let job_type_lib = job_types.find( t => t._id == job_type ); |
227 |
if ( job_type_lib ) { |
228 |
return job_type_lib._str; |
229 |
} |
230 |
return _("Unknown job type '%s'").format(job_type); |
231 |
} |
232 |
|
275 |
$(document).ready(function() { |
233 |
$(document).ready(function() { |
276 |
$("#table_queued_jobs").dataTable($.extend(true, {}, dataTablesDefaults, { |
234 |
[% IF op == 'view' %] |
277 |
"aoColumnDefs": [ |
235 |
$("#job_status_description").html( get_job_status("[% job.status | html %]") ); |
278 |
{ "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, |
236 |
$("#job_type_description").html( get_job_type("[% job.type | html %]") ); |
279 |
], |
237 |
$("fieldset.rows").show(); |
280 |
"aaSorting": [[ 0, "desc" ]], |
238 |
[% END %] |
281 |
"iDisplayLength": 10, |
239 |
|
282 |
"sPaginationType": "full_numbers" |
240 |
let additional_filters = { |
283 |
})); |
241 |
started_on: function(){ |
|
|
242 |
let now = new Date(); |
243 |
if ( $("#include_last_hour").is(":checked") ) { |
244 |
now.setHours(now.getHours() - 1); |
245 |
return { ">": now.toISOString() }; |
246 |
} else { |
247 |
return { "<": now.toISOString() }; |
248 |
} |
249 |
} |
250 |
}; |
251 |
|
252 |
let only_current_filter = function(){ |
253 |
if ( $("#only_current").is(":checked") ) { |
254 |
return 'only_current=1'; |
255 |
} else { |
256 |
return 'only_current=0'; |
257 |
} |
258 |
} |
259 |
|
260 |
let jobs_table = $("#table_jobs").kohaTable({ |
261 |
"ajax": { |
262 |
"url": "/api/v1/jobs?" + only_current_filter() |
263 |
}, |
264 |
"order": [[ 1, "desc" ]], |
265 |
"columns": [ |
266 |
{ |
267 |
"data": "job_id", |
268 |
"searchable": true, |
269 |
"orderable": true |
270 |
}, |
271 |
{ |
272 |
"data": "status", |
273 |
"searchable": true, |
274 |
"orderable": true, |
275 |
"render": function(data, type, row, meta) { |
276 |
return get_job_status(row.status).escapeHtml(); |
277 |
} |
278 |
}, |
279 |
{ |
280 |
"data": "progress,size", |
281 |
"searchable": false, |
282 |
"orderable": true, |
283 |
"render": function(data, type, row, meta) { |
284 |
return "%s/%s".format(row.progress, row.size).escapeHtml(); |
285 |
} |
286 |
}, |
287 |
{ |
288 |
"data": "type", |
289 |
"searchable": true, |
290 |
"orderable": true, |
291 |
"render": function(data, type, row, meta) { |
292 |
return get_job_type(row.type).escapeHtml(); |
293 |
} |
294 |
}, |
295 |
{ |
296 |
"data": "enqueued_date", |
297 |
"searchable": true, |
298 |
"orderable": true, |
299 |
"render": function(data, type, row, meta) { |
300 |
return $datetime(row.enqueued_date); |
301 |
} |
302 |
}, |
303 |
{ |
304 |
"data": "started_date", |
305 |
"searchable": true, |
306 |
"orderable": true, |
307 |
"render": function(data, type, row, meta) { |
308 |
return $datetime(row.started_date); |
309 |
} |
310 |
}, |
311 |
{ |
312 |
"data": "ended_date", |
313 |
"searchable": true, |
314 |
"orderable": true, |
315 |
"render": function(data, type, row, meta) { |
316 |
return $datetime(row.ended_date); |
317 |
} |
318 |
}, |
319 |
{ |
320 |
"data": function( row, type, val, meta ) { |
321 |
var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&id='+ encodeURIComponent(row.job_id) +'"><i class="fa fa-eye" aria-hidden="true"></i> '+_("View")+'</a>'+"\n"; |
322 |
if ( row.status == 'new' || row.status == 'started' ) { |
323 |
result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/bakcground_jobs.pl?op=cancel&id='+ encodeURIComponent(row.job_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</a>'; |
324 |
} |
325 |
return result; |
326 |
}, |
327 |
"searchable": false, |
328 |
"orderable": false |
329 |
} |
330 |
] |
331 |
}, null, 1, additional_filters); |
332 |
|
333 |
$("#include_last_hour").on("change", function(){ |
334 |
jobs_table.DataTable().draw(); |
335 |
return false; |
336 |
}); |
284 |
|
337 |
|
285 |
$("#table_complete_jobs").dataTable($.extend(true, {}, dataTablesDefaults, { |
338 |
$("#only_current").on("change", function(){ |
286 |
"aoColumnDefs": [ |
339 |
jobs_table.DataTable().ajax.url("/api/v1/jobs?" + only_current_filter()).load(); |
287 |
{ "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, |
340 |
return false; |
288 |
], |
341 |
}); |
289 |
"aaSorting": [[ 0, "desc" ]], |
|
|
290 |
"iDisplayLength": 10, |
291 |
"sPaginationType": "full_numbers" |
292 |
})); |
293 |
}); |
342 |
}); |
294 |
</script> |
343 |
</script> |
295 |
[% IF op == 'view' %] |
344 |
[% IF op == 'view' %] |