From: Eric Bollengier Date: Thu, 27 Dec 2007 14:03:09 +0000 (+0000) Subject: ebl Add begin/end param to Bweb::Sched object X-Git-Tag: Release-3.0.0~2096 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4e2676dde8affacab9e7ea30bf670b124119498c;p=bacula%2Fbacula ebl Add begin/end param to Bweb::Sched object git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6145 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/lib/Bweb.pm b/gui/bweb/lib/Bweb.pm index a7e4429098..461921ae2a 100644 --- a/gui/bweb/lib/Bweb.pm +++ b/gui/bweb/lib/Bweb.pm @@ -1031,7 +1031,7 @@ use base q/Bweb::Gui/; my $b = $bweb->get_bconsole(); my $s = $b->send_cmd("show schedule"); - my $sched = new Bweb::Sched(); + my $sched = new Bweb::Sched(begin => '2007-01-01', end => '2007-01-02 12:00'); $sched->parse_scheds(split(/\r?\n/, $s)); @@ -1048,6 +1048,27 @@ $VAR1 = { }; =cut +sub new +{ + my ($class, @arg) = @_; + my $self = $class->SUPER::new(@arg); + + # we compare the current schedule date with begin and end + # in a float form ex: 20071212.1243 > 20070101 + if ($self->{begin} and $self->{end}) { + + $self->{begin} =~ s/(-|:)//g; + $self->{begin} =~ s/ /./; + $self->{end} =~ s/(-|:)//g; + $self->{end} =~ s/ /./; + + } else { + delete $self->{begin}; + delete $self->{end}; + } + return bless($self,$class); +} + # cleanup and add a schedule sub add_sched { @@ -1192,6 +1213,12 @@ sub get_events { foreach my $min (@{$s->{mins}}) # minute { + if ($self->{begin}) { + no integer; + my $d = sprintf('%d%0.2d%0.2d.%0.2d%0.2d', + $year,$m,$md,$h,$min); + next if ($d < $self->{begin} or $d > $self->{end}); + } push @ret, sprintf($format, $year,$m,$md,$h,$min); } } @@ -1696,6 +1723,10 @@ sub get_form voluseduration=> 1, volretention => 1, ); + my %opt_t = (when => 2, # option with time + begin => 1, # 1 hh:min are optionnal + end => 1, # 2 hh:min are required + ); foreach my $i (@what) { if (exists $opt_i{$i}) {# integer param @@ -1743,7 +1774,14 @@ sub get_form if ($value =~ /^\s*(\d+\s+\w+)$/) { $ret{$i} = $1; } - } + } elsif (exists $opt_t{$i}) { # 1: hh:min optionnal, 2: hh:min required + my $when = CGI::param($i) || ''; + if ($when =~ /(\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2}))/) { + if ($opt_t{$i} == 1 or defined $2) { + $ret{$i} = $1; + } + } + } } if ($what{slots}) { @@ -1762,13 +1800,6 @@ sub get_form } } - if ($what{when}) { - my $when = CGI::param('when') || ''; - if ($when =~ /(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/) { - $ret{when} = $1; - } - } - if ($what{lang}) { my $lang = CGI::param('lang') || 'en'; if ($lang =~ /^(\w\w)$/) { @@ -4545,7 +4576,7 @@ sub run_job_now sub display_next_job { my ($self) = @_; - my $arg = $self->get_form(qw/job/); + my $arg = $self->get_form(qw/job begin end/); if (!$arg->{job}) { return $self->error("Can't get job name"); } @@ -4563,7 +4594,7 @@ sub display_next_job } my $out = $b->send_cmd("show schedule=\"$jsched\""); - my $sched = new Bweb::Sched(); + my $sched = new Bweb::Sched(begin => $arg->{begin}, end => $arg->{end}); $sched->parse_scheds(split(/\r?\n/, $out)); my $ss = $sched->get_scheds($jsched); diff --git a/gui/bweb/technotes-2.3 b/gui/bweb/technotes-2.3 index afac31d529..f01ff769be 100644 --- a/gui/bweb/technotes-2.3 +++ b/gui/bweb/technotes-2.3 @@ -1,4 +1,5 @@ 27Dec07 +ebl Add begin/end param to Bweb::Sched object ebl Fix a couple of small bug in GBalloon module when we don't find any valid job