// deck-it - the build VM's running slot // Copyright (C) 2026 Danilo M. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License version 2 as // published by the Free Software Foundation. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License along // 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. export const interval = 10; // each poll is an ssh round trip const ACTIVE = ["running", "busy", "starting"]; const active = (st) => (st.jobs ?? []).filter((j) => ACTIVE.includes(j.status)); export const busy = (st) => !st.offline && active(st).length > 0; export function slot(st, el) { if (!el.firstChild) { el.innerHTML = `
`; } // A running build carries sbb-remote's progress: the package on line 1, done // of total (dependencies included) on the right, op, its ETA, the estimated // end and failures on line 2, and a real bar. Every slot width works the // same: the lines slide when they do not fit. const jobs = active(st); const p = jobs[0]?.progress; const load = st.stats?.load; const hm = (t) => new Date(t * 1000).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }); el.querySelector(".what > span").textContent = p?.current?.split("/").pop() || `Build VM · ${jobs[0]?.kind || "job"}`; el.querySelector(".pct").textContent = p?.total ? `${p.done}/${p.total}` : jobs.length > 1 ? `${jobs.length} jobs` : ""; el.querySelector(".meta > span").textContent = [ p ? p.op : jobs[0]?.status, p?.eta && `ETA ${p.eta}`, p?.end && `ends ~${hm(p.end)}`, p?.failed && `${p.failed} failed`, load && `load ${load[0].toFixed(2)}`, ].filter(Boolean).join(" · "); const bar = el.querySelector(".bar"); bar.classList.toggle("busy", !p?.total); bar.firstChild.style.width = p?.total ? `${Math.min(100, (100 * p.done) / p.total)}%` : ""; }