[web] The web UI: hosts, add/edit with apply progress, undo, history and restore, share links, engine switch, certificates and device installs, signing by hand, settings and tokens; smoke test counts every §4 flow's clicks

This commit is contained in:
2026-11-07 23:44:27 +01:00
parent aed5fbfcff
commit 3e326e85a0
47 changed files with 7868 additions and 3 deletions
+58
View File
@@ -0,0 +1,58 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Following an apply (handoff §2.2 of ui-api, §3 here): GET /applies/{id} every second while it
// runs; quiet retries while edge reloads; the id kept in sessionStorage so a reload resumes it.
import { get } from "./api";
import { refresh } from "./app.svelte";
import type { ApplyView } from "./types";
export const FINAL = ["kept", "reverted", "failed", "needs_attention"];
const KEY = "ianitor.activeApply";
export function remember(id: string | null): void {
try {
if (id) sessionStorage.setItem(KEY, id);
else sessionStorage.removeItem(KEY);
} catch {
/* storage may be off; the bar still shows the running apply */
}
}
export function remembered(): string | null {
try {
return sessionStorage.getItem(KEY);
} catch {
return null;
}
}
/** Poll until the apply ends. Returns a stop function. */
export function follow(id: string, onupdate: (a: ApplyView) => void, every = 1000): () => void {
let stopped = false;
let timer: ReturnType<typeof setTimeout> | undefined;
remember(id);
const tick = async () => {
if (stopped) return;
try {
const a = await get<ApplyView>(`/applies/${encodeURIComponent(id)}`);
if (stopped) return;
onupdate(a);
if (FINAL.includes(a.state)) {
remember(null);
void refresh();
return;
}
} catch {
/* lost contact or a reload in progress: keep trying (the banner says so after 10 s) */
}
timer = setTimeout(tick, every);
};
void tick();
return () => {
stopped = true;
clearTimeout(timer);
};
}