/[omni_gantt]/db2gantt.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /db2gantt.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24 by dpavlin, Mon Nov 18 08:09:58 2002 UTC revision 1.28 by dpavlin, Thu Jun 26 20:36:48 2003 UTC
# Line 10  use POSIX qw(strftime); Line 10  use POSIX qw(strftime);
10    
11  my $debug = 0;  my $debug = 0;
12    
13    # comment out following field if you don't want links to omni reports
14    # or haven't installed repgen.pl
15    my $repgen_url="/omni/"; # URL to pages with rptgen.pl
16    
17  my $width = 600;        # width of bar  my $width = 600;        # width of bar
18  my $height = 15;        # height of bar  my $height = 15;        # height of bar
19  my $use_js = 1;         # use JavaScript pop-up  my $use_js = 1;         # use JavaScript pop-up
# Line 36  my $min_l = 3;                 # min length of bar seg Line 40  my $min_l = 3;                 # min length of bar seg
40    
41  #--- no user servicable parts below this line  #--- no user servicable parts below this line
42    
43  # time range  my $q=new CGI;
   
 $int_t = m_round($int_t);  
44    
45  my ($from_t,$to_t) = (time()-$int_t,time());  my ($from_t,$to_t) = (time()-$int_t,time());
46    
 $to_t = param('to_t') if (param('to_t'));  
47  $from_t = param('from_t') if (param('from_t'));  $from_t = param('from_t') if (param('from_t'));
48    $to_t = param('to_t') if (param('to_t'));
49    
50    if (param('f-1')) {
51            $from_t = $from_t - param('int_f-1') || $int_t;
52    } elsif (param('f+1')) {
53            $from_t = $from_t + param('int_f+1') || $int_t;
54    } elsif (param('t-1')) {
55            $to_t = $from_t - param('int_t-1') || $int_t;
56    } elsif (param('t+1')) {
57            $to_t = $from_t + $int_t;
58    }
59    
60    # time range
61    $int_t = m_round($int_t);
62    
63  # round to nearest minute  # round to nearest minute
64  sub m_round {  sub m_round {
# Line 78  if (path_info()) { Line 93  if (path_info()) {
93          exit;          exit;
94  }  }
95    
96    # open DBI connection
97    my $dbh = DBI->connect("DBI:Pg:dbname=gantt","","") || die $DBI::errstr;
98    
99  print "Content-type: text/html  print "Content-type: text/html
100  Cache-Control: max-age=60, must-revalidate  Cache-Control: max-age=60, must-revalidate
101    
# Line 98  print ' Line 116  print '
116  </script>  </script>
117  ';  ';
118  }  }
119  print "</head><body>";  print "</head><body>
120            <form action=".$q->url(-relative=>1)." method=get>
121            <input type=hidden name=from_t value=$from_t>
122            <input type=hidden name=to_t value=$to_t>
123    ";
124    
125  # all vars ending in *_t have utime in them.  # all vars ending in *_t have utime in them.
126  #  #
127  my $len_t = $to_t - $from_t;  my $len_t = $to_t - $from_t;
128    
129  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;  
130    
131    
132  sub mknav {  sub mknav {
133          my $f = shift @_;       # from_t          my $f = shift @_;       # from_t
134          my $t = shift @_;       # to_t          my $t = shift @_;       # to_t
135            my $d = shift @_;       # delta
136          my $ch = shift @_;      # char          my $ch = shift @_;      # char
137    
138          return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>";          return "
139            <select name=int_${d}>
140            <option value=".(12*60*60).">12h</option>
141            <option value=".(24*60*60).">day</option>
142            <option value=".(7*24*60*60).">week</option>
143            </select>
144            <input type=submit name=$d value=\"$ch\">
145            ";
146            #return "<a href=\"".$q->url(-relative=>1)."?from_t=${f}&to_t=${t}\">$ch</a>";
147  }  }
148    
149  print "<table cellspacing=0 cellpadding=0>";  print "<table cellspacing=0 cellpadding=0>";
150  print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>";  print "<tr bgcolor=#e0e0e0><td>Specification</td><td align=left>";
151  print mknav(($from_t-$int_t),$to_t,'<small>&lt;&lt;</small>'),$from;  print mknav($from_t,$to_t,'f-1','&lt;&lt;'),$from;
152  print mknav(($from_t+$int_t),$to_t,'<small>&gt;&gt;</small>') if ($from_t+$int_t < $to_t);  print mknav($from_t,$to_t,'f+1','&gt;&gt;') if ($from_t+$int_t < $to_t);
153  print "</td><td align=right>";  print "</td><td align=right>";
154  print mknav($from_t,($to_t-$int_t),'<small>&lt;&lt;</small>') if ($to_t-$int_t > $from_t);  print mknav($from_t,$to_t,'t-1','&lt;&lt;') if ($to_t+$int_t > $from_t);
155  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";  print $to,mknav($from_t,$to_t,'t+1','&gt;&gt;'),"</td></tr>\n";
156    
157  # draw hour grid  # draw hour grid
158  sub hour_grid {  sub hour_grid {
# Line 208  sub color_bar { Line 236  sub color_bar {
236    
237          print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);          print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px<br> alt:$alt\n" if ($debug);
238    
239          my $html = "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\"";          my $html;
240    
241            my ($html_end, $img_end) = ("","");
242            if ($repgen_url && $alt =~ m#(\d\d\d\d)/(\d\d)/(\d\d)-(\d+)#) {
243                    $html .= "<a href=\"$repgen_url/$1-$2-$3-$4.html\">";
244                    $html_end .= "</a>";
245                    $img_end .= " border=0";
246            }
247    
248            $html .= "<img src=\"".$q->url(-relative=>1)."/$col\" width=\"$size\" height=\"$h\"";
249    
250          if ($use_js && $alt) {          if ($use_js && $alt) {
251                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";
252          } elsif ($alt) {          } elsif ($alt) {
253                  $html .= " alt=\"$alt\"";                  $html .= " alt=\"$alt\"";
254          }          }
255          $html .= ">";          $html .= "$img_end>$html_end";
256    
257          return($html);          return($html);
258  }  }
# Line 229  my $sql = "select start,finish,specifica Line 266  my $sql = "select start,finish,specifica
266          ";          ";
267    
268  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;
269    print STDERR "sql: $sql\n" if ($debug);
270    
271  my %spec;       # specification hash  my %spec;       # specification hash
272    
# Line 264  sub sum_bar { Line 302  sub sum_bar {
302                          $last_var = $v;                          $last_var = $v;
303                  }                  }
304          }          }
305            # fix division by zero
306            $max_use++ if ($max_use == 0);
307          my $h = $last_var / $max_use * $height;          my $h = $last_var / $max_use * $height;
308          my $c = 255 - int (255 * $last_var / $max_use);          my $c = 255 - int (255 * $last_var / $max_use);
309          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);
# Line 313  while(my $row = $sth->fetchrow_hashref) Line 353  while(my $row = $sth->fetchrow_hashref)
353                  # init vars for next line                  # init vars for next line
354                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar                  ($fix_s,$fix_d) = (0,0); # init fix vars for bar
355    
356                  html_spec if ($curr_spec ne "");                  if ($curr_spec ne "") {
357                            $curr_spec =~ s/ +/&nbsp;/g;
358                            html_spec;
359                    }
360    
361                  $curr_t = $from_t;      # init timeline                  $curr_t = $from_t;      # init timeline
362                  $curr_spec = $row->{specification};                  $curr_spec = $row->{specification};
# Line 406  print "</table>"; Line 449  print "</table>";
449    
450    
451  # label and usage  # label and usage
 $len_t = 50; # disable bar scaling  
452    
453  print "<hr>\nColors for statuses and usage (#):\n";  print "<hr>\nColors for statuses and usage (#):\n";
454  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";
455    my $max = 0;
456    foreach my $status (keys %count) {
457            $max = $count{$status} if ($count{$status} > $max);
458    }
459    $len_t = $max ; # disable bar scaling
460    
461  foreach my $status (keys %count) {  foreach my $status (keys %count) {
462  #foreach my $status (keys %cols) {  #foreach my $status (keys %cols) {
463          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 "");
# Line 418  foreach my $status (keys %count) { Line 466  foreach my $status (keys %count) {
466          # it will first evaluate bar sub (thus increasing number by one) and          # it will first evaluate bar sub (thus increasing number by one) and
467          # then display number (wrongly).          # then display number (wrongly).
468  }  }
469  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>";
   

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.26