feat: live system metrics (CPU, RAM, Disk, GPU, Temp)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user