aboutsummaryrefslogtreecommitdiffstats
path: root/static
diff options
context:
space:
mode:
Diffstat (limited to 'static')
-rw-r--r--static/dashboard.js55
-rw-r--r--static/deck.css34
-rw-r--r--static/modules/sbbuilder.js67
3 files changed, 132 insertions, 24 deletions
diff --git a/static/dashboard.js b/static/dashboard.js
index c6eab3c..1f89da8 100644
--- a/static/dashboard.js
+++ b/static/dashboard.js
@@ -15,13 +15,14 @@
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// The Dashboard tab: a top band of chips, music and spending always on, a
-// row of one to three busy modules, and the action icons. The page keeps the
+// row of chips for one to three busy modules, each opening its full slot,
+// and the action icons. The page keeps the
// trend history; the modules' APIs are the existing ones.
import { offline } from "./offline.js";
export const HISTORY = 120; // trend samples: two minutes at 1 s
-const RUNNING = ["k1c", "sbbuilder", "obs"]; // the running row's order
+const RUNNING = { k1c: "K1C", sbbuilder: "build", obs: "OBS" }; // the running row's order and chip labels
const G = { cpu: "", mem: "\u{f035b}", gpu: "\u{f08ae}", net: "\u{f04e1}",
wifi: "", charging: "\u{f0084}", tux: "", clock: "" };
@@ -90,7 +91,7 @@ export function batteryGlyph(b) {
// one that fits stays still. Only changed values are written, so the
// animation is not restarted by every poll.
function marquee(el) {
- if (!el.offsetParent) return; // another tab is in front: nothing to measure
+ if (!el.getClientRects().length) return; // not shown: nothing to measure
for (const line of el.querySelectorAll(".what, .meta")) {
const over = line.firstElementChild.offsetWidth - line.clientWidth;
line.classList.toggle("marq", over > 0);
@@ -267,25 +268,47 @@ export default {
poll("music", music.interval ?? 2, (st) => music.update(st, el));
});
- // The running row: slots are created now, in RUNNING order, and shown
- // while their module is busy.
+ // The running row: a chip per module, created now in RUNNING order and
+ // shown while it is busy. A tap opens its full slot, and the module's
+ // detail(state, el) when it has one, centred over the page; a tap
+ // outside closes it (closedby="any", Chrome 134+) without reaching what is
+ // under it, a tap inside opens the module's tab.
const row = $(".dash-running");
- for (const name of RUNNING.filter((n) => on.has(n))) {
- const el = document.createElement("div");
- el.className = `card slot slot-${name}`;
- el.hidden = true;
- row.append(el);
+ for (const name of Object.keys(RUNNING).filter((n) => on.has(n))) {
+ const chip = document.createElement("div");
+ chip.className = `chip run-${name}`;
+ chip.hidden = true;
+ chip.innerHTML = `<i class="fill"></i><i class="nf ic"></i><span class="v num"></span><span class="k"></span>`;
+ chip.querySelector(".k").textContent = RUNNING[name];
+ const pop = document.createElement("dialog");
+ pop.setAttribute("closedby", "any");
+ pop.className = "card run-pop";
+ pop.innerHTML = `<div class="slot slot-${name}"></div><div class="detail"></div>`;
+ const [slotEl, detailEl] = pop.children;
+ row.append(chip, pop);
+ chip.addEventListener("click", () => { pop.showModal(); marquee(slotEl); });
import(`./modules/${name}.js`).then((mod) => {
if (!mod.busy || !mod.slot) return;
const tab = mod.default?.tab;
- el.addEventListener("click", (e) => { if (tab && !e.target.closest("button")) open(tab); });
+ pop.addEventListener("click", (e) => {
+ if (tab && !e.target.closest("button")) { pop.close(); open(tab); }
+ });
// ponytail: the K1C and OBS tabs poll the same API; two polls a second, one cache if it matters.
poll(name, mod.interval ?? mod.default?.interval ?? 2, (st) => {
- el.hidden = !mod.busy(st);
- if (!el.hidden) mod.slot(st, el);
- row.hidden = !row.querySelector(".slot:not([hidden])");
- // a slot coming or going changes the others' widths
- for (const s of row.querySelectorAll(".slot:not([hidden])")) marquee(s);
+ chip.hidden = !mod.busy(st);
+ if (chip.hidden) { pop.close(); return; }
+ mod.slot(st, slotEl);
+ mod.detail?.(st, detailEl);
+ // ponytail: the chip mirrors the slot's icon, value and bar, so a
+ // module draws one slot; a chip(state) export if one ever needs more.
+ const bar = slotEl.querySelector(".bar");
+ chip.querySelector(".ic").textContent = slotEl.querySelector(".sic")?.textContent ?? "";
+ chip.querySelector(".v").textContent = slotEl.querySelector(".pct")?.textContent ?? "";
+ chip.querySelector(".fill").style.width = bar?.querySelector("i").style.width ?? "";
+ chip.classList.toggle("busy", !!bar?.classList.contains("busy"));
+ chip.classList.toggle("rec", !!slotEl.querySelector(".sic.rec"));
+ row.hidden = !row.querySelector(".chip:not([hidden])");
+ if (pop.open) marquee(slotEl);
});
});
}
diff --git a/static/deck.css b/static/deck.css
index b6da4c6..a08f037 100644
--- a/static/deck.css
+++ b/static/deck.css
@@ -705,9 +705,6 @@ select {
background: var(--udt-mantle); border: 1px solid var(--udt-surface1); }
.dash-music { flex: 1; }
.dash-spend { flex: 1.4; display: flex; flex-direction: column; gap: 10px; }
-/* With the running row present the spending card is too short for both
- programs: it scrolls instead of clipping the second one. */
-.dash-mid:has(.dash-running:not([hidden])) .dash-spend { overflow-y: auto; overscroll-behavior: contain; }
.dash-music .music .top { margin-bottom: 6px; }
.dash-music .music .art { width: 52px; height: 52px; border-radius: 10px; }
.dash-music .music .title { font-size: 1rem; }
@@ -733,9 +730,34 @@ select {
.dash .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.75rem; color: var(--udt-subtext0); }
.dash .legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--c); }
-/* The running row: one to three slots in equal columns. A line too long for
- its slot slides to its end and back (dashboard.js sets --d and --t). */
-.dash-running { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; flex: none; height: 118px; }
+/* The running row: one to three chips in equal columns, each opening its
+ slot (and detail) as a centred modal. A line too long for the slot slides to its
+ end and back (dashboard.js sets --d and --t). */
+.dash-running { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; flex: none; height: 52px; }
+.dash-running .chip { cursor: pointer; }
+.dash-running .chip.rec .ic { color: var(--udt-red); }
+.dash-running .chip.busy .fill { width: 30% !important; animation: slot-busy 1.6s ease-in-out infinite alternate; }
+.dash-running .chip .k { margin-left: auto; }
+.dash dialog.run-pop { margin: auto; width: min(760px, 92vw); max-height: 85vh; overflow-y: auto; overscroll-behavior: contain;
+ color: var(--udt-text); padding: 16px 20px; }
+.dash dialog.run-pop[open] { display: flex; flex-direction: column; gap: 14px; }
+.dash dialog.run-pop::backdrop { background: color-mix(in srgb, var(--udt-crust) 55%, transparent); }
+.dash .run-pop .slot { flex: none; height: 96px; padding: 0; }
+.dash .run-pop .detail { display: flex; flex-direction: column; gap: 6px; font-size: 0.857rem; }
+.dash .run-pop .detail:empty { display: none; }
+.dash .run-pop .dl { display: flex; gap: 12px; }
+.dash .run-pop .dl .k { flex: none; width: 3rem; font-size: 0.714rem; text-transform: uppercase; letter-spacing: .08em; color: var(--udt-overlay1); padding-top: .15em; }
+.dash .run-pop .dl .v { color: var(--udt-subtext0); }
+.dash .run-pop .vm { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
+.dash .run-pop .vm .chip { height: 60px; }
+.dash .run-pop .plan { margin: 6px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 16px; }
+.dash .run-pop .plan li { display: flex; gap: 8px; padding: 4px 8px; border-radius: 8px; background: var(--udt-surface0); }
+.dash .run-pop .plan .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.dash .run-pop .plan .ps { flex: none; font-size: 0.786rem; color: var(--udt-overlay1); }
+.dash .run-pop .plan .ok .ps { color: var(--udt-green); }
+.dash .run-pop .plan .failed .ps, .dash .run-pop .plan .aborted .ps { color: var(--udt-red); }
+.dash .run-pop .plan .building { outline: 1px solid var(--udt-accent); }
+.dash .run-pop .plan .building .ps { color: var(--udt-accent); }
.dash .slot { container: slot / inline-size; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto 1fr;
column-gap: 14px; row-gap: 4px; align-items: center; padding: 10px 16px 12px; cursor: pointer; }
.dash .slot .sic { grid-column: 1; grid-row: 1 / 3; font-size: 1.9rem; width: 2.4rem; color: var(--udt-accent); }
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 = `<div class="dl cmd"><span class="k">job</span><span class="v"></span></div>
+ <div class="vm">${Object.entries(VM_ICONS).map(([k, ic]) =>
+ `<div class="chip m-${k}" title="${k}"><i class="fill"></i><i class="nf ic">${ic}</i><span class="v num"></span><span class="s"></span></div>`).join("")}</div>
+ <ol class="plan"></ol>`;
+ }
+ 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 = `<span class="pn"></span><span class="ps"></span>`;
+ li.firstChild.textContent = r.name;
+ li.lastChild.textContent = r.status;
+ return li;
+ }));
+}