From e38ba3560b7750edac6d4adfb9108c93785c2998 Mon Sep 17 00:00:00 2001 From: Steve Beaver Date: Fri, 11 Aug 2017 10:24:22 -0400 Subject: Add AJAX version check --- .../widgets/widgets/system_information.widget.php | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src') 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"), ""); + if ($_REQUEST['getupdatestatus']) { require_once("pkg-utils.inc"); @@ -108,6 +111,8 @@ if ($_REQUEST['getupdatestatus']) {
+   +


-
+
@@ -633,9 +638,11 @@ function widgetActive(x) { } } + 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("# [id^=show]", ""); + + + // AJAX function to update the version display with non-cached data + function updver_ajax() { + + // Display the "updating" message + $('[id^=widget-system_information] #updatestatus').html(""); // "); + + $.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){ + } + }); + } }); //]]> -- cgit v1.1