summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-01-13 15:43:20 +0545
committerRenato Botelho <renato@netgate.com>2017-01-13 18:59:20 -0200
commit0f8edf14df0ce01404978cf3afbfc216d61e502e (patch)
tree1bd2560328a4130ecbaee5ab2b4b1506d3f6072c /src
parent2392e8768a592cb7c00b49a610ed739fe156a0a7 (diff)
downloadpfsense-0f8edf14df0ce01404978cf3afbfc216d61e502e.zip
pfsense-0f8edf14df0ce01404978cf3afbfc216d61e502e.tar.gz
Add filter to Interface Statistics widget
(cherry picked from commit 84a7e840eac8f62a95ccb900089faf14a9a9fc65)
Diffstat (limited to 'src')
-rw-r--r--src/usr/local/www/widgets/widgets/interface_statistics.widget.php76
1 files changed, 74 insertions, 2 deletions
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("<thead>");
print( "<tr>");
print( "<th></th>");
- foreach ($ifdescrs as $ifname) {
- print( "<th>" . $ifname . "</th>");
+ foreach ($ifdescrs as $ifdescr => $ifname) {
+ if (!in_array($ifdescr, $skipinterfaces)) {
+ print( "<th>" . $ifname . "</th>");
+ }
}
print( "</tr>");
@@ -97,6 +100,10 @@ if ($_REQUEST && $_REQUEST['ajax']) {
print( "<td><b>" . $name . "</b></td>");
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( "</tbody>");
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
<tr><td><?=gettext("Retrieving interface data")?></td></tr>
</table>
+<!-- close the body we're wrapped in and add a configuration-panel -->
+</div><div id="widget-<?=$widgetname?>_panel-footer" class="panel-footer collapse">
+
+<form action="/widgets/widgets/interface_statistics.widget.php" method="post" class="form-horizontal">
+ <div class="panel panel-default col-sm-10">
+ <div class="panel-body">
+ <div class="table responsive">
+ <table class="table table-striped table-hover table-condensed">
+ <thead>
+ <tr>
+ <th><?=gettext("Interface")?></th>
+ <th><?=gettext("Show")?></th>
+ </tr>
+ </thead>
+ <tbody>
+<?php
+ $skipinterfaces = explode(",", $user_settings['widgets']['interface_statistics']['iffilter']);
+ $idx = 0;
+
+ foreach ($ifdescrs as $ifdescr => $ifname):
+?>
+ <tr>
+ <td><?=$ifname?></td>
+ <td class="col-sm-2"><input id="show[]" name ="show[]" value="<?=$ifdescr?>" type="checkbox" <?=(!in_array($ifdescr, $skipinterfaces) ? 'checked':'')?>></td>
+ </tr>
+<?php
+ endforeach;
+?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+
+ <div class="form-group">
+ <div class="col-sm-offset-3 col-sm-6">
+ <button type="submit" class="btn btn-primary"><i class="fa fa-save icon-embed-btn"></i><?=gettext('Save')?></button>
+ <button id="showallinterfacesforstats" type="button" class="btn btn-info"><i class="fa fa-undo icon-embed-btn"></i><?=gettext('All')?></button>
+ </div>
+ </div>
+</form>
+
<script type="text/javascript">
//<![CDATA[
@@ -145,6 +211,12 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
}
events.push(function(){
+ $("#showallinterfacesforstats").click(function() {
+ $("[id^=show]").each(function() {
+ $(this).prop("checked", true);
+ });
+ });
+
// Start polling for updates some small random number of seconds from now (so that all the widgets don't
// hit the server at exactly the same time)
setTimeout(get_if_stats, Math.floor((Math.random() * 10000) + 1000));
OpenPOWER on IntegriCloud