diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-08-09 11:41:40 -0400 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-08-09 11:41:40 -0400 |
commit | 8bf4cf1f1445f9ec71e0cdc7489c520c40451904 (patch) | |
tree | 60e59dd781e72c98675bde75be0006d69bb77797 /src | |
parent | 634bb06a8de4f807f932dd163cf4596b0a5cf156 (diff) | |
download | pfsense-8bf4cf1f1445f9ec71e0cdc7489c520c40451904.zip pfsense-8bf4cf1f1445f9ec71e0cdc7489c520c40451904.tar.gz |
gateway, ntp, and openVPN widgets updated
Diffstat (limited to 'src')
5 files changed, 76 insertions, 65 deletions
diff --git a/src/usr/local/www/index.php b/src/usr/local/www/index.php index 8a1b997..9620965 100644 --- a/src/usr/local/www/index.php +++ b/src/usr/local/www/index.php @@ -652,7 +652,7 @@ events.push(function() { }, error: function(e){ - alert("Error: " + e) +// alert("Error: " + e); ajaxmutex = false; } }); @@ -678,7 +678,7 @@ events.push(function() { } } - setTimeout(function() { executewidget(); }, 2000); + setTimeout(function() { executewidget(); }, 1000); } } diff --git a/src/usr/local/www/widgets/widgets/gateways.widget.php b/src/usr/local/www/widgets/widgets/gateways.widget.php index f4b2c6a..0707e2c 100644 --- a/src/usr/local/www/widgets/widgets/gateways.widget.php +++ b/src/usr/local/www/widgets/widgets/gateways.widget.php @@ -305,29 +305,33 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); <script> //<![CDATA[ - function get_gw_stats_<?=$widgetkey_nodash?>() { - var ajaxRequest; - - ajaxRequest = $.ajax({ - url: "/widgets/widgets/gateways.widget.php", - type: "post", - data: { ajax: "ajax", widgetkey: "<?=$widgetkey?>"} - }); - - // Deal with the results of the above ajax call - ajaxRequest.done(function (response, textStatus, jqXHR) { - $('#<?=$widgetkey?>-gwtblbody').html(response); - // and do it again - setTimeout(get_gw_stats_<?=$widgetkey_nodash?>, "<?=$widgetperiod?>"); - }); +events.push(function(){ + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ + + // Callback function called by refresh system when data is retrieved + function gateways_callback(s) { + $('#<?=$widgetkey?>-gwtblbody').html(s); } - events.push(function(){ - set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); + // POST data to send via AJAX + var postdata = { + ajax: "ajax", + widgetkey : "<?=$widgetkey?>" + }; + + // Create an object defining the widget refresh AJAX call + var gatewaysObject = new Object(); + gatewaysObject.name = "Gateways"; + gatewaysObject.url = "/widgets/widgets/gateways.widget.php"; + gatewaysObject.callback = gateways_callback; + gatewaysObject.parms = postdata; + gatewaysObject.freq = 1; + + // Register the AJAX object + register_ajax(gatewaysObject); + + // --------------------------------------------------------------------------------------------------- +}); - // 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_<?=$widgetkey_nodash?>, 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 9f0e964..4be7074 100644 --- a/src/usr/local/www/widgets/widgets/ntp_status.widget.php +++ b/src/usr/local/www/widgets/widgets/ntp_status.widget.php @@ -227,30 +227,34 @@ setInterval(function() { <?php if ($widget_first_instance): ?> <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 - }); - } - function ntpstatuscallback(transport) { - // The server returns formatted html code - var responseStringNtp = transport.responseText - $('[id="ntpstatus"]').prop('innerHTML',responseStringNtp); +events.push(function(){ + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ - // Refresh the status at the configured interval - setTimeout('ntp_getstatus()', "<?=$widgetperiod?>"); + // Callback function called by refresh system when data is retrieved + function ntp_callback(s) { + $('[id="ntpstatus"]').prop('innerHTML', s); } - // 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)); + // POST data to send via AJAX + var postdata = { + ajax: "ajax", + updateme : "yes" + }; + + // 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); + + // --------------------------------------------------------------------------------------------------- +}); //]]> </script> diff --git a/src/usr/local/www/widgets/widgets/openvpn.widget.php b/src/usr/local/www/widgets/widgets/openvpn.widget.php index 9879744..d006269 100644 --- a/src/usr/local/www/widgets/widgets/openvpn.widget.php +++ b/src/usr/local/www/widgets/widgets/openvpn.widget.php @@ -264,7 +264,7 @@ if (!function_exists('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>'); } @@ -415,31 +415,34 @@ $widgetkey_nodash = str_replace("-", "", $widgetkey); ); } - // Refresh the panel - function get_openvpn_update_<?=$widgetkey_nodash?>() { - var ajaxRequest; + events.push(function(){ + set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); + + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ - ajaxRequest = $.ajax({ - url: "/widgets/widgets/openvpn.widget.php", - type: "post", - data: { ajax: "ajax", widgetkey: "<?=$widgetkey?>"} - }); + // Callback function called by refresh system when data is retrieved + function openvpn_callback(s) { + $('#<?=$widgetkey?>-openvpn-mainpanel').html(s); + } - // Deal with the results of the above ajax call - ajaxRequest.done(function (response, textStatus, jqXHR) { - $('#<?=$widgetkey?>-openvpn-mainpanel').html(response); + // POST data to send via AJAX + var postdata = { + ajax: "ajax", + widgetkey: "<?=$widgetkey?>" + }; - // and do it again - setTimeout(get_openvpn_update_<?=$widgetkey_nodash?>, "<?=$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_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); + // 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_openvpn_update_<?=$widgetkey_nodash?>, 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 354f66c..a737496 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -662,7 +662,7 @@ events.push(function(){ versionObject.url = "/widgets/widgets/system_information.widget.php"; versionObject.callback = version_callback; versionObject.parms = postdata; - versionObject.freq = 10; + versionObject.freq = 100; // Register the AJAX object register_ajax(versionObject); |