]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Improved last 10 used volumes in main dashboard
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 22 Jul 2011 16:55:24 +0000 (18:55 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:26 +0000 (14:49 +0200)
gui/bacula-web/index.php
gui/bacula-web/templates/index.tpl

index c73910fae7020c6179db4c2b09068f902a39449e..5cd27a6fe97afa0c3ca7dbce501b29b115f9a4c5 100644 (file)
 
 
        // Last 15 used volumes
-       $vol_list = array();
-
-       $query  = "SELECT DISTINCT Media.Volumename, Media.Lastwritten, Media.VolStatus, Job.JobId FROM Job ";
-       $query .= "LEFT JOIN JobMedia ON Job.JobId = JobMedia.JobId ";
-       $query .= "LEFT JOIN Media ON JobMedia.MediaId = Media.MediaId ";
-       $query .= "ORDER BY Job.JobId DESC ";
-       $query .= "LIMIT 10 ";
+       $last_volumes = array();
        
-       try {
-               $result = $dbSql->db_link->runQuery($query);
-               foreach($result->fetchall() as $vol)
-                       $vol_list[] = $vol;
+       try{
+               $result = $dbSql->db_link->runQuery( "SELECT Media.MediaId,Media.Volumename, Media.Lastwritten, Media.VolStatus FROM Media ORDER BY Media.Lastwritten DESC LIMIT 10" );
+                       
+               foreach( $result->fetchAll() as $volume ) {
+                       $query                            = "SELECT COUNT(*) as jobs_count FROM JobMedia WHERE JobMedia.MediaId = '" . $volume['mediaid'] . "'";
+                       $jobs_by_vol              = $dbSql->db_link->runQuery($query);
+                       $jobs_by_vol              = $jobs_by_vol->fetchAll();
+                       $volume['jobs_count'] = $jobs_by_vol[0]['jobs_count'];
+                       $last_volumes[]           = $volume;
+               }
        }catch(PDOException $e) {
                CDBError::raiseError($e);
        }
 
-       $dbSql->tpl->assign( 'volume_list', $vol_list );        
+       $dbSql->tpl->assign( 'volumes_list', $last_volumes );   
 
        // Render template
        $dbSql->tpl->display('index.tpl');
index c2976a7893bc20c6da2322be8926eaa38abfccfd..dff6d232ac2b28526af35ee4d29c7a973567777f 100644 (file)
@@ -39,7 +39,7 @@
        </div>
   </div> <!-- end div box -->
   
-  <div class="box">
+  <div class="box" border=1>
        <p class="title">Last used volumes</p>
          <table>
                <tr>
                  <td class="tbl_header">Last written</td>
                  <td class="tbl_header">Job Id</td>
                </tr>
-               {foreach from=$volume_list item=vol}
+               {foreach from=$volumes_list item=vol}
                <tr>
                  <td>{$vol.volumename}</td>
                  <td>{$vol.volstatus}</td>
                  <td>{$vol.lastwritten}</td>
-                 <td>{$vol.jobid}</td>
+                 <td><b>{$vol.jobs_count}</b></td>
                </tr>
                {/foreach}
          </table>