From c936bf7724acb3c7635dce74e2eb5f229299c761 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 7 Jun 2022 11:08:32 +0100 Subject: [PATCH] Bug 30462: Separate Running and Complete jobs This patch updates the background jobs management page to display running and completed jobs in their own tabs on the page. --- admin/background_jobs.pl | 18 +- .../prog/en/modules/admin/background_jobs.tt | 155 +++++++++++++----- 2 files changed, 127 insertions(+), 46 deletions(-) diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index 8a27c00a27..3c98a4b878 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -76,15 +76,25 @@ if ( $op eq 'cancel' ) { if ( $op eq 'list' ) { - my $jobs = + my $running_jobs = $can_manage_background_jobs - ? Koha::BackgroundJobs->search( {}, + ? Koha::BackgroundJobs->search( { ended_on => undef }, { order_by => { -desc => 'enqueued_on' } } ) : Koha::BackgroundJobs->search( - { borrowernumber => $logged_in_user->borrowernumber }, + { borrowernumber => $logged_in_user->borrowernumber, ended_on => undef }, { order_by => { -desc => 'enqueued_on' } } ); - $template->param( jobs => $jobs ); + $template->param( running => $running_jobs ); + + my $complete_jobs = + $can_manage_background_jobs + ? Koha::BackgroundJobs->search( { ended_on => { '!=' => undef } }, + { order_by => { -desc => 'enqueued_on' } } ) + : Koha::BackgroundJobs->search( + { borrowernumber => $logged_in_user->borrowernumber, ended_on => { '!=' => undef } }, + { order_by => { -desc => 'enqueued_on' } } + ); + $template->param( complete => $complete_jobs ); } $template->param( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index 4da24feed3..6ed9502e68 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -155,50 +155,113 @@ [% IF op == 'list' %]

Background jobs

+ +
+ - [% IF jobs.count %] - - - - - - - - - - - - - - - [% FOREACH job IN jobs %] - - - - - - - - - - +
+
+

Running jobs

+ + [% IF running.count %] +
Job IDStatusProgressTypeQueuedStartedEndedActions
[% job.id | html %] - [% PROCESS show_job_status %] - [% job.progress || 0 | html %] / [% job.size | html %] - [% PROCESS show_job_type job_type => job.type %] - [% job.enqueued_on | $KohaDates with_hours = 1 %][% job.started_on| $KohaDates with_hours = 1 %][% job.ended_on| $KohaDates with_hours = 1 %] - View - [% IF job.status == 'new' || job.status == 'started' %] - Cancel - [% END %] -
+ + + + + + + + + + + + + + [% FOREACH job IN running %] + + + + + + + + + + + [% END %] + +
Job IDStatusProgressTypeQueuedStartedEndedActions
[% job.id | html %] + [% PROCESS show_job_status %] + [% job.progress || 0 | html %] / [% job.size | html %] + [% PROCESS show_job_type job_type => job.type %] + [% job.enqueued_on | $KohaDates with_hours = 1 %][% job.started_on| $KohaDates with_hours = 1 %][% job.ended_on| $KohaDates with_hours = 1 %] + View + [% IF job.status == 'new' || job.status == 'started' %] + Cancel + [% END %] +
+ [% ELSE %] +
+ There are no running background jobs yet. +
[% END %] - - - [% ELSE %] -
- There are no background jobs yet. +
+ +
+

Complete jobs

+ + [% IF complete.count %] + + + + + + + + + + + + + + + [% FOREACH job IN complete %] + + + + + + + + + + + [% END %] + +
Job IDStatusProgressTypeQueuedStartedEndedActions
[% job.id | html %] + [% PROCESS show_job_status %] + [% job.progress || 0 | html %] / [% job.size | html %] + [% PROCESS show_job_type job_type => job.type %] + [% job.enqueued_on | $KohaDates with_hours = 1 %][% job.started_on| $KohaDates with_hours = 1 %][% job.ended_on| $KohaDates with_hours = 1 %] + View + [% IF job.status == 'new' || job.status == 'started' %] + Cancel + [% END %] +
+ [% ELSE %] +
+ There are no completed background jobs yet. +
+ [% END %] +
+
- [% END %] + + [% END %] @@ -216,7 +279,7 @@ [% INCLUDE 'datatables.inc' %] [% IF op == 'view' %] -- 2.20.1