feat: live system metrics (CPU, RAM, Disk, GPU, Temp)

This commit is contained in:
Hitonabi
2026-06-20 21:19:58 +02:00
parent 6c0ba255fe
commit 08eab95178
6 changed files with 125 additions and 4 deletions
+13
View File
@@ -13,6 +13,7 @@ import jobs from "./panels/jobs.js";
const panels = [overview, models, maintenance, jobs];
let lastJobs = [];
let lastSystem = null;
// ---- Topbar / Alert aus dem Status ableiten ----
function applyStatus(s) {
@@ -40,6 +41,11 @@ function applyJobs(jobs) {
for (const p of panels) p.onJobs?.(lastJobs);
}
function applySystem(sys) {
lastSystem = sys;
for (const p of panels) p.onSystem?.(sys);
}
function showAlert(html, warn) {
const a = $("#alert");
a.className = "alert" + (warn ? " warn" : "");
@@ -58,6 +64,11 @@ async function pollJobs() {
catch { /* still */ }
}
async function pollSystem() {
try { applySystem(await api("/api/system/status")); }
catch { /* still */ }
}
// ---- Boot ----
function bootToken() {
const i = $("#token");
@@ -76,6 +87,8 @@ document.addEventListener("mc:refresh", pollStatus);
pollStatus();
pollJobs();
pollSystem();
setInterval(tickClock, 1000);
setInterval(pollStatus, 3000);
setInterval(pollJobs, 1500);
setInterval(pollSystem, 3000);