Bug 31245: Do not call report for job detail view if job not started
[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 %]<span>Unknown job type '[% job_type | html %]'</span>
45     [% END %]
46
47 [% END %]
48 [% INCLUDE 'doc-head-open.inc' %]
49 <title>
50     [% IF op == 'view' %]
51         Details of job #[% job.id | html %] &rsaquo;
52     [% END %]
53     Background jobs &rsaquo;
54     Administration &rsaquo; Koha
55 </title>
56
57 [% INCLUDE 'doc-head-close.inc' %]
58 </head>
59
60 <body id="admin_background_jobs" class="admin">
61 [% INCLUDE 'header.inc' %]
62 [% INCLUDE 'prefs-admin-search.inc' %]
63
64 <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
65     <ol>
66         <li>
67             <a href="/cgi-bin/koha/mainpage.pl">Home</a>
68         </li>
69
70     [% IF CAN_user_parameters_manage_background_jobs %]
71         <li>
72             <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
73         </li>
74         [% IF op == 'view' %]
75             <li>
76                 <a href="/cgi-bin/koha/admin/background_jobs.pl">Background jobs</a>
77             </li>
78             <li>
79                 <a href="#" aria-current="page">Details of job #[% job.id | html %]</a>
80             </li>
81         [% ELSE %]
82             <li>
83                 <a href="#" aria-current="page">Background jobs</a>
84             </li>
85         [% END %]
86     [% ELSE %]
87         <li>
88             <a href="#" aria-current="page">Administration</a>
89         </li>
90     [% END %]
91     </ol>
92 </nav>
93
94 <div class="main container-fluid">
95     <div class="row">
96         <div class="col-sm-10 col-sm-push-2">
97             <main>
98
99 [% FOR m IN messages %]
100     <div class="dialog message">
101         [% SWITCH m.code %]
102         [% CASE 'cannot_view_job' %]
103             <div><i class="fa fa-exclamation error"></i>Insufficient permission to see this job.</div>
104         [% CASE %]
105             [% m.code | html %]
106         [% END %]
107     </div>
108 [% END %]
109
110 [% IF op == 'view' %]
111     <h1>Details of job #[% job.id | html %]</h1>
112
113     [% PROCESS "background_jobs/${job.type}.inc" %]
114
115     <fieldset class="rows">
116         <ol>
117             <li><span class="label">Job ID: </span>[% job.id | html %]</li>
118             <li>
119                 <label for="job_status">Status: </label>
120                 [% PROCESS show_job_status %]
121             </li>
122             <li><label for="job_progress">Progress: </label>[% job.progress || 0 | html %] / [% job.size | html %]</li>
123             <li>
124                 <label for="job_type">Type: </label>
125                 [% PROCESS show_job_type job_type => job.type %]
126             </li>
127             <li>
128                 <label for="job_enqueued_on">Queued: </label>
129                 [% job.enqueued_on | $KohaDates with_hours = 1 %]
130             </li>
131             <li>
132                 <label for="job_started_on">Started: </label>
133                 [% job.started_on | $KohaDates with_hours = 1 %]
134             </li>
135             <li>
136                 <label for="job_ended_on">Ended: </label>
137                 [% job.ended_on | $KohaDates with_hours = 1 %]
138             </li>
139             <li><label for="job_data">Report: </label>
140                 [% IF job.status != 'new' %][% PROCESS 'report' %][% END %]
141             </li>
142             <li><label for="job_data">Detailed messages: </label>
143                 [% IF job.status != 'new' %][% PROCESS 'detail' %][% END %]
144             </li>
145         </ol>
146     </fieldset>
147
148     [% IF CAN_user_parameters_manage_background_jobs %]
149         <fieldset class="action">
150             <a href="/cgi-bin/koha/admin/background_jobs.pl">Return to the job list</a>
151         </fieldset>
152     [% END %]
153 [% END %]
154
155 [% IF op == 'list' %]
156
157     <h1>Background jobs</h1>
158
159     [% IF jobs.count %]
160         <table id="table_background_jobs">
161             <thead>
162                 <tr>
163                     <th>Job ID</th>
164                     <th>Status</th>
165                     <th>Progress</th>
166                     <th>Type</th>
167                     <th>Queued</th>
168                     <th>Started</th>
169                     <th>Ended</th>
170                     <th class="noExport">Actions</th>
171                 </tr>
172             </thead>
173             <tbody>
174                 [% FOREACH job IN jobs %]
175                 <tr>
176                     <td>[% job.id | html %]</td>
177                     <td>
178                         [% PROCESS show_job_status %]
179                     </td>
180                     <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
181                     <td>
182                         [% PROCESS show_job_type job_type => job.type %]
183                     </td>
184                     <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
185                     <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
186                     <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
187                     <td class="actions">
188                         <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>
189                         [% IF job.status == 'new' || job.status == 'started' %]
190                             <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>
191                         [% END %]
192                     </td>
193                 </tr>
194                 [% END %]
195             </tbody>
196         </table>
197     [% ELSE %]
198         <div class="dialog message">
199             There are no background jobs yet.
200         </div>
201     [% END %]
202 [% END %]
203
204             </main>
205         </div> <!-- /.col-sm-10.col-sm-push-2 -->
206
207         <div class="col-sm-2 col-sm-pull-10">
208             <aside>
209                 [% INCLUDE 'admin-menu.inc' %]
210             </aside>
211         </div> <!-- /.col-sm-2.col-sm-pull-10 -->
212      </div> <!-- /.row -->
213
214 [% MACRO jsinclude BLOCK %]
215     [% Asset.js("js/admin-menu.js") | $raw %]
216     [% INCLUDE 'datatables.inc' %]
217     <script>
218         $(document).ready(function() {
219             $("#table_background_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
220                 "aoColumnDefs": [
221                     { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
222                 ],
223                 "aaSorting": [[ 0, "desc" ]],
224                 "iDisplayLength": 10,
225                 "sPaginationType": "full_numbers"
226             }));
227
228         });
229     </script>
230     [% IF op == 'view' %]
231         [% PROCESS 'js' %]
232     [% END %]
233 [% END %]
234
235 [% INCLUDE 'intranet-bottom.inc' %]