diff --git a/public/js/system-status.js b/public/js/system-status.js
index f8a1aaa..afd2079 100644
--- a/public/js/system-status.js
+++ b/public/js/system-status.js
@@ -304,15 +304,36 @@ function initSystemStatus() {
return;
}
- // Show loading state
- updateButton.disabled = true;
- updateButton.innerHTML = ' Updating...';
+ // Show loading state on both update buttons
+ // Original button
+ if (updateButton) {
+ updateButton.disabled = true;
+ updateButton.innerHTML = ' Updating...';
+ }
+
+ // Floating notification button
+ const floatingButton = document.getElementById('floating-update-button');
+ if (floatingButton) {
+ floatingButton.disabled = true;
+ floatingButton.textContent = 'Updating...';
+ }
+
showNotification('Applying update. Please wait...', 'info');
// Set a timeout for the update process
const updateTimeoutId = setTimeout(() => {
- updateButton.disabled = false;
- updateButton.innerHTML = ' Update Now';
+ // Re-enable original button
+ if (updateButton) {
+ updateButton.disabled = false;
+ updateButton.innerHTML = ' Update Now';
+ }
+
+ // Re-enable floating button
+ if (floatingButton) {
+ floatingButton.disabled = false;
+ floatingButton.textContent = 'Update Now';
+ }
+
showNotification('Update process timed out. Please try again or check server logs.', 'warning');
}, 60000); // 60 second timeout for the entire update process
@@ -354,38 +375,93 @@ function initSystemStatus() {
clearTimeout(updateTimeoutId);
if (data.status === 'success') {
+ // Hide update notification immediately after successful update
+ hideUpdateAlert();
+
+ // Show success notification
showNotification('Update applied successfully. The page will reload in 30 seconds.', 'success');
- // Show a countdown to reload
+ // Update both buttons with countdown
let secondsLeft = 30;
- updateButton.innerHTML = ` Reloading in ${secondsLeft}s...`;
+ // Function to update the countdown text
+ function updateCountdown() {
+ // Update original button if it exists
+ if (updateButton) {
+ updateButton.innerHTML = ` Reloading in ${secondsLeft}s...`;
+ }
+
+ // Update floating button if it exists
+ const floatingButton = document.getElementById('floating-update-button');
+ if (floatingButton) {
+ floatingButton.textContent = `Reloading in ${secondsLeft}s...`;
+ }
+ }
+
+ // Initial text update
+ updateCountdown();
+
+ // Start countdown
const countdownInterval = setInterval(() => {
secondsLeft--;
- updateButton.innerHTML = ` Reloading in ${secondsLeft}s...`;
+ updateCountdown();
if (secondsLeft <= 0) {
clearInterval(countdownInterval);
- window.location.reload();
+
+ // Clear localStorage to ensure a clean reload
+ localStorage.removeItem(UPDATE_KEY);
+ localStorage.removeItem(CURRENT_VERSION_KEY);
+ localStorage.removeItem(REMOTE_VERSION_KEY);
+
+ // Force a clean reload
+ window.location.href = window.location.href.split('#')[0];
}
}, 1000);
// Set a timer to reload the page after the service has time to restart
setTimeout(() => {
clearInterval(countdownInterval);
- window.location.reload();
+
+ // Clear localStorage to ensure a clean reload
+ localStorage.removeItem(UPDATE_KEY);
+ localStorage.removeItem(CURRENT_VERSION_KEY);
+ localStorage.removeItem(REMOTE_VERSION_KEY);
+
+ // Force a clean reload
+ window.location.href = window.location.href.split('#')[0];
}, 30000);
} else {
- updateButton.disabled = false;
- updateButton.innerHTML = ' Update Now';
+ // Enable both buttons on failure
+ if (updateButton) {
+ updateButton.disabled = false;
+ updateButton.innerHTML = ' Update Now';
+ }
+
+ const floatingButton = document.getElementById('floating-update-button');
+ if (floatingButton) {
+ floatingButton.disabled = false;
+ floatingButton.textContent = 'Update Now';
+ }
+
showNotification(data.message || 'Failed to apply update', 'danger');
}
})
.catch(error => {
clearTimeout(updateTimeoutId);
console.error('Error applying update:', error);
- updateButton.disabled = false;
- updateButton.innerHTML = ' Update Now';
+
+ // Re-enable both buttons on error
+ if (updateButton) {
+ updateButton.disabled = false;
+ updateButton.innerHTML = ' Update Now';
+ }
+
+ const floatingButton = document.getElementById('floating-update-button');
+ if (floatingButton) {
+ floatingButton.disabled = false;
+ floatingButton.textContent = 'Update Now';
+ }
// More specific error message based on the error type
if (error.name === 'AbortError') {