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
+418 -107

No files matched your search

+11 -3
View File
@@ -20,7 +20,10 @@ All modules from the original plan are built:
- Authentik OIDC login, roles (first user to sign in becomes admin), audit log
(changes made in the app, sign-ins and sign-outs with the IP they came from, new accounts, and the log's own
automatic trimming — attributed to "system"; settings changes show what changed, but never credentials)
- **Dashboard** — an overview of every system this app tracks, all sharing
- **Dashboard** — opens with a status banner that answers "is it fine?": one sentence ("All clear", "3 things need attention"), the root cause when one
problem explains others, which kinds of thing are wrong (each links to those alerts) and the worst few. Below it, a card whose status badge is red or yellow
comes first in its row, with a coloured top edge (switchable under Customise, remembered in that browser; your own arrangement is untouched underneath).
The rest is an overview of every system this app tracks, all sharing
one widget-card design (label + status badge, a small stat row, then its
own breakdown): DNS (domain/record counts per provider, cached records by
type), Secrets (monitored/expiring/expired, by type), and one widget per
@@ -379,12 +382,17 @@ button at the foot of the sidebar — or the `[` key
— narrows it to a strip of icons for more room on a laptop screen: a group's
pages then open in a small menu beside its icon, the alert and maintenance
counts stay visible, and your choice is remembered in that browser. On a phone
the sidebar is the same slide-out menu as ever.
the sidebar is the same slide-out menu as ever, and the pages people reach from a notification or a printed label are made for one hand: on Alerts,
Updates and Inventory each row becomes a compact card (worst first, with its buttons underneath), the buttons are finger-sized, the
acknowledge panel fills the screen, and the Alerts page leaves out its row of figures — the headline already says them. Scanning an
inventory label opens that piece of hardware at the top of the page, with an Edit button for operators.
**Getting around.** Ctrl/Cmd+K opens a search that also runs actions: go to any
page, switch light/dark or the density, start (or end) a maintenance window on
a server, integration or DNS provider ("silence elsa"), open the wall display,
sign out. "g" then a letter goes to a page (`g d` dashboard, `g a` alerts,
sign out. It also does the things you do most often: **acknowledge** one of the worst alerts nobody is on (for 4 hours, handed to you) or all of them
at once, **update** a server that has updates waiting (it opens the update panel, which still asks before anything runs), **print the label** for a piece of
hardware or open it in the inventory, and ask **"What depends on …?"** of a server or service (it opens the dependency map with that box picked). "g" then a letter goes to a page (`g d` dashboard, `g a` alerts,
`g s` servers, `g m` maintenance, `g i` integrations, `g k` secrets, `g p` map,
`g w` wall display), "/" jumps to the page's table search, and "?" lists them
all, and "j" / "k" move down and up the rows of a table that opens a panel (Enter
+74 -2
View File
@@ -3,6 +3,8 @@ import { useLocation, useNavigate } from "react-router-dom";
import { IconSearch } from "@tabler/icons-react";
import {
api,
type AlertItem,
type Asset,
type CurrentUser,
type DnsProviderType,
type IntegrationType,
@@ -11,6 +13,7 @@ import {
type MaintenanceWindow,
type SearchResponse,
type SecretType,
type UpdatesServer,
} from "../api/client";
import { isCurrent, isGroup, visibleNav, type NavLeaf } from "../layout/nav";
import { toggleFavorite, useFavorites } from "../utils/favorites";
@@ -159,6 +162,10 @@ export default function CommandPalette({
const [activeIndex, setActiveIndex] = useState(0);
const [targets, setTargets] = useState<MaintenanceTargets | null>(null);
const [windows, setWindows] = useState<MaintenanceWindow[]>([]);
// What the actions below are offered for, read each time the palette opens.
const [alertsToAck, setAlertsToAck] = useState<AlertItem[]>([]);
const [updatable, setUpdatable] = useState<UpdatesServer[]>([]);
const [assets, setAssets] = useState<Asset[]>([]);
const inputRef = useRef<HTMLInputElement>(null);
const opener = useRef<HTMLElement | null>(null);
const navigate = useNavigate();
@@ -200,6 +207,21 @@ export default function CommandPalette({
setWindows(res.windows);
})
.catch(() => {});
if (canAct) {
api.alerts
.list(false)
.then((res) => setAlertsToAck(res.alerts.filter((a) => !a.silenced && a.severity !== "info" && !a.ack?.active).sort((a, b) => Number(b.severity === "critical") - Number(a.severity === "critical"))))
.catch(() => setAlertsToAck([]));
api.servers
.updates()
.then((res) => setUpdatable(res.servers.filter((s) => (s.updates?.count ?? 0) > 0)))
.catch(() => setUpdatable([]));
}
api.inventory
.list()
.then((res) => setAssets(res.assets))
.catch(() => setAssets([]));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [open]);
// The commands: pages to go to, and things to do.
@@ -248,6 +270,56 @@ export default function CommandPalette({
},
keywords: "refresh reload alerts",
});
// Quick acknowledgements: the worst few alerts nobody is on, and all of them at once.
if (canAct && alertsToAck.length > 0) {
const ack = async (list: AlertItem[]) => {
try {
await Promise.all(list.map((a) => api.alerts.ack({ alertId: a.id, note: "Acknowledged from the command palette", assigneeId: user.id, hours: 4 })));
toast.success(list.length === 1 ? "Acknowledged for 4 hours, handed to you. Change that on the Alerts page." : `Acknowledged ${list.length} alerts for 4 hours, handed to you.`);
window.dispatchEvent(new Event("maintenance-changed"));
} catch (err) {
toast.error(readableError(err));
}
};
for (const a of alertsToAck.slice(0, 5)) {
items.push({ key: `ack-${a.id}`, category: "Alerts", title: `Acknowledge: ${a.message}`, subtitle: `${a.severity} · for 4 hours, handed to you`, run: () => ack([a]), keywords: "acknowledge ack alert on it mine" });
}
if (alertsToAck.length > 1) {
items.push({ key: "ack-all", category: "Alerts", title: `Acknowledge all ${alertsToAck.length} alerts nobody is on`, subtitle: "for 4 hours, handed to you", run: () => ack(alertsToAck), keywords: "acknowledge ack alerts all" });
}
}
items.push({ key: "go-alerts-open", category: "Alerts", title: "Show the alerts nobody is on", subtitle: "", path: "/alerts", keywords: "alerts unacknowledged attention" });
// Update a server straight from here: opens the update drawer for it, which asks before it does anything.
if (canAct) {
for (const s of updatable) {
items.push({
key: `update-${s.id}`,
category: "Updates",
title: `Update ${s.name} now`,
subtitle: `${s.updates?.count ?? 0} waiting${s.updates?.security ? ` · ${s.updates.security} security` : ""}`,
path: `/updates?update=${s.id}`,
keywords: "update upgrade patch install run",
});
}
}
// Hardware: open it, or print its label.
items.push({ key: "inv-labels", category: "Inventory", title: "Print inventory labels", subtitle: "a sheet of QR stickers", path: "/inventory/labels", keywords: "label labels qr print sticker" });
for (const a of assets) {
items.push({ key: `inv-open-${a.id}`, category: "Inventory", title: `Open ${a.name} in the inventory`, subtitle: [a.manufacturer, a.model].filter(Boolean).join(" "), path: `/inventory?asset=${a.id}`, keywords: "hardware asset inventory serial" });
items.push({ key: `inv-label-${a.id}`, category: "Inventory", title: `Print the label for ${a.name}`, subtitle: a.rackUnit ?? a.location ?? "", path: `/inventory/labels?only=${a.id}`, keywords: "label qr print sticker" });
}
// What would go down with a server or a service.
if (targets) {
for (const s of targets.servers) {
items.push({ key: `dep-server-${s.id}`, category: "Dependencies", title: `What depends on ${s.name}?`, subtitle: "server · opens the dependency map", path: `/map?view=dependencies&select=server:${s.id}`, keywords: "depends dependency impact reboot down" });
}
for (const i of targets.integrations) {
items.push({ key: `dep-int-${i.id}`, category: "Dependencies", title: `What depends on ${i.name}?`, subtitle: `${i.type} · opens the dependency map`, path: `/map?view=dependencies&select=integration:${i.id}`, keywords: "depends dependency impact down" });
}
}
items.push({ key: "act-shortcuts", category: "Actions", title: "Show keyboard shortcuts", subtitle: "", hint: "?", run: () => void window.dispatchEvent(new Event(SHOW_SHORTCUTS_EVENT)), keywords: "keys help" });
if (user.role === "admin") {
items.push({
@@ -315,7 +387,7 @@ export default function CommandPalette({
}
return items;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [user.role, canAct, targets, windows, onToggleTheme, onSetDensity, pathname, favorites]);
}, [user.role, user.id, canAct, targets, windows, alertsToAck, updatable, assets, onToggleTheme, onSetDensity, pathname, favorites]);
const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
@@ -438,7 +510,7 @@ export default function CommandPalette({
aria-autocomplete="list"
aria-label="Search, or type a command"
className="form-control form-control-lg border-0"
placeholder="Search, or type a command: silence, theme, wall…"
placeholder="Search, or type a command: acknowledge, update, label…"
value={query}
onChange={(e) => setQuery(e.target.value)}
onKeyDown={handleInputKeyDown}
+4 -2
View File
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import { api, type DependencyGraph, type DependencyGraphNode } from "../api/client";
import { ErrorNotice } from "./Notice";
import { PageSkeleton } from "./Skeleton";
@@ -88,7 +88,9 @@ const names = (graph: DependencyGraph, keys: Iterable<string>) => [...keys].map(
export default function DependencyMap() {
const [graph, setGraph] = useState<DependencyGraph | null>(null);
const [error, setError] = useState<string | null>(null);
const [selected, setSelected] = useState<string | null>(null);
// From the command palette ("What depends on …?"): start with that box picked.
const [params] = useSearchParams();
const [selected, setSelected] = useState<string | null>(params.get("select"));
const [hover, setHover] = useState<string | null>(null);
useEffect(() => {
+66 -57
View File
@@ -1,10 +1,16 @@
import { Link } from "react-router-dom";
import { IconAlertTriangle, IconCircleCheck, IconInfoCircle } from "@tabler/icons-react";
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
import { useAlertsReport } from "../hooks/useAlertsReport";
import { summariseAlerts } from "../utils/alertSummary";
import { CATEGORY_LABELS } from "./RoutingEditor";
import TimeAgo from "./TimeAgo";
const SEVERITY_ORDER = { critical: 0, warning: 1, info: 2 } as const;
/** One line at the top of the dashboard: is anything wrong right now? Reads the same alert report as the Alerts page. */
/**
* The first thing on the dashboard, and the answer to "is it fine?": one sentence, the cause when one problem explains several, which kinds of
* thing are wrong, and the worst few. Reads the same alert report as the Alerts page.
*/
export default function StatusStrip() {
const { report, failed, reload } = useAlertsReport();
@@ -22,82 +28,85 @@ export default function StatusStrip() {
);
}
const badge = alertBadge(report);
const active = report.alerts
.filter((a) => !a.silenced && a.severity !== "info")
.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
const silenced = report.counts.silenced;
const grouped = report.counts.grouped ?? 0;
const sum = summariseAlerts(report);
const needs = sum.standing - sum.acknowledged;
const blind = report.couldntCheck.length;
const acked = report.counts.acknowledged ?? 0;
const silenced = report.counts.silenced;
const active = report.alerts
.filter((a) => !a.silenced && a.severity !== "info" && !a.ack?.active)
.sort((a, b) => SEVERITY_ORDER[a.severity] - SEVERITY_ORDER[b.severity]);
// "All clear" would claim more than is known if some checks couldn't run.
const unsure = needs === 0 && blind > 0;
const tone = unsure ? "yellow" : sum.tone;
const headline = unsure
? "No active alerts, but some checks couldn't run"
: needs > 0
? `${needs} ${needs === 1 ? "thing needs" : "things need"} attention`
: sum.acknowledged > 0
? "Nothing new"
: "All clear";
const notes: string[] = [];
if (needs === 0 && sum.acknowledged > 0) notes.push(`${sum.acknowledged} acknowledged — somebody is on ${sum.acknowledged === 1 ? "it" : "them"}`);
else if (sum.acknowledged > 0) notes.push(`${sum.acknowledged} more acknowledged`);
if (silenced > 0) notes.push(`${silenced} silenced by maintenance`);
if (grouped > 0) notes.push(`${grouped} more explained by a server that is down`);
if (blind > 0 && badge) notes.push(`${blind} check${blind === 1 ? "" : "s"} couldn't run`);
if (sum.held > 0 && sum.roots.length === 0) notes.push(`${sum.held} more explained by something that is down`);
if (needs === 0 && !unsure && notes.length === 0) notes.push("No active alerts.");
if (unsure) notes.push(`${report.couldntCheck.map((c) => c.name).join(", ")} — see Alerts for what that leaves unchecked`);
else if (blind > 0) notes.push(`${blind} check${blind === 1 ? "" : "s"} couldn't run`);
if (!badge) {
// Nothing is wrong that we can see — but if some checks couldn't run, "all clear" would claim more than is known.
const unsure = blind > 0;
return (
<div className={`alert ${unsure ? "alert-warning" : "alert-success"} mb-3`} role="status">
<div className="d-flex align-items-center gap-2">
{unsure ? <IconAlertTriangle size={18} className="flex-shrink-0" /> : <IconCircleCheck size={18} className="flex-shrink-0" />}
<div>
<strong>{unsure ? "No active alerts, but some checks couldn't run." : acked > 0 ? "Nothing new." : "All clear."}</strong>{" "}
{unsure ? (
<span>
{report.couldntCheck.map((c) => c.name).join(", ")} — see <Link to="/alerts">Alerts</Link> for what that leaves unchecked.
</span>
) : (
<span className="text-secondary">{acked > 0 ? `${acked} acknowledged — somebody is on ${acked === 1 ? "it" : "them"}. See Alerts.` : "No active alerts."}</span>
)}
{silenced > 0 && <span className="text-secondary"> {silenced} silenced by maintenance.</span>}
{grouped > 0 && <span className="text-secondary"> {grouped} more explained by a server that is down.</span>}
</div>
</div>
</div>
);
}
const need = report.counts.attention ?? report.counts;
const parts = [
need.critical > 0 ? `${need.critical} critical` : null,
need.warning > 0 ? `${need.warning} warning${need.warning === 1 ? "" : "s"}` : null,
(report.counts.acknowledged ?? 0) > 0 ? `${report.counts.acknowledged} acknowledged` : null,
].filter(Boolean);
const Icon = tone === "green" ? IconCircleCheck : IconAlertTriangle;
return (
<div className={`alert ${badge.level === "critical" ? "alert-danger" : "alert-warning"} mb-3`} role="alert">
<div className="d-flex gap-2 w-100">
<IconAlertTriangle size={18} className="flex-shrink-0 mt-1" />
<div className="flex-fill">
<section className={`card mb-3 status-banner status-banner-${tone}`} aria-label="Status" role={tone === "red" ? "alert" : "status"}>
<div className="card-body">
<div className="d-flex gap-3">
<Icon size={32} className={`flex-shrink-0 status-banner-icon status-banner-icon-${tone}`} aria-hidden="true" />
<div className="flex-fill" style={{ minWidth: 0 }}>
<div className="d-flex flex-wrap align-items-center gap-2">
<div>
<strong>
{badge.count} {badge.count === 1 ? "thing needs" : "things need"} attention
</strong>{" "}
— {parts.join(", ")}
{notes.length > 0 && <span className="opacity-75"> · {notes.join(" · ")}</span>}
</div>
<h3 className="mb-0">{headline}</h3>
<Link to="/alerts" className="btn btn-sm ms-auto flex-shrink-0">
View all alerts
{needs > 0 ? "View all alerts" : "Alerts"}
</Link>
</div>
{sum.roots.length > 0 && (
<div className="mt-1">
<strong>Root cause:</strong>{" "}
{sum.roots.slice(0, 3).map((r, i) => (
<span key={r.alertId}>
{i > 0 && ", "}
{r.name} <span className="text-secondary">(accounts for {r.count} more)</span>
</span>
))}
</div>
)}
{notes.length > 0 && <div className="text-secondary mt-1">{notes.join(" · ")}</div>}
{sum.byCategory.length > 0 && (
<div className="d-flex flex-wrap gap-2 mt-2" aria-label="What is wrong, by kind">
{sum.byCategory.map((c) => (
<Link key={c.category} to={`/alerts?category=${c.category}`} className={`badge ${c.worst === "critical" ? "bg-red-lt text-red" : "bg-yellow-lt text-yellow"}`}>
{CATEGORY_LABELS[c.category]} · {c.count}
</Link>
))}
</div>
)}
{active.length > 0 && (
<ul className="mb-0 mt-2 ps-3">
{active.slice(0, 3).map((a) => (
<li key={a.id}>
<Link to={a.link ?? "/alerts"} className="alert-link">
{a.message}
</Link>
<Link to={a.link ?? "/alerts"}>{a.message}</Link>
</li>
))}
{active.length > 3 && <li className="opacity-75">and {active.length - 3} more</li>}
{active.length > 3 && <li className="text-secondary">and {active.length - 3} more</li>}
</ul>
)}
<div className="text-secondary small mt-2">
Checked <TimeAgo value={report.generatedAt} />
</div>
</div>
</div>
</div>
</section>
);
}
+17 -20
View File
@@ -1,5 +1,5 @@
import { Fragment, useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import { api, type AlertCategory, type AlertItem, type AlertSeverity, type AlertsReport, type CurrentUser } from "../api/client";
import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh";
@@ -16,6 +16,7 @@ import RunPlaybookButton from "../components/RunPlaybookButton";
import RunbookEntry from "../components/RunbookEntry";
import AckDrawer, { ackWords } from "../components/AckDrawer";
import { useAlertsReport } from "../hooks/useAlertsReport";
import { summariseAlerts } from "../utils/alertSummary";
const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: number }> = {
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
@@ -46,7 +47,12 @@ export default function Alerts({ user }: { user: CurrentUser }) {
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
const [severity, setSeverity] = useState<"all" | AlertSeverity>("all");
const [category, setCategory] = useState<"all" | AlertCategory>("all");
// The dashboard's chips link here with ?category=…
const [params] = useSearchParams();
const [category, setCategory] = useState<"all" | AlertCategory>(() => {
const wanted = params.get("category");
return wanted && wanted in CATEGORY_LABELS ? (wanted as AlertCategory) : "all";
});
const [search, setSearch] = useState("");
const [showSilenced, setShowSilenced] = useState(true);
// Which alerts to show by whether somebody is on them, and the one whose acknowledgement is being edited.
@@ -115,18 +121,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
}, [report, severity, category, search, showSilenced, attention, user.id, grouped]);
// One line on where things stand: how many need someone, and which problems explain the rest.
const headline = useMemo(() => {
if (!report || report.alerts.length === 0) return null;
const standing = report.alerts.filter((a) => !a.silenced);
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 }))
.filter((r) => r.count > 0);
const critical = standing.some((a) => a.severity === "critical");
return { standing: standing.length, acknowledged, held, roots, tone: standing.length === 0 ? "green" : critical ? "red" : "yellow" };
}, [report]);
const headline = useMemo(() => (report && report.alerts.length > 0 ? summariseAlerts(report) : null), [report]);
// No initial sort: the server already puts active problems first, worst first.
const { sorted, sortKey, sortDir, requestSort } = useSortable(rows);
@@ -193,8 +188,10 @@ export default function Alerts({ user }: { user: CurrentUser }) {
<div className={`card mb-3 alerts-headline alerts-headline-${headline.tone}`} role="status">
<div className="card-body py-3">
<div className="h3 mb-1">
{headline.standing === 0 ? "Nothing needs attention" : `${headline.standing} ${headline.standing === 1 ? "problem needs" : "problems need"} attention`}
{headline.acknowledged > 0 && headline.standing > 0 && <span className="text-secondary fw-normal fs-4"> · {headline.acknowledged} acknowledged</span>}
{headline.standing - headline.acknowledged === 0
? "Nothing needs attention"
: `${headline.standing - headline.acknowledged} ${headline.standing - headline.acknowledged === 1 ? "problem needs" : "problems need"} attention`}
{headline.acknowledged > 0 && <span className="text-secondary fw-normal fs-4"> · {headline.acknowledged} acknowledged</span>}
</div>
{headline.held > 0 && (
<div className="text-secondary">
@@ -216,7 +213,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</div>
</div>
)}
<div className="row g-3 mb-3">
<div className="row g-3 mb-3 d-none d-md-flex">
{cards.map((c) => (
<div className="col-6 col-md-3" key={c.label}>
<div className="card card-sm">
@@ -309,7 +306,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
}
/>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<SortableTh<Row> label="Severity" sortKeyName="rank" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
@@ -332,7 +329,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</td>
<td>{CATEGORY_LABELS[a.category]}</td>
<td>{a.link ? <Link to={a.link}>{a.source}</Link> : a.source}</td>
<td>
<td className="stack-wide">
{a.message}
{a.causedBy ? (
<span className="badge bg-secondary-lt text-secondary ms-2" title={`${a.causedBy.name} is down too, which explains this — notifications for this are held back. If ${a.causedBy.name} comes back and this stays down, it alerts then.`}>
@@ -404,7 +401,7 @@ export default function Alerts({ user }: { user: CurrentUser }) {
})()}
</td>
{canSilence && (
<td className="text-nowrap">
<td className="text-nowrap stack-wide">
<div className="btn-list flex-nowrap">
{!a.silenced && (
<button type="button" className={`btn btn-sm ${a.ack?.active ? "btn-outline-primary" : "btn-outline-secondary"}`} onClick={() => setAcking(a)}>
+19 -4
View File
@@ -1,7 +1,8 @@
import { useEffect, useState, type ReactNode } from "react";
import { isValidElement, useEffect, useState, type ReactNode } from "react";
import { IconArrowLeft, IconArrowRight, IconEye, IconEyeOff } from "@tabler/icons-react";
import TimeAgo from "../components/TimeAgo";
import WhatChanged from "../components/WhatChanged";
import { setProblemsFirst, useProblemsFirst } from "../utils/problemsFirst";
import { UNPLACED, moveCard, resetDashboardLayout, setCardHidden, setEditingDashboard, useDashboardLayout } from "../utils/dashboardLayout";
import { Link } from "react-router-dom";
import {
@@ -188,16 +189,25 @@ function MiniStat({ label, value, accent }: { label: string; value: ReactNode; a
}
/** The single card shape shared by every dashboard widget — DNS, Secrets, and each integration — so they all read as one family: a label + status badge, then whatever stats/breakdown that widget has. */
/** Whether a card's status badge says something is wrong: the badges of a card in trouble are red or yellow, so that is what is read. */
function problemOf(badge: ReactNode): "bad" | "warn" | null {
if (!isValidElement(badge)) return null;
const cls = String((badge.props as { className?: string }).className ?? "");
return /\bbg-red/.test(cls) ? "bad" : /\bbg-yellow/.test(cls) ? "warn" : null;
}
function WidgetCard({ label, badge, hide, children }: { label: string; badge?: ReactNode; /** Nothing is set up for this yet: it is listed under "Not set up yet" instead of taking a card. */ hide?: boolean; children: ReactNode }) {
const { layout, editing } = useDashboardLayout();
const problemsFirst = useProblemsFirst();
if (hide) return null;
// The person's own arrangement: cards they hid are gone (shown dimmed while arranging, so they can be brought back), and the
// rest follow the order they chose — a card nobody has placed goes last, in the order it was drawn.
const hidden = layout.hidden.includes(label);
const problem = problemOf(badge);
if (hidden && !editing) return null;
return (
<div className="col-md-6" data-card={label} style={{ order: layout.order[label] ?? UNPLACED }}>
<div className={`card h-100 ${hidden ? "card-hidden" : ""}`}>
<div className="col-md-6" data-card={label} style={{ order: (layout.order[label] ?? UNPLACED) - (problemsFirst && !editing ? (problem === "bad" ? 2_000_000 : problem === "warn" ? 1_000_000 : 0) : 0) }}>
<div className={`card h-100 ${hidden ? "card-hidden" : ""} ${problem ? `card-problem card-problem-${problem}` : ""}`}>
{editing && (
<div className="card-customise">
<button type="button" className="btn btn-sm btn-icon" aria-label={`Move ${label} earlier`} title="Move earlier" onClick={(e) => void moveCard(e.currentTarget.closest<HTMLElement>("[data-card]")!, -1)}>
@@ -314,6 +324,7 @@ function formatBytes(bytes: number | null): string {
export default function Dashboard({ user }: { user: CurrentUser }) {
const { editing } = useDashboardLayout();
const problemsFirst = useProblemsFirst();
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
const [tailscaleSummary, setTailscaleSummary] = useState<TailscaleDevicesResponse["summary"] | null>(null);
const [tailscaleExtra, setTailscaleExtra] = useState<TailscaleExtra | null>(null);
@@ -623,7 +634,11 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
{editing && (
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2" role="status">
<span>Move the cards with the arrows and hide the ones you don't use. It saves as you go, for you only, and follows you to other browsers.</span>
<button type="button" className="btn btn-sm ms-auto" onClick={() => void resetDashboardLayout()}>
<label className="form-check mb-0 ms-auto">
<input type="checkbox" className="form-check-input" checked={problemsFirst} onChange={(e) => setProblemsFirst(e.target.checked)} />
<span className="form-check-label">Cards with a problem come first</span>
</label>
<button type="button" className="btn btn-sm" onClick={() => void resetDashboardLayout()}>
Reset to default
</button>
</div>
+20 -9
View File
@@ -203,6 +203,12 @@ export default function Inventory({ user }: { user: CurrentUser }) {
return servers.find((s) => s.name.toLowerCase() === n) ?? servers.find((s) => s.name.length >= 3 && n.includes(s.name.toLowerCase())) ?? null;
})();
// The form can be a long way down (on a phone, below the cards): bring it into view when it opens.
useEffect(() => {
if (draft) document.getElementById("inventory-form")?.scrollIntoView({ behavior: "smooth", block: "start" });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [draft === null, draft?.id]);
const set = <K extends keyof Draft>(key: K, value: Draft[K]) => setDraft((d) => (d ? { ...d, [key]: value } : d));
const cards: { label: string; value: string; note?: string; color: string }[] = [
@@ -238,7 +244,12 @@ export default function Inventory({ user }: { user: CurrentUser }) {
<div className="card mb-3 border-primary">
<div className="card-header">
<h3 className="card-title">{focused.name}</h3>
<div className="card-actions">
<div className="card-actions btn-list">
{canEdit && (
<button className="btn btn-sm btn-primary" onClick={() => setDraft(toDraft(focused))}>
Edit
</button>
)}
<button className="btn btn-sm" onClick={() => setParams((p) => { const n = new URLSearchParams(p); n.delete("asset"); return n; }, { replace: true })}>
Close
</button>
@@ -290,7 +301,7 @@ export default function Inventory({ user }: { user: CurrentUser }) {
</div>
{draft && (
<form className="card mb-3" onSubmit={save}>
<form id="inventory-form" className="card mb-3" onSubmit={save}>
<div className="card-header">
<h3 className="card-title">{draft.id === null ? "Add hardware" : `Edit ${draft.name || "hardware"}`}</h3>
</div>
@@ -446,7 +457,7 @@ export default function Inventory({ user }: { user: CurrentUser }) {
exportDisabled={!sorted || sorted.length === 0}
/>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<SortableTh<Asset> label="Name" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
@@ -468,7 +479,7 @@ export default function Inventory({ user }: { user: CurrentUser }) {
)}
{page.pageItems?.map((a) => (
<tr key={a.id}>
<td>
<td className="stack-wide">
{a.name}
{(a.manufacturer || a.model) && <div className="text-secondary small">{[a.manufacturer, a.model].filter(Boolean).join(" ")}</div>}
{a.server && (
@@ -486,20 +497,20 @@ export default function Inventory({ user }: { user: CurrentUser }) {
)}
</td>
<td>{KIND_LABELS[a.kind]}</td>
<td>
<td className="stack-label" data-label="Where">
{a.location ?? "—"}
{a.rackUnit && <span className="text-secondary"> · {a.rackUnit}</span>}
</td>
<td className="text-secondary">
<td className="text-secondary stack-label" data-label="Bought">
{a.purchaseDate ?? "—"}
{a.purchasePrice !== null && <div className="small">{money(a.purchasePrice, config.currency)}</div>}
</td>
<td>
<td className="stack-label" data-label="Warranty">
<WarrantyBadge until={a.warrantyUntil} />
</td>
<td>{a.powerWatts === null ? <span className="text-secondary">—</span> : `${a.powerWatts} W`}</td>
<td className="stack-label" data-label="Power">{a.powerWatts === null ? <span className="text-secondary">—</span> : `${a.powerWatts} W`}</td>
{canEdit && (
<td>
<td className="stack-wide">
<div className="btn-list flex-nowrap">
<button className="btn btn-sm btn-outline-secondary" onClick={() => setDraft(toDraft(a))}>
Edit
+6 -2
View File
@@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import { api, type Asset } from "../api/client";
import QrCode from "../components/QrCode";
import { ErrorNotice } from "../components/Notice";
@@ -28,15 +28,19 @@ export default function InventoryLabels() {
const [chosen, setChosen] = useState<Set<number>>(new Set());
const [size, setSize] = useState<SizeKey>("medium");
const [showBorder, setShowBorder] = useState(true);
// From the command palette (?only=ID): start with just that piece of hardware ticked.
const [params] = useSearchParams();
const only = /^\d+$/.test(params.get("only") ?? "") ? Number(params.get("only")) : null;
useEffect(() => {
api.inventory
.list()
.then((res) => {
setAssets(res.assets);
setChosen(new Set(res.assets.map((a) => a.id)));
setChosen(new Set(only !== null && res.assets.some((a) => a.id === only) ? [only] : res.assets.map((a) => a.id)));
})
.catch((err) => setError(readableError(err)));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const picked = useMemo(() => (assets ?? []).filter((a) => chosen.has(a.id)), [assets, chosen]);
+24 -8
View File
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import { api, type AgentLatest, type CurrentUser, type DockhandContainer, type UpdatesServer } from "../api/client";
import { agentState, agentVersionWords } from "../utils/agent";
import SortableTh from "../components/SortableTh";
@@ -65,6 +65,22 @@ export default function Updates({ user }: { user: CurrentUser }) {
const [containers, setContainers] = useState<(DockhandContainer & { integrationName: string })[] | null>(null);
const [error, setError] = useState<string | null>(null);
const [onlyWaiting, setOnlyWaiting] = useState(false);
// The command palette sends people here with ?update=ID to update that server straight away.
const [params, setParams] = useSearchParams();
const wantedUpdate = params.get("update");
useEffect(() => {
if (!wantedUpdate || !servers || !canRun) return;
const server = servers.find((s) => String(s.id) === wantedUpdate);
if (server) setUpdating(server);
setParams(
(prev) => {
const next = new URLSearchParams(prev);
next.delete("update");
return next;
},
{ replace: true },
);
}, [wantedUpdate, servers, canRun, setParams]);
function reload() {
api.servers
@@ -178,7 +194,7 @@ export default function Updates({ user }: { user: CurrentUser }) {
exportDisabled={!sorted || sorted.length === 0}
/>
<div className="table-responsive">
<table className="table table-vcenter card-table">
<table className="table table-vcenter card-table table-stack">
<thead>
<tr>
<SortableTh<Row> label="Server" sortKeyName="name" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
@@ -200,16 +216,16 @@ export default function Updates({ user }: { user: CurrentUser }) {
)}
{sorted?.map((r) => (
<tr key={r.id}>
<td>
<td className="stack-wide">
<Link to={`/servers/${r.id}`}>{r.name}</Link> <span className="text-secondary small">{r.manager}</span>
</td>
<td>
<UpdatesBadge updates={r.server.updates} />
</td>
<td>{r.security === null ? <span className="text-secondary">—</span> : r.security}</td>
<td className="text-secondary">{r.since ? <TimeAgo value={r.since} /> : "—"}</td>
<td className="text-secondary">{r.reportedAt ? <TimeAgo value={r.reportedAt} /> : "—"}</td>
<td>
<td className="stack-label" data-label="Security">{r.security === null ? <span className="text-secondary">—</span> : r.security}</td>
<td className="text-secondary stack-label" data-label="Waiting since">{r.since ? <TimeAgo value={r.since} /> : "—"}</td>
<td className="text-secondary stack-label" data-label="Reported">{r.reportedAt ? <TimeAgo value={r.reportedAt} /> : "—"}</td>
<td className="stack-label" data-label="Agent">
{agentVersionWords(r.agentVersion)}{" "}
{agentState(r.server, agentLatest) === "behind" && (
<span className="badge bg-yellow-lt text-yellow" title="Older than the agent this Homelab Manager would install now.">
@@ -218,7 +234,7 @@ export default function Updates({ user }: { user: CurrentUser }) {
)}
</td>
{canRun && (
<td>
<td className="stack-wide">
<button type="button" className="btn btn-sm btn-outline-primary" disabled={r.count === null || r.count === 0 || r.server.lastSeenAt === null} title={r.count ? "Apply this server's updates through a Semaphore playbook" : "Nothing is waiting, or the agent hasn't said"} onClick={() => setUpdating(r.server)}>
Update…
</button>
+103
View File
@@ -1613,3 +1613,106 @@ tr.alert-row-child > td:first-child {
box-shadow: none;
padding-left: 1.5rem;
}
/* ── The dashboard's status banner and the cards that have a problem. ── */
.status-banner {
border-left: 5px solid var(--tblr-border-color);
}
.status-banner-green {
border-left-color: #2fb344;
}
.status-banner-yellow {
border-left-color: #f0a82c;
}
.status-banner-red {
border-left-color: #e05252;
}
.status-banner-icon-green {
color: #2fb344;
}
.status-banner-icon-yellow {
color: #f0a82c;
}
.status-banner-icon-red {
color: #e05252;
}
.card.card-problem-bad {
border-top: 3px solid #e05252;
}
.card.card-problem-warn {
border-top: 3px solid #f0a82c;
}
/* ── On a phone, a table marked table-stack is a compact card per row instead of the labelled list every table gets (see "wide tables become a stack of
cards" above): the cells run on along the line, the ones marked stack-wide take a line of their own, and only those marked stack-label keep their heading. ── */
@media (max-width: 767.98px) {
table.table-stack tbody tr {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.3rem 0.75rem;
padding: 0.85rem 1rem;
}
table.table-stack tbody tr > td {
display: block;
width: auto;
min-width: 0;
min-height: 0;
padding: 0 !important;
white-space: normal !important;
}
table.table-stack tbody tr > td::before {
content: none !important;
}
table.table-stack tbody tr > td.stack-label[data-label]::before {
content: attr(data-label) ": " !important;
position: static;
display: inline;
width: auto;
padding: 0;
font-size: 0.8rem;
font-weight: 400;
color: var(--tblr-secondary);
text-transform: none;
letter-spacing: 0;
}
table.table-stack tbody tr > td.stack-wide,
table.table-stack tbody tr > td[colspan] {
flex: 1 0 100%;
}
table.table-stack .btn-list {
flex-wrap: wrap !important;
}
}
/* Finger-sized controls on a phone or any touch screen. */
@media (max-width: 767.98px), (pointer: coarse) {
.btn.btn-sm:not(.btn-link):not(.btn-icon),
.form-select-sm,
.form-control-sm {
min-height: 2.5rem;
}
.btn.btn-sm:not(.btn-link):not(.btn-icon) {
padding-left: 0.9rem;
padding-right: 0.9rem;
}
.form-check-input {
width: 1.25rem;
height: 1.25rem;
}
}
+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,
);
}