]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl Can delete empty location
authorEric Bollengier <eric@eb.homelinux.org>
Wed, 6 Sep 2006 22:13:04 +0000 (22:13 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Wed, 6 Sep 2006 22:13:04 +0000 (22:13 +0000)
ebl  Drop Bconsole::send_cmd_with_drive and use drive= instead
ebl  Use JavaScript to display Human size and time

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3421 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/ReleaseNotes
gui/bweb/cgi/bweb.pl
gui/bweb/lib/Bconsole.pm
gui/bweb/lib/Bweb.pm

index 2a0d9c1e61ae25d7e2d80238b4f69b00644de6c6..51c66fa8edca097e0f6ef0345813176799bdecc7 100644 (file)
@@ -1,5 +1,10 @@
           Release Notes for bweb 1.39.20
 
+2006/09/06:
+ - Can delete empty location
+ - Drop Bconsole::send_cmd_with_drive and use drive= instead
+ - Use JavaScript to display Human size and time
+
 2006/08/31:
  - Add FileSet view action
  - Add view fileset to job_zoom
index 9363a287213db3f2b9a2b8b52fab43ceca19757c..1d832dd048a1cc2225c84ac761623aad6f864e5b 100755 (executable)
@@ -104,7 +104,7 @@ if ($action eq 'begin') {           # main display
     $bweb->location_add();
 
 } elsif ($action eq 'location_del') {
-    $bweb->del_location();
+    $bweb->location_del();
 
 } elsif ($action eq 'media') {
     $bweb->display_media();
@@ -173,8 +173,7 @@ if ($action eq 'begin') {           # main display
        my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
        # TODO : use template here
        print "<pre>\n";
-       $b->send_cmd_with_drive("mount slot=$arg->{slot} storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
-                               $arg->{drive});
+       $b->send_cmd("mount slot=$arg->{slot} drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
        print "</pre>\n";
     } else {
        $bweb->error("Can't get drive, slot or ach");
@@ -190,9 +189,7 @@ if ($action eq 'begin') {           # main display
        my $b = new Bconsole(pref => $conf, timeout => 300, log_stdout => 1) ;
        # TODO : use template here
        print "<pre>\n";
-       $b->send_cmd_with_drive("umount storage=\"" . $a->get_drive_name($arg->{drive}) . '"',
-                               $arg->{drive});
-
+       $b->send_cmd("umount drive=$arg->{drive} storage=\"" . $a->get_drive_name($arg->{drive}) . '"');
        print "</pre>\n";
 
     } else {
index fe6545196bdcfdc6347af0c57a59791e650eb7b9..ea5495dd9e6aa0192251cc1c76a9c28b75fd0373 100644 (file)
@@ -99,9 +99,9 @@ sub log_stdout
     my ($self, $how) = @_;
 
     if ($self->{bconsole}) {
-       $self->{bconsole}->log_stdout($how);
+       $self->{bconsole}->log_stdout($how);
     }
-    
+
     $self->{log_stdout} = $how;
 }
 
@@ -189,24 +189,6 @@ sub send_cmd_yes
     return $self->before();
 }
 
-sub send_cmd_with_drive
-{
-    my ($self, $cmd, $drive) = @_;
-    $drive = $drive || '0';
-
-    unless ($self->connect()) {
-       return '';
-    }
-    $self->send("$cmd\n");
-    $self->expect_it('-re', qr/:/); # wait for drive input
-
-    $self->send("$drive\n");
-    $self->expect_it('-re', '[0-9]');
-    $self->{bconsole}->clear_accum();
-    $self->expect_it('-re',qr/^[*]/);
-    return $self->before();
-}
-
 sub label_barcodes
 {
     my ($self, %arg) = @_;
@@ -229,7 +211,7 @@ sub label_barcodes
     }
 
     $self->send("$cmd\n");
-    $self->expect_it('-re', ':'); # wait for drive input
+    $self->expect_it('-re', '\[0\]\s*:');
     $self->send("$arg{drive}\n");
     $self->expect_it('-re', '[?].+\)\s*:');
     my $res = $self->before();
@@ -284,8 +266,9 @@ sub director_get_sched
 sub update_slots
 {
     my ($self, $storage, $drive) = @_;
-    
-    return $self->send_cmd_with_drive("update slots storage=$storage", $drive);
+    $drive = $drive || 0;
+
+    return $self->send_cmd("update slots storage=$storage drive=$drive");
 }
 
 sub get_fileset
@@ -435,7 +418,7 @@ print "fileset : ", join(',', $c->list_fileset()), "\n";
 print "job : ",     join(',', $c->list_job()), "\n";
 print "storage : ", join(',', $c->list_storage()), "\n";
 #print "prune : " . $c->prune_volume('000001'), "\n";
-#print "update : " . $c->send_cmd_with_drive('update slots storage=SDLT-1-2'), "\n";
+#print "update : " . $c->send_cmd('update slots storage=SDLT-1-2, drive=0'), "\n";
 #print "label : ", join(',', $c->label_barcodes(storage => 'SDLT-1-2',
 #                                             slots => 6,
 #                                             drive => 0)), "\n";
index aad116b59589aa8858308000861f1ec7f373cef1..8fd86361e9ae2531211dee8825d81f21ed616d1e 100644 (file)
@@ -2138,6 +2138,37 @@ WHERE Location.Location = $arg->{qlocation}
     $self->display_location();
 }
 
+sub location_del
+{
+    my ($self) = @_ ;
+    my $arg = $self->get_form(qw/qlocation/) ;
+
+    unless ($arg->{qlocation}) {
+       return $self->error("Can't get location");
+    }
+
+    my $query = "
+SELECT count(Media.MediaId) AS nb 
+  FROM Media INNER JOIN Location USING (LocationID)
+WHERE Location = $arg->{qlocation}
+";
+
+    my $res = $self->dbh_selectrow_hashref($query);
+
+    if ($res->{nb}) {
+       return $self->error("Sorry, the location must be empty");
+    }
+
+    $query = "
+DELETE FROM Location WHERE Location = $arg->{qlocation} LIMIT 1
+";
+
+    $self->dbh_do($query);
+
+    $self->display_location();
+}
+
+
 sub location_add
 {
     my ($self) = @_ ;
@@ -2474,7 +2505,7 @@ FROM
                ) AS media_avg_size ON (Media.MediaType = media_avg_size.MediaType)
     GROUP BY Media.MediaType, Media.PoolId
   ) AS subq 
-INNER JOIN Pool ON (Pool.PoolId = subq.PoolId) 
+LEFT JOIN Pool ON (Pool.PoolId = subq.PoolId) 
 GROUP BY subq.PoolId
 ";