Project

General

Profile

« Previous | Next » 

Revision 90053cde

Added by Hamish Coleman over 17 years ago

  • ID 90053cdef72eeadc4b5454ebe2e25414a3384661

First pass at frameset interface

View differences:

mrtg.cgi
sub print_menu_table($$) {
my ($lists,$style) = @_;
my $target;
if ($style eq 'wide') {
$target="_self";
} else {
$target="list";
}
print "\n<table border=2 cellpadding=2 cellspacing=0 style=\"margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;\">\n";
if ($style eq 'wide') {
......
}
print " <td valign=top>\n";
for my $j (sort keys %{$lists->{$i}}) {
print " ".a({-href=>"?list=$i,$j"},"$j")."<br>\n";
print " ".a({-href=>"?page=list&list=$i,$j",-target=>$target},"$j")."<br>\n";
}
print " </td>\n";
......
if (!defined $list) {
return undef;
}
if (!defined $lists) {
return undef;
}
my @wantlist = split /,/,$list;
my @list = @{$lists->{$wantlist[0]}->{$wantlist[1]}};
my $selfurl.='list='.param('list').'&';
if ($graph ne 'day') {
$selfurl.='graph='.$graph.'&';
}
for my $router_num (0..$#list){
my $router = $list[$router_num];
......
$ysize = $router->{ysize};
$xsize = $router->{xsize};
print a({-href=>$router->{name}.".html"},
print a({-href=>$router->{name}.".html",-target=>"list"},
img{
-src=>$router->{name}."-$graph.".$router->{imagetype},
-height=>"$ysize",
......
);
print hr,"\n";
}
return 1;
}
sub print_graph_chooser($$) {
my ($this_graph,$selfurl) = @_;
$selfurl .= 'page=list&';
if ($this_graph eq 'day') {
print 'Daily';
} else {
print a({-href=>$selfurl.'graph=day&'}, 'Daily');
print a({-href=>$selfurl.'graph=day&',-target=>'_self'}, 'Daily');
}
print '&nbsp;';
if ($this_graph eq 'week') {
print 'Weekly';
} else {
print a({-href=>$selfurl.'graph=week&'}, 'Weekly')
print a({-href=>$selfurl.'graph=week&',-target=>'_self'}, 'Weekly')
}
print '&nbsp;';
if ($this_graph eq 'month') {
print 'Monthly';
} else {
print a({-href=>$selfurl.'graph=month&'}, 'Monthly')
print a({-href=>$selfurl.'graph=month&',-target=>'_self'}, 'Monthly')
}
print '&nbsp;';
if ($this_graph eq 'year') {
print 'Yearly';
} else {
print a({-href=>$selfurl.'graph=year&'}, 'Yearly')
print a({-href=>$selfurl.'graph=year&',-target=>'_self'}, 'Yearly')
}
print '&nbsp;';
print '&nbsp;';
print a({-href=>'?'}, 'Change List'),
'&nbsp;',
'(Current List is ',param('list'),")\n";
'(This List is ',param('list'),")\n";
}
my @tests = init_tests(@config_files);
my $lists = init_lists(@tests);
#use Data::Dumper;
#print Dumper(\@tests);
#print Dumper(\$lists);
# FIXME - globals
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
my $guardband = 15; # updates occur this many seconds after predicted gif completion
my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
#selfurl is ready to append args to.
my $selfurl = '?';
my $page = param('page') || 'none';
my $this_host = hostname;
print header, start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
# FIXME - use something that doesnt make "&" into "&amp;" in the <a> tags
# you mean, like, a form?. well, duh!
my @wantlist = split /,/,param('list');
if (!@wantlist) {
my @tests;
my $lists;
if($page eq 'frame') {
print "Content-type: text/html\n\n";
print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
print '<frame src="?page=menu" name=menu>';
print '<frame src="?page=list&list=OTHER,OTHER" name=list>';
print "</frameset>\n";
print "</html>\n";
} elsif($page eq 'none') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
print table(
{-width=>"100\%"},
TR(td("Select which list to show"))
);
print_menu_table($lists,'wide');
} elsif (!defined $lists->{$wantlist[0]}->{$wantlist[1]}) {
#FIXME
print table({-width=>"100\%"}, TR(td("That list is unavailable")));
} elsif(defined param('test')) {
print_list($lists,'day',param('list'));
} else {
my $graph = param('graph') || 'day';
print "\n","Direct questions and feedback to ",
a({-href=>"mailto:hamish\@zot.org"}, "Hamish"),
" (Version $VERSION)",
end_html;
} elsif($page eq 'list') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
my $guardband = 15; # updates occur this many seconds after predicted gif completion
my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
$selfurl.='list='.param('list').'&';
my $graph = param('graph') || 'day';
my $selfurl ='?list='.param('list').'&';
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
print_graph_chooser($graph,$selfurl);
print "<br/>";
print_list($lists,$graph,param('list')||'none');
print end_html;
} elsif($page eq 'menu') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
print_menu_table($lists,'high');
print end_html;
} elsif($page eq 'noframe') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
# FIXME - duplicated time calculations from above
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
my $guardband = 15; # updates occur this many seconds after predicted gif completion
my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
print "<table cellpadding=2 cellspacing=0>\n",
"<tr><td colspan=2>";
my $graph = param('graph') || 'day';
print_graph_chooser($graph,$selfurl);
my $selfurl.='list='.param('list').'&';
print "</tr><tr><td valign=top>";
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
print "<table cellpadding=2 cellspacing=0>\n";
print "<tr><td valign=top>";
print_menu_table($lists,'high');
print "</td><td valign=top>\n";
print "<td valign=top>\n";
print_graph_chooser($graph,$selfurl);
print "<br/>";
print_list($lists,$graph,param('list'));
print "</table>\n";
print end_html;
}
if ($warnings) {
print "<pre>\n", "$warnings", "</pre>\n";
}
print "\n","Direct questions and feedback to ",
a({-href=>"mailto:hamish\@zot.org"}, "Hamish"),
" (Version $VERSION)",
end_html;

Also available in: Unified diff