Display live backup and Git telemetry
This commit is contained in:
+36
-3
@@ -41,13 +41,46 @@ function renderServices(targetId, items, disabled = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadConfig()
|
loadConfig()
|
||||||
.then(config => {
|
Promise.all([loadConfig(), loadTelemetry()])
|
||||||
renderStatus(config.status);
|
.then(([config, telemetry]) => {
|
||||||
|
const staticStatus = config.status.filter(
|
||||||
|
item => !['Backups', 'Git'].includes(item.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
renderStatus([
|
||||||
|
...staticStatus,
|
||||||
|
...telemetryStatus(telemetry.systems)
|
||||||
|
]);
|
||||||
|
|
||||||
renderServices('service-grid', config.services);
|
renderServices('service-grid', config.services);
|
||||||
renderServices('home-grid', config.home, true);
|
renderServices('home-grid', config.home, true);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
document.getElementById('status-grid').innerHTML =
|
document.getElementById('status-grid').innerHTML =
|
||||||
'<article class="status-card"><div class="status-name">Configuration</div><div class="status-value">Unavailable</div><div class="status-detail">Could not load services.json</div></article>';
|
'<article class="status-card"><div class="status-name">Telemetry</div><div class="status-value">Unavailable</div><div class="status-detail">Could not load Voyager data</div></article>';
|
||||||
});
|
});
|
||||||
|
async function loadTelemetry() {
|
||||||
|
const response = await fetch('data/status.json', { cache: 'no-store' });
|
||||||
|
if (!response.ok) throw new Error(`Telemetry load failed: ${response.status}`);
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
|
||||||
|
function telemetryStatus(systems) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: 'Backups',
|
||||||
|
state: systems.backup.state,
|
||||||
|
label: systems.backup.summary,
|
||||||
|
value: systems.backup.detail,
|
||||||
|
detail: 'Restic backup repository'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Git',
|
||||||
|
state: systems.git.state,
|
||||||
|
label: systems.git.state === 'online' ? 'Healthy' : 'Attention',
|
||||||
|
value: systems.git.detail,
|
||||||
|
detail: systems.git.summary
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user