[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:
@@ -0,0 +1,73 @@
|
||||
<!-- 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/. -->
|
||||
<script lang="ts">
|
||||
// Handoff §2.8 order: paused / needs attention, lost contact, health unavailable, the Caddy
|
||||
// notice, then (on Hosts) the intermediate banner. First on every screen.
|
||||
import { Banner, Button, Details } from "@ianitor/ui";
|
||||
import { post, sentence } from "../lib/api";
|
||||
import { app, refresh } from "../lib/app.svelte";
|
||||
import { when } from "../lib/format";
|
||||
import type { ApplyView } from "../lib/types";
|
||||
|
||||
const o = $derived(app.overview);
|
||||
let restoring = $state(false);
|
||||
let problem = $state<string | null>(null);
|
||||
|
||||
const restorable = $derived(
|
||||
!!o?.paused && ["apply.needs_attention", "control.files_unwritten"].includes(o.paused_reason ?? "") && !!o.undo?.target,
|
||||
);
|
||||
|
||||
async function restoreLastKept() {
|
||||
if (!o?.undo?.target) return;
|
||||
restoring = true;
|
||||
try {
|
||||
const a = await post<{ apply: ApplyView }>("/restore", { change_id: o.undo.target.change_id, base_rev: o.rev });
|
||||
app.panel = { kind: "host", resume: a.apply.id };
|
||||
} catch (e) {
|
||||
problem = sentence(e);
|
||||
} finally {
|
||||
restoring = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function retry() {
|
||||
await refresh();
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if o?.paused}
|
||||
<Banner tone="down" live="alert">
|
||||
{#snippet title()}<span class="ia-status" data-s="down"><span class="word">{restorable ? "needs attention" : "paused"}</span></span> <strong>{o.paused?.message}</strong>{/snippet}
|
||||
{#if restorable && o.undo?.target}Goes back to "{o.undo.target.summary}" from {when(o.undo.target.kept_at, app.now)}. It is checked like any change.{/if}
|
||||
{#if problem} {problem}{/if}
|
||||
{#snippet actions()}
|
||||
{#if restorable}<Button variant="primary" onclick={restoreLastKept} pending={restoring}>Restore the last kept version</Button>{/if}
|
||||
{/snippet}
|
||||
</Banner>
|
||||
{/if}
|
||||
|
||||
{#if app.lostContact}
|
||||
<Banner tone="down" live="alert">
|
||||
{#snippet title()}<strong>{typeof navigator !== "undefined" && navigator.onLine === false ? "This device is offline. Ianitor keeps running." : "Ianitor's control service is not answering."}</strong>{/snippet}
|
||||
Traffic keeps flowing; changes wait until it is back.{#if app.lastUpdated} Last updated {when(new Date(app.lastUpdated).toISOString(), app.now)}.{/if}
|
||||
{#snippet actions()}<Button onclick={retry}>Try again now</Button>{/snippet}
|
||||
</Banner>
|
||||
{/if}
|
||||
|
||||
{#if o?.health_error}
|
||||
<Banner tone="notice">{#snippet title()}{o.health_error?.message}{/snippet}</Banner>
|
||||
{/if}
|
||||
|
||||
{#if app.switchResult}
|
||||
{@const r = app.switchResult}
|
||||
<Banner tone={r.ok ? "kept" : "down"} live="status" ondismiss={() => (app.switchResult = null)}>
|
||||
{#snippet title()}<strong>{r.title}</strong>{/snippet}
|
||||
{r.text}
|
||||
{#if r.detail}<Details detail={r.detail} />{/if}
|
||||
</Banner>
|
||||
{/if}
|
||||
|
||||
{#if o?.engine.running === "caddy" && (o.hosts.some((h) => h.share_links) ?? false)}
|
||||
<Banner tone="notice">{#snippet title()}Caddy is serving (the fallback), so share links do not work until you switch back.{/snippet}</Banner>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user