From ee144de90e7234b9e07bb16d25a15ecac66b2246 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Mon, 29 Nov 2010 19:39:47 +0100 Subject: [PATCH] bacula-web: New jobs page - New jobs page including last failed and completed jobs (jobs.php and jobs.tpl) - Fixed html and css typo --- gui/bacula-web/index.php | 9 +-- gui/bacula-web/jobs.php | 75 ++++++++++++++++++++ gui/bacula-web/style/default.css | 16 ++++- gui/bacula-web/templates/index.tpl | 4 +- gui/bacula-web/templates/jobs.tpl | 55 ++++++++++++++ gui/bacula-web/templates/last_run_report.tpl | 3 +- 6 files changed, 154 insertions(+), 8 deletions(-) create mode 100644 gui/bacula-web/jobs.php create mode 100644 gui/bacula-web/templates/jobs.tpl diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index f2a5cc171c..4be4567559 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -140,6 +140,7 @@ $smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() ); // last_run_report.tpl if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) { +/* // Total Elapsed Time. Only for single Job. if ( $dbSql->driver == "mysql" ) $ret = $dbSql->db_link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600") @@ -157,10 +158,11 @@ if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) { $TotalElapsed = gmstrftime("%H:%M:%S", $TotalElapsed); $smarty->assign('TotalElapsed',$TotalElapsed); $ret->free(); - +*/ } else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){ +/* $tmp1 = array(); if ( $dbSql->driver == "mysql") $query = "select SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) @@ -182,9 +184,8 @@ else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){ } $smarty->assign('clients',$tmp1); -} - - +*/ +} if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes") $smarty->display('full_popup.tpl'); else diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php new file mode 100644 index 0000000000..4ac5305fa2 --- /dev/null +++ b/gui/bacula-web/jobs.php @@ -0,0 +1,75 @@ +compile_check = true; + $smarty->debugging = false; + $smarty->force_compile = true; + + $smarty->template_dir = "./templates"; + $smarty->compile_dir = "./templates_c"; + $smarty->config_dir = "./configs"; + + // Get the last 10 failed jobs + $query = ""; + $failed_jobs = array(); + + 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 = 'f' "; + //$query .= "WHERE Job.EndTime BETWEEN <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 "; + $query .= "ORDER BY Job.EndTime DESC "; + $query .= "LIMIT 10"; + + 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 <= NOW() and EndTime > NOW() - 86400 * interval '1 second' "; + $query .= "ORDER BY Job.EndTime DESC"; + $query .= "LIMIT 10"; + 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( $failed_jobs, $job); + } + } + $smarty->assign( 'failed_jobs', $failed_jobs ); + + $smarty->display('jobs.tpl'); +?> diff --git a/gui/bacula-web/style/default.css b/gui/bacula-web/style/default.css index 0a39e19472..f4835497ba 100644 --- a/gui/bacula-web/style/default.css +++ b/gui/bacula-web/style/default.css @@ -62,6 +62,14 @@ body{ margin-top: 1em; } +#main_center { + position: absolute; + left:5px; + width: 900px; + border: 1px solid red; + margin-top: 1em; +} + .box { border: 1px solid black; width: 100%; @@ -86,7 +94,7 @@ body{ padding-bottom: 5px; } -.box img { +.box img.report { width: 410px; margin: 0px; } @@ -96,6 +104,12 @@ body{ width: 100%; margin: 0px; } + +.box table th { + font-size: 10pt; + background-color: #CACACA; +} + .box table tr td { padding: 2px; diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index 38bcd304e6..32b65acca8 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -56,9 +56,9 @@

General report

{if $server==""} - + {else} - + {/if}
diff --git a/gui/bacula-web/templates/jobs.tpl b/gui/bacula-web/templates/jobs.tpl new file mode 100644 index 0000000000..a2234532e0 --- /dev/null +++ b/gui/bacula-web/templates/jobs.tpl @@ -0,0 +1,55 @@ + + + +bacula-web + +{literal} + +{/literal} + + + +{popup_init src='./js/overlib.js'} +{include file=header.tpl} +Back to main page + +
+
+

Last failed jobs (limited to 10)

+ + + + + + + + + + + + {foreach from=$failed_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}
+
+
+

Last completed jobs

+ bkjlajkdjaf +
+
+ +{include file="footer.tpl"} \ No newline at end of file diff --git a/gui/bacula-web/templates/last_run_report.tpl b/gui/bacula-web/templates/last_run_report.tpl index 23fa288e57..71338b8dc1 100644 --- a/gui/bacula-web/templates/last_run_report.tpl +++ b/gui/bacula-web/templates/last_run_report.tpl @@ -18,7 +18,8 @@ - {t}Show details{/t} + + Show last jobs status -- 2.39.5