6 [% INCLUDE 'doc-head-open.inc' %]
9 Details of job #[% job.id | html %] ›
12 Administration › Koha
15 [% INCLUDE 'doc-head-close.inc' %]
18 <body id="admin_background_jobs" class="admin">
19 [% WRAPPER 'header.inc' %]
20 [% INCLUDE 'prefs-admin-search.inc' %]
23 [% WRAPPER 'sub-header.inc' %]
24 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
27 <a href="/cgi-bin/koha/mainpage.pl"><i class="fa fa-home"></i></a>
30 [% IF CAN_user_parameters_manage_background_jobs %]
32 <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
36 <a href="/cgi-bin/koha/admin/background_jobs.pl">Jobs</a>
39 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
43 <a href="#" aria-current="page">Jobs</a>
48 <a href="#" aria-current="page">Administration</a>
55 <div class="main container-fluid">
57 <div class="col-sm-10 col-sm-push-2">
60 [% FOR m IN messages %]
61 <div class="dialog message">
63 [% CASE 'cannot_view_job' %]
64 <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
72 <h1>Details of job #[% job.id | html %]</h1>
74 [% PROCESS "background_jobs/${job.type}.inc" %]
76 <fieldset class="rows" style="display:none;">
78 <li><span class="label">Job ID: </span>[% job.id | html %]</li>
80 <label for="job_status">Status: </label>
81 <span id="job_status_description"></span>
83 <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
85 <label for="job_type">Type: </label>
86 <span id="job_type_description"></span>
89 <label for="job_enqueued_on">Queued: </label>
90 [% job.enqueued_on | $KohaDates with_hours = 1 %]
93 <label for="job_started_on">Started: </label>
94 [% job.started_on | $KohaDates with_hours = 1 %]
97 <label for="job_ended_on">Ended: </label>
98 [% job.ended_on | $KohaDates with_hours = 1 %]
100 <li><label for="job_data">Report: </label>
101 [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
103 <li><label for="job_data">Detailed messages: </label>
104 [% IF job.status != 'new' %][% PROCESS 'detail' %][% END %]
109 [% IF CAN_user_parameters_manage_background_jobs %]
110 <fieldset class="action">
111 <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
116 [% IF op == 'list' %]
121 <input type="checkbox" id="only_current" checked />
122 <label for="only_current">Current jobs only</label>
126 <input type="checkbox" id="include_last_hour" checked />
127 <label for="include_last_hour">Only include jobs started in the last hour</label>
130 <table id="table_jobs">
134 <th data-filter="job_statuses">Status</th>
136 <th data-filter="job_types">Type</th>
140 <th class="noExport">Actions</th>
147 </div> <!-- /.col-sm-10.col-sm-push-2 -->
149 <div class="col-sm-2 col-sm-pull-10">
151 [% INCLUDE 'admin-menu.inc' %]
153 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
154 </div> <!-- /.row -->
156 [% MACRO jsinclude BLOCK %]
157 [% Asset.js("js/admin-menu.js") | $raw %]
158 [% INCLUDE 'js-date-format.inc' %]
159 [% INCLUDE 'datatables.inc' %]
161 const job_statuses = [
162 {'_id': 'new', '_str': _("New")},
163 {'_id': 'cancelled', '_str': _("Cancelled")},
164 {'_id': 'finished', '_str': _("Finished")},
165 {'_id': 'started', '_str': _("Started")},
166 {'_id': 'running', '_str': _("Running")},
167 {'_id': 'failed', '_str': _("Failed")},
169 function get_job_status (status) {
170 let status_lib = job_statuses.find( s => s._id == status );
172 return status_lib._str;
179 '_id': 'batch_biblio_record_modification',
180 '_str': _("Batch bibliographic record modification")
183 '_id': 'batch_biblio_record_deletion',
184 '_str': _("Batch bibliographic record record deletion")
187 '_id': 'batch_authority_record_modification',
188 '_str': _("Batch authority record modification")
191 '_id': 'batch_authority_record_deletion',
192 '_str': _("Batch authority record deletion")
195 '_id': 'batch_item_record_modification',
196 '_str': _("Batch item record modification")
199 '_id': 'batch_item_record_deletion',
200 '_str': _("Batch item record deletion")
203 '_id': 'batch_hold_cancel',
204 '_str': _("Batch hold cancellation")
207 '_id': 'update_elastic_index',
208 '_str': _("Update Elasticsearch index")
211 '_id': 'update_holds_queue_for_biblios',
212 '_str': _("Holds queue update")
215 '_id': 'stage_marc_for_import',
216 '_str': _("Staged MARC records for import")
219 '_id': 'marc_import_commit_batch',
220 '_str': _("Import MARC records")
223 '_id': 'marc_import_revert_batch',
224 '_str': _("Revert import MARC records")
228 function get_job_type (job_type) {
229 let job_type_lib = job_types.find( t => t._id == job_type );
230 if ( job_type_lib ) {
231 return job_type_lib._str;
233 return _("Unknown job type '%s'").format(job_type);
236 $(document).ready(function() {
237 [% IF op == 'view' %]
238 $("#job_status_description").html( get_job_status("[% job.status | html %]") );
239 $("#job_type_description").html( get_job_type("[% job.type | html %]") );
240 $("fieldset.rows").show();
243 let additional_filters = {
244 started_on: function(){
245 let now = new Date();
246 if ( $("#include_last_hour").is(":checked") ) {
247 now.setHours(now.getHours() - 1);
248 return { ">": now.toISOString() };
250 return { "<": now.toISOString() };
255 let only_current_filter = function(){
256 if ( $("#only_current").is(":checked") ) {
257 return 'only_current=1';
259 return 'only_current=0';
263 let jobs_table = $("#table_jobs").kohaTable({
265 "url": "/api/v1/jobs?" + only_current_filter()
267 "order": [[ 1, "desc" ]],
278 "render": function(data, type, row, meta) {
279 return get_job_status(row.status).escapeHtml();
283 "data": "progress,size",
286 "render": function(data, type, row, meta) {
287 return "%s/%s".format(row.progress, row.size).escapeHtml();
294 "render": function(data, type, row, meta) {
295 return get_job_type(row.type).escapeHtml();
299 "data": "enqueued_date",
302 "render": function(data, type, row, meta) {
303 return $datetime(row.enqueued_date);
307 "data": "started_date",
310 "render": function(data, type, row, meta) {
311 return $datetime(row.started_date);
315 "data": "ended_date",
318 "render": function(data, type, row, meta) {
319 return $datetime(row.ended_date);
323 "data": function( row, type, val, meta ) {
324 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";
325 if ( row.status == 'new' || row.status == 'started' ) {
326 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>';
334 }, null, 1, additional_filters);
336 $("#include_last_hour").on("change", function(){
337 jobs_table.DataTable().draw();
341 $("#only_current").on("change", function(){
342 jobs_table.DataTable().ajax.url("/api/v1/jobs?" + only_current_filter()).load();
347 [% IF op == 'view' %]
352 [% INCLUDE 'intranet-bottom.inc' %]