From: Davide Franco Date: Fri, 14 Jan 2011 12:52:18 +0000 (+0100) Subject: bacula-web: Improved Jobs page X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3f603dae07f855d78f29eb64b14e68d75ed8a10e;p=bacula%2Fbacula bacula-web: Improved Jobs page - Merged running and last jobs list (all jobs in one list) - Job status filter more dynamic (automaticaly selected with current filter) - New icons for job status - Added job backed up bytes to job details - Changed job list order (by JobId) --- diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php index fba9becf79..cc41205559 100644 --- a/gui/bacula-web/jobs.php +++ b/gui/bacula-web/jobs.php @@ -19,60 +19,32 @@ $smarty->compile_dir = "./templates_c"; $smarty->config_dir = "./configs"; - // Global variables - $job_status = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' ); - - // Running jobs - $running_jobs = array(); - - $query = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS Pool_name "; - $query .= "FROM Job "; - $query .= "JOIN Status ON Job.JobStatus = Status.JobStatus "; - $query .= "LEFT JOIN Pool ON Job.PoolId = Pool.PoolId "; - $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R')"; - $query .= "ORDER BY JobId"; - - $jobsresult = $dbSql->db_link->query( $query ); - - if( PEAR::isError( $jobsresult ) ) { - echo "SQL query = $query
"; - die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() ); - }else { - while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) { - - // Elapsed time for this job - $elapsed = 'N/A'; - if( $job['JobStatus'] == 'R' ) - $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), time() ); - else - $job['elapsed_time'] = 'N/A'; - - // Odd or even row - if( count($running_jobs) % 2) - $job['Job_classe'] = 'odd'; - - // Job Status - $job['Level'] = $job_status[ $job['Level'] ]; - - array_push( $running_jobs, $job); - } - } - - $smarty->assign( 'running_jobs', $running_jobs ); - - // Get the last jobs list + // Jobs list $query = ""; $last_jobs = array(); - $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong "; + // Job Status list + $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' ); + $smarty->assign( 'job_status', $job_status ); + + // Global variables + $job_level = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' ); + + $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Job.JobBytes, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong "; $query .= "FROM Job "; $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId "; $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus "; // Filter by status if( isset( $_POST['status'] ) ) { - switch( $_POST['status'] ) + switch( strtolower( $_POST['status'] ) ) { + case 'running': + $query .= "WHERE Job.JobStatus = 'R' "; + break; + case 'waiting': + $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R') "; + break; case 'completed': $query .= "WHERE Job.JobStatus = 'T' "; break; @@ -85,7 +57,8 @@ } } - $query .= "ORDER BY Job.EndTime DESC "; + // order by + $query .= "ORDER BY Job.JobId DESC "; // Determine how many jobs to display if( isset($_POST['limit']) ) @@ -93,6 +66,8 @@ else $query .= "LIMIT 20 "; + //echo $query . '
'; + $jobsresult = $dbSql->db_link->query( $query ); if( PEAR::isError( $jobsresult ) ) { @@ -100,27 +75,58 @@ die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() ); }else { while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) { - // Determine icon for job - if( $job['JobStatus'] == 'T' ) - $job['Job_icon'] = "s_ok.gif"; - else - $job['Job_icon'] = "s_error.gif"; + + // Determine icon for job status + switch( $job['JobStatus'] ) { + case 'R': + $job['Job_icon'] = "running.png"; + break; + case 'T': + $job['Job_icon'] = "s_ok.png"; + break; + case 'A': + case 'f': + case 'E': + $job['Job_icon'] = "s_error.gif"; + break; + case 'F': + case 'S': + case 'M': + case 'm': + case 's': + case 'j': + case 'c': + case 'd': + case 't': + case 'C': + $job['Job_icon'] = "waiting.png"; + break; + } // end switch // Odd or even row if( count($last_jobs) % 2) $job['Job_classe'] = 'odd'; - // Elapsed time for this job - $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) ); + // Elapsed time for the job + if( $job['StartTime'] == '0000-00-00 00:00:00' ) + $job['elapsed_time'] = 'N/A'; + elseif( $job['EndTime'] == '0000-00-00 00:00:00' ) + $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), mktime() ); + else + $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) ); - // Job Status - $job['Level'] = $job_status[ $job['Level'] ]; + // Job Level + $job['Level'] = $job_level[ $job['Level'] ]; + + // Job Size + $job['JobBytes'] = $dbSql->human_file_size( $job['JobBytes'] ); array_push( $last_jobs, $job); } } $smarty->assign( 'last_jobs', $last_jobs ); + // Count jobs if( isset( $_POST['status'] ) ) $total_jobs = $dbSql->CountJobs( ALL, $_POST['status'] ); else diff --git a/gui/bacula-web/style/default.css b/gui/bacula-web/style/default.css index 29e1e550d3..8b6e73f3cb 100644 --- a/gui/bacula-web/style/default.css +++ b/gui/bacula-web/style/default.css @@ -134,13 +134,6 @@ a:hover { color: #736F6E } vertical-align: middle; } -.box table.list -{ - border-collapse: collapse; - width: 100%; - margin: 0px; -} - .box table tr td { padding: 5px; diff --git a/gui/bacula-web/style/images/s_ok.gif b/gui/bacula-web/style/images/s_ok.gif deleted file mode 100644 index 18116d92eb..0000000000 Binary files a/gui/bacula-web/style/images/s_ok.gif and /dev/null differ diff --git a/gui/bacula-web/templates/jobs.tpl b/gui/bacula-web/templates/jobs.tpl index 23eb843105..0adeb0b96c 100644 --- a/gui/bacula-web/templates/jobs.tpl +++ b/gui/bacula-web/templates/jobs.tpl @@ -17,43 +17,18 @@ {popup_init src='./external_packages/js/overlib.js'} {include file=header.tpl} - - -
-
-

Running jobs

- - - - - - - - - - - {foreach from=$running_jobs item=job} - - - - - - - - - - {/foreach} -
StatusJob IDBackupJobStart TimeElapsed timeLevelPool
{$job.JobStatusLong}{$job.JobId}{$job.Name}{$job.StartTime}{$job.elapsed_time}{$job.Level}{$job.Pool_name}
-
+ +
+
-

Last jobs

+

Jobs report

- +
{$total_jobs} jobs found @@ -71,10 +46,16 @@ Job Status @@ -87,36 +68,36 @@
- +
- - - - - - - - + + + + + + + + + -
StatusJob IDBackupJobStart TimeEnd TimeElapsed timeLevelPoolStatusJob IDBackupJobStart TimeEnd TimeElapsed timeLevelBytesPool
-
- + {foreach from=$last_jobs item=job} - - - - - - - + + + + + + + + {/foreach}
{$job.JobId}{$job.Job_name}{$job.StartTime}{$job.EndTime}{$job.elapsed_time}{$job.Level}{$job.Pool_name}{$job.JobId}{$job.Job_name}{$job.StartTime}{$job.EndTime}{$job.elapsed_time}{$job.Level}{$job.JobBytes}{$job.Pool_name}
-
+