diff options
Diffstat (limited to 'static')
| -rw-r--r-- | static/app.js | 7 | ||||
| -rw-r--r-- | static/dashboard.js | 14 | ||||
| -rw-r--r-- | static/modules/obs.js | 11 |
3 files changed, 16 insertions, 16 deletions
diff --git a/static/app.js b/static/app.js index c296b90..79010bf 100644 --- a/static/app.js +++ b/static/app.js @@ -105,14 +105,17 @@ function mountTab(name, panel, section) { poll(name, panel.interval ?? 1, (st) => panel.update?.(st, wrap)); } +// Modules with no panel file: dashboard.js draws them. +const DRAWN = ["stats", "tablet", "llm", "actions"]; + async function boot() { const r = await fetch("/api/modules"); if (!r.ok) return; // Every panel's code at once; then mount in the server's order, so the // tabs do not shuffle with whichever import lands first. const names = (await r.json()).map(({ name }) => name); - const loaded = await Promise.all(names.map((name) => - import(`./modules/${name}.js`).then((m) => m.default, () => null))); + const loaded = await Promise.all(names.map((name) => (DRAWN.includes(name) ? null + : import(`./modules/${name}.js`).then((m) => m.default, () => null)))); names.forEach((name, i) => { const panel = loaded[i]; if (!panel?.tab) return; // no tab: drawn by the Dashboard, if at all diff --git a/static/dashboard.js b/static/dashboard.js index 5dc8939..de8aaae 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -44,7 +44,7 @@ const pct = (v) => (v == null ? "—" : `${Math.round(v)}%`); const short = (m) => String(m ?? "").split("/").pop(); const uptime = (s) => { const d = Math.floor(s / 86400), h = Math.floor((s % 86400) / 3600); - return d ? `${d}d ${h}h` : `${h}h`; + return d ? `${d}d ${h}h` : h ? `${h}h` : `${Math.floor(s / 60)}m`; }; export function push(list, v, n = HISTORY) { @@ -78,6 +78,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 for (const line of el.querySelectorAll(".what, .meta")) { const over = line.firstElementChild.offsetWidth - line.clientWidth; line.classList.toggle("marq", over > 0); @@ -91,9 +92,9 @@ function marquee(el) { const SKELETON = ` <svg class="dash-defs" width="0" height="0" aria-hidden="true"><defs> - <linearGradient id="hyline"><stop offset="0" style="stop-color:var(--udt-border-1)"/> + <linearGradient id="hyline" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="120" y2="0"><stop offset="0" style="stop-color:var(--udt-border-1)"/> <stop offset=".5" style="stop-color:var(--udt-border-2)"/><stop offset="1" style="stop-color:var(--udt-border-3)"/></linearGradient> - <linearGradient id="hyfill" x1="0" y1="0" x2="0" y2="1"> + <linearGradient id="hyfill" gradientUnits="userSpaceOnUse" x1="0" y1="0" x2="0" y2="100"> <stop offset="0" style="stop-color:var(--udt-border-2);stop-opacity:.45"/> <stop offset="1" style="stop-color:var(--udt-border-1);stop-opacity:.05"/></linearGradient> </defs></svg> @@ -245,11 +246,10 @@ export default { // 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); - marquee(el); - } + 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); }); }); } diff --git a/static/modules/obs.js b/static/modules/obs.js index bcf237b..f7969b8 100644 --- a/static/modules/obs.js +++ b/static/modules/obs.js @@ -55,23 +55,20 @@ async function post(action, body = {}) { } // The dashboard's running slot: what is live, the scene and the elapsed -// time, and a stop for it. +// time. No stop here: a tap opens the OBS tab, so a stray touch cannot end a +// recording. export const busy = (st) => Boolean(st.connected && (st.recording || st.streaming)); export function slot(st, el) { if (!el.firstChild) { el.innerHTML = `<i class="nf sic rec"></i> <span class="what"><span></span></span><span class="pct num"></span> - <span class="meta"><span></span></span> - <button class="act">Stop</button>`; + <span class="meta"><span></span></span>`; } const what = st.recording ? (st.paused ? "Recording paused" : "Recording") : "Streaming"; el.querySelector(".what > span").textContent = `${what} · ${st.currentScene ?? ""}`; el.querySelector(".pct").textContent = st.recording ? clock(st.recordingTime) : "live"; - el.querySelector(".meta > span").textContent = - [st.recording ? "recording" : null, st.streaming ? "streaming" : null].filter(Boolean).join(" + "); - el.querySelector(".act").onclick = () => - post(st.recording ? "record" : "stream", { on: false }); + el.querySelector(".meta > span").textContent = st.recording && st.streaming ? "and streaming" : ""; } function bigButton(kind, name, label, on, times) { |
