From: Davide Franco Date: Mon, 29 Nov 2010 13:55:39 +0000 (+0100) Subject: bacula-web: Internal PHP code improvment X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=adaffc60f135fcfef0c8a5e4c9e52b9b559bcd31;p=bacula%2Fbacula bacula-web: Internal PHP code improvment - New function GetLastJobs in classes.inc.php - New config file config.inc.php --- diff --git a/gui/bacula-web/classes.inc.php b/gui/bacula-web/classes.inc.php index a7cf9159f6..e4241174ee 100644 --- a/gui/bacula-web/classes.inc.php +++ b/gui/bacula-web/classes.inc.php @@ -23,6 +23,7 @@ define('BACULA_TYPE_BYTES_ENDTIME_ALLJOBS', 69); require_once "paths.php"; require_once "DB.php"; // Pear DB +require_once "config.inc.php"; require_once($smarty_path."Config_File.class.php"); if (!function_exists('array_fill')) { // For PHP < 4.2.0 users @@ -353,6 +354,32 @@ class Bweb extends DB { return $volumes; } // end function GetVolumeList() + public function GetLastJobs( $delay = LAST_DAY ) + { + switch( $this->driver ) + { + case 'mysql': + $query = "SELECT JobId, Name, EndTime, JobStatus "; + $query .= "FROM Job "; + $query .= "WHERE EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-86400 and JobStatus!='T'"; + break; + case 'pgsql': + $query = "SELECT JobId, Name, EndTime, JobStatus "; + $query .= "FROM Job "; + $query .= "WHERE EndTime <= NOW() and EndTime >NOW() - 86400 * interval '1 second' and JobStatus!= 'T'"; + break; + } + + $lastjobstatus = $this->db_link->query( $query ); + + if (PEAR::isError( $lastjobstatus ) ) { + die( "Unable to get last job status from catalog
" . $status->getMessage() ); + }else { + //echo "numrows = " . $lastjobstatus->numRows() . "
"; + return $lastjobstatus->numRows(); + } + } // end function GetLastJobStatus() + } // end class Bweb class BGraph { diff --git a/gui/bacula-web/configs/bacula.conf b/gui/bacula-web/configs/bacula.conf index 9f32ab5763..12845b920e 100644 --- a/gui/bacula-web/configs/bacula.conf +++ b/gui/bacula-web/configs/bacula.conf @@ -32,7 +32,7 @@ lang = en_EN [.DATABASE] host = localhost ; Database host or IP login = root ; Database account name -pass = p@ssw0rd ; Database account password +pass = p@ssw0rd ; Database account password db_name = bacula ; Database name db_type = mysql ; Database type ;db_port = 3306 ; Uncomment if not standard port @@ -41,9 +41,9 @@ db_type = mysql ; Database type ; If you want to configure more than 1 Bacula catalog in Bacula-Web, simply copy the previous line (See example below) ; Don't forget the change the name of the section (DATABASE2 in this case) -[.DATABASE2] -host = 192.168.2.55 -login = bacula -pass = -db_name = bacula -db_type = mysql +;[.DATABASE2] +;host = 192.168.2.55 +;login = bacula +;pass = +;db_name = bacula +;db_type = mysql diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 7f36f826c3..cab265a5e8 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -101,7 +101,7 @@ $query = ""; die( "Unable to get Total Job Bytes from catalog" . $last24bytes->getMessage() ); }else { $tmp = $last24bytes->fetchRow(); - var_dump( $tmp ); + //var_dump( $tmp ); // Transfered bytes since last 24 hours $smarty->assign('bytes_totales', $dbSql->human_file_size( $tmp[0] ) ); @@ -144,6 +144,9 @@ $res->free(); // Get volumes list (volumes.tpl) $smarty->assign('pools',$dbSql->GetVolumeList() ); +// Last job status (default is last 24 hours) +$smarty->assign( 'lastjobs', $dbSql->GetLastJobs() ); + // last_run_report.tpl if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) { $tmp = array(); @@ -175,11 +178,17 @@ if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) { or die ( "Error: query at row 98" ); */ $smarty->assign('status', $status->numRows() ); + if ( $status->numRows() ) { - while ( $res = $status->fetchRow() ) - array_push($tmp, $res); - $smarty->assign('errors_array',$tmp); - } + echo "status nomrow -> " . $status->numRows() . "
"; + while ( $res = $status->fetchRow() ) { + array_push($tmp, $res); + } + + $smarty->assign('errors_array',$tmp); + }else { + //echo "status pas marche ...
"; + } $status->free(); // Total Elapsed Time. Only for single Job. diff --git a/gui/bacula-web/style/default.css b/gui/bacula-web/style/default.css index a3a3eb704b..0462f3f64e 100644 --- a/gui/bacula-web/style/default.css +++ b/gui/bacula-web/style/default.css @@ -91,6 +91,22 @@ body{ margin: 0px; } +.box table +{ + margin-left: 5px; + margin-right: 5px; +} +.box table tr td +{ + padding: 2px; +} +.box table tr td.label +{ + font-weight: bold; + width: 150px; + text-align: left; +} + table { width: 100%; margin: 0px; diff --git a/gui/bacula-web/templates/generaldata.tpl b/gui/bacula-web/templates/generaldata.tpl index cbe7d16fb7..f213470e04 100644 --- a/gui/bacula-web/templates/generaldata.tpl +++ b/gui/bacula-web/templates/generaldata.tpl @@ -56,4 +56,5 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/gui/bacula-web/templates/index.tpl b/gui/bacula-web/templates/index.tpl index fc7983cb02..9f70c4ab76 100644 --- a/gui/bacula-web/templates/index.tpl +++ b/gui/bacula-web/templates/index.tpl @@ -2,6 +2,8 @@ "http://www.w3.org/TR/html4/loose.dtd"> +bacula-web + {literal} {/literal} - -bacula-web + {popup_init src='./js/overlib.js'} {include file=header.tpl}
-{include file=generaldata.tpl} -
{include file=volumes.tpl}
- {include file="$last_report"} + +
+

General informations

+ + + + + + + + + + + + + + + + + + + +
{t}Clients{/t} {$clientes_totales}
{t}Total bytes stored{/t}: {$bytes_stored}
{t}Total files:{/t} {$files_totales}
{t}Database size{/t}: {$database_size}
+ {t}Last month, bytes transferred{/t} +
+ {t}Last month, bytes transferred (pie){/t} +
+
+ + {include file="$last_report"} - -
-

General report

- {if $server==""} - - {else} - - {/if} -
- -
+
+

General report

+ {if $server==""} + + {else} + + {/if} +
+ + {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 0b572e5267..6d0c5c6758 100644 --- a/gui/bacula-web/templates/last_run_report.tpl +++ b/gui/bacula-web/templates/last_run_report.tpl @@ -135,39 +135,30 @@

Detailled report

- - - -
- - +
+ + + + + +
{t}Select a job:{/t} + + + +
+ {else if #mode# == "Full" || $smarty.get.Full_popup == "yes"} diff --git a/gui/bacula-web/templates/volumes.tpl b/gui/bacula-web/templates/volumes.tpl index 0d3dc7a70a..2b4a1298e8 100644 --- a/gui/bacula-web/templates/volumes.tpl +++ b/gui/bacula-web/templates/volumes.tpl @@ -1,15 +1,9 @@
-

Pools

- -
+

Pools

+ +
{foreach from=$pools item=pool key=pool_name} {/foreach} -
@@ -40,7 +34,7 @@ {/foreach}
+