]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Internal PHP code improvment
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 29 Nov 2010 13:55:39 +0000 (14:55 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:41 +0000 (14:39 +0200)
 - New function GetLastJobs in classes.inc.php
 - New config file config.inc.php

gui/bacula-web/classes.inc.php
gui/bacula-web/configs/bacula.conf
gui/bacula-web/index.php
gui/bacula-web/style/default.css
gui/bacula-web/templates/generaldata.tpl
gui/bacula-web/templates/index.tpl
gui/bacula-web/templates/last_run_report.tpl
gui/bacula-web/templates/volumes.tpl

index a7cf9159f6dd87d58436392d866d9e8295d7b2e3..e4241174eeee49ee188eb281cf1b01c9d34aeaec 100644 (file)
@@ -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<br />" . $status->getMessage() );
+                       }else {
+                               //echo "numrows = " . $lastjobstatus->numRows() . "<br />";
+                               return $lastjobstatus->numRows();
+                       }
+               } // end function GetLastJobStatus()
+               
 } // end class Bweb
 
 class BGraph {
index 9f32ab57639902c71786b9bf7f5e52cb7da00fb8..12845b920e0ff1bb8a7255a833ddeb192395f9a4 100644 (file)
@@ -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
index 7f36f826c3653c7ede8fff3975f456e9396b7632..cab265a5e8985eb4bba1c84629fc917da981dce3 100644 (file)
@@ -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() . "<br />";
+                       while ( $res = $status->fetchRow() ) {
+                               array_push($tmp, $res);
+                       }
+            
+                       $smarty->assign('errors_array',$tmp);
+        }else {
+                       //echo "status pas marche ...<br />";
+               }
         $status->free();
         
         // Total Elapsed Time. Only for single Job.
index a3a3eb704b779c12561137d5f2be53e27086c3b4..0462f3f64e69358f8a2076633d36a92023ac66e6 100644 (file)
@@ -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;
index cbe7d16fb71316c7b3ce8780a22559cb36fdbaca..f213470e04fe1456e69159a29fd137c1d9fa0300 100644 (file)
@@ -56,4 +56,5 @@
        </td>
 </tr>
 </table>
-</div> <!-- end div box -->
\ No newline at end of file
+</div> 
+<!-- end div box -->
\ No newline at end of file
index fc7983cb0215e75b04446905e460e077f6d6276d..9f70c4ab76c7500eb128defd76a302afd63a0d1f 100644 (file)
@@ -2,6 +2,8 @@
   "http://www.w3.org/TR/html4/loose.dtd">
 <html lang="en">
 <head>
+<title>bacula-web</title>
+<link rel="stylesheet" type="text/css" href="style/default.css">
 {literal}
 <script type="text/javascript">
        function OpenWin(URL,wid,hei) {
        }
 </script>
 {/literal}
-<link rel="stylesheet" type="text/css" href="style/default.css" />
-<title>bacula-web</title>
+
 </head>
 <body>
 {popup_init src='./js/overlib.js'}
 {include file=header.tpl}
 
 <div id="main_left">
-{include file=generaldata.tpl}
-<br /> 
 {include file=volumes.tpl}
 </div>
 
 <div id="main_right">
-       {include file="$last_report"}   
+  <!-- General information -->
+  <div class="box">
+       <p class="title">General informations</p>
+       <table>
+         <tr>
+           <td class="label">{t}Clients{/t}</td> <td>{$clientes_totales}</td>
+         </tr>
+         <tr>
+               <td class="label">{t}Total bytes stored{/t}:</td> <td>{$bytes_stored}</td>
+         </tr>
+         <tr>
+               <td class="label">{t}Total files:{/t}</td> <td>{$files_totales}</td>
+         </tr>
+         <tr>
+               <td class="label">{t}Database size{/t}:</td> <td>{$database_size}</td>
+         </tr>
+         <tr>
+               <td colspan=2 align=center>
+                 <a href="javascript:OpenWin('index.php?pop_graph1=yes','600','400')">{t}Last month, bytes transferred{/t}</a>
+               </td>
+         </tr>
+         <tr>
+               <td colspan=2 align=center>
+                 <a href="javascript:OpenWin('index.php?pop.graph2=yes','600','400')">{t}Last month, bytes transferred (pie){/t}</a>
+               </td>
+         </tr>
+       </table>
+  </div>
+       
+  {include file="$last_report"}        
   
-<!--  <table class=genmed cellspacing="1" cellpadding="3" border=0 align="center">
-               <tr>
-                 <td>
--->
-       <div class="box">
-               <p class="title">General report</p>
-               {if $server==""} 
-                 <img src="stats.php?server={$server}&amp;tipo_dato=69&amp;title=General%20report&amp;modo_graph=bars&amp;sizex=420&amp;sizey=250&amp;MBottom=20&amp;legend=1" alt="" />
-               {else}
-                 <img src="stats.php?server={$server}&amp;tipo_dato=3&amp;title={$server}&amp;modo_graph=bars" alt="" />
-               {/if}
-       </div> <!-- end div box -->
-<!--
-                       </td>
-               </tr>
-  </table>
--->
-</div>
+  <div class="box">
+       <p class="title">General report</p>
+       {if $server==""} 
+         <img src="stats.php?server={$server}&amp;tipo_dato=69&amp;title=General%20report&amp;modo_graph=bars&amp;sizex=420&amp;sizey=250&amp;MBottom=20&amp;legend=1" alt="" />
+       {else}
+         <img src="stats.php?server={$server}&amp;tipo_dato=3&amp;title={$server}&amp;modo_graph=bars" alt="" />
+       {/if}
+  </div> <!-- end div box -->
+
+</div> <!-- end div main_right -->
 
 {include file="footer.tpl"}
\ No newline at end of file
index 0b572e526732e09ef74298ba6f378919c2aa273f..6d0c5c6758e2e7496a8c9169e3fe101e6510f61a 100644 (file)
        <p class="title">Detailled report</p>
  
  <form method="get" action="report.php" target="_blank">
- <table>
-
- <tr>
-       <td align=right colspan=2 valign=bottom>
-
-               <table width="100%" cellpadding="0" cellspacing="3" border="0">
+   <table width="100%" cellpadding="0" cellspacing="3" border="0">
+<!--
                        <tr bgcolor=white>
                                <td colspan="3" style="text-align: center; background-image: url('style/images/bg1.png'); font-size: 12px; font-weight: bold;">
                                Detailed report
                                </td>
                        </tr>
-               
-                       <tr>
-                               <td align=left>
-                                       {t}Select a job:{/t}
-                               </td>                   
-                               <td align=right>
-                                       <input type=hidden name="default" value="1">                            
-                                       <select name=server>
-                                               {if $smarty.get.server!=""}
-                                                       {html_options values=$smarty.get.server output=$smarty.get.server}
-                                               {else}
-                                                       {html_options values=$total_name_jobs output=$total_name_jobs}
-                                               {/if}
-                                       </select>
-                               </td>
-                               <td>
-                                       <input type=submit value="{t}go{/t}">
-                               </td>
-                               
-                       </tr>
- </table>
-               </form>
+-->            
+        <tr>
+          <td class="label">{t}Select a job:{/t}</td>
+          <td align=center>
+            <input type=hidden name="default" value="1">                               
+                  <select name=server>
+                    {if $smarty.get.server != ""}
+                               {html_options values=$smarty.get.server output=$smarty.get.server}
+                        {else}
+                           {html_options values=$total_name_jobs output=$total_name_jobs}
+                    {/if}
+                  </select>
+            <input type=submit value="{t}go{/t}">
+          </td>
+     </tr>
+   </table>
+ </form>
 {else if #mode# == "Full" || $smarty.get.Full_popup == "yes"}
 <table>
        <tr class="tbl_header1">
index 0d3dc7a70ab3d1ac37fe0b5bb8e72810fd35965c..2b4a1298e8e7159b65e185ff24f2ce7145b0d402 100644 (file)
@@ -1,15 +1,9 @@
 <!-- volumes.tpl -->
 
 <div class="box">
-       <p class="title">Pools</p>
-<!--
-<table border=0 width=100% class=code cellspacing=0 cellpadding=0>
-<tr align=center width=100%>
-        <td class=tbl_header2 background="style/images/bg4.png"><b>Pools</b></td>
-        <td class=tbl_header2 background="style/images/end4.png"><img src="style/images/empty.png"></td>
-</tr>
--->
-<table border=0 width="100%" class=code cellspacing=0 cellpadding=0>
+  <p class="title">Pools</p>
+       
+  <table width="100%">
        {foreach from=$pools item=pool key=pool_name}
        <tr>
                <th colspan="6" style="font-size: 10pt; text-align: center; background-color: #E0C8E5; color: black; padding: 3px;">
@@ -40,7 +34,7 @@
                {/foreach}
                </tr>
        {/foreach}
-</table>
+  </table>
 
 </div> <!-- end div box -->