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

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