--- db2gantt.cgi 2002/09/13 11:59:08 1.5 +++ db2gantt.cgi 2002/12/02 14:35:17 1.25 @@ -5,64 +5,98 @@ use Data::Dumper; use Date::Parse; use CGI qw/:standard/; +use CGI::Carp qw(fatalsToBrowser); use POSIX qw(strftime); -my $debug = 1; -my $width = 600; -my $use_js = 1; +my $debug = 0; + +my $width = 600; # width of bar +my $height = 15; # height of bar +my $use_js = 1; # use JavaScript pop-up # status colors my %cols = ( 'In Progress' => '0,255,0', - 'In Progress/Failure' => '255,64,255', - 'In Progress/Errors' => '255,64,0', + 'In Progress/Failures' => '192,64,192', + 'In Progress/Errors' => '255,128,128', 'Queuing' => '255,255,0', + 'Queuing/Errors' => '255,192,64', 'Aborted' => '255,0,0', 'Failed' => '255,0,0', 'Completed' => '64,255,64', 'Completed/Errors' => '255,128,0', 'Completed/Failure' => '128,0,128', 'Mount Request' => '128,128,255', + 'Mount/Errors' => '255,64,128', + 'Mount/Failures' => '255,128,192', ); -#--- no user servicable parts below this line +my $int_t = (12 * 60 * 60); # interval to display on one screen +my $min_l = 3; # min length of bar segment (in pixels) -# time range +#--- no user servicable parts below this line -my $day_t = (24 * 60 * 60); # 24h interval +my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; +my $q=new CGI; -my ($from_t,$to_t) = (time()-$day_t,time()); +my ($from_t,$to_t) = (time()-$int_t,time()); -$to_t = param('to_t') if (param('to_t')); $from_t = param('from_t') if (param('from_t')); +$to_t = param('to_t') if (param('to_t')); -my $to=strftime("%Y-%m-%d %H:%M:%S",localtime ($to_t)); -my $from=strftime("%Y-%m-%d %H:%M:%S",localtime ($from_t)); +if (param('f-1')) { + $from_t = $from_t - param('int_f-1') || $int_t; +} elsif (param('f+1')) { + $from_t = $from_t + param('int_f+1') || $int_t; +} elsif (param('t-1')) { + $to_t = $from_t - param('int_t-1') || $int_t; +} elsif (param('t+1')) { + $to_t = $from_t + $int_t; +} + +# time range +$int_t = m_round($int_t); + +# round to nearest minute +sub m_round { + my $t = shift @_; + return ($t - ($t % 60)); +} + +$to_t = m_round($to_t); +$from_t = m_round($from_t); + +my $to=strftime("%Y-%m-%d %H:%M",localtime ($to_t)); +my $from=strftime("%Y-%m-%d %H:%M",localtime ($from_t)); # keep count of each status my %count; -if (param('pic')) { - print "Content-type: image/png\nCache-Control: max-age=3600, must-revalidate\n\n"; +if (path_info()) { + print "Content-type: image/png\nCache-Control: max-age=86400, must-revalidate\nExpires: ",scalar localtime(time()+24*60*60),"\nLast-Modified: ",scalar localtime(0),"\n"; # create picture using GD use GD; - my $im = new GD::Image(1,8); + my $im = new GD::Image(1,$height); my $back = $im->colorAllocate(255,255,255); $im->transparent($back); - my ($r,$g,$b) = split(/,/,param('pic')); - my $col = $im->colorAllocate($r,$g,$b); + my $col = path_info(); $col =~ s,/,,g; + my ($r,$g,$b) = split(/,/,$col); + $col = $im->colorAllocate($r,$g,$b); $im->fill(0,0,$col); + print "Content-Length: ",length($im->png),"\n\n"; binmode STDOUT; print $im->png; exit; } print "Content-type: text/html +Cache-Control: max-age=60, must-revalidate
-Reload url(-relative=>1),"\">current or see help.