/[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.12 by dpavlin, Fri Sep 13 19:06:46 2002 UTC revision 1.17 by dpavlin, Sun Sep 15 19:17:37 2002 UTC
# Line 8  use CGI qw/:standard/; Line 8  use CGI qw/:standard/;
8  use CGI::Carp qw(fatalsToBrowser);  use CGI::Carp qw(fatalsToBrowser);
9  use POSIX qw(strftime);  use POSIX qw(strftime);
10    
11  my $debug = 0;  my $debug = 1;
12    
13  my $width = 600;        # width of bar  my $width = 600;        # width of bar
14  my $height = 12;        # height of bar  my $height = 19;        # height of bar
15  my $use_js = 1;         # use JavaScript pop-up  my $use_js = 1;         # use JavaScript pop-up
16    
17  # status colors  # status colors
18  my %cols = (  my %cols = (
19          'In Progress'           => '0,255,0',          'In Progress'           => '0,255,0',
20          'In Progress/Failure'   => '255,64,255',          'In Progress/Failures'  => '192,64,192',
21          'In Progress/Errors'    => '255,64,0',          'In Progress/Errors'    => '255,128,128',
22          'Queuing'               => '255,255,0',          'Queuing'               => '255,255,0',
23          'Aborted'               => '255,0,0',          'Aborted'               => '255,0,0',
24          'Failed'                => '255,0,0',          'Failed'                => '255,0,0',
# Line 75  if (param('pic')) { Line 75  if (param('pic')) {
75  }  }
76    
77  print "Content-type: text/html  print "Content-type: text/html
78    Cache-Control: max-age=60, must-revalidate
79    
80  <html>  <html>
81  <head>  <head>
82  <title>OmniBack Gantt: $from - $to</title>";  <title>OmniBack Gantt: $from - $to</title>
83    <meta HTTP-EQUIV=\"Refresh\" CONTENT=60>";
84  if ($use_js) {  if ($use_js) {
85  print '  print '
86  <script type="text/javascript" language="javascript" src="1k.js"></script>  <script type="text/javascript" language="javascript" src="1k.js"></script>
# Line 125  sub hour_grid { Line 127  sub hour_grid {
127          print "<tr><td align=right><small>hour grid</small></td><td colspan=2>";          print "<tr><td align=right><small>hour grid</small></td><td colspan=2>";
128          my @c = ("255,255,128","255,192,128");          my @c = ("255,255,128","255,192,128");
129          my $hr=strftime("%H",localtime ($from_t));          my $hr=strftime("%H",localtime ($from_t));
130          print color_bar(3600 - $from_t % 3600,$c[0],sprintf("%02d",$hr++ % 24));          sub hour_bar {
131                    my ($t,$c,$hr) = @_;
132                    my $clock_hr = $hr % 24;
133                    my $alt = sprintf("%02d:00",$clock_hr);
134                    if ($clock_hr == 0) {
135                            my $pix_hr = int(1 / $width);
136                            print color_bar($pix_hr,"0,0,0",strftime("%Y-%m-%d", localtime($from_t + $hr*3600)));
137                            print color_bar($t-$pix_hr,$c,$alt);
138                    } else {
139                            print color_bar($t,$c,$alt);
140                    }
141            }
142            hour_bar(3600 - $from_t % 3600,$c[0],$hr++);
143          for (my $i=1; $i<int(($to_t-$from_t)/3600); $i++) {          for (my $i=1; $i<int(($to_t-$from_t)/3600); $i++) {
144                  print color_bar(3600,$c[1],sprintf("%02d",$hr++ % 24));                  hour_bar(3600,$c[1],$hr++);
145                  push @c, shift @c;                  push @c, shift @c;
146          }          }
147          print color_bar($from_t % 3600,$c[1],sprintf("%02d",$hr % 24));          hour_bar($from_t % 3600,$c[1],$hr);
148          print "</td></tr>\n";          print "</td></tr>\n";
149  }  }
150    
# Line 157  sub bar { Line 171  sub bar {
171  #               $col .= '240,240,240';  #               $col .= '240,240,240';
172                  $col .= '220,220,220';                  $col .= '220,220,220';
173          }          }
174          return color_bar($l,$col,$alt);          return color_bar($l,$col,$alt,$min_l);
175  }  }
176    
177  sub color_bar {  sub color_bar {
178          my $l = shift @_;                       # lenght of event utime          my $l = shift @_;                       # lenght of event utime
179          my $col = shift @_ || '240,240,240';    # default color (filler)          my $col = shift @_ || '240,240,240';    # default color (filler)
180          my $alt = shift @_ || undef;          my $alt = shift @_ || undef;
181            my $min_l = shift @_ || 1;
182    
183          my $size = $l / ($len_t / $width);          my $size = $l / ($len_t / $width);
184          $fix_s += $size - int($size);          $fix_s += $size - int($size);
185          $size=int($size);          $size=int($size);
186            # add rounding error to size
187          if ($fix_s > 1) {          if ($fix_s > 1) {
188                  $fix_s -= 1;                  my $i = $fix_s ; $i = int($i);
189                  $size++;                  $fix_s -= $i;
190                    $size += $i;
191          }          }
192    
193          if ($alt && $size < $min_l) {          if ($alt && $size < $min_l) {
# Line 203  my $sql = "select start,finish,specifica Line 220  my $sql = "select start,finish,specifica
220          from gantt          from gantt
221          where (start < '$from' and finish > '$from') or          where (start < '$from' and finish > '$from') or
222          (start > '$from' and start < '$to')          (start > '$from' and start < '$to')
223          order by device,specification          order by device,specification,start
224          ";          "
225    
226  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;  my $sth = $dbh->prepare($sql) || die "sql: $sql ".$dbh->errstr;
227    
# Line 225  while(my $row = $sth->fetchrow_hashref) Line 242  while(my $row = $sth->fetchrow_hashref)
242                  }                  }
243    
244                  print "</td></tr>\n" if ($curr_t != $from_t);                  print "</td></tr>\n" if ($curr_t != $from_t);
245                    ($fix_s,$fix_d) = (0,0); # init fix vars for bar
246                  print "<tr><td>", $row->{specification},"</td><td colspan=2>";                  print "<tr><td>", $row->{specification},"</td><td colspan=2>";
247    
248                  $curr_t = $from_t;      # init timeline                  $curr_t = $from_t;      # init timeline
# Line 232  while(my $row = $sth->fetchrow_hashref) Line 250  while(my $row = $sth->fetchrow_hashref)
250    
251          }          }
252    
253          my $start_t = m_round(str2time($row->{start}));          my $start_t = str2time($row->{start});
254          my $fin_t = m_round(str2time($row->{finish}));          my $fin_t = str2time($row->{finish});
255    
256          if ($start_t > $curr_t + 60) {          # Can I squeeze here 1 pixel of time (many seconds) ?
257            if ($start_t > $curr_t + ($len_t / $width)) {
258                  my $t = $start_t - $curr_t;                  my $t = $start_t - $curr_t;
259                  print STDERR "[middle filler $curr_t:$t]" if ($debug);                  print STDERR "[middle filler $curr_t:$t]" if ($debug);
260                  print bar($t);                  print bar($t);
261                  $curr_t = $start_t;                  $curr_t = $start_t;
262            } else {
263                    # prepend too few seconds to next event
264                    $start_t = $curr_t;
265          }          }
266    
267          my $len = $fin_t - $start_t;          my $len = $fin_t - $start_t;
# Line 267  while(my $row = $sth->fetchrow_hashref) Line 289  while(my $row = $sth->fetchrow_hashref)
289          $alt .= $row->{type}." <b>".$row->{status}."</b><br>".          $alt .= $row->{type}." <b>".$row->{status}."</b><br>".
290          $row->{user_group_host}." <i>".$row->{sessionid}."</i><br>".          $row->{user_group_host}." <i>".$row->{sessionid}."</i><br>".
291          $row->{device}."&nbsp;on&nbsp;".$row->{host};          $row->{device}."&nbsp;on&nbsp;".$row->{host};
292    $alt .= "-- ".$row->{specification};
293          print bar($len,$row->{status},$alt);          print bar($len,$row->{status},$alt);
294    
295          $curr_t += $len;          $curr_t += $len;
# Line 306  foreach my $status (keys %count) { Line 329  foreach my $status (keys %count) {
329          # it will first evaluate bar sub (thus increasing number by one) and          # it will first evaluate bar sub (thus increasing number by one) and
330          # then display number (wrongly).          # then display number (wrongly).
331  }  }
332  print "</table>\n<p>Reload <a href=\"",$q->url(-relative=>1),"\">current</a>.</p></body></html>";  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>";
333    

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.26