]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl add media filter to display_media
authorEric Bollengier <eric@eb.homelinux.org>
Tue, 5 Dec 2006 18:02:31 +0000 (18:02 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Tue, 5 Dec 2006 18:02:31 +0000 (18:02 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3756 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/cgi/bweb.pl
gui/bweb/lang/fr/tpl/display_form_media.tpl [new file with mode: 0644]
gui/bweb/lib/Bweb.pm
gui/bweb/tpl/display_form_media.tpl [new file with mode: 0644]
gui/bweb/tpl/display_media.tpl

index d0173dc32ccd849219bd49875d0f62bf8d1bb051..8e35eb40a3c04cbdd1d28243cfd13b39b5baf2e3 100755 (executable)
@@ -99,7 +99,15 @@ if ($action eq 'begin') {            # main display
     $bweb->location_del();
 
 } elsif ($action eq 'media') {
+    print "<div><table border='0'><tr><td valign='top'>\n";
+    my $fields = $bweb->get_form(qw/db_locations db_pools
+                                   qlocations qpools volstatus qre_media
+                                   limit  qmediatypes db_mediatypes/);
+    $bweb->display($fields, "display_form_media.tpl");
+
+    print "</td><td valign='top'>";
     $bweb->display_media();
+    print "</td></tr></table></div>";
 
 } elsif ($action eq 'medias') {
     $bweb->display_medias();
diff --git a/gui/bweb/lang/fr/tpl/display_form_media.tpl b/gui/bweb/lang/fr/tpl/display_form_media.tpl
new file mode 100644 (file)
index 0000000..33d519e
--- /dev/null
@@ -0,0 +1,91 @@
+<div class="otherboxtitle">
+  Filtre &nbsp;
+</div>
+<div class="otherbox">
+<form name='form1' action='?' method='GET'>
+<table border='0'>
+<tr>
+  <td valign='top'>
+    <h2>Type de Média</h2>
+    <select name='mediatype' class='formulaire'>
+      <option id='mediatype_all' value=''></option>
+<TMPL_LOOP NAME=db_mediatypes>
+      <option id='mediatype_<TMPL_VAR mediatype>'><TMPL_VAR mediatype></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+<tr>
+  <td valign='top'>
+    <h2>Localisation</h2>
+    <select name='location' class='formulaire'>
+      <option id='location_all>' value=''></option>
+<TMPL_LOOP NAME=db_locations>
+      <option id='location_<TMPL_VAR location>'><TMPL_VAR location></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+<tr>
+ <td valign='top'>
+    <h2>Statut</h2>
+    <select name='volstatus' class='formulaire'>
+      <option id='volstatus_All' value=''></option>
+      <option id='volstatus_Append' value='Append'>Append</option>
+      <option id='volstatus_Full'   value='Full'>Full</option>
+      <option id='volstatus_Error'  value='Error'>Error</option>
+      <option id='volstatus_Used'   value='Used'>Used</option>
+      <option id='volstatus_Purged' value='Purged'>Purged</option>
+    </select>     
+  </td>
+</tr>
+<tr>
+ <td valign='top'>
+    <h2>Pool</h2>
+    <select name='pool' class='formulaire'>
+      <option id='pool_all>' value=''></option>
+<TMPL_LOOP NAME=db_pools>
+      <option id='pool_<TMPL_VAR name>'><TMPL_VAR name></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+ <tr>
+  <td valign='bottom'> 
+    <h2>Label</h2>
+    <input type='text' name='re_media' 
+      <TMPL_IF qre_media>value=<TMPL_VAR qre_media></TMPL_IF>
+       class='formulaire' size='8'>
+  </td>
+</tr>
+ <tr>
+  <td valign='bottom'> 
+    <h2>Nombre d'éléments</h2>
+    <input type='text' name='limit' value='<TMPL_VAR limit>' 
+       class='formulaire' size='4'>
+  </td>
+</tr>
+
+</table>
+  <input type="image" name='action' value='media' src='/bweb/update.png'>
+
+</form>
+</div>
+<script type="text/javascript" language="JavaScript">
+  <TMPL_IF volstatus>
+     document.getElementById('volstatus_<TMPL_VAR volstatus>').selected=true;
+  </TMPL_IF>
+
+  <TMPL_LOOP qmediatypes>
+     document.getElementById('mediatype_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+
+  <TMPL_LOOP qpools>
+     document.getElementById('pool_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+  <TMPL_LOOP qlocations>
+     document.getElementById('location_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+
+</script>
+
index 0d7feaa40b108befc4cbeb3b07390932e98768bd..9f83c7b657e8e6652c44515fe857d2eef24d8f9d 100644 (file)
@@ -1389,7 +1389,7 @@ sub get_form
                $ret{$i} = $1;
            }
        } elsif ($i =~ /^j(\w+)s$/) { # quote join args
-           my @value = CGI::param($1) ;
+           my @value = grep { ! /^\s*$/ } CGI::param($1) ;
            if (@value) {
                $ret{$i} = $self->dbh_join(@value) ;
            }
@@ -1402,7 +1402,7 @@ sub get_form
 
        } elsif ($i =~ /^q(\w+)s$/) { #[ 'arg1', 'arg2']
            $ret{$i} = [ map { { name => $self->dbh_quote($_) } } 
-                                 CGI::param($1) ];
+                                          grep { ! /^\s*$/ } CGI::param($1) ];
        } elsif (exists $opt_p{$i}) {
            my $value = CGI::param($i) || '';
            if ($value =~ /^([\w\d\.\/\s:\@\-]+)$/) {
@@ -1757,7 +1757,7 @@ sub get_param
     my $limit = '';
 
     if ($elt{clients}) {
-       my @clients = CGI::param('client');
+       my @clients = grep { ! /^\s*$/ } CGI::param('client');
        if (@clients) {
            $ret{clients} = \@clients;
            my $str = $self->dbh_join(@clients);
@@ -1766,7 +1766,7 @@ sub get_param
     }
 
     if ($elt{filesets}) {
-       my @filesets = CGI::param('fileset');
+       my @filesets = grep { ! /^\s*$/ } CGI::param('fileset');
        if (@filesets) {
            $ret{filesets} = \@filesets;
            my $str = $self->dbh_join(@filesets);
@@ -1775,7 +1775,7 @@ sub get_param
     }
 
     if ($elt{mediatypes}) {
-       my @medias = CGI::param('mediatype');
+       my @medias = grep { ! /^\s*$/ } CGI::param('mediatype');
        if (@medias) {
            $ret{mediatypes} = \@medias;
            my $str = $self->dbh_join(@medias);
@@ -1819,8 +1819,16 @@ sub get_param
        }
     }
 
+    if ($elt{volstatus}) {
+       my $status = CGI::param('volstatus') || '';
+       if ($status =~ /^(\w)$/) {
+           $ret{status} = $1;
+           $limit .= "AND Media.VolStatus = '$1' ";            
+       }
+    }
+
     if ($elt{locations}) {
-       my @location = CGI::param('location') ;
+       my @location = grep { ! /^\s*$/ } CGI::param('location') ;
        if (@location) {
            $ret{locations} = \@location;           
            my $str = $self->dbh_join(@location);
@@ -1829,7 +1837,7 @@ sub get_param
     }
 
     if ($elt{pools}) {
-       my @pool = CGI::param('pool') ;
+       my @pool = grep { ! /^\s*$/ } CGI::param('pool') ;
        if (@pool) {
            $ret{pools} = \@pool; 
            my $str = $self->dbh_join(@pool);
@@ -1978,6 +1986,7 @@ sub display_media
 
     my ($where, %elt) = $self->get_param('pools',
                                         'mediatypes',
+                                        'volstatus',
                                         'locations');
 
     my $arg = $self->get_form('jmedias', 'qre_media');
diff --git a/gui/bweb/tpl/display_form_media.tpl b/gui/bweb/tpl/display_form_media.tpl
new file mode 100644 (file)
index 0000000..4cea050
--- /dev/null
@@ -0,0 +1,91 @@
+<div class="otherboxtitle">
+  Filter &nbsp;
+</div>
+<div class="otherbox">
+<form name='form1' action='?' method='GET'>
+<table border='0'>
+<tr>
+  <td valign='top'>
+    <h2>Media Type</h2>
+    <select name='mediatype' class='formulaire'>
+      <option id='mediatype_all' value=''></option>
+<TMPL_LOOP NAME=db_mediatypes>
+      <option id='mediatype_<TMPL_VAR mediatype>'><TMPL_VAR mediatype></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+<tr>
+  <td valign='top'>
+    <h2>Location</h2>
+    <select name='location' class='formulaire'>
+      <option id='location_all>' value=''></option>
+<TMPL_LOOP NAME=db_locations>
+      <option id='location_<TMPL_VAR location>'><TMPL_VAR location></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+<tr>
+ <td valign='top'>
+    <h2>Status</h2>
+    <select name='volstatus' class='formulaire'>
+      <option id='volstatus_All' value=''></option>
+      <option id='volstatus_Append' value='Append'>Append</option>
+      <option id='volstatus_Full'   value='Full'>Full</option>
+      <option id='volstatus_Error'  value='Error'>Error</option>
+      <option id='volstatus_Used'   value='Used'>Used</option>
+      <option id='volstatus_Purged' value='Purged'>Purged</option>
+    </select>     
+  </td>
+</tr>
+<tr>
+ <td valign='top'>
+    <h2>Pool</h2>
+    <select name='pool' class='formulaire'>
+      <option id='pool_all>' value=''></option>
+<TMPL_LOOP NAME=db_pools>
+      <option id='pool_<TMPL_VAR name>'><TMPL_VAR name></option>
+</TMPL_LOOP>
+    </select>     
+  </td>
+</tr>
+ <tr>
+  <td valign='bottom'> 
+    <h2>Name</h2>
+    <input type='text' name='re_media' 
+      <TMPL_IF qre_media>value=<TMPL_VAR qre_media></TMPL_IF>
+       class='formulaire' size='8'>
+  </td>
+</tr>
+ <tr>
+  <td valign='bottom'> 
+    <h2>Number of items</h2>
+    <input type='text' name='limit' value='<TMPL_VAR limit>' 
+       class='formulaire' size='4'>
+  </td>
+</tr>
+
+</table>
+  <input type="image" name='action' value='media' src='/bweb/update.png'>
+
+</form>
+</div>
+<script type="text/javascript" language="JavaScript">
+  <TMPL_IF volstatus>
+     document.getElementById('volstatus_<TMPL_VAR volstatus>').selected=true;
+  </TMPL_IF>
+
+  <TMPL_LOOP qmediatypes>
+     document.getElementById('mediatype_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+
+  <TMPL_LOOP qpools>
+     document.getElementById('pool_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+  <TMPL_LOOP qlocations>
+     document.getElementById('location_' + <TMPL_VAR name>).selected = true;
+  </TMPL_LOOP>
+
+</script>
+
index 0258ed69f78f925cd7afc1bdc28cf42c40de2b87..2ebbc35e6d2122b3614b103093dd7aa499cf56c4 100644 (file)
@@ -1,4 +1,3 @@
-<br/>
  <div class='titlediv'>
   <h1 class='newstitle'> 
    Media