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

(-)a/admin/background_jobs.pl (-4 / +25 lines)
Lines 19-24 use Modern::Perl; Link Here
19
use CGI qw ( -utf8 );
19
use CGI qw ( -utf8 );
20
20
21
use C4::Context;
21
use C4::Context;
22
use Koha::DateUtils qw( dt_from_string );
22
use C4::Auth qw( get_template_and_user );
23
use C4::Auth qw( get_template_and_user );
23
use C4::Output qw( output_html_with_http_headers );
24
use C4::Output qw( output_html_with_http_headers );
24
25
Lines 78-92 if ( $op eq 'cancel' ) { Link Here
78
79
79
80
80
if ( $op eq 'list' ) {
81
if ( $op eq 'list' ) {
81
    my $jobs =
82
    my $queued_jobs =
82
      $can_manage_background_jobs
83
      $can_manage_background_jobs
83
      ? Koha::BackgroundJobs->search( {},
84
      ? Koha::BackgroundJobs->search( { ended_on => undef },
84
        { order_by => { -desc => 'enqueued_on' } } )
85
        { order_by => { -desc => 'enqueued_on' } } )
85
      : Koha::BackgroundJobs->search(
86
      : Koha::BackgroundJobs->search(
86
        { borrowernumber => $logged_in_user->borrowernumber },
87
        { borrowernumber => $logged_in_user->borrowernumber, ended_on => undef },
87
        { order_by       => { -desc => 'enqueued_on' } }
88
        { order_by       => { -desc => 'enqueued_on' } }
88
      );
89
      );
89
    $template->param( jobs => $jobs );
90
    $template->param( queued => $queued_jobs );
91
92
    my $ended_since = dt_from_string->subtract( minutes => '60' );
93
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
94
95
    my $complete_jobs =
96
      $can_manage_background_jobs
97
      ? Koha::BackgroundJobs->search(
98
        {
99
            ended_on => { '>=' => $dtf->format_datetime($ended_since) }
100
        },
101
        { order_by => { -desc => 'enqueued_on' } }
102
      )
103
      : Koha::BackgroundJobs->search(
104
        {
105
            borrowernumber => $logged_in_user->borrowernumber,
106
            ended_on       => { '>=' => $dtf->format_datetime($ended_since) }
107
        },
108
        { order_by => { -desc => 'enqueued_on' } }
109
      );
110
    $template->param( complete => $complete_jobs );
90
}
111
}
91
112
92
$template->param(
113
$template->param(
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt (-43 / +107 lines)
Lines 156-204 Link Here
156
156
157
    <h1>Background jobs</h1>
157
    <h1>Background jobs</h1>
158
158
159
    [% IF jobs.count %]
159
    <div id="taskstabs" class="toptabs">
160
        <table id="table_background_jobs">
160
        <ul class="nav nav-tabs" role="tablist">
161
            <thead>
161
            <li role="presentation" class="active"><a href="#queued" aria-controls="queued" role="tab" data-toggle="tab">Queued jobs</a></li>
162
                <tr>
162
            <li role="presentation"><a href="#complete" aria-controls="complete" role="tab" data-toggle="tab">Completed jobs</a></li>
163
                    <th>Job ID</th>
163
        </ul>
164
                    <th>Status</th>
164
165
                    <th>Progress</th>
165
        <div class="tab-content">
166
                    <th>Type</th>
166
            <div role="tabpanel" class="tab-pane active" id="queued">
167
                    <th>Queued</th>
167
                [% IF queued.count %]
168
                    <th>Started</th>
168
                    <table id="table_queued_jobs">
169
                    <th>Ended</th>
169
                        <thead>
170
                    <th class="noExport">Actions</th>
170
                            <tr>
171
                </tr>
171
                                <th>Job ID</th>
172
            </thead>
172
                                <th>Status</th>
173
            <tbody>
173
                                <th>Progress</th>
174
                [% FOREACH job IN jobs %]
174
                                <th>Type</th>
175
                <tr>
175
                                <th>Queued</th>
176
                    <td>[% job.id | html %]</td>
176
                                <th>Started</th>
177
                    <td>
177
                                <th class="noExport">Actions</th>
178
                        [% PROCESS show_job_status %]
178
                            </tr>
179
                    </td>
179
                        </thead>
180
                    <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
180
                        <tbody>
181
                    <td>
181
                            [% FOREACH job IN queued %]
182
                        [% PROCESS show_job_type job_type => job.type %]
182
                            <tr>
183
                    </td>
183
                                <td>[% job.id | html %]</td>
184
                    <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
184
                                <td>
185
                    <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
185
                                    [% PROCESS show_job_status %]
186
                    <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
186
                                </td>
187
                    <td class="actions">
187
                                <td>[% job.progress || 0 | html %] / [% job.size | html %]</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>
188
                                <td>
189
                        [% IF job.status == 'new' || job.status == 'started' %]
189
                                    [% PROCESS show_job_type job_type => job.type %]
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>
190
                                </td>
191
                        [% END %]
191
                                <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
192
                    </td>
192
                                <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
193
                </tr>
193
                                <td class="actions">
194
                                    <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>
195
                                    [% IF job.status == 'new' || job.status == 'started' %]
196
                                        <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>
197
                                    [% END %]
198
                                </td>
199
                            </tr>
200
                            [% END %]
201
                        </tbody>
202
                    </table>
203
                [% ELSE %]
204
                    <div class="dialog message">
205
                        There are no queued background jobs yet.
206
                    </div>
194
                [% END %]
207
                [% END %]
195
            </tbody>
208
            </div>
196
        </table>
209
197
    [% ELSE %]
210
            <div role="tabpanel" class="tab-pane" id="complete">
198
        <div class="dialog message">
211
                [% IF complete.count %]
199
            There are no background jobs yet.
212
                    <p>Jobs completed in the last 60 minutes.</p>
213
                    <table id="table_complete_jobs">
214
                        <thead>
215
                            <tr>
216
                                <th>Job ID</th>
217
                                <th>Status</th>
218
                                <th>Progress</th>
219
                                <th>Type</th>
220
                                <th>Queued</th>
221
                                <th>Started</th>
222
                                <th>Ended</th>
223
                                <th class="noExport">Actions</th>
224
                            </tr>
225
                        </thead>
226
                        <tbody>
227
                            [% FOREACH job IN complete %]
228
                            <tr>
229
                                <td>[% job.id | html %]</td>
230
                                <td>
231
                                    [% PROCESS show_job_status %]
232
                                </td>
233
                                <td>[% job.progress || 0 | html %] / [% job.size | html %]</td>
234
                                <td>
235
                                    [% PROCESS show_job_type job_type => job.type %]
236
                                </td>
237
                                <td>[% job.enqueued_on | $KohaDates with_hours = 1 %]</td>
238
                                <td>[% job.started_on| $KohaDates with_hours = 1 %]</td>
239
                                <td>[% job.ended_on| $KohaDates with_hours = 1 %]</td>
240
                                <td class="actions">
241
                                    <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>
242
                                    [% IF job.status == 'new' || job.status == 'started' %]
243
                                        <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>
244
                                    [% END %]
245
                                </td>
246
                            </tr>
247
                            [% END %]
248
                        </tbody>
249
                    </table>
250
                [% ELSE %]
251
                    <div class="dialog message">
252
                        There were no completed background jobs completed in the last 60 minutes.
253
                    </div>
254
                [% END %]
255
            </div>
200
        </div>
256
        </div>
201
    [% END %]
257
    </div>
258
202
[% END %]
259
[% END %]
203
260
204
            </main>
261
            </main>
Lines 216-222 Link Here
216
    [% INCLUDE 'datatables.inc' %]
273
    [% INCLUDE 'datatables.inc' %]
217
    <script>
274
    <script>
218
        $(document).ready(function() {
275
        $(document).ready(function() {
219
            $("#table_background_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
276
            $("#table_queued_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
220
                "aoColumnDefs": [
277
                "aoColumnDefs": [
221
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
278
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
222
                ],
279
                ],
Lines 225-230 Link Here
225
                "sPaginationType": "full_numbers"
282
                "sPaginationType": "full_numbers"
226
            }));
283
            }));
227
284
285
            $("#table_complete_jobs").dataTable($.extend(true, {}, dataTablesDefaults, {
286
                "aoColumnDefs": [
287
                    { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
288
                ],
289
                "aaSorting": [[ 0, "desc" ]],
290
                "iDisplayLength": 10,
291
                "sPaginationType": "full_numbers"
292
            }));
228
        });
293
        });
229
    </script>
294
    </script>
230
    [% IF op == 'view' %]
295
    [% IF op == 'view' %]
231
- 

Return to bug 30462