From ff6d5f22d15329d34854d6804c1a44a9de12d47b Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sat, 9 Sep 2006 10:39:39 +0000 Subject: [PATCH] ebl Eject media takes Location as Autochanger Name ebl Email is now sent when request to move media git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3444 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/ReleaseNotes | 6 ++++- gui/bweb/cgi/bweb.pl | 5 +++- gui/bweb/lib/Bweb.pm | 43 ++++++++++++++++++++++++-------- gui/bweb/tpl/change_location.tpl | 7 +++--- gui/bweb/tpl/location_add.tpl | 3 +++ 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/gui/bweb/ReleaseNotes b/gui/bweb/ReleaseNotes index 51c66fa8ed..8d070a70c2 100644 --- a/gui/bweb/ReleaseNotes +++ b/gui/bweb/ReleaseNotes @@ -1,4 +1,8 @@ - Release Notes for bweb 1.39.20 + Release Notes for bweb 1.39.23 + +2006/09/08: + - Eject media takes Location as Autochanger Name + - Email is now sent when request to move media 2006/09/06: - Can delete empty location diff --git a/gui/bweb/cgi/bweb.pl b/gui/bweb/cgi/bweb.pl index 1d832dd048..bee4e76cc3 100755 --- a/gui/bweb/cgi/bweb.pl +++ b/gui/bweb/cgi/bweb.pl @@ -208,9 +208,12 @@ if ($action eq 'begin') { # main display $bweb->help_extern_compute(); } elsif ($action eq 'extern') { - print "TODO : Eject ", join(",", CGI::param('media')); + $bweb->eject_media(); $bweb->move_media(); +} elsif ($action eq 'move_email') { + $bweb->move_email(); + } elsif ($action eq 'change_location') { $bweb->change_location(); diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index 8fd86361e9..7891371ad4 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -853,7 +853,7 @@ sub transfer if ($? == 0) { my $content = $self->get_slot($src); - print "content = $content
$src => $dst
"; + print "$content ($src) => $dst
"; $self->{slot}->[$src] = 'empty'; $self->set_slot($dst, $content); return 1; @@ -2395,7 +2395,9 @@ sub save_location my $nb = $self->dbh_do($query); - print "$nb media updated"; + print "$nb media updated, you may have to update your autochanger."; + + $self->display_media(); } sub change_location @@ -2599,17 +2601,12 @@ WHERE JobStatus IN ('C','R','B','e','D','F','S','m','M','s','j','c','d','t','p') sub eject_media { my ($self) = @_; - my $arg = $self->get_form('jmedias', 'slots', 'ach'); + my $arg = $self->get_form('jmedias'); unless ($arg->{jmedias}) { return $self->error("Can't get media selection"); } - my $a = $self->ach_get($arg->{ach}); - unless ($a) { - return 0; - } - my $query = " SELECT Media.VolumeName AS volumename, Storage.Name AS storage, @@ -2623,9 +2620,18 @@ WHERE Media.VolumeName IN ($arg->{jmedias}) my $all = $self->dbh_selectall_hashref($query, 'volumename'); - $a->status(); - foreach my $vol (values %$all) { + my $a = $self->ach_get($vol->{location}); + unless ($a) { + $self->error("Can't find autochanger $vol->{location}"); + next; + } + + unless ($a->{have_status}) { + $a->status(); + $a->{have_status} = 1; + } + print "eject $vol->{volumename} from $vol->{storage} : "; if ($a->send_to_io($vol->{slot})) { print "ok
"; @@ -2635,6 +2641,23 @@ WHERE Media.VolumeName IN ($arg->{jmedias}) } } +sub move_email +{ + my ($self) = @_; + + my ($to, $subject, $content) = (CGI::param('email'), + CGI::param('subject'), + CGI::param('content')); + $to =~ s/[^\w\d\.\@<>,]//; + $subject =~ s/[^\w\d\.\[\]]/ /; + + open(MAIL, "|mail -s '$subject' '$to'") ; + print MAIL $content; + close(MAIL); + + print "Mail sent"; +} + sub restore { my ($self) = @_; diff --git a/gui/bweb/tpl/change_location.tpl b/gui/bweb/tpl/change_location.tpl index 273e414bf8..d7f96519ce 100644 --- a/gui/bweb/tpl/change_location.tpl +++ b/gui/bweb/tpl/change_location.tpl @@ -24,14 +24,13 @@ Media : - () -When it's finish, could you update media location ? (you can use -this link). +When it's finish, could you update media location ? +(you can use this link : ). Thanks - +
update nowUpdate now diff --git a/gui/bweb/tpl/location_add.tpl b/gui/bweb/tpl/location_add.tpl index 50a868189e..8dd702600e 100644 --- a/gui/bweb/tpl/location_add.tpl +++ b/gui/bweb/tpl/location_add.tpl @@ -22,4 +22,7 @@ + +Tips: It's a good idea to have a location per autochanger. + -- 2.39.5