feat: rebuild the orbital vault as an operational map
This commit is contained in:
@@ -1,89 +1,132 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { VaultStatus } from "../../lib/format";
|
||||
import { StatusDot } from "../ui/StatusDot";
|
||||
import { formatBytes } from "../../lib/format";
|
||||
import type { Snapshot } from "../../api";
|
||||
|
||||
export function CockpitFrame({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="absolute inset-0 pointer-events-none z-20">
|
||||
<motionBorder />
|
||||
<p className="absolute top-3 left-4 text-[10px] font-mono tracking-[0.35em] text-star-400/80 uppercase">
|
||||
Tessera · orbital vault
|
||||
</p>
|
||||
<p className="absolute top-3 right-4 text-[10px] font-mono text-star-400/60">
|
||||
SYS // VAULT-01
|
||||
</p>
|
||||
<div className="absolute bottom-3 left-4 right-4 h-px bg-gradient-to-r from-transparent via-wormhole-violet/40 to-transparent" />
|
||||
<div className="vignette" />
|
||||
<div className="scanlines" />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function motionBorder() {
|
||||
return (
|
||||
<>
|
||||
<span className="absolute top-8 left-6 w-12 h-12 border-l-2 border-t-2 border-wormhole-violet/50 rounded-tl" />
|
||||
<span className="absolute top-8 right-6 w-12 h-12 border-r-2 border-t-2 border-wormhole-violet/50 rounded-tr" />
|
||||
<span className="absolute bottom-16 left-6 w-16 h-10 border-l-2 border-b-2 border-star-400/25 rounded-bl" />
|
||||
<span className="absolute bottom-16 right-6 w-16 h-10 border-r-2 border-b-2 border-star-400/25 rounded-br" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
import type { KeyboardEvent, ReactNode } from "react";
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
import { formatBytes, formatWhen, orbitStatus, schedulePhrase } from "../../lib/format";
|
||||
|
||||
export function TelemetryStrip({
|
||||
status,
|
||||
online,
|
||||
snapCount,
|
||||
totalBytes,
|
||||
orbitCount, failedCount, snapCount, totalBytes,
|
||||
}: {
|
||||
status: VaultStatus;
|
||||
online: boolean;
|
||||
snapCount: number;
|
||||
orbitCount?: number;
|
||||
failedCount: number;
|
||||
snapCount?: number;
|
||||
totalBytes: number;
|
||||
}) {
|
||||
return (
|
||||
<div className="pointer-events-none absolute top-12 left-4 right-4 flex justify-between items-start gap-2 text-[11px] font-mono">
|
||||
<div className="flex items-center gap-2 bg-space-950/50 backdrop-blur-sm border border-space-700/50 rounded px-2 py-1">
|
||||
<StatusDot status={online ? status : "grey"} size="sm" />
|
||||
<span className="text-star-300">{online ? "LINK OK" : "NO LINK"}</span>
|
||||
</div>
|
||||
<div className="text-right text-star-400/90 bg-space-950/40 px-2 py-1 rounded border border-space-800/40">
|
||||
<div>TILES {snapCount}</div>
|
||||
<div className="text-[10px] opacity-70">{formatBytes(totalBytes)} mass</div>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="vault-telemetry">
|
||||
<div><dt>Orbits</dt><dd>{orbitCount ?? "—"}</dd></div>
|
||||
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>{orbitCount === undefined ? "—" : failedCount}</dd></div>
|
||||
<div><dt>Snapshots</dt><dd>{snapCount ?? "—"}</dd></div>
|
||||
<div><dt>Payload</dt><dd>{snapCount === undefined ? "—" : formatBytes(totalBytes)}</dd></div>
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
export function SnapshotsMiniList({
|
||||
snapshots,
|
||||
selected,
|
||||
onSelect,
|
||||
export function OrbitRegister({
|
||||
orbits, selected, message, onSelect, onManage,
|
||||
}: {
|
||||
snapshots: Snapshot[];
|
||||
selected: string | null;
|
||||
orbits: Orbit[];
|
||||
selected?: string;
|
||||
message?: string;
|
||||
onSelect: (id: string) => void;
|
||||
onManage: () => void;
|
||||
}) {
|
||||
if (!snapshots.length) return null;
|
||||
const active = orbits.some(({ id }) => id === selected) ? selected : orbits[0]?.id;
|
||||
|
||||
function moveFocus(event: KeyboardEvent<HTMLButtonElement>, index: number) {
|
||||
const next = { ArrowUp: index - 1, ArrowDown: index + 1, Home: 0, End: orbits.length - 1 }[event.key];
|
||||
if (next === undefined) return;
|
||||
event.preventDefault();
|
||||
const target = orbits[Math.min(orbits.length - 1, Math.max(0, next))];
|
||||
onSelect(target.id);
|
||||
document.getElementById(`register-${target.id}`)?.focus();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pointer-events-auto absolute left-4 bottom-24 max-w-[140px] space-y-1">
|
||||
{snapshots.slice(0, 4).map((s, i) => (
|
||||
<button
|
||||
key={s.id}
|
||||
type="button"
|
||||
onClick={() => onSelect(s.id)}
|
||||
className={`w-full text-left text-[10px] font-mono px-2 py-1 rounded border transition-colors ${
|
||||
selected === s.id
|
||||
? "border-orbit-green/60 bg-orbit-green/10 text-orbit-green"
|
||||
: "border-space-700/50 bg-space-950/60 text-star-400 hover:border-star-400/40"
|
||||
}`}
|
||||
>
|
||||
{String(i + 1).padStart(2, "0")} · {s.orbit_name.slice(0, 12)}
|
||||
<section className="vault-console orbit-register" aria-labelledby="register-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Flight register</p>
|
||||
<h2 id="register-title">Orbits</h2>
|
||||
</header>
|
||||
{message && <p className="console-empty" role="status">{message}</p>}
|
||||
<ul className="register-list">
|
||||
{orbits.map((orbit, index) => {
|
||||
const status = orbitStatus(orbit.last_status);
|
||||
return (
|
||||
<li key={orbit.id}>
|
||||
<button
|
||||
type="button"
|
||||
id={`register-${orbit.id}`}
|
||||
className="register-row"
|
||||
aria-pressed={selected === orbit.id}
|
||||
tabIndex={active === orbit.id ? 0 : -1}
|
||||
onClick={() => onSelect(orbit.id)}
|
||||
onKeyDown={(event) => moveFocus(event, index)}
|
||||
>
|
||||
<span className={`register-signal signal-${status.tone}`} aria-hidden="true" />
|
||||
<span className="register-content">
|
||||
<span title={orbit.name}>{orbit.name}</span>
|
||||
<small>{orbit.provider}</small>
|
||||
</span>
|
||||
<span className={`register-state tone-${status.tone}`}>{status.label}</span>
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<div className="console-bottom">
|
||||
<button type="button" className="console-control" onClick={onManage}>
|
||||
{orbits.length ? "Manage orbits" : "Set up an orbit"} <span aria-hidden="true">↗</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function OrbitInspector({
|
||||
orbit, snapshots, snapshotMessage, capture, onSelectSnapshot,
|
||||
}: {
|
||||
orbit?: Orbit;
|
||||
snapshots: Snapshot[];
|
||||
snapshotMessage?: string;
|
||||
capture?: ReactNode;
|
||||
onSelectSnapshot: (id: string) => void;
|
||||
}) {
|
||||
const status = orbitStatus(orbit?.last_status ?? "idle");
|
||||
return (
|
||||
<section className="vault-console orbit-inspector" aria-labelledby="inspector-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Orbit detail</p>
|
||||
<h2 id="inspector-title">{orbit?.name ?? "Select an orbit"}</h2>
|
||||
{orbit && <p className={`inspector-state tone-${status.tone}`}><span className={`register-signal signal-${status.tone}`} />{status.label}</p>}
|
||||
</header>
|
||||
{orbit ? (
|
||||
<>
|
||||
<p className="inspector-schedule">{schedulePhrase(orbit.schedule, orbit.dry_run)}</p>
|
||||
<div className="inspector-capture">{capture}</div>
|
||||
<section className="inspector-history" aria-labelledby="history-title">
|
||||
<header>
|
||||
<h3 id="history-title">Snapshot history</h3>
|
||||
<span>{snapshots.length.toString().padStart(2, "0")}</span>
|
||||
</header>
|
||||
{snapshotMessage && <p className="console-empty" role="status">{snapshotMessage}</p>}
|
||||
<ul>
|
||||
{snapshots.map((snapshot, index) => (
|
||||
<li key={snapshot.id}>
|
||||
<button id={`snapshot-${snapshot.id}`} type="button" className="snapshot-row" onClick={() => onSelectSnapshot(snapshot.id)}>
|
||||
<span className="snapshot-glyph" aria-hidden="true">◇</span>
|
||||
<span>
|
||||
<strong>{formatWhen(snapshot.taken_at)}</strong>
|
||||
<small>{formatBytes(snapshot.size_bytes)}{index === 0 ? " · Latest" : ""}</small>
|
||||
</span>
|
||||
<span className="snapshot-arrow" aria-hidden="true">›</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
<p className="console-empty">Choose a star on the map or an orbit in the register to inspect its status and recovery points.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user