From ee965a5c7bf37b852795e1201688e3b20bf3d8d1 Mon Sep 17 00:00:00 2001 From: Darren Embry Date: Fri, 6 Apr 2012 19:45:25 -0400 Subject: fix for Bug #2231 --- Dashboard: Traffic Graph: Unable to save settings --- usr/local/www/widgets/javascript/traffic_graph.js | 34 +---- .../www/widgets/widgets/traffic_graphs.widget.php | 157 +++++++++++---------- 2 files changed, 89 insertions(+), 102 deletions(-) diff --git a/usr/local/www/widgets/javascript/traffic_graph.js b/usr/local/www/widgets/javascript/traffic_graph.js index 4970f25..9cdff97 100644 --- a/usr/local/www/widgets/javascript/traffic_graph.js +++ b/usr/local/www/widgets/javascript/traffic_graph.js @@ -1,5 +1,5 @@ function trafficshowDiv(incDiv,swapButtons){ - //appear element + //appear element selectedDiv = incDiv + "graphdiv"; jQuery('#' + selectedDiv).effect('blind',{mode:'show'},1000); showSave(); @@ -13,10 +13,7 @@ function trafficshowDiv(incDiv,swapButtons){ textlink = d.getElementById(selectIntLink); textlink.style.display = "none"; } - selectIntLink = incDiv + "_graph-config"; - textlink = d.getElementById(selectIntLink); - textlink.value = "show"; - updateGraphDisplays(); + document.iform["shown[" + incDiv + "]"].value = "show"; } function trafficminimizeDiv(incDiv,swapButtons){ @@ -34,31 +31,6 @@ function trafficminimizeDiv(incDiv,swapButtons){ textlink = d.getElementById(selectIntLink); textlink.style.display = "none"; } - selectIntLink = incDiv + "_graph-config"; - textlink = d.getElementById(selectIntLink); - textlink.value = "hide"; - updateGraphDisplays(); + document.iform["shown[" + incDiv + "]"].value = "hide"; } -function updateGraphDisplays(){ - var graphs = document.getElementsByClassName('graphsettings'); - var graphsdisplayed = ""; - var firstprint = false; - d = document; - for (i=0; i $ifdescr) { + $state = $_POST["shown"][$ifname]; + if ($state === "show") { + $a_config["shown"]["item"][] = $ifname; + } + } + write_config("Updated traffic graph settings via dashboard."); + header("Location: /"); + exit(0); +} + +$shown = array(); +foreach ($a_config["shown"]["item"] as $if) { + $shown[$if] = true; +} +if ($first_time) { + $keys = array_keys($ifdescrs); + $shown[$keys[0]] = true; +} + +if (isset($a_config["refreshinterval"])) { + $refreshinterval = $a_config["refreshinterval"]; +} else { + $refreshinterval = 10; +} + ?> + $ifname) { - $ifinfo = get_interface_info($ifdescr); - $currentgraph = $showngraphlist[$graphcounter]; - $colposition = strpos($currentgraph,":"); - $currentgraph = substr($currentgraph, $colposition+1); - if($config['widgets']['traffic_graphs-config']) { - if ($currentgraph =="show") { - $mingraphbutton = "inline"; - $showgraphbutton = "none"; - $graphdisplay = "inline"; - $interfacevalue = "show"; - } else { - $mingraphbutton = "none"; - $showgraphbutton = "inline"; - $graphdisplay = "none"; - $interfacevalue = "hide"; - } - } else { - if(!$firstgraphshown) { - $mingraphbutton = "inline"; - $showgraphbutton = "none"; - $graphdisplay = "inline"; - $interfacevalue = "show"; - } else { - $mingraphbutton = "none"; - $showgraphbutton = "inline"; - $graphdisplay = "none"; - $interfacevalue = "hide"; - } - } - - if ($ifinfo['status'] != "down") { - ?> -
- -
-
- Current Traffic +foreach ($ifdescrs as $ifname => $ifdescr) { + $ifinfo = get_interface_info($ifname); + if ($shown[$ifname]) { + $mingraphbutton = "inline"; + $showgraphbutton = "none"; + $graphdisplay = "inline"; + $interfacevalue = "show"; + } else { + $mingraphbutton = "none"; + $showgraphbutton = "inline"; + $graphdisplay = "none"; + $interfacevalue = "hide"; + } + if ($ifinfo['status'] != "down") { ?> +
+
+
+ Current Traffic +
+
+
Minimize <?=$ifname;?> traffic graph
+
Show <?=$ifname;?> traffic graph
+
+
-
-
Minimize <?=$ifname;?> traffic graph
-
Show <?=$ifname;?> traffic graph
+
+
-
-
- -
- -
- -- cgit v1.1