]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Enabled catalog selection in header template
authorDavide Franco <bacula-dev@dflc.ch>
Wed, 23 Mar 2011 15:47:44 +0000 (16:47 +0100)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 2 Aug 2011 09:56:15 +0000 (11:56 +0200)
 - 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
gui/bacula-web/config/config.php
gui/bacula-web/index.php
gui/bacula-web/style/default.css
gui/bacula-web/templates/header.tpl

index 482fc66940bb9d5019282bff793af1bff18d4f55..f22637835cada016c74d7cde3260f88b69441b88 100644 (file)
@@ -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
index 521bbcb6ba335423bd5faa33f59ac83414f11cdf..d27214a4abd61f45188f02e78b815c78de53157e 100644 (file)
@@ -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';
index 0b51e2c5c3e26300bd6f09533ccbc50d14dac4d1..f4d1ad456055230f693bbf5ad0f361859c8c08e3 100644 (file)
@@ -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 );
index 4419c49701c8c412276267fe6de881c24657e0b9..284c03722df4f8f2e8983c6de17f0a1021283597 100644 (file)
@@ -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 {
index 74487552eb0d75c5f3e338d73f5500996c2fc12c..61c986f1ee765ecd39d749242370313e12faf66c 100644 (file)
@@ -6,13 +6,16 @@
 <div id="subheader">
  <ul>
        <li> <a href="http://bacula-web.dflc.ch/bugs" target="_blank">Bugs</a> </li>
-       <li><a href="http://bacula-web.dflc.ch" target="_blank">About</a> </li>
+       <li> <a href="http://bacula-web.dflc.ch" target="_blank">About</a> </li>
 
        <!-- Condifitional catalog selection if more than 1 catalog is defined in the configuration -->
-       {if $dbs > 1}
+       {if $catalog_nb > 1}
        <li>
-               <form method=post action=index.php>
-                       Catalog&nbsp; <select name=sel_database OnChange=submit()> {html_options values={$dbs} name=$selected_db=$dbs_now} </select>
+               <form method="post" action="index.php">
+                       Catalog&nbsp;
+                       <select name="catalog_id" OnChange="submit()">
+                               {html_options options=$catalogs} 
+                       </select>
                </form>
        </li>
        {/if}