summaryrefslogtreecommitdiffstats
path: root/src/usr/local
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2017-03-21 00:21:36 +0545
committerPhil Davis <phil.davis@inf.org>2017-03-21 00:21:36 +0545
commit9f48e7200b6e2dcb09be3361ac48eba5f6bd3195 (patch)
tree473ab95b871865fd8e2c3ef2739ec0c91ab220ad /src/usr/local
parent65ff7b82d2cda65b184b2d57ac986157543bc4d3 (diff)
downloadpfsense-9f48e7200b6e2dcb09be3361ac48eba5f6bd3195.zip
pfsense-9f48e7200b6e2dcb09be3361ac48eba5f6bd3195.tar.gz
Integrate new interfaces widget AJAX
Diffstat (limited to 'src/usr/local')
-rw-r--r--src/usr/local/www/widgets/widgets/interfaces.widget.php33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php
index dcaf247..0528402 100644
--- a/src/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -49,14 +49,21 @@ if ($_POST['widgetkey']) {
header("Location: /index.php");
}
+// When this widget is included in the dashboard, $widgetkey is already defined before the widget is included.
+// When the ajax call is made to refresh the interfaces table, 'widgetkey' comes in $_REQUEST.
+if ($_REQUEST['widgetkey']) {
+ $widgetkey = $_REQUEST['widgetkey'];
+}
+
?>
-<div class="table-responsive" id="ifaces_status">
+<div class="table-responsive" id="ifaces_status_<?=$widgetkey?>">
<table class="table table-striped table-hover table-condensed">
<tbody>
<?php
$skipinterfaces = explode(",", $user_settings['widgets'][$widgetkey]['iffilter']);
+$widgetkey_nodash = str_replace("-", "", $widgetkey);
$interface_is_displayed = false;
foreach ($ifdescrs as $ifdescr => $ifname):
@@ -189,36 +196,38 @@ endif;
</div>
</form>
-<script>
-//<![CDATA[
- events.push(function(){
- set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
- });
-//]]>
-</script>
+<?php
+
+/* for AJAX response, we only need the panels */
+if ($_REQUEST['widgetkey']) {
+ exit;
+}
+?>
<script type="text/javascript">
//<![CDATA[
-function getstatus_ifaces() {
+function getstatus_ifaces_<?=$widgetkey_nodash?>() {
$.ajax({
type: 'get',
url: '/widgets/widgets/interfaces.widget.php',
dataType: 'html',
+ data: { widgetkey: "<?=$widgetkey?>" },
dataFilter: function(raw){
// We reload the entire widget, strip this block of javascript from it
return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
},
success: function(data){
- $('#ifaces_status').html(data);
+ $('#ifaces_status_<?=$widgetkey?>').html(data);
},
error: function(){
- $('#ifaces_status').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
+ $('#ifaces_status_<?=$widgetkey?>').html("<div class=\"alert alert-danger\"><?=gettext('Unable to retrieve status'); ?></div>");
}
});
}
events.push(function(){
- setInterval('getstatus_ifaces()', "<?=$widgetperiod?>");
+ set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
+ setInterval('getstatus_ifaces_<?=$widgetkey_nodash?>()', "<?=$widgetperiod?>");
});
//]]>
</script>
OpenPOWER on IntegriCloud