From bd2a806983f3b0c8a64af531a1254f9e092b2f1e Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Tue, 30 Nov 2010 11:49:57 +0100 Subject: [PATCH] bacula-web: Added completed jobs in jobs page - Fixed some css attributes - Added navigation bar in jobs page (back to dashboard) - Add last 24 hours completed jobs in job page --- gui/bacula-web/jobs.php | 70 ++++++++++++++++++++++--------- gui/bacula-web/style/default.css | 35 ++++++++++++---- gui/bacula-web/templates/jobs.tpl | 34 +++++++++++++-- 3 files changed, 109 insertions(+), 30 deletions(-) diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php index 4ac5305fa2..a165641090 100644 --- a/gui/bacula-web/jobs.php +++ b/gui/bacula-web/jobs.php @@ -1,23 +1,9 @@ NOW() - 86400 * interval '1 second' "; + $query .= "WHERE Job.JobStatus = 'f' "; + //$query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' AND "; $query .= "ORDER BY Job.EndTime DESC"; $query .= "LIMIT 10"; break; @@ -71,5 +58,48 @@ } $smarty->assign( 'failed_jobs', $failed_jobs ); + // Get the last completed jobs (last 24 hours) + $query = ""; + $completed_jobs = array(); + + // Interval calculation + $end_date = mktime(); + $start_date = $end_date - LAST_DAY; + + $start_date = date( "Y-m-d H:m:s", $start_date ); + $end_date = date( "Y-m-d H:m:s", $end_date ); + + switch( $dbSql->driver ) + { + case 'mysql': + $query = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, Job.JobId, Job.Name AS job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS pool_name, Job.JobStatus "; + $query .= "FROM Job "; + $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId "; + $query .= "WHERE Job.JobStatus = 'T' AND "; + $query .= "Job.EndTime BETWEEN '$start_date' AND '$end_date' "; + $query .= "ORDER BY Job.EndTime DESC "; + + break; + + case 'pgsql': + $query = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus "; + $query .= "FROM Job "; + $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId "; + $query .= "WHERE EndTime BETWEEN '$start_date' and '$end_date' "; + $query .= "ORDER BY Job.EndTime DESC"; + break; + } + $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 ) ) { + array_push( $completed_jobs, $job); + } + } + $smarty->assign( 'completed_jobs', $completed_jobs ); + $smarty->display('jobs.tpl'); ?> diff --git a/gui/bacula-web/style/default.css b/gui/bacula-web/style/default.css index f4835497ba..32a06b9898 100644 --- a/gui/bacula-web/style/default.css +++ b/gui/bacula-web/style/default.css @@ -2,8 +2,32 @@ body{ background-color: #ffffff; padding: 3px; margin: 0px; - font-family: Arial,Verdana; + font-size: 10pt; +} + +a:link, a:visited { + color: #736F6E; + font-size: 10pt; +} + +a:hover { color: #736F6E } + +#nav +{ + margin: 10px; + /*border: 1px solid green;*/ + font-size: 11pt; +} + +#nav a:link{ + font-size: 11pt; + font-weight: bold; +} + +#nav a:visited{ + font-size: 11pt; + font-weight: bold; } #header{ @@ -47,7 +71,7 @@ body{ #main_left { position: absolute; - left:5px; + left:10px; width: 550px; border:none; margin-top: 1em; @@ -64,9 +88,9 @@ body{ #main_center { position: absolute; - left:5px; + left:10px; width: 900px; - border: 1px solid red; + /*border: 1px solid red; */ margin-top: 1em; } @@ -147,9 +171,6 @@ table { background-image: url('../style/images/bg5.png'); } -a:link { color: #0000c0 } -a:visited { color: #0000c0 } -a:hover { color: #6040ff } img {border: 0} td,input,select { diff --git a/gui/bacula-web/templates/jobs.tpl b/gui/bacula-web/templates/jobs.tpl index a2234532e0..c37f94aa49 100644 --- a/gui/bacula-web/templates/jobs.tpl +++ b/gui/bacula-web/templates/jobs.tpl @@ -16,9 +16,13 @@ {popup_init src='./js/overlib.js'} {include file=header.tpl} -Back to main page + +
+

Last failed jobs (limited to 10)

@@ -34,7 +38,7 @@ {foreach from=$failed_jobs item=job} - + @@ -46,9 +50,33 @@ {/foreach}
{$job.JobId} {$job.job_name} {$job.StartTime}
+

Last completed jobs

- bkjlajkdjaf + + + + + + + + + + + + {foreach from=$completed_jobs item=job} + + + + + + + + + + + {/foreach} +
StatusJob IDBackupJobStart TimeEnd TimeElapsed timeLevelPool
{$job.JobId}{$job.job_name}{$job.StartTime}{$job.EndTime}{$job.elapsed}{$job.Level}{$job.pool_name}
-- 2.39.5