From 52e5bc10e1ae0baa7bea9b7511978eda5fd17825 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 7 Jun 2022 11:08:32 +0100 Subject: [PATCH] Bug 30462: Separate Queued and Complete jobs This patch updates the background jobs management page to display queued and completed jobs in their own tabs on the page. JD Amended patch: Fix QA failures: FAIL koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt FAIL forbidden patterns forbidden pattern: trailing space char (line 158) forbidden pattern: trailing space char (line 256) Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- admin/background_jobs.pl | 18 +- .../prog/en/modules/admin/background_jobs.tt | 154 +++++++++++++----- 2 files changed, 126 insertions(+), 46 deletions(-) diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index a4b7b90c0a..ae70985091 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -78,15 +78,25 @@ if ( $op eq 'cancel' ) { if ( $op eq 'list' ) { - my $jobs = + my $queued_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( queued => $queued_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 ab1cd65cba..1304fd57c4 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 @@ -156,49 +156,111 @@

Background jobs

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

Queued jobs

+ + [% IF queued.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 queued %] + + + + + + + + + + + [% 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 queued 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 +278,7 @@ [% INCLUDE 'datatables.inc' %] [% IF op == 'view' %] -- 2.39.5