summaryrefslogtreecommitdiffstats
path: root/src/usr/local/www/widgets
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2016-08-18 11:41:19 -0400
committerStephen Beaver <sbeaver@netgate.com>2016-08-18 11:44:25 -0400
commitc1f9ca7a73c562145f777b850bf3f4000f938c14 (patch)
tree113d57343b82f41c05166508bd1b416b68d5fe0b /src/usr/local/www/widgets
parent3d0a77036ce363e369aa360bb55c47cad2ccb2a5 (diff)
downloadpfsense-c1f9ca7a73c562145f777b850bf3f4000f938c14.zip
pfsense-c1f9ca7a73c562145f777b850bf3f4000f938c14.tar.gz
Added control to set dashboard widget refresh period
Start each widget refresh system after a short random delay to prevent all widgets hitting the server at the exactsame time Fix issues wherein two widgets were resetting the refresh timer from the AJAX call, not the call-back function, thereby risking stepping on themselves (cherry picked from commit 512f2c10af716243046bdd08140856bb8e45222b)
Diffstat (limited to 'src/usr/local/www/widgets')
-rw-r--r--src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/gateways.widget.php8
-rw-r--r--src/usr/local/www/widgets/widgets/installed_packages.widget.php3
-rw-r--r--src/usr/local/www/widgets/widgets/interface_statistics.widget.php8
-rw-r--r--src/usr/local/www/widgets/widgets/ipsec.widget.php7
-rw-r--r--src/usr/local/www/widgets/widgets/ntp_status.widget.php16
-rw-r--r--src/usr/local/www/widgets/widgets/openvpn.widget.php6
-rw-r--r--src/usr/local/www/widgets/widgets/system_information.widget.php14
8 files changed, 46 insertions, 22 deletions
diff --git a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
index d9642c6..5a37cac 100644
--- a/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/dyn_dns_status.widget.php
@@ -198,8 +198,7 @@ if ($_REQUEST['getdyndnsstatus']) {
data: pars,
complete: dyndnscallback
});
- // Refresh the status every 5 minutes
- setTimeout('dyndns_getstatus()', 5*60*1000);
+
}
function dyndnscallback(transport) {
// The server returns a string of statuses separated by vertical bars
@@ -208,6 +207,9 @@ if ($_REQUEST['getdyndnsstatus']) {
var divlabel = '#dyndnsstatus' + count;
$(divlabel).prop('innerHTML',responseStrings[count]);
}
+
+ // Refresh the status every 5 minutes
+ setTimeout('dyndns_getstatus()', 5*60*1000);
}
// Do the first status check 2 seconds after the dashboard opens
setTimeout('dyndns_getstatus()', 2000);
diff --git a/src/usr/local/www/widgets/widgets/gateways.widget.php b/src/usr/local/www/widgets/widgets/gateways.widget.php
index ecd238b..d57cfdc 100644
--- a/src/usr/local/www/widgets/widgets/gateways.widget.php
+++ b/src/usr/local/www/widgets/widgets/gateways.widget.php
@@ -80,6 +80,8 @@ if ($_POST) {
header("Location: /");
exit(0);
}
+
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
?>
<div class="table-responsive">
@@ -165,12 +167,14 @@ if ($_POST) {
ajaxRequest.done(function (response, textStatus, jqXHR) {
$('#gwtblbody').html(response);
// and do it again
- setTimeout(get_gw_stats, 5000);
+ setTimeout(get_gw_stats, "<?=$widgetperiod?>");
});
}
events.push(function(){
- get_gw_stats();
+ // 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_gw_stats, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/installed_packages.widget.php b/src/usr/local/www/widgets/widgets/installed_packages.widget.php
index 7444d57..0069019 100644
--- a/src/usr/local/www/widgets/widgets/installed_packages.widget.php
+++ b/src/usr/local/www/widgets/widgets/installed_packages.widget.php
@@ -195,7 +195,8 @@ if ($_REQUEST && $_REQUEST['ajax']) {
$('#pkgtbl').html(response);
// and do it again
- setTimeout(get_pkg_stats, 5000);
+ // NOT! There is no need to refresh this widget
+ // setTimeout(get_pkg_stats, 5000);
});
}
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 569071d..ff35a81 100644
--- a/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
+++ b/src/usr/local/www/widgets/widgets/interface_statistics.widget.php
@@ -116,6 +116,8 @@ if ($_REQUEST && $_REQUEST['ajax']) {
exit;
}
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+
?>
<table id="iftbl" class="table table-striped table-hover">
<tr><td><?=gettext("Retrieving interface data")?></td></tr>
@@ -138,12 +140,14 @@ if ($_REQUEST && $_REQUEST['ajax']) {
$('#iftbl').html(response);
// and do it again
- setTimeout(get_if_stats, 5000);
+ setTimeout(get_if_stats, "<?=$widgetperiod?>");
});
}
events.push(function(){
- get_if_stats();
+ // 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));
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/ipsec.widget.php b/src/usr/local/www/widgets/widgets/ipsec.widget.php
index 49589e9..bc66c61 100644
--- a/src/usr/local/www/widgets/widgets/ipsec.widget.php
+++ b/src/usr/local/www/widgets/widgets/ipsec.widget.php
@@ -212,6 +212,7 @@ if (isset($config['ipsec']['phase1'])) {
}
$mobile = ipsec_dump_mobile();
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
if (isset($config['ipsec']['phase2'])): ?>
<div id="ipsec-Overview" style="display:block;" class="table-responsive">
@@ -337,12 +338,14 @@ function get_ipsec_stats() {
$('tbody', '#ipsec-' + curtab).html(response);
// and do it again
- setTimeout(get_ipsec_stats, 6000);
+ setTimeout(get_ipsec_stats, "<?=$widgetperiod?>");
});
}
events.push(function(){
- get_ipsec_stats();
+ // 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_ipsec_stats, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/ntp_status.widget.php b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
index 99d6342..1bc9279 100644
--- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
@@ -71,6 +71,10 @@ function clockTimeString($inDate, $showSeconds) {
return date($showSeconds ? 'G:i:s' : 'g:i', $inDate) . ' ';
}
+// For this widget the update period is 6 x larger than most others. It typically defaults
+// to once per 60 seconds, not once per 10 seconds
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+
if ($_REQUEST['updateme']) {
//this block displays only on ajax refresh
if (isset($config['system']['ipv6allow'])) {
@@ -506,16 +510,20 @@ clockUpdate();
data: pars,
complete: ntpstatuscallback
});
- // Refresh the status every 1 minute
- setTimeout('ntp_getstatus()', 1*60*1000);
}
function ntpstatuscallback(transport) {
// The server returns formatted html code
var responseStringNtp = transport.responseText
$('#ntpstatus').prop('innerHTML',responseStringNtp);
+
+ // Refresh the status at the configured interval
+ setTimeout('ntp_getstatus()', "<?=$widgetperiod?>");
}
- // Do the first status check 1 second after the dashboard opens
- setTimeout('ntp_getstatus()', 1000);
+
+ // 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(ntp_getstatus, Math.floor((Math.random() * 10000) + 1000));
+
//]]>
</script>
diff --git a/src/usr/local/www/widgets/widgets/openvpn.widget.php b/src/usr/local/www/widgets/widgets/openvpn.widget.php
index 554425c..f08125a 100644
--- a/src/usr/local/www/widgets/widgets/openvpn.widget.php
+++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php
@@ -265,6 +265,8 @@ function printPanel() {
}
}
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+
?>
<script type="text/javascript">
@@ -305,14 +307,14 @@ function printPanel() {
$('#mainpanel').html(response);
// and do it again
- setTimeout(get_update, 5000);
+ setTimeout(get_update, "<?=$widgetperiod?>");
});
}
events.push(function(){
// 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_update, Math.floor((Math.random() * 10000) + 1000));
+ setTimeout(get_update, Math.floor((Math.random() * 10000) + 1000));
});
//]]>
</script>
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 290a4a5..b451af0 100644
--- a/src/usr/local/www/widgets/widgets/system_information.widget.php
+++ b/src/usr/local/www/widgets/widgets/system_information.widget.php
@@ -109,6 +109,12 @@ if ($_REQUEST['getupdatestatus']) {
exit;
}
+/* Adding one second to the system widet update period
+ * will ensure that we update the GUI right after the stats are updated.
+ */
+$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
+$widgetperiod += 1000;
+
$filesystems = get_mounted_filesystems();
?>
@@ -352,13 +358,7 @@ events.push(function(){
});
<?php endif; ?>
-/* Most widgets update their backend data every 10 seconds. 11 seconds
- * will ensure that we update the GUI right after the stats are updated.
- * Seconds * 1000 = value
- */
-
-var Seconds = 11;
-var update_interval = (Math.abs(Math.ceil(Seconds))-1)*1000 + 990;
+var update_interval = "<?=$widgetperiod?>";
function setProgress(barName, percent) {
$('#' + barName).css('width', percent + '%').attr('aria-valuenow', percent);
OpenPOWER on IntegriCloud