28 |
'Completed/Failure' => '128,0,128', |
'Completed/Failure' => '128,0,128', |
29 |
'Mount Request' => '128,128,255', |
'Mount Request' => '128,128,255', |
30 |
'Mount/Errors' => '255,64,128', |
'Mount/Errors' => '255,64,128', |
31 |
|
'Mount/Failures' => '255,128,192', |
32 |
); |
); |
33 |
|
|
34 |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
my $int_t = (12 * 60 * 60); # interval to display on one screen |
36 |
|
|
37 |
#--- no user servicable parts below this line |
#--- no user servicable parts below this line |
38 |
|
|
39 |
# time range |
my $q=new CGI; |
|
|
|
|
$int_t = m_round($int_t); |
|
40 |
|
|
41 |
my ($from_t,$to_t) = (time()-$int_t,time()); |
my ($from_t,$to_t) = (time()-$int_t,time()); |
42 |
|
|
|
$to_t = param('to_t') if (param('to_t')); |
|
43 |
$from_t = param('from_t') if (param('from_t')); |
$from_t = param('from_t') if (param('from_t')); |
44 |
|
$to_t = param('to_t') if (param('to_t')); |
45 |
|
|
46 |
|
if (param('f-1')) { |
47 |
|
$from_t = $from_t - param('int_f-1') || $int_t; |
48 |
|
} elsif (param('f+1')) { |
49 |
|
$from_t = $from_t + param('int_f+1') || $int_t; |
50 |
|
} elsif (param('t-1')) { |
51 |
|
$to_t = $from_t - param('int_t-1') || $int_t; |
52 |
|
} elsif (param('t+1')) { |
53 |
|
$to_t = $from_t + $int_t; |
54 |
|
} |
55 |
|
|
56 |
|
# time range |
57 |
|
$int_t = m_round($int_t); |
58 |
|
|
59 |
# round to nearest minute |
# round to nearest minute |
60 |
sub m_round { |
sub m_round { |
81 |
$im->transparent($back); |
$im->transparent($back); |
82 |
my $col = path_info(); $col =~ s,/,,g; |
my $col = path_info(); $col =~ s,/,,g; |
83 |
my ($r,$g,$b) = split(/,/,$col); |
my ($r,$g,$b) = split(/,/,$col); |
84 |
my $col = $im->colorAllocate($r,$g,$b); |
$col = $im->colorAllocate($r,$g,$b); |
85 |
$im->fill(0,0,$col); |
$im->fill(0,0,$col); |
86 |
print "Content-Length: ",length($im->png),"\n\n"; |
print "Content-Length: ",length($im->png),"\n\n"; |
87 |
binmode STDOUT; |
binmode STDOUT; |
89 |
exit; |
exit; |
90 |
} |
} |
91 |
|
|
92 |
|
# open DBI connection |
93 |
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
94 |
|
|
95 |
print "Content-type: text/html |
print "Content-type: text/html |
96 |
Cache-Control: max-age=60, must-revalidate |
Cache-Control: max-age=60, must-revalidate |
97 |
|
|
112 |
</script> |
</script> |
113 |
'; |
'; |
114 |
} |
} |
115 |
print "</head><body>"; |
print "</head><body> |
116 |
|
<form action=".$q->url(-relative=>1)." method=get> |
117 |
|
<input type=hidden name=from_t value=$from_t> |
118 |
|
<input type=hidden name=to_t value=$to_t> |
119 |
|
"; |
120 |
|
|
121 |
# all vars ending in *_t have utime in them. |
# all vars ending in *_t have utime in them. |
122 |
# |
# |
123 |
my $len_t = $to_t - $from_t; |
my $len_t = $to_t - $from_t; |
124 |
|
|
125 |
die "interval must be positive and bigger than 1 sec !" if ($len_t < 1); |
die "interval must be positive and bigger than 1 sec !" if (abs($len_t) < 1); |
|
|
|
|
my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr; |
|
|
my $q=new CGI; |
|
126 |
|
|
127 |
|
|
128 |
sub mknav { |
sub mknav { |
129 |
my $f = shift @_; # from_t |
my $f = shift @_; # from_t |
130 |
my $t = shift @_; # to_t |
my $t = shift @_; # to_t |
131 |
|
my $d = shift @_; # delta |
132 |
my $ch = shift @_; # char |
my $ch = shift @_; # char |
133 |
|
|
134 |
return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
return " |
135 |
|
<select name=int_${d}> |
136 |
|
<option value=".(12*60*60).">12h</option> |
137 |
|
<option value=".(24*60*60).">day</option> |
138 |
|
<option value=".(7*24*60*60).">week</option> |
139 |
|
</select> |
140 |
|
<input type=submit name=$d value=\"$ch\"> |
141 |
|
"; |
142 |
|
#return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>"; |
143 |
} |
} |
144 |
|
|
145 |
print "<table cellspacing=0 cellpadding=0>"; |
print "<table cellspacing=0 cellpadding=0>"; |
146 |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>"; |
147 |
print mknav(($from_t-$int_t),$to_t,'<small><<</small>'),$from; |
print mknav($from_t,$to_t,'f-1','<<'),$from; |
148 |
print mknav(($from_t+$int_t),$to_t,'<small>>></small>') if ($from_t+$int_t < $to_t); |
print mknav($from_t,$to_t,'f+1','>>') if ($from_t+$int_t < $to_t); |
149 |
print "</td><td align=right>"; |
print "</td><td align=right>"; |
150 |
print mknav($from_t,($to_t-$int_t),'<small><<</small>') if ($to_t-$int_t > $from_t); |
print mknav($from_t,$to_t,'t-1','<<') if ($to_t+$int_t > $from_t); |
151 |
print $to,mknav($from_t,($to_t+$int_t),'<small>>></small>'),"</td></tr>\n"; |
print $to,mknav($from_t,$to_t,'t+1','>>'),"</td></tr>\n"; |
152 |
|
|
153 |
# draw hour grid |
# draw hour grid |
154 |
sub hour_grid { |
sub hour_grid { |
253 |
"; |
"; |
254 |
|
|
255 |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr; |
256 |
|
print STDERR "sql: $sql\n" if ($debug); |
257 |
|
|
258 |
my %spec; # specification hash |
my %spec; # specification hash |
259 |
|
|
260 |
my $curr_spec; |
my $curr_spec = ""; |
261 |
my $curr_t = $from_t; |
my $curr_t = $from_t; |
262 |
|
|
263 |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
$sth->execute() || die "sql: $sql ".$dbh->errstr; |
289 |
$last_var = $v; |
$last_var = $v; |
290 |
} |
} |
291 |
} |
} |
292 |
|
# fix division by zero |
293 |
|
$max_use++ if ($max_use == 0); |
294 |
my $h = $last_var / $max_use * $height; |
my $h = $last_var / $max_use * $height; |
295 |
my $c = 255 - int (255 * $last_var / $max_use); |
my $c = 255 - int (255 * $last_var / $max_use); |
296 |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len); |
print color_bar($len,"$c,$c,$c","$last_var concurrent jobs",1,$h+1) if ($len); |
340 |
# init vars for next line |
# init vars for next line |
341 |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
($fix_s,$fix_d) = (0,0); # init fix vars for bar |
342 |
|
|
343 |
html_spec if ($curr_spec ne ""); |
if ($curr_spec ne "") { |
344 |
|
$curr_spec =~ s/ +/ /g; |
345 |
|
html_spec; |
346 |
|
} |
347 |
|
|
348 |
$curr_t = $from_t; # init timeline |
$curr_t = $from_t; # init timeline |
349 |
$curr_spec = $row->{specification}; |
$curr_spec = $row->{specification}; |
436 |
|
|
437 |
|
|
438 |
# label and usage |
# label and usage |
|
$len_t = 50; # disable bar scaling |
|
439 |
|
|
440 |
print "<hr>\nColors for statuses and usage (#):\n"; |
print "<hr>\nColors for statuses and usage (#):\n"; |
441 |
print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n"; |
print "<table border=0><tr bgcolor=#e0e0e0><th>status</th><th>#</th><th>color</th></tr>\n"; |
442 |
|
my $max = 0; |
443 |
|
foreach my $status (keys %count) { |
444 |
|
$max = $count{$status} if ($count{$status} > $max); |
445 |
|
} |
446 |
|
$len_t = $max ; # disable bar scaling |
447 |
|
|
448 |
foreach my $status (keys %count) { |
foreach my $status (keys %count) { |
449 |
#foreach my $status (keys %cols) { |
#foreach my $status (keys %cols) { |
450 |
print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne ""); |
print "<tr bgcolor=#e0e0e0><td><small>$status</small></td><td><small>",$count{$status}*1,"</small></td><td>",bar($count{$status},$status),"</td></tr>\n" if ($status ne ""); |
453 |
# it will first evaluate bar sub (thus increasing number by one) and |
# it will first evaluate bar sub (thus increasing number by one) and |
454 |
# then display number (wrongly). |
# then display number (wrongly). |
455 |
} |
} |
456 |
print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
print "</table></form>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a> or see <a href=\"db2gantt_help.html\">help</a>.</p></body></html>"; |
|
|
|