UI: Add git commit hash and age to status bar

This commit is contained in:
2025-12-24 00:03:24 +11:00
parent e4848a6e56
commit 9f3a914d0f
4 changed files with 92 additions and 1 deletions

View File

@@ -13,7 +13,12 @@ class DatabaseStatusMonitor {
detailsPanel: document.getElementById('dbStatusDetails'),
errorBanner: document.getElementById('sqlErrorBanner'),
errorMessage: document.getElementById('sqlErrorMessage'),
errorDetails: document.getElementById('sqlErrorDetails')
errorDetails: document.getElementById('sqlErrorDetails'),
version: {
container: document.getElementById('gitVersion'),
hash: document.getElementById('commitHash'),
age: document.getElementById('commitAge')
}
};
this.logs = [];
this.maxLogs = 50;
@@ -289,10 +294,37 @@ class DatabaseStatusMonitor {
}
}
async fetchVersion() {
try {
const response = await fetch('/api/version');
const data = await response.json();
if (data.hash && this.elements.version.container) {
this.elements.version.container.style.display = 'flex';
this.elements.version.hash.textContent = data.hash;
// Calculate age
const now = Math.floor(Date.now() / 1000);
const diff = now - data.timestamp;
let ageText = '';
if (diff < 60) ageText = 'just now';
else if (diff < 3600) ageText = `${Math.floor(diff / 60)}m ago`;
else if (diff < 86400) ageText = `${Math.floor(diff / 3600)}h ago`;
else ageText = `${Math.floor(diff / 86400)}d ago`;
this.elements.version.age.textContent = ageText;
}
} catch (e) {
console.warn('Failed to fetch version:', e);
}
}
start() {
// Initial check
this.addLog('Database status monitor started', 'success');
this.checkStatus();
this.fetchVersion();
// Set up periodic checks
this.intervalId = setInterval(() => {