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:
bobbanandClaude Sonnet 5.5 committed 2026-10-15 21:10:56 +02:00
1 parent f7f5e1cd41
commit 57fd4f8c52
36 files changed
+2790 -210

No files matched your search

+2
View File
@@ -28,6 +28,7 @@ import { privacyRouter } from "./routes/privacy.js";
import { tagsRouter } from "./routes/tags.js";
import { portsRouter } from "./routes/ports.js";
import { alertsRouter } from "./routes/alerts.js";
import { mapRouter } from "./routes/map.js";
import { generatorRouter } from "./routes/generator.js";
import { alertTicketsRouter } from "./routes/alertTickets.js";
import { apiErrorHandler } from "./utils/apiErrorHandler.js";
@@ -105,6 +106,7 @@ export function createApp() {
app.use("/api/tags", tagsRouter);
app.use("/api/ports", portsRouter);
app.use("/api/alerts", alertsRouter);
app.use("/api/map", mapRouter);
app.use("/api/generator", generatorRouter);
app.use("/api/alert-tickets", alertTicketsRouter);
+14
View File
@@ -0,0 +1,14 @@
import { Router } from "express";
import { requireAuth } from "../auth/middleware.js";
import { buildTopology } from "../services/topology.js";
import { asyncHandler } from "../utils/asyncHandler.js";
export const mapRouter = Router();
mapRouter.use(requireAuth);
// How servers, Proxmox hosts, DNS names and monitors connect. Everyone signed in can see it: it is the same information the pages
// it links to already show.
mapRouter.get("/", asyncHandler(async (_req, res) => {
res.json(await buildTopology());
}));
+11
View File
@@ -7,6 +7,7 @@ import { requireAuth, requireRole } from "../auth/middleware.js";
import { generateApiToken } from "../services/tokens.js";
import { recordAudit } from "../services/audit.js";
import { getServerMetrics, RETENTION_DAYS } from "../services/serverMetrics.js";
import { getServerActivity } from "../services/serverActivity.js";
import { asyncHandler } from "../utils/asyncHandler.js";
import { ID_PATTERNS } from "../utils/pathSegment.js";
import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
@@ -201,6 +202,16 @@ serversRouter.get("/:id/metrics", asyncHandler(async (req, res) => {
res.json({ days, series: await getServerMetrics(id, days) });
}));
// What has happened to a server: changes to it, the health check seeing it stop reporting or a disk fill, and its maintenance
// windows. Operators and above — the audit log it draws on is theirs to read.
serversRouter.get("/:id/activity", requireRole("operator"), asyncHandler(async (req, res) => {
const id = Number(req.params.id);
if (!Number.isInteger(id)) return res.status(400).json({ error: "invalid_id" });
const [server] = await db.select({ id: servers.id }).from(servers).where(eq(servers.id, id)).limit(1);
if (!server) return res.status(404).json({ error: "not_found" });
res.json({ events: await getServerActivity(id) });
}));
serversRouter.get("/:id/detail", asyncHandler(async (req, res) => {
const id = Number(req.params.id);
if (!Number.isInteger(id)) return res.status(400).json({ error: "invalid_id" });
+29
View File
@@ -5,6 +5,7 @@ import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
import { createProxmoxAdapter, type ProxmoxNodeStats } from "../integrations/proxmox/adapter.js";
import { createSynologyAdapter, type SynologyStorageInfo } from "../integrations/synology/adapter.js";
import { notifyHealthIssues, notifyHealthRecovered } from "./notify.js";
import { recordAudit } from "./audit.js";
import { getInternalFlag, getSettings, setInternalFlag } from "./settingsStore.js";
import { activeSubjects, subjectOfConditionKey } from "./maintenance.js";
@@ -318,6 +319,33 @@ async function loadState(): Promise<ActiveState> {
}
}
/**
* Writes down, in the audit log, the moments a server stopped reporting or a disk filled up — and when they ended — so a server's
* page can tell the story afterwards. Only for problems that are about a server; never allowed to hold up the check itself.
*/
export async function recordServerTransitions(added: { key: string; message: string }[], resolved: { key: string; message: string }[]): Promise<void> {
const about = (key: string) => /^(offline|disk):server:(\d+)(?::(.*))?$/.exec(key);
const write = async (items: { key: string; message: string }[], names: { offline: string; disk: string }, withMessage: boolean) => {
for (const item of items) {
const m = about(item.key);
if (!m) continue;
try {
await recordAudit({
category: "server",
action: m[1] === "offline" ? names.offline : names.disk,
targetType: "server",
targetId: m[2],
detail: withMessage ? { message: item.message, ...(m[3] ? { mount: m[3] } : {}) } : m[3] ? { mount: m[3] } : undefined,
});
} catch (err) {
console.error("[health] couldn't record a server event:", err);
}
}
};
await write(added, { offline: "went_offline", disk: "disk_full" }, true);
await write(resolved, { offline: "back_online", disk: "disk_ok" }, false);
}
export async function runHealthCheck(now: number = Date.now()): Promise<{ added: number; resolved: number }> {
const { healthChecks } = await getSettings();
const { snapshot, held } = await collectSnapshot();
@@ -331,6 +359,7 @@ export async function runHealthCheck(now: number = Date.now()): Promise<{ added:
// State is tracked even when the alert toggle is off (the notify functions check it),
// so turning alerts back on doesn't dump every long-standing condition at once.
await recordServerTransitions(added, resolved);
if (added.length > 0) await notifyHealthIssues(added);
if (resolved.length > 0) await notifyHealthRecovered(resolved);
return { added: added.length, resolved: resolved.length };
+117
View File
@@ -0,0 +1,117 @@
/**
* What has happened to one server, newest first: changes people made to it, the moments the health check saw it stop reporting or
* a disk fill (and recover), and its maintenance windows. Built from the audit log and the maintenance windows, so it needs
* nothing of its own — except that the health check now writes down those moments when they happen.
*/
import { and, desc, eq } from "drizzle-orm";
import { db } from "../db/client.js";
import { auditLog, maintenanceWindows } from "../db/schema.js";
export type ActivityTone = "good" | "bad" | "neutral" | "info";
export interface ActivityEvent {
/** ISO. */
at: string;
kind: "change" | "health" | "maintenance";
tone: ActivityTone;
title: string;
detail: string | null;
/** Who did it; "system" for the app's own checks. Null when it isn't a person's doing. */
actor: string | null;
}
/** The audit log stores SQLite's "2026-10-03 14:05:09" (UTC); the rest of the app speaks ISO. */
export function auditTimeToIso(value: string): string {
return /T|Z$/.test(value) ? new Date(value).toISOString() : new Date(`${value.replace(" ", "T")}Z`).toISOString();
}
const humanize = (s: string) => {
const t = s.replace(/[_-]+/g, " ");
return t.charAt(0).toUpperCase() + t.slice(1);
};
function parseDetail(detail: string | null): Record<string, unknown> {
if (!detail) return {};
try {
const v = JSON.parse(detail);
return v && typeof v === "object" ? (v as Record<string, unknown>) : {};
} catch {
return {};
}
}
/** A readable line for one audit entry about a server. */
export function describeAudit(category: string, action: string, detail: Record<string, unknown>): { title: string; tone: ActivityTone; kind: ActivityEvent["kind"]; detail: string | null } {
const message = typeof detail.message === "string" ? detail.message : null;
const label = typeof detail.label === "string" ? detail.label : null;
if (category === "server") {
switch (action) {
case "went_offline":
return { title: "Stopped reporting — marked offline", tone: "bad", kind: "health", detail: message };
case "back_online":
return { title: "Reporting again", tone: "good", kind: "health", detail: null };
case "disk_full":
return { title: "A disk got nearly full", tone: "bad", kind: "health", detail: message };
case "disk_ok":
return { title: "A disk is no longer nearly full", tone: "good", kind: "health", detail: null };
case "create":
return { title: "Server added", tone: "neutral", kind: "change", detail: null };
case "update":
return { title: "Details changed", tone: "neutral", kind: "change", detail: null };
case "rotate_token":
return { title: "Agent token replaced", tone: "neutral", kind: "change", detail: null };
case "set_tags":
return { title: "Tags changed", tone: "neutral", kind: "change", detail: null };
case "add_link":
return { title: "Admin link added", tone: "neutral", kind: "change", detail: label };
case "update_link":
return { title: "Admin link changed", tone: "neutral", kind: "change", detail: label };
case "remove_link":
return { title: "Admin link removed", tone: "neutral", kind: "change", detail: label };
}
}
return { title: `${humanize(category)}: ${action.replace(/_/g, " ")}`, tone: "neutral", kind: "change", detail: message ?? label };
}
export async function getServerActivity(serverId: number, now: Date = new Date(), limit = 60): Promise<ActivityEvent[]> {
const events: ActivityEvent[] = [];
const audits = await db
.select()
.from(auditLog)
.where(and(eq(auditLog.targetType, "server"), eq(auditLog.targetId, String(serverId))))
.orderBy(desc(auditLog.createdAt))
.limit(limit);
for (const a of audits) {
// Maintenance is shown from the windows themselves below, which also cover the ones nobody started by hand.
if (a.category === "maintenance") continue;
const d = describeAudit(a.category, a.action, parseDetail(a.detail));
events.push({ at: auditTimeToIso(a.createdAt), kind: d.kind, tone: d.tone, title: d.title, detail: d.detail, actor: a.actorLabel });
}
const windows = await db
.select()
.from(maintenanceWindows)
.where(and(eq(maintenanceWindows.targetType, "server"), eq(maintenanceWindows.targetId, serverId)))
.orderBy(desc(maintenanceWindows.startedAt))
.limit(20);
const nowIso = now.toISOString();
for (const w of windows) {
const cancelled = w.endsAt <= w.startedAt;
if (cancelled) continue; // set up and withdrawn before it began: nothing happened
const until = `until ${w.endsAt.slice(0, 16).replace("T", " ")} UTC`;
events.push({
at: w.startedAt,
kind: "maintenance",
tone: "info",
title: w.startedAt > nowIso ? "Maintenance scheduled" : "Maintenance started — alerts silenced",
detail: [w.reason, until].filter(Boolean).join(" · "),
actor: w.createdBy,
});
if (w.endsAt <= nowIso) {
events.push({ at: w.endsAt, kind: "maintenance", tone: "info", title: "Maintenance ended", detail: null, actor: null });
}
}
return events.sort((a, b) => b.at.localeCompare(a.at)).slice(0, limit);
}
+136
View File
@@ -0,0 +1,136 @@
/**
* How the things in the app connect, as a graph for the Map page: which Proxmox host each server runs on, which DNS names point
* at it, and which Uptime Kuma monitors watch it. Everything here is already known elsewhere in the app; this only puts it side
* by side. Nothing is guessed: a DNS name is a server's only when an A or AAAA record holds one of the server's own addresses,
* and a monitor only when its target is the server's (the same matching the Uptime Kuma page uses).
*/
import { and, eq, inArray } from "drizzle-orm";
import { db } from "../db/client.js";
import { dnsRecordsCache, dnsZonesCache, integrations, servers } from "../db/schema.js";
import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
import { createUptimeKumaAdapter } from "../integrations/uptimekuma/adapter.js";
import { getSettings } from "./settingsStore.js";
import { attachMatchedServers, toMatchableServers } from "./uptimeKumaMatch.js";
export type MapStatus = "ok" | "bad" | "warn" | "unknown";
export interface MapNode {
id: string;
kind: "host" | "server" | "dns" | "monitor";
label: string;
sub: string | null;
status: MapStatus;
/** Where in the app to find out more. */
href: string | null;
}
export interface MapEdge {
from: string;
to: string;
}
export interface MapData {
nodes: MapNode[];
edges: MapEdge[];
/** Things that couldn't be read, so the picture is incomplete. */
notes: string[];
}
/** More than this many DNS names on the map and it stops being a map. */
const MAX_DNS_NAMES = 60;
const KUMA_TIMEOUT_MS = 8_000;
function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {
let timer: ReturnType<typeof setTimeout>;
const limit = new Promise<never>((_, reject) => {
timer = setTimeout(() => reject(new Error(`timed out after ${ms / 1000}s`)), ms);
});
return Promise.race([work, limit]).finally(() => clearTimeout(timer));
}
function parseIps(stored: string | null): string[] {
if (!stored) return [];
try {
const v = JSON.parse(stored);
return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
} catch {
return [];
}
}
export async function buildTopology(now: Date = new Date()): Promise<MapData> {
const nodes: MapNode[] = [];
const edges: MapEdge[] = [];
const notes: string[] = [];
const { healthChecks } = await getSettings();
const offlineAfterMs = healthChecks.serverOfflineMinutes * 60_000;
const serverRows = await db.select().from(servers);
const integrationRows = await db.select({ id: integrations.id, name: integrations.name, type: integrations.type, enabled: integrations.enabled }).from(integrations);
const integrationName = new Map(integrationRows.map((i) => [i.id, i.name]));
// Servers, and the Proxmox hosts they run on.
const hostIds = new Set<string>();
for (const s of serverRows) {
const lastSeen = s.lastSeenAt ? Date.parse(s.lastSeenAt) : null;
const status: MapStatus = lastSeen === null ? "unknown" : now.getTime() - lastSeen > offlineAfterMs ? "bad" : "ok";
nodes.push({ id: `server:${s.id}`, kind: "server", label: s.name, sub: s.hostname, status, href: `/servers/${s.id}` });
if (s.proxmoxIntegrationId && s.proxmoxNode) {
const hostId = `host:${s.proxmoxIntegrationId}:${s.proxmoxNode}`;
if (!hostIds.has(hostId)) {
hostIds.add(hostId);
nodes.push({ id: hostId, kind: "host", label: s.proxmoxNode, sub: integrationName.get(s.proxmoxIntegrationId) ?? "Proxmox", status: "unknown", href: "/proxmox" });
}
edges.push({ from: hostId, to: `server:${s.id}` });
}
}
// DNS names that point at a server's own address.
const serversByIp = new Map<string, number[]>();
for (const s of serverRows) for (const ip of parseIps(s.ipAddresses)) serversByIp.set(ip, [...(serversByIp.get(ip) ?? []), s.id]);
if (serversByIp.size > 0) {
const records = await db
.select({ name: dnsRecordsCache.name, content: dnsRecordsCache.content, zoneName: dnsZonesCache.zoneName })
.from(dnsRecordsCache)
.leftJoin(dnsZonesCache, and(eq(dnsZonesCache.providerId, dnsRecordsCache.providerId), eq(dnsZonesCache.zoneId, dnsRecordsCache.zoneId)))
.where(and(inArray(dnsRecordsCache.type, ["A", "AAAA"]), inArray(dnsRecordsCache.content, [...serversByIp.keys()])));
const seen = new Set<string>();
for (const r of records) {
const zone = r.zoneName?.replace(/\.$/, "") ?? "";
const name = r.name === "@" ? zone : zone && !r.name.replace(/\.$/, "").endsWith(zone) ? `${r.name}.${zone}` : r.name.replace(/\.$/, "");
const id = `dns:${name}`;
if (!seen.has(id)) {
if (seen.size >= MAX_DNS_NAMES) {
if (!notes.some((n) => n.startsWith("Only the first"))) notes.push(`Only the first ${MAX_DNS_NAMES} DNS names are shown.`);
continue;
}
seen.add(id);
nodes.push({ id, kind: "dns", label: name, sub: null, status: "unknown", href: "/dns" });
}
for (const serverId of serversByIp.get(r.content) ?? []) {
if (!edges.some((e) => e.from === `server:${serverId}` && e.to === id)) edges.push({ from: `server:${serverId}`, to: id });
}
}
}
// Uptime Kuma monitors watching a server.
const matchable = toMatchableServers(serverRows.map((s) => ({ id: s.id, name: s.name, hostname: s.hostname, ips: s.ipAddresses })));
for (const row of integrationRows.filter((i) => i.type === "uptimekuma" && i.enabled)) {
try {
const loaded = await loadIntegrationConfig(row.id);
if (!loaded) continue;
const monitors = await withTimeout(createUptimeKumaAdapter(loaded.config as never).listMonitors(), KUMA_TIMEOUT_MS);
for (const m of attachMatchedServers(monitors, matchable)) {
if (!m.matchedServer) continue;
const id = `monitor:${row.id}:${m.id}`;
const status: MapStatus = m.status === "up" ? "ok" : m.status === "down" ? "bad" : m.status === "unknown" ? "unknown" : "warn";
nodes.push({ id, kind: "monitor", label: m.name, sub: row.name, status, href: "/uptime-kuma" });
edges.push({ from: `server:${m.matchedServer.id}`, to: id });
}
} catch (err) {
notes.push(`Couldn't read Uptime Kuma “${row.name}” (${err instanceof Error ? err.message : String(err)}), so its monitors are missing.`);
}
}
return { nodes, edges, notes };
}