Bug 27421: Commit and revert
[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 [% 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 '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>
51     [% END %]
52
53 [% END %]
54 [% INCLUDE 'doc-head-open.inc' %]
55 <title>
56     [% IF op == 'view' %]
57         Details of job #[% job.id | html %] &rsaquo;
58     [% END %]
59     Background jobs &rsaquo;
60     Administration &rsaquo; Koha
61 </title>
62
63 [% INCLUDE 'doc-head-close.inc' %]
64 </head>
65
66 <body id="admin_background_jobs" class="admin">
67 [% INCLUDE 'header.inc' %]
68 [% INCLUDE 'prefs-admin-search.inc' %]
69
70 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
71     <ol>
72         <li>
73             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
74         </li>
75
76     [% IF CAN_user_parameters_manage_background_jobs %]
77         <li>
78             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
79         </li>
80         [% IF op == 'view' %]
81             <li>
82                 <a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a>
83             </li>
84             <li>
85                 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
86             </li>
87         [% ELSE %]
88             <li>
89                 <a href="#" aria-current="page">Background jobs</a>
90             </li>
91         [% END %]
92     [% ELSE %]
93         <li>
94             <a href="#" aria-current="page">Administration</a>
95         </li>
96     [% END %]
97     </ol>
98 </nav>
99
100 <div class="main container-fluid">
101     <div class="row">
102         <div class="col-sm-10 col-sm-push-2">
103             <main>
104
105 [% FOR m IN messages %]
106     <div class="dialog message">
107         [% SWITCH m.code %]
108         [% CASE 'cannot_view_job' %]
109             <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
110         [% CASE %]
111             [% m.code | html %]
112         [% END %]
113     </div>
114 [% END %]
115
116 [% IF op == 'view' %]
117     <h1>Details of job #[% job.id | html %]</h1>
118
119     [% PROCESS "background_jobs/${job.type}.inc" %]
120
121     <fieldset class="rows">
122         <ol>
123             <li><span class="label">Job ID: </span>[% job.id | html %]</li>
124             <li>
125                 <label for="job_status">Status: </label>
126                 [% PROCESS show_job_status %]
127             </li>
128             <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
129             <li>
130                 <label for="job_type">Type: </label>
131                 [% PROCESS show_job_type job_type => job.type %]
132             </li>
133             <li>
134                 <label for="job_enqueued_on">Queued: </label>
135                 [% job.enqueued_on | $KohaDates with_hours = 1 %]
136             </li>
137             <li>
138                 <label for="job_started_on">Started: </label>
139                 [% job.started_on | $KohaDates with_hours = 1 %]
140             </li>
141             <li>
142                 <label for="job_ended_on">Ended: </label>
143                 [% job.ended_on | $KohaDates with_hours = 1 %]
144             </li>
145             <li><label for="job_data">Report: </label>
146                 [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
147             </li>
148             <li><label for="job_data">Detailed messages: </label>
149                 [% IF job.status != 'new' %][% PROCESS 'detail' %][% END %]
150             </li>
151         </ol>
152     </fieldset>
153
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>
157         </fieldset>
158     [% END %]
159 [% END %]
160
161 [% IF op == 'list' %]
162
163     <h1>Background jobs</h1>
164
165     <div id="taskstabs" class="toptabs">
166         <ul class="nav nav-tabs" role="tablist">
167             <li role="presentation" class="active"><a href="#queued" aria-controls="queued" role="tab" data-toggle="tab">Queued jobs</a></li>
168             <li role="presentation"><a href="#complete" aria-controls="complete" role="tab" data-toggle="tab">Completed jobs</a></li>
169         </ul>
170
171         <div class="tab-content">
172             <div role="tabpanel" class="tab-pane active" id="queued">
173                 [% IF queued.count %]
174                     <table id="table_queued_jobs">
175                         <thead>
176                             <tr>
177                                 <th>Job ID</th>
178                                 <th>Status</th>
179                                 <th>Progress</th>
180                                 <th>Type</th>
181                                 <th>Queued</th>
182                                 <th>Started</th>
183                                 <th class="noExport">Actions</th>
184                             </tr>
185                         </thead>
186                         <tbody>
187                             [% FOREACH job IN queued %]
188                             <tr>
189                                 <td>[% job.id | html %]</td>
190                                 <td>
191                                     [% PROCESS show_job_status %]
192                                 </td>
193                                 <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
194                                 <td>
195                                     [% PROCESS show_job_type job_type => job.type %]
196                                 </td>
197                                 <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
198                                 <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
199                                 <td class="actions">
200                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&amp;id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a>
201                                     [% IF job.status == 'new' || job.status == 'started' %]
202                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&amp;id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a>
203                                     [% END %]
204                                 </td>
205                             </tr>
206                             [% END %]
207                         </tbody>
208                     </table>
209                 [% ELSE %]
210                     <div class="dialog message">
211                         There are no queued background jobs yet.
212                     </div>
213                 [% END %]
214             </div>
215
216             <div role="tabpanel" class="tab-pane" id="complete">
217                 [% IF complete.count %]
218                     <p>Jobs completed in the last 60 minutes.</p>
219                     <table id="table_complete_jobs">
220                         <thead>
221                             <tr>
222                                 <th>Job ID</th>
223                                 <th>Status</th>
224                                 <th>Progress</th>
225                                 <th>Type</th>
226                                 <th>Queued</th>
227                                 <th>Started</th>
228                                 <th>Ended</th>
229                                 <th class="noExport">Actions</th>
230                             </tr>
231                         </thead>
232                         <tbody>
233                             [% FOREACH job IN complete %]
234                             <tr>
235                                 <td>[% job.id | html %]</td>
236                                 <td>
237                                     [% PROCESS show_job_status %]
238                                 </td>
239                                 <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
240                                 <td>
241                                     [% PROCESS show_job_type job_type => job.type %]
242                                 </td>
243                                 <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
244                                 <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
245                                 <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
246                                 <td class="actions">
247                                     <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=view&amp;id=[% job.id | html %]"><i class="fa fa-eye"></i> View</a>
248                                     [% IF job.status == 'new' || job.status == 'started' %]
249                                         <a class="btn btn-default btn-xs" href="/cgi-bin/koha/admin/background_jobs.pl?op=cancel&amp;id=[% job.id | html %]"><i class="fa fa-trash"></i> Cancel</a>
250                                     [% END %]
251                                 </td>
252                             </tr>
253                             [% END %]
254                         </tbody>
255                     </table>
256                 [% ELSE %]
257                     <div class="dialog message">
258                         There were no completed background jobs completed in the last 60 minutes.
259                     </div>
260                 [% END %]
261             </div>
262         </div>
263     </div>
264
265 [% END %]
266
267             </main>
268         </div> <!-- /.col-sm-10.col-sm-push-2 -->
269
270         <div class="col-sm-2 col-sm-pull-10">
271             <aside>
272                 [% INCLUDE 'admin-menu.inc' %]
273             </aside>
274         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
275      </div> <!-- /.row -->
276
277 [% MACRO jsinclude BLOCK %]
278     [% Asset.js("js/admin-menu.js") | $raw %]
279     [% INCLUDE 'datatables.inc' %]
280     <script>
281         $(document).ready(function() {
282             $("#table_queued_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
283                 "aoColumnDefs": [
284                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
285                 ],
286                 "aaSorting": [[ 0, "desc" ]],
287                 "iDisplayLength": 10,
288                 "sPaginationType": "full_numbers"
289             }));
290
291             $("#table_complete_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
292                 "aoColumnDefs": [
293                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
294                 ],
295                 "aaSorting": [[ 0, "desc" ]],
296                 "iDisplayLength": 10,
297                 "sPaginationType": "full_numbers"
298             }));
299         });
300     </script>
301     [% IF op == 'view' %]
302         [% PROCESS 'js' %]
303     [% END %]
304 [% END %]
305
306 [% INCLUDE 'intranet-bottom.inc' %]