From 943d52cf12b3d3cf97760f1c7124baa04bb550e0 Mon Sep 17 00:00:00 2001 From: dwayne voelker Date: Thu, 5 Dec 2013 00:19:31 -0500 Subject: Allow setting a default scale type preference for the traffic graphs widget I originally submitted this at https://redmine.pfsense.org/issues/2994 but it seems that is not used for commits now so I am adding it here. It works great on my box, and I can't see these changes causing any issues on other types. I like to have Autoscale (follow) set for the traffic graphs widget and hate having to click on Autoscale (up) to change it to follow every time I enter the dashboard page. This preference is written to the traffic graph widget section in config.xml --- usr/local/www/graph.php | 6 +++++- .../www/widgets/widgets/traffic_graphs.widget.php | 25 ++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'usr/local') diff --git a/usr/local/www/graph.php b/usr/local/www/graph.php index 6a227fa..c7c8c39 100755 --- a/usr/local/www/graph.php +++ b/usr/local/www/graph.php @@ -55,7 +55,11 @@ $ifnum = get_real_interface($ifnum); $ifname=@$_GET["ifname"]?$_GET["ifname"]:"Interface $ifnum"; //Interface name that will be showed on top right of graph /********* Other conf *******/ -$scale_type="up"; //Autoscale default setup : "up" = only increase scale; "follow" = increase and decrease scale according to current graphed datas +if (isset($config["widgets"]["trafficgraphs"]["scale_type"])) + $scale_type = $config["widgets"]["trafficgraphs"]["scale_type"]; +else + $scale_type = "up"; + $nb_plot=120; //NB plot in graph if ($_GET["timeint"]) $time_interval = $_GET["timeint"]; //Refresh time Interval diff --git a/usr/local/www/widgets/widgets/traffic_graphs.widget.php b/usr/local/www/widgets/widgets/traffic_graphs.widget.php index c313575..1314be4 100644 --- a/usr/local/www/widgets/widgets/traffic_graphs.widget.php +++ b/usr/local/www/widgets/widgets/traffic_graphs.widget.php @@ -59,6 +59,9 @@ if ($_POST) { if (isset($_POST["refreshinterval"])) { $a_config["refreshinterval"] = $_POST["refreshinterval"]; } + if (isset($_POST["scale_type"])) { + $a_config["scale_type"] = $_POST["scale_type"]; + } $a_config["shown"]["item"] = array(); foreach ($ifdescrs as $ifname => $ifdescr) { $state = $_POST["shown"][$ifname]; @@ -86,6 +89,12 @@ if (isset($a_config["refreshinterval"])) { $refreshinterval = 10; } +if (isset($a_config["scale_type"])) { + $scale_type = $a_config["scale_type"]; +} else { + $scale_type = up; +} + ?> @@ -100,6 +109,22 @@ if (isset($a_config["refreshinterval"])) { $ifdescr) { ?> " /> + Default AutoScale: + + onchange="updateGraphDisplays();" /> up + onchange="updateGraphDisplays();" /> follow

Refresh Interval: