summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteve Beaver <sbeaver@netgate.com>2017-08-09 10:50:19 -0400
committerSteve Beaver <sbeaver@netgate.com>2017-08-09 10:50:19 -0400
commit67dd6c11a4668673c0daac09bacf58685b80f1bf (patch)
treed6710a2f688d2279292d76e49c9b2ecc769241a1 /src
parentec922197ed92e3dc0e15ab4d6ba340015f46bf43 (diff)
downloadpfsense-67dd6c11a4668673c0daac09bacf58685b80f1bf.zip
pfsense-67dd6c11a4668673c0daac09bacf58685b80f1bf.tar.gz
dd system information widget to central refresh system
Add ability for a widget to specify how often it wants to be updated
Diffstat (limited to 'src')
-rw-r--r--src/usr/local/www/index.php16
-rw-r--r--src/usr/local/www/widgets/widgets/interface_statistics.widget.php1
-rw-r--r--src/usr/local/www/widgets/widgets/interfaces.widget.php1
-rw-r--r--src/usr/local/www/widgets/widgets/ipsec.widget.php1
-rw-r--r--src/usr/local/www/widgets/widgets/system_information.widget.php94
5 files changed, 70 insertions, 43 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php
index e14f2a3..8a1b997 100644
--- a/src/usr/local/www/index.php
+++ b/src/usr/local/www/index.php
@@ -572,6 +572,7 @@ function set_widget_checkbox_events(checkbox_panel_ref, all_none_button_id) {
var ajaxspecs = new Array(); // Array to hold widget refresh specifications (objects )
var ajaxidx = 0;
var ajaxmutex = false;
+var ajaxcntr = 0;
// Add a widget refresh object to the array list
function register_ajax(ws) {
@@ -661,9 +662,20 @@ events.push(function() {
// results back to the widget's callback function
function executewidget() {
if (ajaxspecs.length > 0) {
+ var freq = ajaxspecs[ajaxidx].freq; // widget can specifify it should be called freq times around hte loop
+
if (!ajaxmutex) {
- make_ajax_call(ajaxspecs[ajaxidx]);
- ajaxidx = ++ajaxidx % ajaxspecs.length;
+ if ((ajaxcntr % freq) === 0) {
+ make_ajax_call(ajaxspecs[ajaxidx]);
+ }
+
+ if (++ajaxidx >= ajaxspecs.length) {
+ ajaxidx = 0;
+
+ if (++ajaxcntr >= 4096) {
+ ajaxcntr = 0;
+ }
+ }
}
setTimeout(function() { executewidget(); }, 2000);
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 e0ab840..43e20b3 100644
--- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
+++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
@@ -336,6 +336,7 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey);
ifstatObject.url = "/widgets/widgets/interface_statistics.widget.php";
ifstatObject.callback = interface_statistics_callback;
ifstatObject.parms = postdata;
+ ifstatObject.freq = 1;
// Register the AJAX object
register_ajax(ifstatObject);
diff --git a/src/usr/local/www/widgets/widgets/interfaces.widget.php b/src/usr/local/www/widgets/widgets/interfaces.widget.php
index 705e4d3..06f5841 100644
--- a/src/usr/local/www/widgets/widgets/interfaces.widget.php
+++ b/src/usr/local/www/widgets/widgets/interfaces.widget.php
@@ -230,6 +230,7 @@ if ($_REQUEST['ajax']) {
interfacesObject.url = "/widgets/widgets/interfaces.widget.php";
interfacesObject.callback = interfaces_callback;
interfacesObject.parms = postdata;
+ interfacesObject.freq = 1;
// Register the AJAX object
register_ajax(interfacesObject);
diff --git a/src/usr/local/www/widgets/widgets/ipsec.widget.php b/src/usr/local/www/widgets/widgets/ipsec.widget.php
index e1d86a5..4ffeb3d 100644
--- a/src/usr/local/www/widgets/widgets/ipsec.widget.php
+++ b/src/usr/local/www/widgets/widgets/ipsec.widget.php
@@ -311,6 +311,7 @@ events.push(function(){
ipsecObject.url = "/widgets/widgets/ipsec.widget.php";
ipsecObject.callback = ipsec_callback;
ipsecObject.parms = postdata;
+ ipsecObject.freq = 1;
// Register the AJAX object
register_ajax(ipsecObject);
diff --git a/src/usr/local/www/widgets/widgets/system_information.widget.php b/src/usr/local/www/widgets/widgets/system_information.widget.php
index 2109d3e..354f66c 100644
--- a/src/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/src/usr/local/www/widgets/widgets/system_information.widget.php
@@ -492,43 +492,6 @@ $rows_displayed = false;
<script type="text/javascript">
//<![CDATA[
<?php if ($widget_first_instance): ?>
-<?php if (!isset($config['system']['firmware']['disablecheck'])): ?>
-function systemStatusGetUpdateStatus() {
- $.ajax({
- type: 'get',
- url: '/widgets/widgets/system_information.widget.php',
- data: 'getupdatestatus=1',
- dataFilter: function(raw){
- // We reload the entire widget, strip this block of javascript from it
- return raw.replace(/<script>([\s\S]*)<\/script>/gi, '');
- },
- dataType: 'html',
- success: function(data){
- $('[id^=widget-system_information] #updatestatus').html(data);
- }
- });
-}
-
-setTimeout('systemStatusGetUpdateStatus()', 4000);
-<?php endif; ?>
-var updateMeters_running = false;
-function updateMeters() {
- if (updateMeters_running) {
- return;
- }
- updateMeters_running = true;
- url = '/getstats.php';
-
- $.ajax(url, {
- type: 'get',
- success: function(data) {
- response = data || "";
- if (response != "")
- stats(data);
- updateMeters_running = false;
- }
- });
-}
var update_interval = "<?=$widgetperiod?>";
@@ -654,13 +617,62 @@ function widgetActive(x) {
}
}
-/* start updater */
-events.push(function(){
- timeout = window.setInterval(updateMeters, update_interval);
-});
<?php endif; // $widget_first_instance ?>
+
events.push(function(){
+ // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
+
+ // Callback function called by refresh system when data is retrieved
+ function meters_callback(s) {
+ stats(s);
+ }
+
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax"
+ };
+
+ // Create an object defining the widget refresh AJAX call
+ var metersObject = new Object();
+ metersObject.name = "Meters";
+ metersObject.url = "/getstats.php";
+ metersObject.callback = meters_callback;
+ metersObject.parms = postdata;
+ metersObject.freq = 1;
+
+ // Register the AJAX object
+ register_ajax(metersObject);
+
+<?php if (!isset($config['system']['firmware']['disablecheck'])): ?>
+
+ // Callback function called by refresh system when data is retrieved
+ function version_callback(s) {
+ $('[id^=widget-system_information] #updatestatus').html(s);
+ }
+
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax",
+ getupdatestatus: "1"
+ };
+
+ // Create an object defining the widget refresh AJAX call
+ var versionObject = new Object();
+ versionObject.name = "Version";
+ versionObject.url = "/widgets/widgets/system_information.widget.php";
+ versionObject.callback = version_callback;
+ versionObject.parms = postdata;
+ versionObject.freq = 10;
+
+ // Register the AJAX object
+ register_ajax(versionObject);
+<?php endif; ?>
+ // ---------------------------------------------------------------------------------------------------
+
set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>");
});
//]]>
</script>
+
+
+
OpenPOWER on IntegriCloud