Dashboard status banner, phone-friendly lists, and more command palette actions

- Dashboard: a banner that answers "is it fine?" (headline, root cause, kinds of problem, worst few); cards with a problem come first in their row
- Phone: Alerts, Updates and Inventory rows become compact cards, finger-sized buttons, Alerts drops its figure row; scanned inventory labels get an Edit button
- Command palette: acknowledge alerts, update a server, print a label, open hardware, "What depends on ...?"

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 22:00:19 +02:00
1 parent 43fc5e0272
commit b5384c1e03
12 files changed
+429 -118

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import type { AlertCategory, AlertItem, AlertsReport } from "../api/client";
export interface AlertSummary {
/** Problems that are raised and not under maintenance, held back or information only. */
standing: number;
/** Of those, how many somebody has said they are on. */
acknowledged: number;
/** Alerts held back because something they depend on is down. */
held: number;
/** The problems that explain others, and how many each accounts for. */
roots: { name: string; count: number; alertId: string }[];
/** How many problems nobody is on, by kind of alert. */
byCategory: { category: AlertCategory; count: number; worst: "critical" | "warning" }[];
tone: "green" | "yellow" | "red";
}
/** Where things stand, in numbers: the same reading of an alert report wherever it is told (the dashboard banner and the Alerts page). */
export function summariseAlerts(report: Pick<AlertsReport, "alerts">): AlertSummary {
const standing = report.alerts.filter((a: AlertItem) => !a.silenced && a.severity !== "info");
const acknowledged = standing.filter((a) => a.ack?.active).length;
const held = report.alerts.filter((a) => a.causedBy).length;
const roots = standing
.filter((a) => (a.affects?.length ?? 0) > 0)
.map((a) => ({ name: a.target?.name ?? a.source, count: report.alerts.filter((x) => x.causedBy?.alertId === a.id).length, alertId: a.id }))
.filter((r) => r.count > 0)
.sort((a, b) => b.count - a.count);
const cats = new Map<AlertCategory, { count: number; worst: "critical" | "warning" }>();
for (const a of standing) {
if (a.ack?.active) continue;
const have = cats.get(a.category) ?? { count: 0, worst: "warning" as const };
cats.set(a.category, { count: have.count + 1, worst: have.worst === "critical" || a.severity === "critical" ? "critical" : "warning" });
}
const byCategory = [...cats].map(([category, v]) => ({ category, ...v })).sort((a, b) => Number(b.worst === "critical") - Number(a.worst === "critical") || b.count - a.count);
const critical = standing.some((a) => a.severity === "critical" && !a.ack?.active);
return { standing: standing.length, acknowledged, held, roots, byCategory, tone: standing.length - acknowledged === 0 ? "green" : critical ? "red" : "yellow" };
}
+38
View File
@@ -0,0 +1,38 @@
import { useSyncExternalStore } from "react";
/**
* Whether dashboard cards that show a problem float to the top of their row (on by default). A preference of this browser only: the
* arrangement the person made with the arrows is untouched underneath and is what they edit.
*/
const KEY = "dashboard.problemsFirst";
const listeners = new Set<() => void>();
function read(): boolean {
try {
return localStorage.getItem(KEY) !== "0";
} catch {
return true;
}
}
let value = read();
export function setProblemsFirst(on: boolean): void {
value = on;
try {
localStorage.setItem(KEY, on ? "1" : "0");
} catch {
// a remembered choice is only a convenience
}
for (const l of listeners) l();
}
export function useProblemsFirst(): boolean {
return useSyncExternalStore(
(l) => {
listeners.add(l);
return () => listeners.delete(l);
},
() => value,
);
}