summaryrefslogtreecommitdiffstats
path: root/src/usr/local
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-01-13 15:43:20 +0545
committerPhil Davis <phil.davis@inf.org>2017-01-13 15:43:20 +0545
commit84a7e840eac8f62a95ccb900089faf14a9a9fc65 (patch)
tree1388ebe8ec75c61dbb89ce5b2263e254e44f96eb /src/usr/local
parentc1f1072e147e2b77fc1bbf7d6230267b9d340c83 (diff)
downloadpfsense-84a7e840eac8f62a95ccb900089faf14a9a9fc65.zip
pfsense-84a7e840eac8f62a95ccb900089faf14a9a9fc65.tar.gz
Add filter to Interface Statistics widget
Diffstat (limited to 'src/usr/local')
-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 0dac8cd..cb9fb92 100644
--- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
+++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
@@ -47,13 +47,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>");
@@ -65,6 +68,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") {
@@ -82,6 +89,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;
@@ -91,6 +115,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[
@@ -113,6 +179,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