Fix version display with direct package.json reading
- Added direct package.json file reading instead of require caching - Enhanced system status endpoint to always return current version - Added manual refresh button to floating notification - Implemented aggressive cache-busting for all version checks - Added double-check system status after update completion - Added detailed logging for version retrieval for debugging - Improved error handling for package.json reading - Added immediate user feedback for refresh operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -724,7 +724,10 @@
|
||||
<div id="floating-update-notification">
|
||||
<div>Update Available!</div>
|
||||
<div id="floating-update-version">New version available</div>
|
||||
<button id="floating-update-button">Update Now</button>
|
||||
<div class="button-container">
|
||||
<button id="floating-update-button">Update Now</button>
|
||||
<button id="floating-refresh-button" style="background-color: #4CAF50; margin-left: 10px;">Refresh Status</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- JavaScript Files -->
|
||||
|
||||
@@ -275,6 +275,9 @@ function initSystemStatus() {
|
||||
// No update available
|
||||
updateStatusElement.innerHTML = '<i class="fas fa-check-circle text-success"></i> Up to date';
|
||||
hideUpdateAlert();
|
||||
|
||||
// Force reload system status to ensure version is current
|
||||
setTimeout(() => loadSystemStatus(), 1000);
|
||||
}
|
||||
} else {
|
||||
// Error status but with a response
|
||||
@@ -405,6 +408,12 @@ function initSystemStatus() {
|
||||
|
||||
// Update page to show current version without reloading
|
||||
loadSystemStatus();
|
||||
|
||||
// Double-check system status again after a delay to ensure version is updated
|
||||
setTimeout(() => {
|
||||
loadSystemStatus();
|
||||
checkForUpdates(); // Run check again to update status text
|
||||
}, 2000);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -516,6 +525,48 @@ function initSystemStatus() {
|
||||
updateButton.addEventListener('click', applyUpdate);
|
||||
}
|
||||
|
||||
// Add handler for floating refresh button
|
||||
const floatingRefreshButton = document.getElementById('floating-refresh-button');
|
||||
if (floatingRefreshButton) {
|
||||
floatingRefreshButton.addEventListener('click', () => {
|
||||
// Force a hard refresh of everything
|
||||
floatingRefreshButton.textContent = 'Refreshing...';
|
||||
floatingRefreshButton.disabled = true;
|
||||
|
||||
// Force reload system status
|
||||
loadSystemStatus();
|
||||
|
||||
// Force a check without the test parameter to get real status
|
||||
const realCheckUrl = `/api/system/check-updates?_=${new Date().getTime()}`;
|
||||
fetch(realCheckUrl, { headers: authHeaders() })
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log('Manual refresh result:', data);
|
||||
|
||||
if (data.status === 'success') {
|
||||
// Show notification about current status
|
||||
if (data.data && data.data.updateAvailable) {
|
||||
showUpdateAlert(data.data.currentVersion, data.data.remoteVersion);
|
||||
showNotification(`Update is available: ${data.data.currentVersion} → ${data.data.remoteVersion}`, 'info');
|
||||
} else {
|
||||
hideUpdateAlert();
|
||||
showNotification(`Current version: ${data.data.currentVersion}. You are up to date.`, 'success');
|
||||
}
|
||||
}
|
||||
|
||||
// Re-enable button
|
||||
floatingRefreshButton.textContent = 'Refresh Status';
|
||||
floatingRefreshButton.disabled = false;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error during manual refresh:', error);
|
||||
floatingRefreshButton.textContent = 'Refresh Status';
|
||||
floatingRefreshButton.disabled = false;
|
||||
showNotification('Error checking update status', 'danger');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Test mode toggle (for developers)
|
||||
const testToggle = document.getElementById('toggle-test-update-button');
|
||||
if (testToggle) {
|
||||
|
||||
Reference in New Issue
Block a user