From: Davide Franco Date: Fri, 1 Jul 2011 16:10:30 +0000 (+0200) Subject: bacula-web: Improved job status filter in jobs page and template X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cc766ec19d52efee0a0f6dd6fa0193f127d5cd47;p=bacula%2Fbacula bacula-web: Improved job status filter in jobs page and template --- diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php index b3741aa10d..ed1268ad2c 100644 --- a/gui/bacula-web/jobs.php +++ b/gui/bacula-web/jobs.php @@ -19,11 +19,24 @@ $dbSql = new Bweb(); // Jobs list - $query = ""; - $last_jobs = array(); + $query = ""; + $last_jobs = array(); // Job Status list - $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' ); + define( 'STATUS_ALL', 0 ); + define( 'STATUS_RUNNING', 1 ); + define( 'STATUS_WAITING', 2 ); + define( 'STATUS_COMPLETED', 3 ); + define( 'STATUS_FAILED', 4 ); + define( 'STATUS_CANCELED', 5 ); + + $job_status = array( STATUS_ALL => 'All', + STATUS_RUNNING => 'Running', + STATUS_WAITING => 'Waiting', + STATUS_COMPLETED => 'Completed', + STATUS_FAILED => 'Failed', + STATUS_CANCELED => 'Canceled' ); + $dbSql->tpl->assign( 'job_status', $job_status ); // Jobs per page @@ -40,24 +53,25 @@ // Filter by status if( isset( $_POST['status'] ) ) { - switch( strtolower( $_POST['status'] ) ) + switch( $_POST['status'] ) { - case 'running': + case STATUS_RUNNING: $query .= "WHERE Job.JobStatus = 'R' "; break; - case 'waiting': + case STATUS_WAITING: $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','p','C') "; break; - case 'completed': + case STATUS_COMPLETED: $query .= "WHERE Job.JobStatus IN ('T', 'E') "; break; - case 'failed': + case STATUS_FAILED: $query .= "WHERE Job.JobStatus = 'f' "; break; - case 'canceled': + case STATUS_CANCELED: $query .= "WHERE Job.JobStatus = 'A' "; break; } + $dbSql->tpl->assign('job_status_filter', $_POST['status'] ); } // order by diff --git a/gui/bacula-web/templates/jobs.tpl b/gui/bacula-web/templates/jobs.tpl index 4fdb68dafe..21c9bb9eda 100644 --- a/gui/bacula-web/templates/jobs.tpl +++ b/gui/bacula-web/templates/jobs.tpl @@ -24,7 +24,7 @@ {$total_jobs} jobs found - + Jobs / Page - - Job Status - + + Job status + {html_options name=status values=$job_status options=$job_status selected=$job_status_filter onChange="submit();"} +