]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New jobs page
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 29 Nov 2010 18:39:47 +0000 (19:39 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:42 +0000 (14:39 +0200)
 - New jobs page including last failed and completed jobs (jobs.php and jobs.tpl)
 - Fixed html and css typo

gui/bacula-web/index.php
gui/bacula-web/jobs.php [new file with mode: 0644]
gui/bacula-web/style/default.css
gui/bacula-web/templates/index.tpl
gui/bacula-web/templates/jobs.tpl [new file with mode: 0644]
gui/bacula-web/templates/last_run_report.tpl

index f2a5cc171c588dc89290c0e8d898837260a7eb12..4be456755987c627aa86da5e57d9b4ef03b0964f 100644 (file)
@@ -140,6 +140,7 @@ $smarty->assign( 'elapsed_jobs', $dbSql->Get_ElapsedTime_Job() );
 
 // last_run_report.tpl
 if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) {
+/*
         // Total Elapsed Time. Only for single Job.
         if ( $dbSql->driver == "mysql" )
           $ret = $dbSql->db_link->query("select UNIX_TIMESTAMP(EndTime)-UNIX_TIMESTAMP(StartTime) as elapsed from Job where EndTime <= NOW() and UNIX_TIMESTAMP(EndTime) > UNIX_TIMESTAMP(NOW())-84600")
@@ -157,10 +158,11 @@ if ( $mode == "Lite" && $_GET['Full_popup'] == "yes" ) {
                 $TotalElapsed = gmstrftime("%H:%M:%S", $TotalElapsed);
         $smarty->assign('TotalElapsed',$TotalElapsed);
         $ret->free();
-               
+*/             
                
 }
 else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){
+/*
         $tmp1 = array();
         if ( $dbSql->driver == "mysql")
                 $query = "select SEC_TO_TIME( UNIX_TIMESTAMP(Job.EndTime)-UNIX_TIMESTAMP(Job.StartTime) )
@@ -182,9 +184,8 @@ else if ($mode == "Full" || $_GET['Full_popup'] == "yes" ){
         }
         
         $smarty->assign('clients',$tmp1);
-}  
-
-
+*/
+}
 if ($_GET['Full_popup'] == "yes" || $_GET['pop_graph1'] == "yes" || $_GET['pop_graph2'] == "yes")
         $smarty->display('full_popup.tpl');
 else
diff --git a/gui/bacula-web/jobs.php b/gui/bacula-web/jobs.php
new file mode 100644 (file)
index 0000000..4ac5305
--- /dev/null
@@ -0,0 +1,75 @@
+<?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";
+
+  $smarty = new Smarty();     
+  $dbSql = new Bweb();
+
+  require("lang.php");
+
+  // Smarty configuration
+  $smarty->compile_check = true;
+  $smarty->debugging = false;
+  $smarty->force_compile = true;
+
+  $smarty->template_dir = "./templates";
+  $smarty->compile_dir = "./templates_c";
+  $smarty->config_dir     = "./configs";
+  
+  // Get the last 10 failed jobs
+  $query          = "";
+  $failed_jobs = array();
+  
+  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 = 'f' ";
+               //$query .= "WHERE Job.EndTime BETWEEN <= NOW() and UNIX_TIMESTAMP(EndTime) >UNIX_TIMESTAMP(NOW())-86400 ";
+               $query .= "ORDER BY Job.EndTime DESC ";  
+               $query .= "LIMIT 10";
+       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 <= NOW() and EndTime > NOW() - 86400 * interval '1 second' ";
+               $query .= "ORDER BY Job.EndTime DESC";
+               $query .= "LIMIT 10";
+       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( $failed_jobs, $job);
+         }
+  }
+  $smarty->assign( 'failed_jobs', $failed_jobs );
+  
+  $smarty->display('jobs.tpl');
+?>
index 0a39e19472794727cd737057ec249c4c12da1ad3..f4835497babc78a2fc67bb56a20420418a9d60ee 100644 (file)
@@ -62,6 +62,14 @@ body{
  margin-top: 1em;
 }
 
+#main_center {
+ position: absolute; 
+ left:5px; 
+ width: 900px; 
+ border: 1px solid red; 
+ margin-top: 1em;
+}
+
 .box {
  border: 1px solid black;
  width: 100%;
@@ -86,7 +94,7 @@ body{
  padding-bottom: 5px;
 }
 
-.box img {
+.box img.report {
  width: 410px;
  margin: 0px;
 }
@@ -96,6 +104,12 @@ body{
  width: 100%;
  margin: 0px;
 }
+
+.box table th {
+ font-size: 10pt;
+ background-color: #CACACA;
+}
+
 .box table tr td
 {
  padding: 2px;
index 38bcd304e6921f94a889473349b6b4860c32187d..32b65acca857f8eef6574d73f7d317409ef2dc95 100644 (file)
@@ -56,9 +56,9 @@
   <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="" />
+         <img class="report" 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="" />
+         <img class="report" src="stats.php?server={$server}&amp;tipo_dato=3&amp;title={$server}&amp;modo_graph=bars" alt="" />
        {/if}
   </div> <!-- end div box -->
 
diff --git a/gui/bacula-web/templates/jobs.tpl b/gui/bacula-web/templates/jobs.tpl
new file mode 100644 (file)
index 0000000..a223453
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
+  "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) {
+               window.open(URL,"window1","width="+wid+",height="+hei+",scrollbars=yes,menubar=no,location=no,resizable=no")
+       }
+</script>
+{/literal}
+
+</head>
+<body>
+{popup_init src='./js/overlib.js'}
+{include file=header.tpl}
+<a href="index.php">Back to main page</a>
+
+<div id="main_center">
+  <div class="box">
+       <p class="title">Last failed jobs (limited to 10)</p>
+       <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=$failed_jobs item=job}
+         <tr>
+               <td> <img width="20px" src="style/images/s_error.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 class="box">
+       <p class="title">Last completed jobs</p>
+       bkjlajkdjaf
+  </div>
+</div>
+
+{include file="footer.tpl"}
\ No newline at end of file
index 23fa288e5704bf08185ecff02d09213e58fd2159..71338b8dc19ba3ba482146ba672fcaf9e147b634 100644 (file)
@@ -18,7 +18,8 @@
  </tr> 
  <tr>
        <td colspan=2 align=center>
-               <a href="javascript:OpenWin('index.php?Full_popup=yes','490','350')">{t}Show details{/t}</a>
+               <!-- <a href="javascript:OpenWin('index.php?Full_popup=yes','490','350')">{t}Show details{/t}</a> -->
+               <a href="jobs.php" title="Show last jobs details">Show last jobs status</a>
        </td>
  </tr>
 </table>