]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: Improved job status filter in jobs page and template
authorDavide Franco <bacula-dev@dflc.ch>
Fri, 1 Jul 2011 16:10:30 +0000 (18:10 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:49:18 +0000 (14:49 +0200)
gui/bacula-web/jobs.php
gui/bacula-web/templates/jobs.tpl

index b3741aa10da88dbd054ef53d73906f219d0c2ef5..ed1268ad2ce52082c66c3ea092e0e62447cea480 100644 (file)
 
   $dbSql = new Bweb();
   // Jobs list
-  $query          = "";
-  $last_jobs = array();
+  $query           = "";
+  $last_jobs   = array();
   
   // Job Status list
-  $job_status = array( 'Any', 'Waiting', 'Running', 'Completed', 'Failed', 'Canceled' );
+  define( 'STATUS_ALL',                  0 );
+  define( 'STATUS_RUNNING',   1 );
+  define( 'STATUS_WAITING',   2 );
+  define( 'STATUS_COMPLETED', 3 );
+  define( 'STATUS_FAILED',       4 );
+  define( 'STATUS_CANCELED',  5 );
+  
+  $job_status = array( STATUS_ALL       => 'All', 
+                                          STATUS_RUNNING   => 'Running', 
+                                          STATUS_WAITING   => 'Waiting',
+                                          STATUS_COMPLETED => 'Completed',
+                                          STATUS_FAILED        => 'Failed',
+                                          STATUS_CANCELED      => 'Canceled' );
+                                          
   $dbSql->tpl->assign( 'job_status', $job_status );
   
   // Jobs per page
   
   // Filter by status
   if( isset( $_POST['status'] ) ) {
-       switch( strtolower( $_POST['status'] ) )
+       switch( $_POST['status'] ) 
        {
-               case 'running':
+               case STATUS_RUNNING:
                        $query .= "WHERE Job.JobStatus = 'R' ";
                break;
-               case 'waiting':
+               case STATUS_WAITING:
                        $query .= "WHERE Job.JobStatus IN ('F','S','M','m','s','j','c','d','t','p','C') ";
                break;
-               case 'completed':
+               case STATUS_COMPLETED:
                        $query .= "WHERE Job.JobStatus IN ('T', 'E') ";
                break;
-               case 'failed':
+               case STATUS_FAILED:
                        $query .= "WHERE Job.JobStatus = 'f' ";
                break;
-               case 'canceled':
+               case STATUS_CANCELED:
                        $query .= "WHERE Job.JobStatus = 'A' ";
                break;
        }
+    $dbSql->tpl->assign('job_status_filter', $_POST['status'] );
   }
   
   // order by
index 4fdb68dafecb3c0102c9764dbb604de089c472f6..21c9bb9eda15d78af587fcd44e7de48370b4234d 100644 (file)
@@ -24,7 +24,7 @@
            <td class="info" width="200">
                        {$total_jobs} jobs found
                </td>
-               <td class="info" colspan="5" style="text-align: right;">
+               <td class="info" colspan="5">
                        Jobs / Page
                        <select name="jobs_per_page">
                          {foreach from=$jobs_per_page item=nb_jobs}
                          {/foreach}
                        </select>
                </td>
-               <td class="info" width="200">
-                       Job Status
-                       <select name="status">
-                               {foreach from=$job_status item=status_label}
-                                 <option value="{$status_label}" {if $smarty.post.status == $status_label}Selected{/if} >{$status_label}
-                               {/foreach}
-                       </select>
+               <td class="info" width="160">
+                       Job status
+                       {html_options name=status values=$job_status options=$job_status selected=$job_status_filter onChange="submit();"}
                </td>
+               <!--
                <td class="info" width="120">
                        <input type="submit" value="Update" />
                </td>
+               -->
          </tr>
          <tr>
                <td colspan="8">&nbsp;</td>