View | Details | Raw Unified | Return to bug 30462
Collapse All | Expand All

(-)a/admin/background_jobs.pl (-4 / +14 lines)
Lines 76-90 if ( $op eq 'cancel' ) { Link Here
76
76
77
77
78
if ( $op eq 'list' ) {
78
if ( $op eq 'list' ) {
79
    my $jobs =
79
    my $running_jobs =
80
      $can_manage_background_jobs
80
      $can_manage_background_jobs
81
      ? Koha::BackgroundJobs->search( {},
81
      ? Koha::BackgroundJobs->search( { ended_on => undef },
82
        { order_by => { -desc => 'enqueued_on' } } )
82
        { order_by => { -desc => 'enqueued_on' } } )
83
      : Koha::BackgroundJobs->search(
83
      : Koha::BackgroundJobs->search(
84
        { borrowernumber => $logged_in_user->borrowernumber },
84
        { borrowernumber => $logged_in_user->borrowernumber, ended_on => undef },
85
        { order_by       => { -desc => 'enqueued_on' } }
85
        { order_by       => { -desc => 'enqueued_on' } }
86
      );
86
      );
87
    $template->param( jobs => $jobs );
87
    $template->param( running => $running_jobs );
88
89
    my $complete_jobs =
90
      $can_manage_background_jobs
91
      ? Koha::BackgroundJobs->search( { ended_on => { '!=' => undef } },
92
        { order_by => { -desc => 'enqueued_on' } } )
93
      : Koha::BackgroundJobs->search(
94
        { borrowernumber => $logged_in_user->borrowernumber, ended_on => { '!=' => undef } },
95
        { order_by       => { -desc => 'enqueued_on' } }
96
      );
97
    $template->param( complete => $complete_jobs );
88
}
98
}
89
99
90
$template->param(
100
$template->param(
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt (-43 / +113 lines)
Lines 155-204 Link Here
155
[% IF op == 'list' %]
155
[% IF op == 'list' %]
156
156
157
    <h1>Background jobs</h1>
157
    <h1>Background jobs</h1>
158
    
159
    <div id="taskstabs" class="toptabs">
160
        <ul class="nav nav-tabs" role="tablist">
161
            <li role="presentation" class="active"><a href="#running" aria-controls="running" role="tab" data-toggle="tab">Running jobs</a></li>
162
            <li role="presentation"><a href="#complete" aria-controls="complete" role="tab" data-toggle="tab">Complete jobs</a></li>
163
        </ul>
158
164
159
    [% IF jobs.count %]
165
        <div class="tab-content">
160
        <table id="table_background_jobs">
166
            <div role="tabpanel" class="tab-pane active" id="running">
161
            <thead>
167
                <h2>Running jobs</h2>
162
                <tr>
168
163
                    <th>Job ID</th>
169
                [% IF running.count %]
164
                    <th>Status</th>
170
                    <table id="table_running_jobs">
165
                    <th>Progress</th>
171
                        <thead>
166
                    <th>Type</th>
172
                            <tr>
167
                    <th>Queued</th>
173
                                <th>Job ID</th>
168
                    <th>Started</th>
174
                                <th>Status</th>
169
                    <th>Ended</th>
175
                                <th>Progress</th>
170
                    <th class="noExport">Actions</th>
176
                                <th>Type</th>
171
                </tr>
177
                                <th>Queued</th>
172
            </thead>
178
                                <th>Started</th>
173
            <tbody>
179
                                <th>Ended</th>
174
                [% FOREACH job IN jobs %]
180
                                <th class="noExport">Actions</th>
175
                <tr>
181
                            </tr>
176
                    <td>[% job.id | html %]</td>
182
                        </thead>
177
                    <td>
183
                        <tbody>
178
                        [% PROCESS show_job_status %]
184
                            [% FOREACH job IN running %]
179
                    </td>
185
                            <tr>
180
                    <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
186
                                <td>[% job.id | html %]</td>
181
                    <td>
187
                                <td>
182
                        [% PROCESS show_job_type job_type => job.type %]
188
                                    [% PROCESS show_job_status %]
183
                    </td>
189
                                </td>
184
                    <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
190
                                <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
185
                    <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
191
                                <td>
186
                    <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
192
                                    [% PROCESS show_job_type job_type => job.type %]
187
                    <td class="actions">
193
                                </td>
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>
194
                                <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
189
                        [% IF job.status == 'new' || job.status == 'started' %]
195
                                <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
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>
196
                                <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
191
                        [% END %]
197
                                <td class="actions">
192
                    </td>
198
                                    <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>
193
                </tr>
199
                                    [% IF job.status == 'new' || job.status == 'started' %]
200
                                        <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>
201
                                    [% END %]
202
                                </td>
203
                            </tr>
204
                            [% END %]
205
                        </tbody>
206
                    </table>
207
                [% ELSE %]
208
                    <div class="dialog message">
209
                        There are no running background jobs yet.
210
                    </div>
194
                [% END %]
211
                [% END %]
195
            </tbody>
212
            </div>
196
        </table>
213
197
    [% ELSE %]
214
            <div role="tabpanel" class="tab-pane active" id="complete">
198
        <div class="dialog message">
215
                <h2>Complete jobs</h2>
199
            There are no background jobs yet.
216
217
                [% IF complete.count %]
218
                    <table id="table_complete_jobs">
219
                        <thead>
220
                            <tr>
221
                                <th>Job ID</th>
222
                                <th>Status</th>
223
                                <th>Progress</th>
224
                                <th>Type</th>
225
                                <th>Queued</th>
226
                                <th>Started</th>
227
                                <th>Ended</th>
228
                                <th class="noExport">Actions</th>
229
                            </tr>
230
                        </thead>
231
                        <tbody>
232
                            [% FOREACH job IN complete %]
233
                            <tr>
234
                                <td>[% job.id | html %]</td>
235
                                <td>
236
                                    [% PROCESS show_job_status %]
237
                                </td>
238
                                <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
239
                                <td>
240
                                    [% PROCESS show_job_type job_type => job.type %]
241
                                </td>
242
                                <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
243
                                <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
244
                                <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
245
                                <td class="actions">
246
                                    <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>
247
                                    [% IF job.status == 'new' || job.status == 'started' %]
248
                                        <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>
249
                                    [% END %]
250
                                </td>
251
                            </tr>
252
                            [% END %]
253
                        </tbody>
254
                    </table>
255
                [% ELSE %]
256
                    <div class="dialog message">
257
                        There are no completed background jobs yet.
258
                    </div>
259
                [% END %]
260
            </div>
261
            
200
        </div>
262
        </div>
201
    [% END %]
263
    </div>
264
202
[% END %]
265
[% END %]
203
266
204
            </main>
267
            </main>
Lines 216-222 Link Here
216
    [% INCLUDE 'datatables.inc' %]
279
    [% INCLUDE 'datatables.inc' %]
217
    <script>
280
    <script>
218
        $(document).ready(function() {
281
        $(document).ready(function() {
219
            $("#table_background_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
282
            $("#table_running_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
220
                "aoColumnDefs": [
283
                "aoColumnDefs": [
221
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
284
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
222
                ],
285
                ],
Lines 225-230 Link Here
225
                "sPaginationType": "full_numbers"
288
                "sPaginationType": "full_numbers"
226
            }));
289
            }));
227
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
            }));
228
        });
299
        });
229
    </script>
300
    </script>
230
    [% IF op == 'view' %]
301
    [% IF op == 'view' %]
231
- 

Return to bug 30462