6 [% BLOCK show_job_status %]
7 [% SWITCH job.status %]
10 [% CASE "cancelled" %]
11 <span>Cancelled</span>
20 [% CASE # Default case %]
21 [% job.status | html %]
24 [% BLOCK show_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 'stage_marc_for_import' %]
45 <span>Staged MARC records for import</span>
46 [% CASE 'marc_import_commit_batch' %]
47 <span>Import MARC records</span>
48 [% CASE 'marc_import_revert_batch' %]
49 <span>Revert import MARC records</span>
50 [% CASE %]<span>Unknown job type '[% job_type | html %]'</span>
54 [% INCLUDE 'doc-head-open.inc' %]
57 Details of job #[% job.id | html %] ›
60 Administration › Koha
63 [% INCLUDE 'doc-head-close.inc' %]
66 <body id="admin_background_jobs" class="admin">
67 [% INCLUDE 'header.inc' %]
68 [% INCLUDE 'prefs-admin-search.inc' %]
70 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
73 <a href="/cgi-bin/koha/mainpage.pl">Home</a>
76 [% IF CAN_user_parameters_manage_background_jobs %]
78 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
82 <a href="/cgi-bin/koha/admin/background_jobs.pl">Jobs</a>
85 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
89 <a href="#" aria-current="page">Jobs</a>
94 <a href="#" aria-current="page">Administration</a>
100 <div class="main container-fluid">
102 <div class="col-sm-10 col-sm-push-2">
105 [% FOR m IN messages %]
106 <div class="dialog message">
108 [% CASE 'cannot_view_job' %]
109 <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
116 [% IF op == 'view' %]
117 <h1>Details of job #[% job.id | html %]</h1>
119 [% PROCESS "background_jobs/${job.type}.inc" %]
121 <fieldset class="rows">
123 <li><span class="label">Job ID: </span>[% job.id | html %]</li>
125 <label for="job_status">Status: </label>
126 [% PROCESS show_job_status %]
128 <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
130 <label for="job_type">Type: </label>
131 [% PROCESS show_job_type job_type => job.type %]
134 <label for="job_enqueued_on">Queued: </label>
135 [% job.enqueued_on | $KohaDates with_hours = 1 %]
138 <label for="job_started_on">Started: </label>
139 [% job.started_on | $KohaDates with_hours = 1 %]
142 <label for="job_ended_on">Ended: </label>
143 [% job.ended_on | $KohaDates with_hours = 1 %]
145 <li><label for="job_data">Report: </label>
146 [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
148 <li><label for="job_data">Detailed messages: </label>
149 [% IF job.status != 'new' %][% PROCESS 'detail' %][% END %]
154 [% IF CAN_user_parameters_manage_background_jobs %]
155 <fieldset class="action">
156 <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
161 [% IF op == 'list' %]
166 <input type="checkbox" id="only_current" checked />
167 <label for="only_current">Current jobs only</label>
171 <input type="checkbox" id="include_last_hour" checked />
172 <label for="include_last_hour">Only include jobs started in the last hour</label>
175 <table id="table_jobs">
179 <th data-filter="job_statuses">Status</th>
181 <th data-filter="job_types">Type</th>
185 <th class="noExport">Actions</th>
192 </div> <!-- /.col-sm-10.col-sm-push-2 -->
194 <div class="col-sm-2 col-sm-pull-10">
196 [% INCLUDE 'admin-menu.inc' %]
198 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
199 </div> <!-- /.row -->
201 [% MACRO jsinclude BLOCK %]
202 [% Asset.js("js/admin-menu.js") | $raw %]
203 [% INCLUDE 'js-date-format.inc' %]
204 [% INCLUDE 'datatables.inc' %]
206 const job_statuses = [
207 {'_id': 'new', '_str': _("New")},
208 {'_id': 'cancelled', '_str': _("Cancelled")},
209 {'_id': 'finished', '_str': _("Finished")},
210 {'_id': 'started', '_str': _("Started")},
211 {'_id': 'running', '_str': _("Running")},
212 {'_id': 'failed', '_str': _("Failed")},
214 function get_job_status (status) {
215 let status_lib = job_statuses.find( s => s._id == status );
217 return status_lib._str;
224 '_id': 'batch_biblio_record_modification',
225 '_str': _("Batch bibliographic record modification")
228 '_id': 'batch_biblio_record_deletion',
229 '_str': _("Batch bibliographic record record deletion")
232 '_id': 'batch_authority_record_modification',
233 '_str': _("Batch authority record modification")
236 '_id': 'batch_authority_record_deletion',
237 '_str': _("Batch authority record deletion")
240 '_id': 'batch_item_record_modification',
241 '_str': _("Batch item record modification")
244 '_id': 'batch_item_record_deletion',
245 '_str': _("Batch item record deletion")
248 '_id': 'batch_hold_cancel',
249 '_str': _("Batch hold cancellation")
252 '_id': 'update_elastic_index'
253 , '_str': _("Update Elasticsearch index")
256 '_id': 'update_holds_queue_for_biblios',
257 '_str': _("Holds queue update")
261 function get_job_type (job_type) {
262 let job_type_lib = job_types.find( t => t._id == job_type );
263 if ( job_type_lib ) {
264 return job_type_lib._str;
266 return _("Unknown job type '%s'").format(job_type);
269 $(document).ready(function() {
270 let additional_filters = {
271 started_on: function(){
272 let now = new Date();
273 if ( $("#include_last_hour").is(":checked") ) {
274 now.setHours(now.getHours() - 1);
275 return { ">": now.toISOString() };
277 return { "<": now.toISOString() };
282 let only_current_filter = function(){
283 if ( $("#only_current").is(":checked") ) {
284 return 'only_current=1';
286 return 'only_current=0';
290 let jobs_table = $("#table_jobs").kohaTable({
292 "url": "/api/v1/jobs?" + only_current_filter()
294 "order": [[ 1, "desc" ]],
305 "render": function(data, type, row, meta) {
306 return get_job_status(row.status).escapeHtml();
310 "data": "progress,size",
313 "render": function(data, type, row, meta) {
314 return "%s/%s".format(row.progress, row.size).escapeHtml();
321 "render": function(data, type, row, meta) {
322 return get_job_type(row.type).escapeHtml();
326 "data": "enqueued_date",
329 "render": function(data, type, row, meta) {
330 return $datetime(row.enqueued_date);
334 "data": "started_date",
337 "render": function(data, type, row, meta) {
338 return $datetime(row.started_date);
342 "data": "ended_date",
345 "render": function(data, type, row, meta) {
346 return $datetime(row.ended_date);
350 "data": function( row, type, val, meta ) {
351 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";
352 if ( row.status == 'new' || row.status == 'started' ) {
353 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>';
361 }, null, 1, additional_filters);
363 $("#include_last_hour").on("change", function(){
364 jobs_table.DataTable().draw();
368 $("#only_current").on("change", function(){
369 jobs_table.DataTable().ajax.url("/api/v1/jobs?" + only_current_filter()).load();
374 [% IF op == 'view' %]
379 [% INCLUDE 'intranet-bottom.inc' %]