Add saved filter views, a customisable dashboard, server comparison, row keyboard navigation and share links

- Table search, status, tag and sort live in the address; Save view pins one as a favourite.
- Dashboard cards can be moved and hidden per user (users.dashboard_layout, migration 0022).
- Compare two to four servers' load, memory or disk on one chart.
- j/k move through table rows that open a detail panel.
- Share links open a read-only wall without signing in, numbers only or with names
  (share_links, migration 0023); the wall is split into a shared view over two data sources.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-16 22:15:29 +02:00
1 parent 906220040e
commit 44e393f172
50 files changed
+6114 -258

No files matched your search

+7 -1
View File
@@ -14,6 +14,7 @@ import {
} from "../api/client";
import { isCurrent, isGroup, visibleNav, type NavLeaf } from "../layout/nav";
import { toggleFavorite, useFavorites } from "../utils/favorites";
import { describeView, splitView } from "../utils/savedViews";
import { SHOW_SHORTCUTS_EVENT, shortcutHintFor } from "../layout/shortcuts";
import { DENSITIES, type Density } from "../utils/density";
import { readableError } from "../utils/errors";
@@ -340,7 +341,12 @@ export default function CommandPalette({
const items = useMemo(() => {
if (terms.length === 0) {
const pinned = favorites
.map((p) => commands.find((c) => c.key === `page-${p}`))
.map((p) => {
const [base, search] = splitView(p);
const c = commands.find((x) => x.key === `page-${base}`);
// A pinned view goes to the page with its filters, and says what they are.
return c && search ? { ...c, key: `page-${p}`, path: p, title: `${c.title}: ${describeView(search)}` } : c;
})
.filter((c): c is PaletteItem => !!c)
.map((c) => ({ ...c, key: `fav-${c.key}`, category: "Favourites" }));
const wanted = ["page-/", "page-/alerts", "page-/servers", "page-/maintenance", "page-/wall", "act-theme", "act-shortcuts"];
+53
View File
@@ -0,0 +1,53 @@
import { formatDate, formatTime } from "../utils/date";
export interface ChartSeries {
name: string;
color: string;
/** SVG dash pattern, so lines can be told apart without their colour. Empty for a solid line. */
dash: string;
points: { t: string; v: number }[];
}
const W = 720;
const H = 260;
const PAD = { left: 40, right: 12, top: 10, bottom: 26 };
/**
* Several percentage lines over the same stretch of time, on a fixed 0–100% scale (so a quiet server never looks as busy as a loaded
* one). Each line has its own colour and dash pattern. It is a picture: the numbers are in the table beside it.
*/
export default function MultiLineChart({ series, from, to, label }: { series: ChartSeries[]; from: number; to: number; label: string }) {
const x = (t: number) => PAD.left + ((t - from) / Math.max(to - from, 1)) * (W - PAD.left - PAD.right);
const y = (v: number) => PAD.top + (1 - Math.min(100, Math.max(0, v)) / 100) * (H - PAD.top - PAD.bottom);
const ticks = [0, 0.25, 0.5, 0.75, 1].map((f) => from + f * (to - from));
const spanDays = (to - from) / 86_400_000;
const tickLabel = (t: number) => (spanDays <= 1.5 ? formatTime(new Date(t), false) : formatDate(new Date(t)).replace(/^\d{4}-|\/\d{4}$/, ""));
return (
<svg viewBox={`0 0 ${W} ${H}`} className="multi-chart" role="img" aria-label={label}>
{[0, 25, 50, 75, 100].map((v) => (
<g key={v}>
<line x1={PAD.left} x2={W - PAD.right} y1={y(v)} y2={y(v)} stroke="currentColor" strokeOpacity={v === 0 ? 0.4 : 0.15} />
<text x={PAD.left - 6} y={y(v) + 4} textAnchor="end" fontSize="11" fill="currentColor" fillOpacity="0.7">
{v}%
</text>
</g>
))}
{ticks.map((t, i) => (
<text key={i} x={x(t)} y={H - 6} textAnchor={i === 0 ? "start" : i === ticks.length - 1 ? "end" : "middle"} fontSize="11" fill="currentColor" fillOpacity="0.7">
{tickLabel(t)}
</text>
))}
{series.map((s) => {
if (s.points.length === 0) return null;
const d = s.points.map((p, i) => `${i === 0 ? "M" : "L"}${x(Date.parse(p.t)).toFixed(1)},${y(p.v).toFixed(1)}`).join(" ");
return s.points.length === 1 ? (
<circle key={s.name} cx={x(Date.parse(s.points[0].t))} cy={y(s.points[0].v)} r="3" fill={s.color} />
) : (
<path key={s.name} d={d} fill="none" stroke={s.color} strokeWidth="2" strokeDasharray={s.dash || undefined} strokeLinejoin="round" strokeLinecap="round" />
);
})}
</svg>
);
}
+39
View File
@@ -0,0 +1,39 @@
import { IconStar, IconStarFilled } from "@tabler/icons-react";
import { useLocation } from "react-router-dom";
import { toggleFavorite, useFavorites } from "../utils/favorites";
import { MAX_VIEW_QUERY, canonicalSearch, describeView, hasViewParams } from "../utils/savedViews";
import { toast } from "../utils/toast";
/**
* Pins the page as it is now — with its search words, status, tag and sort — to the top of the menu. It appears once something
* narrows or orders the table; a page with nothing set is saved with the star in the menu itself.
*/
export default function SaveViewButton() {
const { pathname, search } = useLocation();
const favorites = useFavorites();
if (!hasViewParams(search)) return null;
const view = canonicalSearch(search);
const path = `${pathname}${view}`;
const on = favorites.includes(path);
const label = on ? "Remove this view from favourites" : "Save this view to favourites";
return (
<button
type="button"
className="btn btn-sm btn-outline-secondary d-inline-flex align-items-center gap-1"
aria-pressed={on}
title={`${label}: ${describeView(view)}`}
onClick={() => {
if (!on && view.length - 1 > MAX_VIEW_QUERY) {
toast.info("That view is too long to save. Shorten the search first.");
return;
}
void toggleFavorite(path);
}}
>
{on ? <IconStarFilled size={16} aria-hidden="true" /> : <IconStar size={16} aria-hidden="true" />}
<span>{on ? "Saved view" : "Save view"}</span>
</button>
);
}
+2
View File
@@ -1,5 +1,6 @@
import type { ReactNode } from "react";
import { IconSearch } from "@tabler/icons-react";
import SaveViewButton from "./SaveViewButton";
/** The search box every table uses, so they look and behave alike. Esc clears it. */
export function SearchBox({
@@ -67,6 +68,7 @@ export default function TableToolbar({
{filters}
{narrowed && <span className="text-secondary small">{shown} of {total}</span>}
<div className="table-toolbar-actions">
<SaveViewButton />
{actions}
{onExport && (
<button type="button" className="btn btn-sm btn-outline-secondary" onClick={onExport} disabled={exportDisabled}>
+199
View File
@@ -0,0 +1,199 @@
import { useEffect, useState, type ReactNode } from "react";
import { formatDate, formatTime } from "../utils/date";
import { formatRemaining } from "../utils/duration";
export const REFRESH_MS = 30_000;
const TYPE_LABELS: Record<string, string> = {
tailscale: "Tailscale",
proxmox: "Proxmox",
synology: "Synology",
semaphore: "Semaphore",
gitea: "Gitea",
dockhand: "Docker",
uptimekuma: "Uptime Kuma",
phpipam: "phpIPAM",
pbs: "Proxmox Backup",
osticket: "osTicket",
};
export type WallLevel = "critical" | "warning" | "ok" | "unsure";
/** Everything the board shows. A list that is null is not shown on this board (a share link that only gives numbers). */
export interface WallData {
level: WallLevel;
headline: string;
servers: { online: number; total: number } | null;
alerts: { critical: number; warning: number } | null;
maintenance: number;
integrationsFailing: number | null;
problems: { id: string; severity: "critical" | "warning"; message: string }[] | null;
windows: { id: number; name: string; endsAt: string }[] | null;
integrations: { id: number; name: string; type: string; status: "ok" | "failing" | "unknown" }[] | null;
environmentName: string | null;
updatedAt: Date | null;
}
/** The headline in words for how many things need a look, or why there is no answer yet. */
export function wallHeadline(level: WallLevel, count: number, state: { loaded: boolean; failed: boolean }): string {
if (level === "critical" || level === "warning") return `${count} ${count === 1 ? "thing needs" : "things need"} attention`;
if (level === "unsure") return state.loaded ? "No alerts — but some checks couldn't run" : state.failed ? "Can't reach the server" : "Checking…";
return "All clear";
}
function useClock(): Date {
const [now, setNow] = useState(() => new Date());
useEffect(() => {
const t = setInterval(() => setNow(new Date()), 1000);
return () => clearInterval(t);
}, []);
return now;
}
/** Keeps the screen awake while the page is open, where the browser allows it. */
function useWakeLock() {
useEffect(() => {
let lock: { release: () => Promise<void> } | null = null;
let gone = false;
const request = async () => {
try {
const nav = navigator as Navigator & { wakeLock?: { request: (type: "screen") => Promise<{ release: () => Promise<void> }> } };
if (nav.wakeLock && !gone) lock = await nav.wakeLock.request("screen");
} catch {
// not allowed (battery saver, no permission): the screen may sleep like any other
}
};
void request();
const onVisible = () => document.visibilityState === "visible" && void request();
document.addEventListener("visibilitychange", onVisible);
return () => {
gone = true;
document.removeEventListener("visibilitychange", onVisible);
void lock?.release().catch(() => {});
};
}, []);
}
/**
* The board itself: a full-screen status picture in type big enough to read across a room. It only draws what it is given, so the
* signed-in wall and the one a share link opens look the same and can't drift apart.
*/
export default function WallView({ data, idle, footerActions }: { data: WallData; idle: boolean; footerActions: ReactNode }) {
const now = useClock();
useWakeLock();
const { level } = data;
const offline = data.servers ? data.servers.total - data.servers.online : 0;
const alertCount = data.alerts ? data.alerts.critical + data.alerts.warning : 0;
const showsDetail = data.problems !== null || data.windows !== null || data.integrations !== null;
return (
<div className={`wall ${idle ? "wall-idle" : ""}`} data-bs-theme="dark">
<header className="wall-header">
<img src="/logo.webp" alt="Homelab Manager" width={901} height={460} className="wall-logo" />
{data.environmentName && <span className="badge env-badge">{data.environmentName}</span>}
<div className="wall-clock" aria-label="Time">
<div className="wall-time">{formatTime(now, false)}</div>
<div className="wall-date">
{now.toLocaleDateString([], { weekday: "long" })} {formatDate(now)}
</div>
</div>
</header>
<section className={`wall-status wall-status-${level}`} role="status" aria-live="polite">
<span className="wall-status-symbol" aria-hidden="true">
{level === "critical" ? "✕" : level === "warning" ? "▲" : level === "ok" ? "✓" : "?"}
</span>
<span>{data.headline}</span>
</section>
<section className="wall-tiles" aria-label="Summary">
<div className={`wall-tile ${offline > 0 ? "wall-tile-bad" : ""}`}>
<div className="wall-tile-figure">{data.servers ? (data.servers.total === 0 ? "—" : `${data.servers.online}/${data.servers.total}`) : "…"}</div>
<div className="wall-tile-label">servers online</div>
</div>
<div className={`wall-tile ${(data.alerts?.critical ?? 0) > 0 ? "wall-tile-bad" : (data.alerts?.warning ?? 0) > 0 ? "wall-tile-warn" : ""}`}>
<div className="wall-tile-figure">{data.alerts ? alertCount : "…"}</div>
<div className="wall-tile-label">alerts{data.alerts && alertCount > 0 ? ` (${data.alerts.critical} critical, ${data.alerts.warning} warning)` : ""}</div>
</div>
<div className={`wall-tile ${data.maintenance > 0 ? "wall-tile-info" : ""}`}>
<div className="wall-tile-figure">{data.maintenance}</div>
<div className="wall-tile-label">in maintenance</div>
</div>
<div className={`wall-tile ${(data.integrationsFailing ?? 0) > 0 ? "wall-tile-bad" : ""}`}>
<div className="wall-tile-figure">{data.integrationsFailing === null ? "…" : data.integrationsFailing}</div>
<div className="wall-tile-label">integrations failing</div>
</div>
</section>
{showsDetail ? (
<section className="wall-columns">
<div>
{data.problems && (
<>
<h2 className="wall-heading">Needs attention</h2>
{data.problems.length === 0 ? (
<div className="wall-empty">Nothing right now.</div>
) : (
<ul className="wall-list">
{data.problems.slice(0, 7).map((a) => (
<li key={a.id} className={a.severity === "critical" ? "wall-bad" : "wall-warn"}>
<span aria-hidden="true">{a.severity === "critical" ? "✕" : "▲"}</span> <span className="visually-hidden">{a.severity}: </span>
{a.message}
</li>
))}
{alertCount > 7 && <li className="wall-more">and {alertCount - 7} more</li>}
</ul>
)}
</>
)}
{data.windows && data.windows.length > 0 && (
<>
<h2 className="wall-heading mt-4">In maintenance</h2>
<ul className="wall-list wall-list-small">
{data.windows.slice(0, 8).map((w) => (
<li key={w.id}>
{w.name} <span className="wall-dim">· {formatRemaining(w.endsAt, now.getTime())} left</span>
</li>
))}
{data.maintenance > 8 && <li className="wall-more">and {data.maintenance - 8} more</li>}
</ul>
</>
)}
</div>
<div>
{data.integrations && (
<>
<h2 className="wall-heading">Integrations</h2>
{data.integrations.length === 0 ? (
<div className="wall-empty">None connected.</div>
) : (
<ul className="wall-list wall-list-small">
{data.integrations.map((i) => (
<li key={i.id} className={i.status === "failing" ? "wall-bad" : i.status === "ok" ? "wall-good" : "wall-dim"}>
<span aria-hidden="true">{i.status === "failing" ? "✕" : i.status === "ok" ? "✓" : "·"}</span> {i.name}{" "}
<span className="wall-dim">
{TYPE_LABELS[i.type] ?? i.type} — {i.status === "failing" ? "failing" : i.status === "ok" ? "working" : "not checked yet"}
</span>
</li>
))}
</ul>
)}
</>
)}
</div>
</section>
) : (
<section className="wall-columns">
<div className="wall-empty">This board shows the numbers only.</div>
</section>
)}
<footer className="wall-footer">
<span>
{data.updatedAt ? `Updated ${formatTime(data.updatedAt)}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s
</span>
<span className="wall-footer-actions">{footerActions}</span>
</footer>
</div>
);
}