diff options
author | Steve Beaver <sbeaver@netgate.com> | 2017-08-11 10:24:22 -0400 |
---|---|---|
committer | Steve Beaver <sbeaver@netgate.com> | 2017-08-11 10:24:22 -0400 |
commit | e38ba3560b7750edac6d4adfb9108c93785c2998 (patch) | |
tree | c96ee80c1cdcb55b4afda1941171db69024afd4d /src/usr/local/www/widgets/widgets | |
parent | cbaf07f41d381afaaf076d77680e4c70c1463d78 (diff) | |
download | pfsense-e38ba3560b7750edac6d4adfb9108c93785c2998.zip pfsense-e38ba3560b7750edac6d4adfb9108c93785c2998.tar.gz |
Add AJAX version check
Diffstat (limited to 'src/usr/local/www/widgets/widgets')
-rw-r--r-- | src/usr/local/www/widgets/widgets/system_information.widget.php | 45 |
1 files changed, 44 insertions, 1 deletions
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 27d5ccb..fc2ea29 100644 --- a/src/usr/local/www/widgets/widgets/system_information.widget.php +++ b/src/usr/local/www/widgets/widgets/system_information.widget.php @@ -51,6 +51,9 @@ $sysinfo_items = array( 'disk_usage' => gettext('Disk Usage') ); +// Declared here so that JavaScript cann access it +$updtext = sprintf(gettext("Obtaining update status %s"), "<i class='fa fa-cog fa-spin'></i>"); + if ($_REQUEST['getupdatestatus']) { require_once("pkg-utils.inc"); @@ -108,6 +111,8 @@ if ($_REQUEST['getupdatestatus']) { <div> <?printf("%s %s", gettext("Version information updated at"), date("Y-m-d H:i", filemtime($cache_file)));?> + + <a id="updver" href="#" class="fa fa-refresh"></a> </div> <?php endif; @@ -228,7 +233,7 @@ $rows_displayed = false; <?php endif; ?> <?php if (!isset($config['system']['firmware']['disablecheck'])): ?> <br /><br /> - <div id='updatestatus'><?php echo gettext("Obtaining update status "); ?><i class="fa fa-cog fa-spin"></i></div> + <div id='updatestatus'><?=$updtext?></div> <?php endif; ?> </td> </tr> @@ -633,9 +638,11 @@ function widgetActive(x) { } } + <?php endif; // $widget_first_instance ?> events.push(function(){ + // --------------------- EXPERIMENTAL centralized widget refresh system ------------------------------ // Callback function called by refresh system when data is retrieved @@ -664,6 +671,11 @@ events.push(function(){ // Callback function called by refresh system when data is retrieved function version_callback(s) { $('[id^=widget-system_information] #updatestatus').html(s); + + // The click handler has to be attached after the div is updated + $('#updver').click(function() { + updver_ajax(); + }); } // POST data to send via AJAX @@ -686,6 +698,37 @@ events.push(function(){ // --------------------------------------------------------------------------------------------------- set_widget_checkbox_events("#<?=$widget_panel_footer_id?> [id^=show]", "<?=$widget_showallnone_id?>"); + + + // AJAX function to update the version display with non-cached data + function updver_ajax() { + + // Display the "updating" message + $('[id^=widget-system_information] #updatestatus').html("<?=$updtext?>"); // <?=$updtext?>"); + + $.ajax({ + type: 'POST', + url: "/widgets/widgets/system_information.widget.php", + dataType: 'html', + data: { + ajax: "ajax", + getupdatestatus: "2" + }, + + success: function(data){ + // Display the returned data + $('[id^=widget-system_information] #updatestatus').html(data); + // Re-attach the click handler + + $('#updver').click(function() { + updver_ajax(); + }); + }, + + error: function(e){ + } + }); + } }); //]]> </script> |