From 7fe03c672df5222211a72eca877266f256481fb6 Mon Sep 17 00:00:00 2001 From: Davide Franco Date: Wed, 23 Mar 2011 16:47:44 +0100 Subject: [PATCH] bacula-web: Enabled catalog selection in header template - ability to choose which catalog to use (when more than 1 catalog areconfigured) - some php code cleanup in index.php --- gui/bacula-web/classes/bweb.inc.php | 23 +++++++++++++++++++---- gui/bacula-web/config/config.php | 4 ++-- gui/bacula-web/index.php | 5 +++-- gui/bacula-web/style/default.css | 10 ++++++++-- gui/bacula-web/templates/header.tpl | 11 +++++++---- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/gui/bacula-web/classes/bweb.inc.php b/gui/bacula-web/classes/bweb.inc.php index 482fc66940..f22637835c 100644 --- a/gui/bacula-web/classes/bweb.inc.php +++ b/gui/bacula-web/classes/bweb.inc.php @@ -23,12 +23,13 @@ class Bweb extends DB { var $driver; - public $tpl; - public $db_link; // Database link + public $tpl; + public $db_link; // Database link private $config_file; // Config filename private $config; // Loaded config from bacula.conf private $catalogs = array(); // Catalog array + public $catalog_nb; private $bwcfg; function __construct() @@ -39,9 +40,11 @@ class Bweb extends DB { // Checking if config file exist and is readable if( !$this->bwcfg->Check_Config_File() ) die( "Unable to load configuration file" ); - else + else { $this->bwcfg->Load_Config(); - + $this->catalog_nb = $this->bwcfg->Count_Catalogs(); + } + // Select which catalog to connect to if( isset( $_POST['catalog_id'] ) ) $dsn = $this->bwcfg->Get_Dsn( $_POST['catalog_id'] ); @@ -62,6 +65,18 @@ class Bweb extends DB { $this->init_tpl(); // Initialize smarty gettext function $this->init_gettext(); + + // Catalog selection + if( $this->catalog_nb > 1 ) { + // Set current catalog in header template + if(isset( $_POST['catalog_id'] ) ) + $this->tpl->assign( 'catalog_current', $_POST['catalog_id'] ); + + $this->tpl->assign( 'catalogs', $this->bwcfg->Get_Catalogs() ); + }else + { + + } } // Initialize Smarty template classe diff --git a/gui/bacula-web/config/config.php b/gui/bacula-web/config/config.php index 521bbcb6ba..d27214a4ab 100644 --- a/gui/bacula-web/config/config.php +++ b/gui/bacula-web/config/config.php @@ -11,7 +11,7 @@ $config['language'] = 'en_EN'; //MySQL bacula catalog - $config[0]['label'] = 'Backup Server'; + $config[0]['label'] = 'Backup/mysql'; $config[0]['host'] = 'localhost'; $config[0]['login'] = 'root'; $config[0]['password'] = 'p@ssw0rd'; @@ -20,7 +20,7 @@ $config[0]['db_port'] = '3306'; //MySQL bacula catalog - $config[1]['label'] = 'Backup Server'; + $config[1]['label'] = 'Backup/pgsql'; $config[1]['host'] = 'localhost'; $config[1]['login'] = 'bacula'; $config[1]['password'] = 'bacula'; diff --git a/gui/bacula-web/index.php b/gui/bacula-web/index.php index 0b51e2c5c3..f4d1ad4560 100644 --- a/gui/bacula-web/index.php +++ b/gui/bacula-web/index.php @@ -19,8 +19,6 @@ include_once( 'config.inc.php' ); $dbSql = new Bweb(); -$mode = ""; - // Assign to template catalogs number //$dbSql->tpl->assign( "dbs", $dbSql->bwcfg->Count_Catalogs() ); // Assign dbs @@ -30,6 +28,9 @@ if ( count($dbSql->dbs) >1 ) { $smarty->assign("dbs_now", $_SESSION['DATABASE']); } */ +// Catalog count +$catalog_nb = $dbSql->catalog_nb; +$dbSql->tpl->assign( 'catalog_nb', $catalog_nb ); // Stored files number $totalfiles = $dbSql->GetStoredFiles( ALL ); diff --git a/gui/bacula-web/style/default.css b/gui/bacula-web/style/default.css index 4419c49701..284c03722d 100644 --- a/gui/bacula-web/style/default.css +++ b/gui/bacula-web/style/default.css @@ -34,9 +34,10 @@ a:link, a:visited, a:hover, a:visited { width: 100%; padding: 0px; margin: 0px; - margin-bottom: 15px; + margin-bottom: 0px; background-color: #736F6E; } + #header p { margin: 0px; padding: 5px; @@ -53,16 +54,21 @@ a:link, a:visited, a:hover, a:visited { margin: 0em; padding: 0px; border-bottom: 1px solid black; + height: 30px; } + #subheader ul { - height: 20px; + height: 30px; margin: 0px; + /* margin-top: 5px; */ } #subheader li { display: inline; float: right; padding: 0px 10px 0px 10px; + margin-top: 5px; + vertical-align: middle; } #subheader li a { diff --git a/gui/bacula-web/templates/header.tpl b/gui/bacula-web/templates/header.tpl index 74487552eb..61c986f1ee 100644 --- a/gui/bacula-web/templates/header.tpl +++ b/gui/bacula-web/templates/header.tpl @@ -6,13 +6,16 @@