From b9b4407ef96b8d71d7218dca332bd5f2dd667aac Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Wed, 6 Sep 2006 22:13:04 +0000 Subject: [PATCH] ebl Can delete empty location 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 | 5 +++++ gui/bweb/cgi/bweb.pl | 9 +++------ gui/bweb/lib/Bconsole.pm | 31 +++++++------------------------ gui/bweb/lib/Bweb.pm | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 31 deletions(-) diff --git a/gui/bweb/ReleaseNotes b/gui/bweb/ReleaseNotes index 2a0d9c1e61..51c66fa8ed 100644 --- a/gui/bweb/ReleaseNotes +++ b/gui/bweb/ReleaseNotes @@ -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 diff --git a/gui/bweb/cgi/bweb.pl b/gui/bweb/cgi/bweb.pl index 9363a28721..1d832dd048 100755 --- a/gui/bweb/cgi/bweb.pl +++ b/gui/bweb/cgi/bweb.pl @@ -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 "
\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 "
\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 "
\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 "
\n"; } else { diff --git a/gui/bweb/lib/Bconsole.pm b/gui/bweb/lib/Bconsole.pm index fe6545196b..ea5495dd9e 100644 --- a/gui/bweb/lib/Bconsole.pm +++ b/gui/bweb/lib/Bconsole.pm @@ -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"; diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index aad116b595..8fd86361e9 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -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 "; -- 2.39.5