From 8812db11cc471e69e9a9b2d03a94a3481dce017c Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Sun, 23 Dec 2007 08:44:00 +0000 Subject: [PATCH] ebl Can use nb files instead of file size git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6106 91ce42f0-d328-0410-95d8-f526ca767f89 --- gui/bweb/cgi/bgraph.pl | 40 +++++++++++++++++++++++++++++----------- gui/bweb/lib/GBalloon.pm | 9 +++++++++ 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/gui/bweb/cgi/bgraph.pl b/gui/bweb/cgi/bgraph.pl index bbf61e33fc..535d92733b 100755 --- a/gui/bweb/cgi/bgraph.pl +++ b/gui/bweb/cgi/bgraph.pl @@ -121,10 +121,37 @@ if ($gtype eq 'balloon') { use Digest::MD5 qw(md5_hex); use GBalloon; + my $b = new GBalloon(width=>$arg->{width}, + height =>$arg->{height}); + + my $order; + my %legend = (x_title => 'Time', + x_func => sub { + POSIX::strftime('%H:%M', gmtime($_[0])) + } + ) ; + if ($graph eq 'job_time_size') { + $order = 'JobFiles,JobBytes'; + + $legend{y_title} = 'Nb files'; + $legend{y_func} = sub { int(shift)}; + $legend{z_title} = 'Size'; + $legend{z_func} = \&Bweb::human_size; + } else { + $order = 'JobBytes,JobFiles'; + + $legend{y_title} = 'Size'; + $legend{y_func} = \&Bweb::human_size; + $legend{z_title} = 'Nb files'; + $legend{z_func} = sub { int(shift)}; + } + + $b->set_legend_axis(%legend); + my $all = $dbh->selectall_arrayref(" SELECT $bweb->{sql}->{SEC_TO_INT}( $bweb->{sql}->{UNIX_TIMESTAMP}(EndTime) - $bweb->{sql}->{UNIX_TIMESTAMP}(StartTime)) - AS duration, JobBytes, JobFiles, JobId, $jobt.Name + AS duration, $order, JobId, $jobt.Name FROM $jobt, Client $filter $groupf WHERE $jobt.ClientId = Client.ClientId @@ -137,19 +164,10 @@ WHERE $jobt.ClientId = Client.ClientId $limitq "); - my $b = new GBalloon(width=>$arg->{width}, - height =>$arg->{height}); - $b->set_legend_axis(x_title => 'Time', - x_func => sub { - POSIX::strftime('%H:%M', gmtime($_[0])) - }, - y_title => 'Size', y_func => \&Bweb::human_size, - z_title => 'Nb files'); - foreach my $a (@$all) { $b->add_point($a->[0], $a->[1], $a->[2], "?action=job_zoom;jobid=$a->[3]", - "$a->[4] $a->[2] files"); + "$a->[4] $legend{z_title} " . $legend{z_func}($a->[2])); } $b->init_gd(); diff --git a/gui/bweb/lib/GBalloon.pm b/gui/bweb/lib/GBalloon.pm index cf6a4a0208..4ff45f2b1b 100644 --- a/gui/bweb/lib/GBalloon.pm +++ b/gui/bweb/lib/GBalloon.pm @@ -179,6 +179,15 @@ sub finalize sub set_legend_axis { my ($self, %arg) = @_; + + unless ($arg{x_func}) { + $arg{x_func} = sub { join(" ", @_) } + } + + unless ($arg{y_func}) { + $arg{y_func} = sub { join(" ", @_) } + } + $self->{axis} = \%arg; } -- 2.39.5