]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Added completed jobs in jobs page
authorDavide Franco <bacula-dev@dflc.ch>
Tue, 30 Nov 2010 10:49:57 +0000 (11:49 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:42 +0000 (14:39 +0200)
 - Fixed some css attributes
 - Added navigation bar in jobs page (back to dashboard)
 - Add last 24 hours completed jobs in job page

gui/bacula-web/jobs.php
gui/bacula-web/style/default.css
gui/bacula-web/templates/jobs.tpl

index 4ac5305fa25a9d6c8ac3adac813082ee000ab60c..a16564109046a87be93c54b755a4c00364584d44 100644 (file)
@@ -1,23 +1,9 @@
 <?php
-/* 
-+-------------------------------------------------------------------------+
-| Copyright (C) 2004 Juan Luis Francés Jiménez                            |
-|                                                                         |
-| This program is free software; you can redistribute it and/or           |
-| modify it under the terms of the GNU General Public License             |
-| as published by the Free Software Foundation; either version 2          |
-| of the License, or (at your option) any later version.                  |
-|                                                                         |
-| This program is distributed in the hope that it will be useful,         |
-| but WITHOUT ANY WARRANTY; without even the implied warranty of          |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
-| GNU General Public License for more details.                            |
-+-------------------------------------------------------------------------+ 
-*/
   session_start();
-  require ("paths.php");
-  require($smarty_path."Smarty.class.php");
-  include "classes.inc.php";
+  require_once ("paths.php");
+  require_once ($smarty_path."Smarty.class.php");
+  require_once ("classes.inc.php");
+  require_once ("config.inc.php");  
 
   $smarty = new Smarty();     
   $dbSql = new Bweb();
        break;
        
        case 'pgsql':
-               $query  = "select (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
+               $query  = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
                $query .= "FROM Job ";
                $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
-               $query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' ";
+               $query .= "WHERE Job.JobStatus = 'f' ";
+               //$query .= "WHERE EndTime <= NOW() and EndTime > NOW() - 86400 * interval '1 second' AND ";
                $query .= "ORDER BY Job.EndTime DESC";
                $query .= "LIMIT 10";
        break;
   }
   $smarty->assign( 'failed_jobs', $failed_jobs );
   
+  // Get the last completed jobs (last 24 hours)
+  $query          = "";
+  $completed_jobs = array();
+  
+  // Interval calculation
+  $end_date   = mktime();
+  $start_date = $end_date - LAST_DAY;
+                       
+  $start_date = date( "Y-m-d H:m:s", $start_date );
+  $end_date   = date( "Y-m-d H:m:s", $end_date );
+  
+  switch( $dbSql->driver ) 
+  {
+       case 'mysql':
+               $query  = "SELECT SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) ) AS elapsed, Job.JobId, Job.Name AS job_name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name AS pool_name, Job.JobStatus ";
+               $query .= "FROM Job ";
+               $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
+               $query .= "WHERE Job.JobStatus = 'T' AND ";
+               $query .= "Job.EndTime BETWEEN '$start_date' AND '$end_date' ";
+               $query .= "ORDER BY Job.EndTime DESC ";  
+               
+       break;
+       
+       case 'pgsql':
+               $query  = "SELECT (Job.EndTime - Job.StartTime ) AS elapsed, Job.Name, Job.StartTime, Job.EndTime, Job.Level, Pool.Name, Job.JobStatus ";
+               $query .= "FROM Job ";
+               $query .= "LEFT JOIN Pool ON Job.PoolId=Pool.PoolId ";
+               $query .= "WHERE EndTime BETWEEN '$start_date' and '$end_date' ";
+               $query .= "ORDER BY Job.EndTime DESC";
+       break;
+  }
+  $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 ) ) {
+               array_push( $completed_jobs, $job);
+         }
+  }
+  $smarty->assign( 'completed_jobs', $completed_jobs );
+  
   $smarty->display('jobs.tpl');
 ?>
index f4835497babc78a2fc67bb56a20420418a9d60ee..32a06b98981a68c801ce749af13d6a9e8e7a8666 100644 (file)
@@ -2,8 +2,32 @@ body{
   background-color: #ffffff;
   padding: 3px;
   margin: 0px;
-  
   font-family: Arial,Verdana;
+  font-size: 10pt;
+}
+
+a:link, a:visited {
+  color: #736F6E;
+  font-size: 10pt;
+}
+
+a:hover { color: #736F6E }
+
+#nav
+{
+ margin: 10px;
+ /*border: 1px solid green;*/
+ font-size: 11pt;
+}
+
+#nav a:link{
+ font-size: 11pt;
+ font-weight: bold;
+}
+
+#nav a:visited{
+ font-size: 11pt;
+ font-weight: bold;
 }
 
 #header{
@@ -47,7 +71,7 @@ body{
 
 #main_left {
  position: absolute; 
- left:5px; 
+ left:10px; 
  width: 550px; 
  border:none; 
  margin-top: 1em; 
@@ -64,9 +88,9 @@ body{
 
 #main_center {
  position: absolute; 
- left:5px; 
+ left:10px; 
  width: 900px; 
- border: 1px solid red; 
+ /*border: 1px solid red; */
  margin-top: 1em;
 }
 
@@ -147,9 +171,6 @@ table {
  background-image: url('../style/images/bg5.png'); 
 }
 
-a:link { color: #0000c0 }
-a:visited { color: #0000c0 }
-a:hover { color: #6040ff }
 img {border: 0}
 
 td,input,select { 
index a2234532e00489b1376f701424176e91b0aa7cbb..c37f94aa49b90caa2b582e955af4ce1bf92b329e 100644 (file)
 <body>
 {popup_init src='./js/overlib.js'}
 {include file=header.tpl}
-<a href="index.php">Back to main page</a>
+
+<div id="nav">
+  <a href="index.php">Dashboard</a> > Jobs list
+</div>
 
 <div id="main_center">
+  <!-- Failed jobs -->  
   <div class="box">
        <p class="title">Last failed jobs (limited to 10)</p>
        <table>
@@ -34,7 +38,7 @@
          </tr>
          {foreach from=$failed_jobs item=job}
          <tr>
-               <td> <img width="20px" src="style/images/s_error.gif" alt=""/> </td>
+               <td> <img width="20" src="style/images/s_error.gif" alt=""/> </td>
                <td>{$job.JobId}</td>
                <td>{$job.job_name}</td>
                <td>{$job.StartTime}</td>
          {/foreach}
        </table>
   </div>
+  <!-- Completed jobs --> 
   <div class="box">
        <p class="title">Last completed jobs</p>
-       bkjlajkdjaf
+       <table>
+         <tr>
+               <th>Status</th>
+               <th>Job ID</th>
+               <th>BackupJob</th>
+               <th>Start Time</th>
+               <th>End Time</th>
+               <th>Elapsed time</th>
+               <th>Level</th>
+               <th>Pool</th>
+         </tr>
+         {foreach from=$completed_jobs item=job}
+         <tr>
+               <td> <img width="20px" src="style/images/s_ok.gif" alt=""/> </td>
+               <td>{$job.JobId}</td>
+               <td>{$job.job_name}</td>
+               <td>{$job.StartTime}</td>
+               <td>{$job.EndTime}</td>
+               <td>{$job.elapsed}</td>
+               <td align="center">{$job.Level}</td>
+               <td>{$job.pool_name}</td>
+         </tr>
+         {/foreach}
+       </table>        
   </div>
 </div>