diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-08-08 16:00:38 -0400 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-08-08 16:00:38 -0400 |
commit | 60f485ed7aa2325267da3ee18946c80e171f1bad (patch) | |
tree | 6329f7658c274b320080b4fe2aef86594d3197e5 /src/usr/local/www | |
parent | 53547a05e07294ef32f2db90e456e009058e1ef5 (diff) | |
download | pfsense-60f485ed7aa2325267da3ee18946c80e171f1bad.zip pfsense-60f485ed7aa2325267da3ee18946c80e171f1bad.tar.gz |
interface_statistics widget added to central refresh system
Diffstat (limited to 'src/usr/local/www')
-rw-r--r-- | src/usr/local/www/widgets/widgets/interface_statistics.widget.php | 31 | ||||
-rw-r--r-- | src/usr/local/www/widgets/widgets/interfaces.widget.php | 4 |
2 files changed, 29 insertions, 6 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 32c2365..e0ab840 100644 --- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php +++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php @@ -297,7 +297,7 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); <script type="text/javascript"> //<![CDATA[ - +/* function get_if_stats_<?=$widgetkey_nodash?>() { var ajaxRequest; @@ -315,16 +315,37 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); setTimeout(get_if_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>"); }); } +*/ + events.push(function() { + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ + + // Callback function called by refresh system when data is retrieved + function interface_statistics_callback(s) { + $('#<?=$widgetkey?>-iftbl').html(s); + } + + // POST data to send via AJAX + var postdata = { + ajax : "ajax", + widgetkey :"<?=$widgetkey?>" + }; + + // Create an object defining the widget refresh AJAX call + var ifstatObject = new Object(); + ifstatObject.name = "IFstats"; + ifstatObject.url = "/widgets/widgets/interface_statistics.widget.php"; + ifstatObject.callback = interface_statistics_callback; + ifstatObject.parms = postdata; + + // Register the AJAX object + register_ajax(ifstatObject); - events.push(function(){ + // --------------------------------------------------------------------------------------------------- // Note: This manages all settings checkboxes with id starting with "show" // (i.e. both the interface and stats item selection groups) // using a single All/None button set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); - // 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_<?=$widgetkey_nodash?>, Math.floor((Math.random() * 10000) + 1000)); }); //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php index fdec201..d5d7df6 100644 --- a/src/usr/local/www/widgets/widgets/interfaces.widget.php +++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php @@ -219,7 +219,9 @@ if ($_REQUEST['widgetkey']) { } // POST data to send via AJAX - var postdata = '{"widgetkey":"<?=$widgetkey?>"}'; + var postdata = { + widgetkey :"<?=$widgetkey?>" + }; // Create an object defining the widget refresh AJAX call var interfacesObject = new Object(); |