]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Improved Jobs page
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 14 Jan 2011 12:52:18 +0000 (13:52 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:43:36 +0000 (14:43 +0200)
 - Merged running and last jobs list (all jobs in one list)
 - Job status filter more dynamic (automaticaly selected with current filter)
 - New icons for job status
 - Added job backed up bytes to job details
 - Changed job list order (by JobId)

gui/bacula-web/jobs.php
gui/bacula-web/style/default.css
gui/bacula-web/style/images/s_ok.gif [deleted file]
gui/bacula-web/templates/jobs.tpl

index fba9becf79635456a005ea8a7e2fc511e831abc9..cc41205559a5c3283a88039c43fa4db10e9f268d 100644 (file)
   $smarty->compile_dir = "./templates_c";
   $smarty->config_dir     = "./configs";
   
-  // Global variables
-  $job_status = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
-
-  // Running jobs
-  $running_jobs = array();
-  
-  $query  = "SELECT Job.JobId, Job.JobStatus, Status.JobStatusLong, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS Pool_name ";
-  $query .= "FROM Job ";
-  $query .= "JOIN Status ON Job.JobStatus = Status.JobStatus ";
-  $query .= "LEFT JOIN Pool ON Job.PoolId = Pool.PoolId ";
-  $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R')";
-  $query .= "ORDER BY JobId";
-  
-  $jobsresult = $dbSql->db_link->query( $query );
-  
-  if( PEAR::isError( $jobsresult ) ) {
-         echo "SQL query = $query <br />";
-         die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
-  }else {
-         while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
-       
-               // Elapsed time for this job
-               $elapsed = 'N/A';
-               if( $job['JobStatus'] == 'R' )
-                       $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), time() );
-               else
-                       $job['elapsed_time'] = 'N/A';
-                       
-               // Odd or even row
-               if( count($running_jobs) % 2)
-                       $job['Job_classe'] = 'odd';
-
-               // Job Status
-               $job['Level'] = $job_status[ $job['Level'] ];
-               
-               array_push( $running_jobs, $job);
-         }
-  }
-  
-  $smarty->assign( 'running_jobs', $running_jobs );
-  
-  // Get the last jobs list
+  // Jobs list
   $query          = "";
   $last_jobs = array();
   
-  $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
+  // Job Status list
+  $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' );
+  $smarty->assign( 'job_status', $job_status );
+  
+  // Global variables
+  $job_level = array( 'D' => 'Diff', 'I' => 'Incr', 'F' => 'Full' );
+  
+  $query .= "SELECT Job.JobId, Job.Name AS Job_name, Job.StartTime, Job.EndTime, Job.Level, Job.JobBytes, Pool.Name, Job.JobStatus, Pool.Name AS Pool_name, Status.JobStatusLong ";
   $query .= "FROM Job ";
   $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
   $query .= "LEFT JOIN Status ON Job.JobStatus = Status.JobStatus ";
   
   // Filter by status
   if( isset( $_POST['status'] ) ) {
-       switch( $_POST['status'] )
+       switch( strtolower( $_POST['status'] ) )
        {
+               case 'running':
+                       $query .= "WHERE Job.JobStatus = 'R' ";
+               break;
+               case 'waiting':
+                       $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','C','R') ";
+               break;
                case 'completed':
                        $query .= "WHERE Job.JobStatus = 'T' ";
                break;
@@ -85,7 +57,8 @@
        }
   }
   
-  $query .= "ORDER BY Job.EndTime DESC ";
+  // order by
+  $query .= "ORDER BY Job.JobId DESC ";
   
   // Determine how many jobs to display
   if( isset($_POST['limit']) )
@@ -93,6 +66,8 @@
   else
        $query .= "LIMIT 20 ";
   
+  //echo $query . '<br />';
+  
   $jobsresult = $dbSql->db_link->query( $query );
   
   if( PEAR::isError( $jobsresult ) ) {
          die("Unable to get last failed jobs from catalog" . $jobsresult->getMessage() );
   }else {
          while( $job = $jobsresult->fetchRow( DB_FETCHMODE_ASSOC ) ) {
-               // Determine icon for job
-               if( $job['JobStatus'] == 'T' )
-                       $job['Job_icon'] = "s_ok.gif";
-               else
-                       $job['Job_icon'] = "s_error.gif";
+               
+               // Determine icon for job status
+               switch( $job['JobStatus'] ) {
+                       case 'R':
+                               $job['Job_icon'] = "running.png";
+                       break;
+                       case 'T':
+                               $job['Job_icon'] = "s_ok.png";
+                       break;
+                       case 'A':
+                       case 'f':
+                       case 'E':
+                               $job['Job_icon'] = "s_error.gif";
+                       break;
+                       case 'F':
+                       case 'S':
+                       case 'M':
+                       case 'm':
+                       case 's':
+                       case 'j':
+                       case 'c':
+                       case 'd':
+                       case 't':
+                       case 'C':
+                               $job['Job_icon'] = "waiting.png";
+                       break;
+               } // end switch
                
                // Odd or even row
                if( count($last_jobs) % 2)
                        $job['Job_classe'] = 'odd';
                
-               // Elapsed time for this job
-               $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
+               // Elapsed time for the job
+               if( $job['StartTime'] == '0000-00-00 00:00:00' )
+                       $job['elapsed_time'] = 'N/A';
+               elseif( $job['EndTime'] == '0000-00-00 00:00:00' )
+                       $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), mktime() );
+               else
+                       $job['elapsed_time'] = $dbSql->Get_ElapsedTime( strtotime($job['StartTime']), strtotime($job['EndTime']) );
 
-               // Job Status
-                $job['Level'] = $job_status[ $job['Level'] ];
+               // Job Level
+        $job['Level'] = $job_level[ $job['Level'] ];
+               
+               // Job Size
+               $job['JobBytes'] = $dbSql->human_file_size( $job['JobBytes'] );
 
                array_push( $last_jobs, $job);
          }
   }
   $smarty->assign( 'last_jobs', $last_jobs );
   
+  // Count jobs
   if( isset( $_POST['status'] ) )
        $total_jobs = $dbSql->CountJobs( ALL, $_POST['status'] );
   else
index 29e1e550d33da27ab387598d1f310efc39b2c68f..8b6e73f3cb0727a2ea2c9078e2909d085f58e4fe 100644 (file)
@@ -134,13 +134,6 @@ a:hover { color: #736F6E }
  vertical-align: middle;
 }
 
-.box table.list
-{
- border-collapse: collapse;
- width: 100%;
- margin: 0px;
-}
-
 .box table tr td
 {
  padding: 5px;
diff --git a/gui/bacula-web/style/images/s_ok.gif b/gui/bacula-web/style/images/s_ok.gif
deleted file mode 100644 (file)
index 18116d9..0000000
Binary files a/gui/bacula-web/style/images/s_ok.gif and /dev/null differ
index 23eb84310561b8b39a9e240da0afa860f5bb80ea..0adeb0b96cc49eeea37cbab56ca417fb31dff607 100644 (file)
 {popup_init src='./external_packages/js/overlib.js'}
 {include file=header.tpl}
 
-<div id="nav">
-  <a href="index.php" title="Back to the dashboard">Dashboard</a> > Jobs list
-</div>
-
-<div id="main_center">
-  <div class="box">
-       <p class="title">Running jobs</p>
-       <table class="list">
-               <tr>
-                       <td class="info">Status</td>
-                       <td class="info">Job ID</td>
-                       <td class="info">BackupJob</td>
-                       <td class="info">Start Time</td>
-                       <td class="info">Elapsed time</td>
-                       <td class="info">Level</td>
-                       <td class="info">Pool</td>
-               </tr>
-               {foreach from=$running_jobs item=job}
-               <tr>
-                       <td class="{$job.Job_classe}">{$job.JobStatusLong}</td>
-                       <td class="{$job.Job_classe}">{$job.JobId}</td>
-                       <td class="{$job.Job_classe}">{$job.Name}</td>
-                       <td class="{$job.Job_classe}">{$job.StartTime}</td>
-                       <td class="{$job.Job_classe}">{$job.elapsed_time}</td>
-                       <td class="{$job.Job_classe}">{$job.Level}</td>
-                       <td class="{$job.Job_classe}">{$job.Pool_name}</td>
-               </tr>
-               {/foreach}
-       </table>
-  </div> <!-- end div box -->
+  <div id="nav">
+    <a href="index.php" title="Back to the dashboard">Dashboard</a> > Jobs list
+  </div>
 
+  <div id="main_center">
+  
   <!-- Last jobs -->  
   <div class="box">
-       <p class="title">Last jobs</p>
+       <p class="title">Jobs report</p>
        <!-- Filter jobs -->
        <form action="jobs.php" method="post">
-       <table class="list" border="0">
+       <table border="0">
          <tr>
            <td class="info" width="200">
                        {$total_jobs} jobs found
                <td class="info" width="200">
                        Job Status
                        <select name="status">
-                               <option value="Any">Any
+                               {foreach from=$job_status item=status_label}
+                               <option value="{$status_label}" {if $smarty.post.status == $status_label}Selected{/if}>{$status_label}
+<!--
+                               <option value="waiting">Waiting
+                               <option value="running">Running
                                <option value="completed">Completed
                                <option value="failed">Failed
                                <option value="canceled">Canceled
+-->                    
+                               {/foreach}
                        </select>
                </td>
                <td class="info" width="120">
        </table>
        </form>
        
-       <table class="list" border="0">
+       <table border="0">
          <tr>
-               <td width="50" class="info">Status</td>
-               <td width="50" class="info">Job ID</td>
-               <td width="70" class="info">BackupJob</td>
-               <td width="80" class="info">Start Time</td>
-               <td width="80" class="info">End Time</td>
-               <td width="70" class="info">Elapsed time</td>
-               <td width="50" class="info">Level</td>
-               <td width="80" class="info">Pool</td>
+               <td class="info">Status</td>
+               <td class="info">Job ID</td>
+               <td class="info">BackupJob</td>
+               <td class="info">Start Time</td>
+               <td class="info">End Time</td>
+               <td class="info">Elapsed time</td>
+               <td class="info">Level</td>
+               <td class="info">Bytes</td>
+               <td class="info">Pool</td>
          </tr>
-       </table>
-       <div class="listbox">
-       <table class="list" border="0">
+       <!-- <div class="listbox"> -->
          {foreach from=$last_jobs item=job}
          <tr>
                <td width="50" class="{$job.Job_classe}">
                        <img width="20" src="style/images/{$job.Job_icon}" alt="" title="{$job.JobStatusLong}" />
                </td>
-               <td width="50" class="{$job.Job_classe}">{$job.JobId}</td>
-               <td width="70" class="{$job.Job_classe}">{$job.Job_name}</td>
-               <td width="80" class="{$job.Job_classe}">{$job.StartTime}</td>
-               <td width="80" class="{$job.Job_classe}">{$job.EndTime}</td>
-               <td width="70" class="{$job.Job_classe}">{$job.elapsed_time}</td>
-               <td width="50" class="{$job.Job_classe}">{$job.Level}</td>
-               <td width="80" class="{$job.Job_classe}">{$job.Pool_name}</td>
+               <td class="{$job.Job_classe}">{$job.JobId}</td>
+               <td class="{$job.Job_classe}">{$job.Job_name}</td>
+               <td class="{$job.Job_classe}">{$job.StartTime}</td>
+               <td class="{$job.Job_classe}">{$job.EndTime}</td>
+               <td class="{$job.Job_classe}">{$job.elapsed_time}</td>
+               <td class="{$job.Job_classe}">{$job.Level}</td>
+               <td class="{$job.Job_classe}">{$job.JobBytes}</td>
+               <td class="{$job.Job_classe}">{$job.Pool_name}</td>
          </tr>
          {/foreach}
        </table>
-       </div> <!-- end div class=listbox -->
+       <!-- </div> --> <!-- end div class=listbox -->
   </div>
 
 </div>