#!/usr/local/bin/perl
# edit_res.cgi
# Display all resource file entries

require './heartbeat-lib.pl';
&header($text{'res_title'}, "");
print "<hr>\n";

@res = &list_resources();
if (@res) {
	print "<table border width=100%>\n";
	print "<tr $tb> <td><b>$text{'res_node'}</b></td> ",
	      "<td><b>$text{'res_ips'}</b></td> ",
	      "<td><b>$text{'res_servs'}</b></td> </tr>\n";
	local $i = 0;
	foreach $r (@res) {
		print "<tr $cb> <td><a href='edit_node.cgi?idx=$i'>",
		      "$r->{'node'}</a></td>\n";
		printf "<td>%s</td>\n",
			$r->{'ips'} ? join(" ", @{$r->{'ips'}})
				    : $text{'res_none'};
		printf "<td>%s</td> </tr>\n", $r->{'servs'} ?
		    join("&nbsp;,&nbsp;", map { s/::/ /g; $_ } @{$r->{'servs'}})
		    : $text{'res_none'};
		$i++;
		}
	print "</table>\n";
	}
else {
	print "<b>$text{'res_nores'}</b><br>\n";
	}
print "<a href='edit_node.cgi?new=1'>$text{'res_add'}</a><p>\n";

print "<hr>\n";
&footer("", $text{'index_return'});

