summaryrefslogtreecommitdiffstats
path: root/src/usr/local
diff options
context:
space:
mode:
authorSteve Beaver <sbeaver@netgate.com>2017-08-14 17:45:53 -0400
committerSteve Beaver <sbeaver@netgate.com>2017-08-14 17:48:02 -0400
commit8dd64719f16825ed2040a6c57fb80840c2ba012d (patch)
tree731aee978c0e90aa2dea70581c457d73cf9c491f /src/usr/local
parentf704d091e388511728e6f0c1f7b09d0784d58cc6 (diff)
downloadpfsense-8dd64719f16825ed2040a6c57fb80840c2ba012d.zip
pfsense-8dd64719f16825ed2040a6c57fb80840c2ba012d.tar.gz
COmpleted conversion of dashboard widget to ventralized refresh system
(cherry picked from commit fe0eb5b1112791cf28e98e00757c4645d6b9234a)
Diffstat (limited to 'src/usr/local')
-rw-r--r--src/usr/local/www/widgets/widgets/ntp_status.widget.php44
-rw-r--r--src/usr/local/www/widgets/widgets/openvpn.widget.php44
2 files changed, 47 insertions, 41 deletions
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 5914c7d..be4f588 100644
--- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php
+++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php
@@ -259,30 +259,34 @@ setInterval(function() {
<script type="text/javascript">
//<![CDATA[
- function ntp_getstatus() {
- var url = "/widgets/widgets/ntp_status.widget.php";
- var pars = 'updateme=yes';
- $.ajax(
- url,
- {
- type: 'get',
- data: pars,
- complete: ntpstatuscallback
- });
+events.push(function(){
+ // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
+
+ // Callback function called by refresh system when data is retrieved
+ function ntp_callback(s) {
+ $('[id="ntpstatus"]').prop('innerHTML', s);
}
- function ntpstatuscallback(transport) {
- // The server returns formatted html code
- var responseStringNtp = transport.responseText
- $('#ntpstatus').prop('innerHTML',responseStringNtp);
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax",
+ updateme : "yes"
+ };
- // Refresh the status at the configured interval
- setTimeout('ntp_getstatus()', "<?=$widgetperiod?>");
- }
+ // Create an object defining the widget refresh AJAX call
+ var ntpObject = new Object();
+ ntpObject.name = "NTP";
+ ntpObject.url = "/widgets/widgets/ntp_status.widget.php";
+ ntpObject.callback = ntp_callback;
+ ntpObject.parms = postdata;
+ ntpObject.freq = 4;
+
+ // Register the AJAX object
+ register_ajax(ntpObject);
+
+ // ---------------------------------------------------------------------------------------------------
+});
- // 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 35a7865..c106be4 100644
--- a/src/usr/local/www/widgets/widgets/openvpn.widget.php
+++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php
@@ -331,7 +331,7 @@ function printPanel() {
} else {
$none_to_display_text = "";
}
-
+
if (strlen($none_to_display_text) > 0) {
print('<table class="table"><tbody><td class="text-center">' . $none_to_display_text . '</td></tbody></table>');
}
@@ -364,31 +364,33 @@ $widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period
);
}
- // Refresh the panel
- function get_update() {
- var ajaxRequest;
+ events.push(function(){
+ set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallovpns");
+ // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------
- ajaxRequest = $.ajax({
- url: "/widgets/widgets/openvpn.widget.php",
- type: "post",
- data: { ajax: "ajax"}
- });
+ // Callback function called by refresh system when data is retrieved
+ function openvpn_callback(s) {
+ $('#mainpanel').html(s);
+ }
- // Deal with the results of the above ajax call
- ajaxRequest.done(function (response, textStatus, jqXHR) {
- $('#mainpanel').html(response);
+ // POST data to send via AJAX
+ var postdata = {
+ ajax: "ajax",
+ widgetkey: "<?=$widgetkey?>"
+ };
- // and do it again
- setTimeout(get_update, "<?=$widgetperiod?>");
- });
- }
+ // Create an object defining the widget refresh AJAX call
+ var openvpnObject = new Object();
+ openvpnObject.name = "OpenVPN";
+ openvpnObject.url = "/widgets/widgets/openvpn.widget.php";
+ openvpnObject.callback = openvpn_callback;
+ openvpnObject.parms = postdata;
+ openvpnObject.freq = 4;
- events.push(function(){
- set_widget_checkbox_events("#widget-<?=$widgetname?>_panel-footer [id^=show]", "showallovpns");
+ // Register the AJAX object
+ register_ajax(openvpnObject);
- // 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));
+ // ---------------------------------------------------------------------------------------------------
});
//]]>
</script>
OpenPOWER on IntegriCloud