From 2795f40b0cfe3c79c028c04cc185931ff17c1394 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 20 Dec 2014 22:53:58 +0545 Subject: Interfaces widget create all div All div for the various things need to be created here, so that later AJAX can switch the necessary things on/off and write a new IPv4 or IPv6 address into the div when an interface acquires an address. --- .../www/widgets/widgets/interfaces.widget.php | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) (limited to 'usr') diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php index 4cdee4e..99d52d9 100644 --- a/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/usr/local/www/widgets/widgets/interfaces.widget.php @@ -59,19 +59,22 @@ foreach ($ifdescrs as $ifdescr => $ifname): $icon = 'cablenic'; if ($ifinfo['status'] == "up" || $ifinfo['status'] == "associated") { - $status = '-up'; - $status_text = 'up'; - $status_icon = 'icon_interface_up.gif'; + $known_status = true; + $up_display = "inline"; + $down_display = "none"; + $block_display = "none"; } elseif ($ifinfo['status'] == "no carrier") { - $status = '-down'; - $status_text = 'down'; - $status_icon = 'icon_interface_down.gif'; + $known_status = true; + $up_display = "none"; + $down_display = "inline"; + $block_display = "none"; } elseif ($ifinfo['status'] == "down") { - $status = '-block'; - $status_text = 'disabled'; - $status_icon = 'icon_block.gif'; + $known_status = true; + $up_display = "none"; + $down_display = "none"; + $block_display = "inline"; } else - $status = ''; + $known_status = false; ?> @@ -85,16 +88,22 @@ foreach ($ifdescrs as $ifdescr => $ifname): ?> -
- <?=$status;?> +
" style="display:" > + up +
+
" style="display:" > + down +
+
" style="display:" > + block
@@ -103,19 +112,9 @@ foreach ($ifdescrs as $ifdescr => $ifname): -

-
- Date: Sat, 20 Dec 2014 22:57:47 +0545 Subject: Send IPv4 and IPv6 address in get_interfacestatus And make them strong (bold), which is how they are displayed originally by interfaces.widget.php This allows the AJAX that manipulates the div's in interfaces.widget.php to get the data, so it can make it update. --- usr/local/www/includes/functions.inc.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'usr') diff --git a/usr/local/www/includes/functions.inc.php b/usr/local/www/includes/functions.inc.php index f2d8cf0..4a212ec 100644 --- a/usr/local/www/includes/functions.inc.php +++ b/usr/local/www/includes/functions.inc.php @@ -336,7 +336,10 @@ function get_interfacestatus() { } $data .= ","; if ($ifinfo['ipaddr']) - $data .= htmlspecialchars($ifinfo['ipaddr']); + $data .= "" . htmlspecialchars($ifinfo['ipaddr']) . ""; + $data .= ","; + if ($ifinfo['ipaddrv6']) + $data .= "" . htmlspecialchars($ifinfo['ipaddrv6']) . ""; $data .= ","; if ($ifinfo['status'] != "down") $data .= htmlspecialchars($ifinfo['media']); -- cgit v1.1 From 6e795218c4807a0f865446eb8f0d6c01f0ba91ea Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 20 Dec 2014 23:01:21 +0545 Subject: Set Interfaces widget IPv6 address Now that get_interfacestatus() is returning us the IPv6 address, and interfaces.widget.php has a div to put it in, actually update the IPv6 address on the widget. --- usr/local/www/javascript/index/ajax.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'usr') diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 47c1ee7..50e0145 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -156,14 +156,16 @@ function updateInterfaces(x){ jQuery('#' + details[0] + '-down').css("display","none"); jQuery('#' + details[0] + '-block').css("display","none"); jQuery('#' + details[0] + '-ip').html(details[2]); - jQuery('#' + details[0] + '-media').html(details[3]); + jQuery('#' + details[0] + '-ipv6').html(details[3]); + jQuery('#' + details[0] + '-media').html(details[4]); break; case "down": jQuery('#' + details[0] + '-down').css("display","inline"); jQuery('#' + details[0] + '-up').css("display","none"); jQuery('#' + details[0] + '-block').css("display","none"); jQuery('#' + details[0] + '-ip').html(details[2]); - jQuery('#' + details[0] + '-media').html(details[3]); + jQuery('#' + details[0] + '-ipv6').html(details[3]); + jQuery('#' + details[0] + '-media').html(details[4]); break; case "block": jQuery('#' + details[0] + '-block').css("display","inline"); -- cgit v1.1 From 7a0c88f82773c77580999c04ba6224e7ba18b0de Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 20 Dec 2014 23:50:35 +0545 Subject: Interfaces widget remove blank line if no IPv4 address If the interface had an IPv6 address but no IPv4 address, there was a blank line where the IPv4 address would have been. There is no need for that, and one day IPv4 will be old legacy and systems will routinely have no IPv4 addresses at all - they will all be IPv6. Might as well make that look ordinary on the display now. The br goes in the div so we can put it in and out from the AJAX also. --- usr/local/www/widgets/widgets/interfaces.widget.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'usr') diff --git a/usr/local/www/widgets/widgets/interfaces.widget.php b/usr/local/www/widgets/widgets/interfaces.widget.php index 99d52d9..8dbcad0 100644 --- a/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/usr/local/www/widgets/widgets/interfaces.widget.php @@ -112,8 +112,7 @@ foreach ($ifdescrs as $ifdescr => $ifname): -
-
+
";?>
-- cgit v1.1 From fe416714b988023bf3a985643936ebfa5584c793 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sat, 20 Dec 2014 23:57:29 +0545 Subject: Put line break only if IPv4 address exists This makes a line for the IPv4 address if it is there. If the IPv4 address goes away, the whole line will disappear, leaving just the IPv6 address without an empty line above it. --- usr/local/www/javascript/index/ajax.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'usr') diff --git a/usr/local/www/javascript/index/ajax.js b/usr/local/www/javascript/index/ajax.js index 50e0145..d2ac90e 100644 --- a/usr/local/www/javascript/index/ajax.js +++ b/usr/local/www/javascript/index/ajax.js @@ -150,12 +150,16 @@ function updateInterfaces(x){ interfaces_split = x.split("~"); interfaces_split.each(function(iface){ details = iface.split(","); + if (details[2] == '') + ipv4_details = ''; + else + ipv4_details = details[2] + '
'; switch(details[1]) { case "up": jQuery('#' + details[0] + '-up').css("display","inline"); jQuery('#' + details[0] + '-down').css("display","none"); jQuery('#' + details[0] + '-block').css("display","none"); - jQuery('#' + details[0] + '-ip').html(details[2]); + jQuery('#' + details[0] + '-ip').html(ipv4_details); jQuery('#' + details[0] + '-ipv6').html(details[3]); jQuery('#' + details[0] + '-media').html(details[4]); break; @@ -163,14 +167,14 @@ function updateInterfaces(x){ jQuery('#' + details[0] + '-down').css("display","inline"); jQuery('#' + details[0] + '-up').css("display","none"); jQuery('#' + details[0] + '-block').css("display","none"); - jQuery('#' + details[0] + '-ip').html(details[2]); + jQuery('#' + details[0] + '-ip').html(ipv4_details); jQuery('#' + details[0] + '-ipv6').html(details[3]); jQuery('#' + details[0] + '-media').html(details[4]); break; case "block": - jQuery('#' + details[0] + '-block').css("display","inline"); - jQuery('#' + details[0] + '-down').css("display","none"); - jQuery('#' + details[0] + '-up').css("display","none"); + jQuery('#' + details[0] + '-block').css("display","inline"); + jQuery('#' + details[0] + '-down').css("display","none"); + jQuery('#' + details[0] + '-up').css("display","none"); break; } }); -- cgit v1.1