From b148d9ad66bd5a1a927409fc9dce73a7f3afd8cd Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 13 Nov 2026 17:44:44 +0100 Subject: feat(dashboard): running modules as chips that open a panel The running row of 118px cards took height from music and spending and cut its lines into marquees. It is now a row of chips (icon, value, progress fill) copied from each module's slot; a tap opens the full slot in a centred , which a tap outside closes without reaching what is under it, and a tap inside opens the tab. A module may export detail(state, el) for the panel. The build VM's shows the job command, start and elapsed time, CPU, memory and disk as meters, and the plan package by package: its result once finished (progress.results, sbb-remote 0.13.1), building, or waiting. Co-Authored-By: Claude Opus 5.5 --- static/modules/sbbuilder.js | 67 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) (limited to 'static/modules') diff --git a/static/modules/sbbuilder.js b/static/modules/sbbuilder.js index e183132..6131bc0 100644 --- a/static/modules/sbbuilder.js +++ b/static/modules/sbbuilder.js @@ -14,8 +14,8 @@ // with this program; if not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -// The build VM has no tab: on the Dashboard it is a running slot while a job -// is active, and nothing otherwise. +// The build VM has no tab: on the Dashboard it is a running chip while a job +// is active, opening to its slot and detail, and nothing otherwise. export const interval = 10; // each poll is an ssh round trip @@ -54,3 +54,66 @@ export function slot(st, el) { bar.classList.toggle("busy", !p?.total); bar.firstChild.style.width = p?.total ? `${Math.min(100, (100 * p.done) / p.total)}%` : ""; } + +// Each package of a job's plan with where it stands: its result once done +// (progress.results while running, sbb-remote 0.13.1; results once ended), +// "building" for the one in progress, "waiting" for the rest. +export function planRows(job) { + const results = job?.progress?.results ?? job?.results ?? {}; + return (job?.plan ?? []).map((name) => ({ + name, + status: results[name] ?? (name === job.progress?.current ? "building" : "waiting"), + })); +} + +// The dashboard's own cpu and memory glyphs, and nf-md-harddisk. +const VM_ICONS = { cpu: "\u{f2db}", mem: "\u{f035b}", disk: "\u{f02ca}" }; +const gib = (b) => `${(b / 2 ** 30).toFixed(1)} GiB`; +const since = (t) => { + const m = Math.max(0, Math.round((Date.now() / 1000 - t) / 60)); + return m < 60 ? `${m} min` : `${Math.floor(m / 60)} h ${m % 60} min`; +}; + +// The opened chip's extra lines: the command and its start, the VM's CPU, +// memory and disk as meters, and every package of the plan. The plan is redrawn only when a +// package moves on. +export function detail(st, el) { + const job = active(st)[0]; + if (!el.firstChild) { + el.innerHTML = `
job
+
${Object.entries(VM_ICONS).map(([k, ic]) => + `
${ic}
`).join("")}
+
    `; + } + const hm = (t) => new Date(t * 1000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); + el.querySelector(".cmd .v").textContent = job ? [ + [job.kind, ...(job.args ?? [])].join(" "), + job.start && `started ${hm(job.start)}, ${since(job.start)} ago`, + ].filter(Boolean).join(" ยท ") : ""; + const s = st.stats ?? {}; + const meter = (k, share, v, sub) => { + const c = el.querySelector(`.m-${k}`); + c.querySelector(".fill").style.width = `${Math.min(100, Math.max(0, share * 100))}%`; + c.querySelector(".v").textContent = v; + c.querySelector(".s").textContent = sub; + }; + meter("cpu", (s.cpu ?? 0) / 100, s.cpu == null ? "โ€“" : `${Math.round(s.cpu)}%`, + s.load ? `load ${s.load.map((x) => x.toFixed(1)).join(" ")}` : ""); + const used = s.mem ? s.mem.total - s.mem.available : 0; + meter("mem", s.mem ? used / s.mem.total : 0, s.mem ? gib(used) : "โ€“", s.mem ? `of ${gib(s.mem.total)}` : ""); + meter("disk", s.disk ? 1 - s.disk.free / s.disk.total : 0, s.disk ? `${gib(s.disk.free)}` : "โ€“", s.disk ? "free" : ""); + const rows = planRows(job); + const key = JSON.stringify(rows); + const plan = el.querySelector(".plan"); + if (plan._key === key) return; + plan._key = key; + plan.hidden = rows.length === 0; + plan.replaceChildren(...rows.map((r) => { + const li = document.createElement("li"); + li.className = r.status; + li.innerHTML = ``; + li.firstChild.textContent = r.name; + li.lastChild.textContent = r.status; + return li; + })); +} -- cgit v1.2.3