Accessibility pass, command palette actions, row detail panel, server activity, map, wall display and setup guide
Accessibility: skip link, labelled landmarks, visible focus, page-change announcements, sortable headings as real buttons, every label tied to its field, named row checkboxes, and text contrast raised to 4.5:1 in both themes. Command palette: also runs actions (silence/end maintenance, theme, density, wall display, sign out) and is a proper dialog; g-then-letter shortcuts, "/" and "?". Row detail panel for six tables. Server Activity card, with the health check now recording offline/back-online and disk events in the audit log. Map page of hosts, servers, DNS names and monitors. Full-screen wall display. A getting-started checklist on the admin dashboard. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7f5e1cd41
commit
57fd4f8c52
36 files changed
+2790
-210
No files matched your search
@@ -0,0 +1,187 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type MapData, type MapNode } from "../api/client";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { PageSkeleton } from "../components/Skeleton";
|
||||
import { readableError } from "../utils/errors";
|
||||
|
||||
const NODE_W = 210;
|
||||
const NODE_H = 46;
|
||||
const GAP_Y = 12;
|
||||
const COL_GAP = 130;
|
||||
|
||||
const STATUS_SYMBOL: Record<MapNode["status"], string> = { ok: "✓", bad: "✕", warn: "▲", unknown: "·" };
|
||||
const STATUS_WORD: Record<MapNode["status"], string> = { ok: "working", bad: "problem", warn: "check", unknown: "no status" };
|
||||
const KIND_WORD: Record<MapNode["kind"], string> = { host: "Proxmox host", server: "Server", dns: "DNS name", monitor: "Uptime Kuma monitor" };
|
||||
|
||||
interface Placed extends MapNode {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
/** Places each node: hosts, then servers, then names and monitors, each column ordered so the lines cross as little as is easy. */
|
||||
function layout(data: MapData): { placed: Map<string, Placed>; width: number; height: number; columns: { x: number; title: string }[] } {
|
||||
const neighbours = new Map<string, string[]>();
|
||||
for (const e of data.edges) {
|
||||
neighbours.set(e.from, [...(neighbours.get(e.from) ?? []), e.to]);
|
||||
neighbours.set(e.to, [...(neighbours.get(e.to) ?? []), e.from]);
|
||||
}
|
||||
const byKind = (kinds: MapNode["kind"][]) => data.nodes.filter((n) => kinds.includes(n.kind));
|
||||
const hosts = byKind(["host"]).sort((a, b) => a.label.localeCompare(b.label));
|
||||
const serverNodes = byKind(["server"]);
|
||||
const rightNodes = byKind(["dns", "monitor"]);
|
||||
|
||||
// Servers grouped under their host, then those with none.
|
||||
const hostOf = (s: MapNode) => (neighbours.get(s.id) ?? []).find((id) => id.startsWith("host:"));
|
||||
const servers: MapNode[] = [];
|
||||
for (const h of hosts) servers.push(...serverNodes.filter((s) => hostOf(s) === h.id).sort((a, b) => a.label.localeCompare(b.label)));
|
||||
servers.push(...serverNodes.filter((s) => !hostOf(s)).sort((a, b) => a.label.localeCompare(b.label)));
|
||||
|
||||
const step = NODE_H + GAP_Y;
|
||||
const placed = new Map<string, Placed>();
|
||||
const hasHosts = hosts.length > 0;
|
||||
const hasRight = rightNodes.length > 0;
|
||||
const colX = [0, hasHosts ? NODE_W + COL_GAP : 0, 0];
|
||||
colX[2] = colX[1] + (servers.length > 0 ? NODE_W + COL_GAP : 0);
|
||||
servers.forEach((s, i) => placed.set(s.id, { ...s, x: colX[1], y: i * step }));
|
||||
|
||||
// A column of nodes sits at the average height of the servers it connects to, pushed down as needed so none overlap.
|
||||
const stack = (nodes: MapNode[], x: number) => {
|
||||
const wanted = nodes.map((n) => {
|
||||
const ys = (neighbours.get(n.id) ?? []).map((id) => placed.get(id)?.y).filter((y): y is number => y !== undefined);
|
||||
return { n, y: ys.length ? ys.reduce((a, b) => a + b, 0) / ys.length : Number.MAX_SAFE_INTEGER / 2 };
|
||||
});
|
||||
wanted.sort((a, b) => a.y - b.y || a.n.label.localeCompare(b.n.label));
|
||||
let next = 0;
|
||||
for (const { n, y } of wanted) {
|
||||
const at = Math.max(next, y >= Number.MAX_SAFE_INTEGER / 4 ? next : y);
|
||||
placed.set(n.id, { ...n, x, y: at });
|
||||
next = at + step;
|
||||
}
|
||||
};
|
||||
stack(hosts, colX[0]);
|
||||
stack(rightNodes, colX[2]);
|
||||
|
||||
const all = [...placed.values()];
|
||||
const height = all.length ? Math.max(...all.map((p) => p.y)) + NODE_H : 0;
|
||||
const width = Math.max(...all.map((p) => p.x), 0) + NODE_W;
|
||||
const columns = [
|
||||
...(hasHosts ? [{ x: colX[0], title: "Proxmox hosts" }] : []),
|
||||
...(servers.length > 0 ? [{ x: colX[1], title: "Servers" }] : []),
|
||||
...(hasRight ? [{ x: colX[2], title: "DNS names & monitors" }] : []),
|
||||
];
|
||||
return { placed, width, height, columns };
|
||||
}
|
||||
|
||||
/** The picture: how the servers, their Proxmox hosts, DNS names and monitors connect. Hover or tab to a box to light up its connections. */
|
||||
export default function MapPage() {
|
||||
const [data, setData] = useState<MapData | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [focus, setFocus] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
api.map
|
||||
.get()
|
||||
.then(setData)
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}, []);
|
||||
|
||||
const view = useMemo(() => (data ? layout(data) : null), [data]);
|
||||
const lit = useMemo(() => {
|
||||
if (!data || !focus) return null;
|
||||
const set = new Set<string>([focus]);
|
||||
for (const e of data.edges) {
|
||||
if (e.from === focus) set.add(e.to);
|
||||
if (e.to === focus) set.add(e.from);
|
||||
}
|
||||
return set;
|
||||
}, [data, focus]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title mb-1">Map</h2>
|
||||
<p className="text-secondary">
|
||||
How things connect: which Proxmox host a server runs on, which DNS names point at it, and which Uptime Kuma monitors watch it. Hover or tab to a box to light up what it is
|
||||
connected to.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
{data?.notes.map((n) => (
|
||||
<div key={n} className="alert alert-warning">
|
||||
{n}
|
||||
</div>
|
||||
))}
|
||||
{!data && !error && <PageSkeleton />}
|
||||
{data && view && data.nodes.length === 0 && <div className="card"><div className="card-body text-secondary">Nothing to draw yet — add a server first.</div></div>}
|
||||
{data && view && data.nodes.length > 0 && (
|
||||
<div className="card">
|
||||
<div className="card-body map-scroll">
|
||||
<div className="map-columns" style={{ width: view.width }}>
|
||||
{view.columns.map((c) => (
|
||||
<div key={c.title} className="map-column-title" style={{ left: c.x, width: NODE_W }}>
|
||||
{c.title}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<div className="map-canvas" style={{ width: view.width, height: view.height }}>
|
||||
<svg className="map-lines" width={view.width} height={view.height} aria-hidden="true">
|
||||
{data.edges.map((e) => {
|
||||
const a = view.placed.get(e.from);
|
||||
const b = view.placed.get(e.to);
|
||||
if (!a || !b) return null;
|
||||
// Always drawn from the node on the left to the one on the right.
|
||||
const [l, r] = a.x <= b.x ? [a, b] : [b, a];
|
||||
const x1 = l.x + NODE_W;
|
||||
const y1 = l.y + NODE_H / 2;
|
||||
const x2 = r.x;
|
||||
const y2 = r.y + NODE_H / 2;
|
||||
const mid = (x1 + x2) / 2;
|
||||
const active = !lit || (lit.has(e.from) && lit.has(e.to) && (e.from === focus || e.to === focus));
|
||||
return <path key={`${e.from}>${e.to}`} d={`M${x1},${y1} C${mid},${y1} ${mid},${y2} ${x2},${y2}`} className={active ? "map-edge" : "map-edge map-dim"} fill="none" />;
|
||||
})}
|
||||
</svg>
|
||||
{[...view.placed.values()].map((n) => {
|
||||
const dim = lit && !lit.has(n.id);
|
||||
const body = (
|
||||
<>
|
||||
<span className={`map-status map-status-${n.status}`} aria-hidden="true">
|
||||
{STATUS_SYMBOL[n.status]}
|
||||
</span>
|
||||
<span className="map-label">
|
||||
<span className="map-title">{n.label}</span>
|
||||
{n.sub && <span className="map-sub">{n.sub}</span>}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
const props = {
|
||||
className: `map-node map-node-${n.kind} ${dim ? "map-dim" : ""}`,
|
||||
style: { left: n.x, top: n.y, width: NODE_W, height: NODE_H },
|
||||
onMouseEnter: () => setFocus(n.id),
|
||||
onMouseLeave: () => setFocus((f) => (f === n.id ? null : f)),
|
||||
onFocus: () => setFocus(n.id),
|
||||
onBlur: () => setFocus((f) => (f === n.id ? null : f)),
|
||||
"aria-label": `${KIND_WORD[n.kind]}: ${n.label}${n.sub ? `, ${n.sub}` : ""}, ${STATUS_WORD[n.status]}`,
|
||||
};
|
||||
return n.href ? (
|
||||
<Link key={n.id} to={n.href} {...props}>
|
||||
{body}
|
||||
</Link>
|
||||
) : (
|
||||
<div key={n.id} {...props}>
|
||||
{body}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-footer text-secondary small d-flex flex-wrap gap-3">
|
||||
<span>✓ working</span>
|
||||
<span>✕ problem or not reporting</span>
|
||||
<span>▲ needs a look</span>
|
||||
<span>· no status</span>
|
||||
<span className="ms-auto">DNS names appear where a record holds a server's own address; monitors where their target is the server's.</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user