From 0f8edf14df0ce01404978cf3afbfc216d61e502e Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 13 Jan 2017 15:43:20 +0545 Subject: Add filter to Interface Statistics widget (cherry picked from commit 84a7e840eac8f62a95ccb900089faf14a9a9fc65) --- .../widgets/interface_statistics.widget.php | 76 +++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php index 8eca7ed..d56b10f 100644 --- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -79,13 +79,16 @@ if ($_REQUEST && $_REQUEST['ajax']) { ); $ifdescrs = get_configured_interface_with_descr(); + $skipinterfaces = explode(",", $user_settings['widgets']['interface_statistics']['iffilter']); print(""); print( ""); print( ""); - foreach ($ifdescrs as $ifname) { - print( "" . $ifname . ""); + foreach ($ifdescrs as $ifdescr => $ifname) { + if (!in_array($ifdescr, $skipinterfaces)) { + print( "" . $ifname . ""); + } } print( ""); @@ -97,6 +100,10 @@ if ($_REQUEST && $_REQUEST['ajax']) { print( "" . $name . ""); foreach ($ifdescrs as $ifdescr => $ifname) { + if (in_array($ifdescr, $skipinterfaces)) { + continue; + } + $ifinfo = get_interface_info($ifdescr); if ($ifinfo['status'] == "down") { @@ -114,6 +121,23 @@ if ($_REQUEST && $_REQUEST['ajax']) { } print( ""); exit; +} else if ($_POST) { + + $ifdescrs = get_configured_interface_with_descr(); + $validNames = array(); + + foreach ($ifdescrs as $ifdescr => $ifname) { + array_push($validNames, $ifdescr); + } + + if (is_array($_POST['show'])) { + $user_settings['widgets']['interface_statistics']['iffilter'] = implode(',', array_diff($validNames, $_POST['show'])); + } else { + $user_settings['widgets']['interface_statistics']['iffilter'] = ""; + } + + save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved Interface Statistics Filter via Dashboard.")); + header("Location: /index.php"); } $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000; @@ -123,6 +147,48 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period + +