/[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.8 by dpavlin, Fri Sep 13 14:03:47 2002 UTC revision 1.10 by dpavlin, Fri Sep 13 16:54:44 2002 UTC
# Line 5  use DBI; Line 5  use DBI;
5  use Data::Dumper;  use Data::Dumper;
6  use Date::Parse;  use Date::Parse;
7  use CGI qw/:standard/;  use CGI qw/:standard/;
8    use CGI::Carp qw(fatalsToBrowser);
9  use POSIX qw(strftime);  use POSIX qw(strftime);
10    
11  my $debug = 0;  my $debug = 0;
# Line 25  my %cols = ( Line 26  my %cols = (
26          'Completed/Errors'      => '255,128,0',          'Completed/Errors'      => '255,128,0',
27          'Completed/Failure'     => '128,0,128',          'Completed/Failure'     => '128,0,128',
28          'Mount Request'         => '128,128,255',          'Mount Request'         => '128,128,255',
29            'Mount/Errors'          => '255,64,128',
30          );          );
31    
32  my $int_t = (12 * 60 * 60);     # interval to display on one screen  my $int_t = (12 * 60 * 60);     # interval to display on one screen
# Line 34  my $min_l = 3;                 # min length of bar seg Line 36  my $min_l = 3;                 # min length of bar seg
36    
37  # time range  # time range
38    
39    $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    
43  $to_t = param('to_t') if (param('to_t'));  $to_t = param('to_t') if (param('to_t'));
44  $from_t = param('from_t') if (param('from_t'));  $from_t = param('from_t') if (param('from_t'));
45    
46  # round to nearest minute  # round to nearest minute
47  $to_t = $to_t - ($to_t % 60);  sub m_round {
48  $from_t = $from_t - ($from_t % 60) + 60;          my $t = shift @_;
49            return ($t - ($t % 60));
50    }
51    
52    $to_t = m_round($to_t);
53    $from_t = m_round($from_t);
54    
55  my $to=strftime("%Y-%m-%d %H:%M",localtime ($to_t));  my $to=strftime("%Y-%m-%d %H:%M",localtime ($to_t));
56  my $from=strftime("%Y-%m-%d %H:%M",localtime ($from_t));  my $from=strftime("%Y-%m-%d %H:%M",localtime ($from_t));
# Line 111  print "</td><td align=right>"; Line 120  print "</td><td align=right>";
120  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-$int_t),'<small>&lt;&lt;</small>') if ($to_t-$int_t > $from_t);
121  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";  print $to,mknav($from_t,($to_t+$int_t),'<small>&gt;&gt;</small>'),"</td></tr>\n";
122    
123    # draw hour grid
124    print "<tr><td align=right><small>hour grid</small></td><td colspan=2>";
125    my @c = ("255,255,128","255,192,128");
126    my $hr=strftime("%H",localtime ($from_t));
127    print color_bar(3600 - $from_t % 3600,$c[0],$hr++ % 24);
128    for (my $i=1; $i<int(($to_t-$from_t)/3600); $i++) {
129            print color_bar(3600,$c[1],sprintf("%02d",$hr++ % 24));
130            push @c, shift @c;
131    }
132    print color_bar($from_t % 3600,$c[1],$hr % 24);
133    print "</td></tr>\n";
134    
135  my $fix_d = 0;  # used to fix graph len  my $fix_d = 0;  # used to fix graph len
136    
137  sub bar {  sub bar {
138          my $l = shift @_;       # lenght of event utime          my $l = shift @_;
139          my $status = shift @_ || undef; # what to draw          my $status = shift @_;
140            my $alt = shift @_;
141    
142            my $col;
143    
144            if ($status) {
145                    if ($cols{$status}) {
146                            $col .= $cols{$status};
147                    } else {
148                            $col .= "0,0,0";        # unknown status, black
149                    }
150                    $count{$status}++;
151            } else {
152    #               $col .= '240,240,240';
153                    $col .= '220,220,220';
154            }
155            return color_bar($l,$col,$alt);
156    }
157    
158    sub color_bar {
159            my $l = shift @_;                       # lenght of event utime
160            my $col = shift @_ || '240,240,240';    # default color (filler)
161          my $alt = shift @_ || undef;          my $alt = shift @_ || undef;
162    
163          my $size = int($l / ($len_t / $width));          my $size = int($l / ($len_t / $width));
# Line 130  sub bar { Line 172  sub bar {
172                  print STDERR "fix_d: $fix_d\n" if ($debug);                  print STDERR "fix_d: $fix_d\n" if ($debug);
173          }          }
174    
175          print STDERR "bar[$status] 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);
   
         my $html = "<img src=\"".$q->url(-relative=>1)."?pic=";  
176    
177          if ($status) {          my $html = "<img src=\"".$q->url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$height\"";
                 if ($cols{$status}) {  
                         $html .= $cols{$status};  
                 } else {  
                         $html .= "0,0,0";       # unknown status, black  
                 }  
                 $count{$status}++;  
         } else {  
 #               $html .= '240,240,240';  
                 $html .= '220,220,220';  
         }  
178    
         $html .= "\" width=\"$size\" height=\"$height\"";  
179          if ($use_js && $alt) {          if ($use_js && $alt) {
180                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";                  $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\"";
181          } elsif ($alt) {          } elsif ($alt) {
# Line 191  while(my $row = $sth->fetchrow_hashref) Line 220  while(my $row = $sth->fetchrow_hashref)
220    
221          }          }
222    
223          my $start_t = str2time($row->{start});          my $start_t = m_round(str2time($row->{start}));
224          my $fin_t = str2time($row->{finish});          my $fin_t = m_round(str2time($row->{finish}));
225    
226          if ($start_t > $curr_t) {          if ($start_t > $curr_t + 60) {
227                  my $t = $start_t - $curr_t;                  my $t = $start_t - $curr_t;
228                  print STDERR "[middle filler $curr_t:$t]" if ($debug);                  print STDERR "[middle filler $curr_t:$t]" if ($debug);
229                  print bar($t);                  print bar($t);

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.26