feat(webui): surface per-component update status on /api/version and Configuration
The prior two changes gave every component an InstallType/Reference and a way to observe what's actually running (installtype.Type(), daemon.AgentStatus, [nats] config), but nothing consumed any of it -- an operator still had no single place to see whether a component's actual running state agrees with what the update-check command claims. Add GET /api/version: per component, install type, observed running version, the check command's installed/available claims, and a computed status -- ok / update_available / drift / unknown. drift takes priority over update_available (a claim the running system contradicts is worse than a newer release merely existing), and a component with no installed claim at all reports unknown rather than guessing "ok" or "update_available" from a comparison that was never actually made. Surface it as an "Update status" card above the Configuration page's existing config view, sourced independently so its own failure (or a 501 on deployments with no update-check command configured, which renders nothing rather than an error) never blocks the config view that's already there. Closes archie-core-1786751948782-3-837a8fd0.3 and, with it, archie-core-1786751948782-3-837a8fd0 (all 5 design points landed).
This commit is contained in:
1 parent
25af279d7a
commit
08fa79e5af
9 files changed
+417
-25
No files matched your search
@@ -86,6 +86,7 @@ export const api = {
|
||||
return res.json();
|
||||
},
|
||||
config: () => req("/api/config"),
|
||||
version: () => req("/api/version"),
|
||||
configUpdate: async (updates) => {
|
||||
const res = await fetch("/api/config", {
|
||||
method: "PATCH",
|
||||
|
||||
@@ -2,6 +2,7 @@ import "./settings.css";
|
||||
import { api } from "../base/api.js";
|
||||
import { el, empty, mount, pill } from "../base/dom.js";
|
||||
import { row } from "./config-row.js";
|
||||
import { updateStatusCard } from "./update-status.js";
|
||||
|
||||
/**
|
||||
* A view of the config archied is actually running with, grouped by
|
||||
@@ -23,9 +24,11 @@ export function settingsPage() {
|
||||
// tables on one shared measure; see settings.css.
|
||||
const root = el("div.cfg-page");
|
||||
const body = el("div");
|
||||
const versionSlot = el("div");
|
||||
|
||||
render();
|
||||
load();
|
||||
loadVersionStatus();
|
||||
|
||||
function render() {
|
||||
mount(
|
||||
@@ -37,8 +40,9 @@ export function settingsPage() {
|
||||
el("h1.page-title", "Configuration"),
|
||||
el("p.page-sub", "What archied is actually running with right now."),
|
||||
),
|
||||
el("div.page-actions", el("button.btn", { onclick: load }, "Refresh")),
|
||||
el("div.page-actions", el("button.btn", { onclick: () => { load(); loadVersionStatus(); } }, "Refresh")),
|
||||
),
|
||||
versionSlot,
|
||||
body,
|
||||
);
|
||||
}
|
||||
@@ -52,6 +56,22 @@ export function settingsPage() {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadVersionStatus() {
|
||||
try {
|
||||
const data = await api.version();
|
||||
mount(versionSlot, updateStatusCard(data?.components || []));
|
||||
} catch (err) {
|
||||
// 501 means updates just aren't configured for this deployment --
|
||||
// that's the ordinary state for most installs, not a failure to
|
||||
// report as loudly as an unreachable daemon.
|
||||
if (err?.status === 501) {
|
||||
mount(versionSlot);
|
||||
return;
|
||||
}
|
||||
mount(versionSlot, el("div.card", empty("Update status unavailable", String(err.message || err))));
|
||||
}
|
||||
}
|
||||
|
||||
function renderBody(cfg, reload) {
|
||||
if (!cfg || Object.keys(cfg).length === 0) {
|
||||
mount(
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { el, empty, pill } from "../base/dom.js";
|
||||
|
||||
const STATUS_LABELS = {
|
||||
ok: "OK",
|
||||
update_available: "Update available",
|
||||
drift: "Drift",
|
||||
unknown: "Unknown",
|
||||
};
|
||||
|
||||
const STATUS_KINDS = {
|
||||
ok: "ok",
|
||||
update_available: "info",
|
||||
drift: "danger",
|
||||
unknown: "idle",
|
||||
};
|
||||
|
||||
/**
|
||||
* Per-component deployment/update status (GET /api/version): how each
|
||||
* component is installed, what's actually running, and whether that
|
||||
* agrees with what the update-check command claims. The comparison basis
|
||||
* -- the exact installed claim, running version and reference this status
|
||||
* was computed from -- sits in the row's title attribute (a hover tooltip)
|
||||
* rather than a separate expand control, since it's supplementary detail
|
||||
* an operator wants on demand, not on every glance at the table.
|
||||
*
|
||||
* Split out from settings.js (which top-level imports settings.css) so it
|
||||
* can be unit tested under plain node --test.
|
||||
*/
|
||||
export function updateStatusCard(components) {
|
||||
if (!components.length) {
|
||||
return section(
|
||||
"How each component is deployed, and whether what's running matches what's installed.",
|
||||
empty("No components reported", "The configured update-check command returned nothing."),
|
||||
);
|
||||
}
|
||||
return section(
|
||||
"How each component is deployed, and whether what's running matches what's installed. Hover a row for the exact versions compared.",
|
||||
el(
|
||||
"div.table-scroll",
|
||||
el(
|
||||
"table.table",
|
||||
el("thead", el("tr", ...["Component", "Install type", "Running", "Latest available", "Status"].map((h) => el("th", h)))),
|
||||
el(
|
||||
"tbody",
|
||||
...components.map((c) => {
|
||||
const basis = [
|
||||
`Installed claim: ${c.installed_claim || "unknown"}`,
|
||||
`Running: ${c.running_version || "not observed"}`,
|
||||
c.reference ? `Reference: ${c.reference}` : null,
|
||||
].filter(Boolean).join("\n");
|
||||
return el(
|
||||
"tr",
|
||||
{ title: basis },
|
||||
el("td.strong", c.label || c.id),
|
||||
el("td.mono", c.install_type || "—"),
|
||||
el("td.mono", c.running_version || "—"),
|
||||
el("td.mono", c.latest_available || "—"),
|
||||
el("td", pill(STATUS_LABELS[c.status] || c.status, STATUS_KINDS[c.status] || "idle")),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
function section(sub, ...children) {
|
||||
return el(
|
||||
"div.card.cfg-section",
|
||||
el("div.card-head", el("div", el("h2.card-title", "Update status"), el("p.card-sub", sub))),
|
||||
...children,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user