Bug 31378: Add domain settings to IdP add page
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / background_jobs.tt
1 [% USE raw %]
2 [% USE KohaDates %]
3 [% USE Asset %]
4 [% USE KohaDates %]
5 [% SET footerjs = 1 %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>
8     [% IF op == 'view' %]
9         Details of job #[% job.id | html %] &rsaquo;
10     [% END %]
11     Jobs &rsaquo;
12     Administration &rsaquo; Koha
13 </title>
14
15 [% INCLUDE 'doc-head-close.inc' %]
16 </head>
17
18 <body id="admin_background_jobs" class="admin">
19 [% WRAPPER 'header.inc' %]
20     [% INCLUDE 'prefs-admin-search.inc' %]
21 [% END %]
22
23 [% WRAPPER 'sub-header.inc' %]
24 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
25     <ol>
26         <li>
27             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
28         </li>
29
30     [% IF CAN_user_parameters_manage_background_jobs %]
31         <li>
32             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
33         </li>
34         [% IF op == 'view' %]
35             <li>
36                 <a href="/cgi-bin/koha/admin/background_jobs.pl">Jobs</a>
37             </li>
38             <li>
39                 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
40             </li>
41         [% ELSE %]
42             <li>
43                 <a href="#" aria-current="page">Jobs</a>
44             </li>
45         [% END %]
46     [% ELSE %]
47         <li>
48             <a href="#" aria-current="page">Administration</a>
49         </li>
50     [% END %]
51     </ol>
52 </nav>
53 [% END %]
54
55 <div class="main container-fluid">
56     <div class="row">
57         <div class="col-sm-10 col-sm-push-2">
58             <main>
59
60 [% FOR m IN messages %]
61     <div class="dialog message">
62         [% SWITCH m.code %]
63         [% CASE 'cannot_view_job' %]
64             <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
65         [% CASE %]
66             [% m.code | html %]
67         [% END %]
68     </div>
69 [% END %]
70
71 [% IF op == 'view' %]
72     <h1>Details of job #[% job.id | html %]</h1>
73
74     [% PROCESS "background_jobs/${job.type}.inc" %]
75
76     <div id="job_details" style="display:none">
77         <fieldset class="rows">
78             <ol>
79                 <li><span class="label">Job ID: </span>[% job.id | html %]</li>
80                 <li>
81                     <label for="job_status">Status: </label>
82                     <span id="job_status_description"></span>
83                 </li>
84                 <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
85                 <li>
86                     <label for="job_type">Type: </label>
87                     <span id="job_type_description"></span>
88                 </li>
89                 <li>
90                     <label for="job_enqueued_on">Queued: </label>
91                     [% job.enqueued_on | $KohaDates with_hours = 1 %]
92                 </li>
93                 <li>
94                     <label for="job_started_on">Started: </label>
95                     [% job.started_on | $KohaDates with_hours = 1 %]
96                 </li>
97                 <li>
98                     <label for="job_ended_on">Ended: </label>
99                     [% job.ended_on | $KohaDates with_hours = 1 %]
100                 </li>
101             </ol>
102         </fieldset>
103         <div class="page-section">
104             <h2>Report</h2>
105             [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
106         </div>
107         <div class="page-section">
108             <h2>Detailed messages</h2>
109             [% IF job.status != 'new' %][% PROCESS 'detail' %][% END %]
110         </div>
111     </div> <!-- /#job_details -->
112
113     [% IF CAN_user_parameters_manage_background_jobs %]
114         <fieldset class="action">
115             <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
116         </fieldset>
117     [% END %]
118 [% END %]
119
120 [% IF op == 'list' %]
121
122     <h1>Jobs</h1>
123
124     <div>
125         <input type="checkbox" id="only_current" checked />
126         <label for="only_current">Current jobs only</label>
127     </div>
128
129     <div>
130         <input type="checkbox" id="include_last_hour" checked />
131         <label for="include_last_hour">Only include jobs started in the last hour</label>
132     </div>
133
134     <div class="page-section">
135         <table id="table_jobs">
136             <thead>
137                 <tr>
138                     <th>Job ID</th>
139                     <th data-filter="job_statuses">Status</th>
140                     <th>Progress</th>
141                     <th data-filter="job_types">Type</th>
142                     <th>Queued</th>
143                     <th>Started</th>
144                     <th>Ended</th>
145                     <th class="noExport">Actions</th>
146                 </tr>
147             </thead>
148         </table>
149     </div>
150 [% END %]
151
152             </main>
153         </div> <!-- /.col-sm-10.col-sm-push-2 -->
154
155         <div class="col-sm-2 col-sm-pull-10">
156             <aside>
157                 [% INCLUDE 'admin-menu.inc' %]
158             </aside>
159         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
160      </div> <!-- /.row -->
161
162 [% MACRO jsinclude BLOCK %]
163     [% Asset.js("js/admin-menu.js") | $raw %]
164     [% INCLUDE 'js-date-format.inc' %]
165     [% INCLUDE 'datatables.inc' %]
166     <script>
167         const job_statuses = [
168             {'_id': 'new',       '_str': _("New")},
169             {'_id': 'cancelled', '_str': _("Cancelled")},
170             {'_id': 'finished',  '_str': _("Finished")},
171             {'_id': 'started',   '_str': _("Started")},
172             {'_id': 'running',   '_str': _("Running")},
173             {'_id': 'failed',    '_str': _("Failed")},
174         ];
175         function get_job_status (status) {
176             let status_lib = job_statuses.find( s => s._id == status );
177             if (status_lib) {
178                 return status_lib._str;
179             }
180             return status;
181         }
182
183         const job_types = [
184             {
185                 '_id': 'batch_biblio_record_modification',
186                 '_str': _("Batch bibliographic record modification")
187             },
188             {
189                 '_id': 'batch_biblio_record_deletion',
190                 '_str': _("Batch bibliographic record record deletion")
191             },
192             {
193                 '_id': 'batch_authority_record_modification',
194                 '_str': _("Batch authority record modification")
195             },
196             {
197                 '_id': 'batch_authority_record_deletion',
198                 '_str': _("Batch authority record deletion")
199             },
200             {
201                 '_id': 'batch_item_record_modification',
202                 '_str': _("Batch item record modification")
203             },
204             {
205                 '_id': 'batch_item_record_deletion',
206                 '_str': _("Batch item record deletion")
207             },
208             {
209                 '_id': 'batch_hold_cancel',
210                 '_str': _("Batch hold cancellation")
211             },
212             {
213                 '_id': 'create_eholdings_from_biblios',
214                 '_str': _("Create eHolding titles")
215             },
216             {
217                 '_id': 'update_elastic_index',
218                 '_str': _("Update Elasticsearch index")
219             },
220             {
221                 '_id': 'update_holds_queue_for_biblios',
222                 '_str': _("Holds queue update")
223             },
224             {
225                 '_id': 'stage_marc_for_import',
226                 '_str': _("Staged MARC records for import")
227             },
228             {
229                 '_id': 'marc_import_commit_batch',
230                 '_str': _("Import MARC records")
231             },
232             {
233                 '_id': 'marc_import_revert_batch',
234                 '_str': _("Revert import MARC records")
235             },
236         ];
237
238         function get_job_type (job_type) {
239             let job_type_lib = job_types.find( t => t._id == job_type );
240             if ( job_type_lib ) {
241                 return job_type_lib._str;
242             }
243             return _("Unknown job type '%s'").format(job_type);
244         }
245
246         $(document).ready(function() {
247             [% IF op == 'view' %]
248                 $("#job_status_description").html( get_job_status("[% job.status | html %]") );
249                 $("#job_type_description").html( get_job_type("[% job.type | html %]") );
250                 $("#job_details").show();
251             [% END %]
252
253             let additional_filters = {
254                 started_on: function(){
255                     let now = new Date();
256                     if ( $("#include_last_hour").is(":checked") ) {
257                         now.setHours(now.getHours() - 1);
258                         return { ">": now.toISOString() };
259                     } else {
260                         return { "<": now.toISOString() };
261                     }
262                 }
263             };
264
265             let only_current_filter = function(){
266                 if ( $("#only_current").is(":checked") ) {
267                     return 'only_current=1';
268                 } else {
269                     return 'only_current=0';
270                 }
271             }
272
273             let jobs_table = $("#table_jobs").kohaTable({
274                 "ajax": {
275                     "url": "/api/v1/jobs?" + only_current_filter()
276                 },
277                 "order": [[ 1, "desc" ]],
278                 "columns": [
279                     {
280                         "data": "job_id",
281                         "searchable": true,
282                         "orderable": true
283                     },
284                     {
285                         "data": "status",
286                         "searchable": true,
287                         "orderable": true,
288                         "render": function(data, type, row, meta) {
289                             return get_job_status(row.status).escapeHtml();
290                         }
291                     },
292                     {
293                         "data": "progress,size",
294                         "searchable": false,
295                         "orderable": true,
296                         "render": function(data, type, row, meta) {
297                             return "%s/%s".format(row.progress, row.size).escapeHtml();
298                         }
299                     },
300                     {
301                         "data": "type",
302                         "searchable": true,
303                         "orderable": true,
304                         "render": function(data, type, row, meta) {
305                             return get_job_type(row.type).escapeHtml();
306                         }
307                     },
308                     {
309                         "data": "enqueued_date",
310                         "searchable": true,
311                         "orderable": true,
312                         "render": function(data, type, row, meta) {
313                             return $datetime(row.enqueued_date);
314                         }
315                     },
316                     {
317                         "data": "started_date",
318                         "searchable": true,
319                         "orderable": true,
320                         "render": function(data, type, row, meta) {
321                             return $datetime(row.started_date);
322                         }
323                     },
324                     {
325                         "data": "ended_date",
326                         "searchable": true,
327                         "orderable": true,
328                         "render": function(data, type, row, meta) {
329                             return $datetime(row.ended_date);
330                         }
331                     },
332                     {
333                         "data": function( row, type, val, meta ) {
334                             var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&amp;id='+ encodeURIComponent(row.job_id) +'"><i class="fa fa-eye" aria-hidden="true"></i> '+_("View")+'</a>'+"\n";
335                             if ( row.status == 'new' || row.status == 'started' ) {
336                                 result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/bakcground_jobs.pl?op=cancel&amp;id='+ encodeURIComponent(row.job_id) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Cancel")+'</a>';
337                             }
338                             return result;
339                         },
340                         "searchable": false,
341                         "orderable": false
342                     }
343                 ]
344             }, null, 1, additional_filters);
345
346             $("#include_last_hour").on("change", function(){
347                 jobs_table.DataTable().draw();
348                 return false;
349             });
350
351             $("#only_current").on("change", function(){
352                 jobs_table.DataTable().ajax.url("/api/v1/jobs?" + only_current_filter()).load();
353                 return false;
354             });
355         });
356     </script>
357     [% IF op == 'view' %]
358         [% PROCESS 'js' %]
359     [% END %]
360 [% END %]
361
362 [% INCLUDE 'intranet-bottom.inc' %]