% unless ($ok) {
<H3>Map data missing</h3>

Have you run <B><TT>netdisco -g</TT></B> yet?
<P>
<% $mapfile %> : <% $have_image ? "OK" : "unaccessible" %>.<BR>
netmap.map : <% $have_map ? "OK" : $! %>.
<P>
You can also do this from the <A HREF="admin.html">Admin Panel</A> if you have
administrative rights.
%#
% } else {
%#
%#
<MAP NAME="netmap">
% foreach my $line (@map){
    <%$line%>
% }
</MAP>
<IMG SRC="<% $mapfile %>" ISMAP USEMAP="#netmap" BORDER=0>
<BR>Map Data is <%$map_days%> days old.
% }
<h4>Key</h4>
<TABLE BORDER=0>
% for(my $i = 0; $i <= $#{$left_key} || $i <= $#{$right_key}; $i++) {
<tr>
%  if (defined($left_key->[$i])) {
    <td bgcolor="black"><%$left_key->[$i]->[0]%></td>
    <td><%$left_key->[$i]->[1]%></td>
%  } else {
    <td colspan="2">&nbsp;</td>
%  }
%  if (defined($right_key->[$i])) {
    <td bgcolor="black"><%$right_key->[$i]->[0]%></td>
    <td><%$right_key->[$i]->[1]%></td>
%  } else {
    <td colspan="2">&nbsp;</td>
%  }
</tr>
% }
</TABLE>
<%init>
my $comp = $m->current_comp;
my $dir  = $comp->source_dir;
my $have_map = open (MAP, "< $dir/netmap.map");
my (@map, $map_age, $secs_per_day, $map_days);

my $mapfile = 'netmap.gif';
if (defined $netdisco::CONFIG{graph_png} and $netdisco::CONFIG{graph_png}){
    $mapfile = 'netmap.png';
}
my $have_image = -r "$dir/$mapfile";

my $ok = ($have_map && $have_image);

if ($ok){ 
    @map = (<MAP>);
    close (MAP);
    $map_age = (stat("$dir/$mapfile"))[9];
    $map_age = time - $map_age;
    $secs_per_day = 60*60*24;
    $map_days = sprintf("%-2.2f", $map_age/$secs_per_day);
}

my $right_key = [
 [ '<font color="green">--------</font>', 'Green Lines - WAN' ],
 [ '<font color="#f5deb3">-------</font>', 'Thin lines - 10Mbps' ],
 [ '<font color="#f5deb3">=======</font>', 'Thick lines - 100Mbps' ],
 [ '<font color="cyan">=======</font>', 'Cyan lines - 1.0 Gbps' ] ];

my $left_key = [];
foreach my $map (@{$netdisco::CONFIG{node_map}}) {
        my ($var,$regex,$attr,$val,$name,$label) = split(':',$map);
	next unless $name && $label;
	my ($textcolor) = $netdisco::CONFIG{node_fontcolor} || 'white';
	my ($bracketcolor) = $netdisco::CONFIG{graph_color} || 'white';

	if ($attr eq 'fillcolor') {
		$textcolor = $bracketcolor = $val;
	} elsif ($attr eq 'color') {
		$bracketcolor = $val;
	}
	my($txt) = '<font color="' . $bracketcolor . '">[';
	if ($textcolor ne $bracketcolor) {
		$txt .= '</font><font color="' . $textcolor . '">';
	}
	$txt .= $name;
	if ($textcolor ne $bracketcolor) {
		$txt .= '</font><font color="' . $bracketcolor . '">';
	}
	$txt .= ']</font>';
	push(@{$left_key}, [ $txt, $label ]);
}
my $problem = $netdisco::CONFIG{node_problem} || 'red';
my $colorname = $problem; $colorname =~ s/^./\U$&/;
push(@{$left_key}, [ '<font color="' . $problem . '">[bad-dev]</font>',
			$colorname . ' Box - Device unaccessable' ]);

</%init>
<%method title>
- Network Map \
</%method>
%# $Id: netmap.html,v 1.7 2006/11/21 18:48:57 fenner Exp $
%# vim:syntax=mason
