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:
1 parent
906220040e
commit
44e393f172
50 files changed
+6114
-258
No files matched your search
+26
-165
@@ -3,56 +3,7 @@ import { Link, useNavigate } from "react-router-dom";
|
||||
import { api, type IntegrationSummary, type MaintenanceWindow, type ServerSummary } from "../api/client";
|
||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
import { useEnvironment } from "../utils/environment";
|
||||
import { formatRemaining } from "../utils/duration";
|
||||
import { formatDate, formatTime } from "../utils/date";
|
||||
|
||||
const REFRESH_MS = 30_000;
|
||||
|
||||
const TYPE_LABELS: Record<IntegrationSummary["type"], string> = {
|
||||
tailscale: "Tailscale",
|
||||
proxmox: "Proxmox",
|
||||
synology: "Synology",
|
||||
semaphore: "Semaphore",
|
||||
gitea: "Gitea",
|
||||
dockhand: "Docker",
|
||||
uptimekuma: "Uptime Kuma",
|
||||
phpipam: "phpIPAM",
|
||||
pbs: "Proxmox Backup",
|
||||
osticket: "osTicket",
|
||||
};
|
||||
|
||||
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(() => {});
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
import WallView, { REFRESH_MS, wallHeadline, type WallData } from "../components/WallView";
|
||||
|
||||
/**
|
||||
* A full-screen status board for a spare monitor or tablet: how things are, in type big enough to read across a room, refreshing
|
||||
@@ -61,14 +12,12 @@ function useWakeLock() {
|
||||
export default function Wall() {
|
||||
const navigate = useNavigate();
|
||||
const environment = useEnvironment();
|
||||
const now = useClock();
|
||||
const { report, failed, reload } = useAlertsReport();
|
||||
const [servers, setServers] = useState<ServerSummary | null>(null);
|
||||
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||
const [windows, setWindows] = useState<MaintenanceWindow[]>([]);
|
||||
const [updatedAt, setUpdatedAt] = useState<Date | null>(null);
|
||||
const [idle, setIdle] = useState(false);
|
||||
useWakeLock();
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
@@ -112,129 +61,41 @@ export default function Wall() {
|
||||
|
||||
const badge = alertBadge(report);
|
||||
const blind = report?.couldntCheck.length ?? 0;
|
||||
const level: "critical" | "warning" | "ok" | "unsure" = !report ? "unsure" : badge ? badge.level : blind > 0 ? "unsure" : "ok";
|
||||
const level: WallData["level"] = !report ? "unsure" : badge ? badge.level : blind > 0 ? "unsure" : "ok";
|
||||
const active = (report?.alerts ?? []).filter((a) => !a.silenced && a.severity !== "info").sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "critical" ? -1 : 1));
|
||||
const failing = (integrations ?? []).filter((i) => i.enabled && i.health?.status === "failing");
|
||||
const offline = servers?.offline.length ?? 0;
|
||||
|
||||
const headline =
|
||||
level === "critical" || level === "warning"
|
||||
? `${badge!.count} ${badge!.count === 1 ? "thing needs" : "things need"} attention`
|
||||
: level === "unsure"
|
||||
? report
|
||||
? "No alerts — but some checks couldn't run"
|
||||
: failed
|
||||
? "Can't reach the server"
|
||||
: "Checking…"
|
||||
: "All clear";
|
||||
const data: WallData = {
|
||||
level,
|
||||
headline: wallHeadline(level, badge?.count ?? 0, { loaded: !!report, failed }),
|
||||
servers: servers ? { online: servers.online, total: servers.online + servers.offline.length } : null,
|
||||
alerts: report ? { critical: report.counts.critical, warning: report.counts.warning } : null,
|
||||
maintenance: windows.length,
|
||||
integrationsFailing: integrations ? failing.length : null,
|
||||
problems: active.map((a) => ({ id: a.id, severity: a.severity as "critical" | "warning", message: a.message })),
|
||||
windows: windows.map((w) => ({ id: w.id, name: w.targetName, endsAt: w.endsAt })),
|
||||
integrations: (integrations ?? [])
|
||||
.filter((i) => i.enabled)
|
||||
.sort((a, b) => Number(b.health?.status === "failing") - Number(a.health?.status === "failing") || a.name.localeCompare(b.name))
|
||||
.map((i) => ({ id: i.id, name: i.name, type: i.type, status: i.health?.status === "failing" ? "failing" : i.health?.status === "ok" ? "ok" : "unknown" })),
|
||||
environmentName: environment?.name || null,
|
||||
updatedAt,
|
||||
};
|
||||
|
||||
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" />
|
||||
{environment?.name && <span className="badge env-badge">{environment.name}</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>{headline}</span>
|
||||
</section>
|
||||
|
||||
<section className="wall-tiles" aria-label="Summary">
|
||||
<div className={`wall-tile ${offline > 0 ? "wall-tile-bad" : ""}`}>
|
||||
<div className="wall-tile-figure">{servers ? (servers.online + offline === 0 ? "—" : `${servers.online}/${servers.online + offline}`) : "…"}</div>
|
||||
<div className="wall-tile-label">servers online</div>
|
||||
</div>
|
||||
<div className={`wall-tile ${(report?.counts.critical ?? 0) > 0 ? "wall-tile-bad" : (report?.counts.warning ?? 0) > 0 ? "wall-tile-warn" : ""}`}>
|
||||
<div className="wall-tile-figure">{report ? report.counts.critical + report.counts.warning : "…"}</div>
|
||||
<div className="wall-tile-label">
|
||||
alerts{report && report.counts.critical + report.counts.warning > 0 ? ` (${report.counts.critical} critical, ${report.counts.warning} warning)` : ""}
|
||||
</div>
|
||||
</div>
|
||||
<div className={`wall-tile ${windows.length > 0 ? "wall-tile-info" : ""}`}>
|
||||
<div className="wall-tile-figure">{windows.length}</div>
|
||||
<div className="wall-tile-label">in maintenance</div>
|
||||
</div>
|
||||
<div className={`wall-tile ${failing.length > 0 ? "wall-tile-bad" : ""}`}>
|
||||
<div className="wall-tile-figure">{integrations ? failing.length : "…"}</div>
|
||||
<div className="wall-tile-label">integrations failing</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="wall-columns">
|
||||
<div>
|
||||
<h2 className="wall-heading">Needs attention</h2>
|
||||
{active.length === 0 ? (
|
||||
<div className="wall-empty">Nothing right now.</div>
|
||||
) : (
|
||||
<ul className="wall-list">
|
||||
{active.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>
|
||||
))}
|
||||
{active.length > 7 && <li className="wall-more">and {active.length - 7} more</li>}
|
||||
</ul>
|
||||
)}
|
||||
{windows.length > 0 && (
|
||||
<>
|
||||
<h2 className="wall-heading mt-4">In maintenance</h2>
|
||||
<ul className="wall-list wall-list-small">
|
||||
{windows.slice(0, 8).map((w) => (
|
||||
<li key={w.id}>
|
||||
{w.targetName} <span className="wall-dim">· {formatRemaining(w.endsAt, now.getTime())} left</span>
|
||||
</li>
|
||||
))}
|
||||
{windows.length > 8 && <li className="wall-more">and {windows.length - 8} more</li>}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="wall-heading">Integrations</h2>
|
||||
{(integrations ?? []).filter((i) => i.enabled).length === 0 ? (
|
||||
<div className="wall-empty">None connected.</div>
|
||||
) : (
|
||||
<ul className="wall-list wall-list-small">
|
||||
{[...(integrations ?? [])]
|
||||
.filter((i) => i.enabled)
|
||||
.sort((a, b) => Number(b.health?.status === "failing") - Number(a.health?.status === "failing") || a.name.localeCompare(b.name))
|
||||
.map((i) => {
|
||||
const status = i.health?.status;
|
||||
return (
|
||||
<li key={i.id} className={status === "failing" ? "wall-bad" : status === "ok" ? "wall-good" : "wall-dim"}>
|
||||
<span aria-hidden="true">{status === "failing" ? "✕" : status === "ok" ? "✓" : "·"}</span> {i.name}{" "}
|
||||
<span className="wall-dim">
|
||||
{TYPE_LABELS[i.type]} — {status === "failing" ? "failing" : status === "ok" ? "working" : "not checked yet"}
|
||||
</span>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer className="wall-footer">
|
||||
<span>
|
||||
{updatedAt ? `Updated ${formatTime(updatedAt)}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s
|
||||
</span>
|
||||
<span className="wall-footer-actions">
|
||||
<WallView
|
||||
data={data}
|
||||
idle={idle}
|
||||
footerActions={
|
||||
<>
|
||||
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
|
||||
Full screen
|
||||
</button>
|
||||
<Link to="/" className="wall-link">
|
||||
Exit (Esc)
|
||||
</Link>
|
||||
</span>
|
||||
</footer>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user