Files
Homelab-manager/web/src/pages/Dashboard.tsx
T
bobbanandClaude Sonnet 5.5 d69962528e Brand colours and logos for integrations and DNS providers
Kind tags (Integrations, Servers, DNS) are in the brand's colour with its logo
(Simple Icons, CC0), kept readable on both themes; the dashboard cards, the
kind picker and the menu show the logos too, with a per-browser switch for the
menu icons. Settings -> Display -> Badge colours shows the brand defaults and
Use the brand's goes back to them.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 20:14:20 +01:00

1596 lines
69 KiB
TypeScript

import { useMyWork } from "../hooks/useMyWork";
import { Fragment, 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 DashboardTodos from "../components/DashboardTodos";
import Hideable, { HideBar, useCardState } from "../components/Hideable";
import { setProblemsFirst, useProblemsFirst } from "../utils/problemsFirst";
import { UNPLACED, moveCard, resetDashboardLayout, setCardHidden, setEditingDashboard, useDashboardLayout } from "../utils/dashboardLayout";
import { Link } from "react-router-dom";
import {
api,
type CurrentUser,
type DomainList,
type EndpointCheck,
type IntegrationSummary,
type IntegrationType,
type OsTicketTicketsResponse,
type PbsDatastoresResponse,
type SecretRecord,
type ServerSummary,
type TailscaleDevicesResponse,
type TechnitiumInstance,
} from "../api/client";
import { formatAgo } from "../utils/duration";
import StatusStrip from "../components/StatusStrip";
import SetupGuide, { type SetupStep } from "../components/SetupGuide";
import { ErrorNotice } from "../components/Notice";
import { WidgetSkeleton } from "../components/Skeleton";
import { TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
import type { Agenda, Heartbeat } from "../api/client";
import BrandIcon from "../components/BrandIcon";
import { kindOfLabel } from "../utils/brands";
const DNS_TYPE_COLORS: Record<string, string> = {
A: "#60a5fa",
AAAA: "#93c5fd",
CNAME: "#c084fc",
MX: "#4ade80",
TXT: "#fb923c",
NS: "#94a3b8",
SRV: "#a3e635",
CAA: "#f472b6",
PTR: "#facc15",
};
const SECRET_TYPE_LABELS: Record<SecretRecord["type"], string> = {
api_token: "API Token",
ssl_certificate: "SSL Certificate",
password: "Password",
generic: "Generic",
};
const SECRET_TYPE_COLORS: Record<SecretRecord["type"], string> = {
api_token: "#6366f1",
ssl_certificate: "#22d3ee",
password: "#f472b6",
generic: "#94a3b8",
};
const DOMAIN_STATE_COLORS: Record<string, string> = {
OK: "#4ade80",
Expiring: "#fbbf24",
Expired: "#f87171",
"No date": "#94a3b8",
};
const SERVER_STATE_COLORS: Record<string, string> = {
Online: "#4ade80",
Offline: "#f87171",
"No data": "#94a3b8",
};
const MONITOR_STATE_COLORS: Record<string, string> = {
Up: "#4ade80",
Down: "#f87171",
Pending: "#fbbf24",
Maintenance: "#60a5fa",
Unknown: "#94a3b8",
};
const CONTAINER_STATE_COLORS: Record<string, string> = {
running: "#4ade80",
exited: "#f87171",
dead: "#f87171",
paused: "#fbbf24",
restarting: "#60a5fa",
};
const TASK_STATUS_COLORS: Record<string, string> = {
success: "#4ade80",
error: "#f87171",
stopped: "#94a3b8",
rejected: "#94a3b8",
waiting: "#fbbf24",
starting: "#fbbf24",
waiting_confirmation: "#fbbf24",
confirmed: "#fbbf24",
running: "#60a5fa",
stopping: "#60a5fa",
"never run": "#94a3b8",
};
const REPO_STATUS_COLORS: Record<string, string> = {
success: "#4ade80",
failure: "#f87171",
cancelled: "#94a3b8",
skipped: "#94a3b8",
waiting: "#fbbf24",
queued: "#fbbf24",
pending: "#fbbf24",
running: "#60a5fa",
in_progress: "#60a5fa",
"no runs": "#94a3b8",
};
const GENERIC_PALETTE = ["#6366f1", "#22d3ee", "#f472b6", "#4ade80", "#fb923c", "#a3e635", "#c084fc", "#facc15", "#60a5fa"];
function paletteColors(labels: string[]): Record<string, string> {
const colors: Record<string, string> = {};
labels.forEach((label, i) => {
colors[label] = GENERIC_PALETTE[i % GENERIC_PALETTE.length];
});
return colors;
}
function healthColors(labels: string[]): Record<string, string> {
const colors: Record<string, string> = {};
for (const label of labels) colors[label] = label === "normal" ? "#4ade80" : "#f87171";
return colors;
}
function SectionHeader({ title, hint }: { title: string; hint?: ReactNode }) {
return (
<div className="mb-3 mt-4">
<h3 className="mb-0">{title}</h3>
{hint && <div className="text-secondary small mt-1">{hint}</div>}
</div>
);
}
function breakdownFrom<T>(items: T[], keyOf: (item: T) => string): { label: string; count: number }[] {
const counts = new Map<string, number>();
for (const item of items) {
const key = keyOf(item);
counts.set(key, (counts.get(key) ?? 0) + 1);
}
return [...counts.entries()].map(([label, count]) => ({ label, count })).sort((a, b) => b.count - a.count);
}
function BreakdownBar({ data, colors, compact }: { data: { label: string; count: number }[]; colors: Record<string, string>; compact?: boolean }) {
const total = data.reduce((s, d) => s + d.count, 0);
if (total === 0) return null;
return (
<div>
<div className="progress" style={{ height: compact ? 6 : 10 }}>
{data.map((d) => (
<div
key={d.label}
className="progress-bar"
style={{ width: `${(d.count / total) * 100}%`, backgroundColor: colors[d.label] ?? "#94a3b8" }}
title={`${d.label}: ${d.count}`}
/>
))}
</div>
<div className={`d-flex flex-wrap gap-${compact ? "2" : "3"} mt-2`}>
{data.map((d) => (
<div key={d.label} className={`d-flex align-items-center gap-1 ${compact ? "small" : ""}`}>
<span
style={{
width: compact ? 8 : 10,
height: compact ? 8 : 10,
borderRadius: 2,
backgroundColor: colors[d.label] ?? "#94a3b8",
display: "inline-block",
flexShrink: 0,
}}
/>
<span className={compact ? "text-secondary" : ""}>
{d.label} {compact ? `(${d.count})` : <span className="text-secondary">({d.count})</span>}
</span>
</div>
))}
</div>
</div>
);
}
function MiniStat({ label, value, accent }: { label: string; value: ReactNode; accent?: string }) {
return (
<div>
<div className="h4 mb-0" style={accent ? { color: accent } : undefined}>
{value}
</div>
<div className="text-secondary small">{label}</div>
</div>
);
}
/** 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);
const kind = kindOfLabel(label);
if (hidden && !editing) return null;
return (
<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)}>
<IconArrowLeft size={16} aria-hidden="true" />
</button>
<button type="button" className="btn btn-sm btn-icon" aria-label={`Move ${label} later`} title="Move later" onClick={(e) => void moveCard(e.currentTarget.closest<HTMLElement>("[data-card]")!, 1)}>
<IconArrowRight size={16} aria-hidden="true" />
</button>
<button type="button" className="btn btn-sm ms-auto d-inline-flex align-items-center gap-1" aria-pressed={hidden} onClick={() => void setCardHidden(label, !hidden)}>
{hidden ? <IconEye size={16} aria-hidden="true" /> : <IconEyeOff size={16} aria-hidden="true" />}
{hidden ? "Show" : "Hide"}
<span className="visually-hidden"> {label}</span>
</button>
</div>
)}
<div className="card-body">
<div className="d-flex align-items-center mb-2">
<div className="subheader d-flex align-items-center gap-1">
{kind && <BrandIcon kind={kind} size={14} />}
{label}
</div>
{badge && <div className="ms-auto">{badge}</div>}
</div>
{children}
</div>
</div>
</div>
);
}
/** The status badge of a Technitium DNS Server widget: switched off, not read yet, can't be read, or what its alerts say (red for a critical one, yellow for the rest). */
function technitiumBadge(enabled: boolean, t: TechnitiumInstance | null): ReactNode {
if (!enabled) return <span className="badge bg-secondary-lt text-secondary">Disabled</span>;
if (!t || !t.state) return <span className="badge bg-secondary-lt text-secondary">Not read yet</span>;
if (!t.fresh) return <span className="badge bg-yellow-lt text-yellow">Can&rsquo;t be read</span>;
if (t.problems.some((p) => p.severity === "critical")) return <span className="badge bg-red-lt text-red">Needs a look</span>;
if (t.problems.length > 0) return <span className="badge bg-yellow-lt text-yellow">Needs a look</span>;
return <span className="badge bg-green-lt text-green">In order</span>;
}
const TECHNITIUM_HOW_COLORS: Record<string, string> = { "from cache": "#60a5fa", resolved: "#22d3ee", "own zones": "#4ade80", blocked: "#fb923c", dropped: "#f87171" };
/** What the Technitium DNS Server widget says: whether DNS answers and how fast, the last day's queries and how many were blocked, how they were answered, and what is wrong. The page has the rest. */
function TechnitiumBody({ enabled, instance, loading }: { enabled: boolean; instance: TechnitiumInstance | null; loading: boolean }) {
if (!enabled) return <div className="text-secondary">Switched off under Integrations.</div>;
if (loading) return <WidgetSkeleton />;
const s = instance?.state ?? null;
const open = (
<div className="mt-2">
<Link to="/technitium">Open Technitium DNS</Link>
</div>
);
if (!instance || !s) {
return (
<>
<div className="text-secondary">Not read yet.</div>
{open}
</>
);
}
const st = s.stats;
const how = st
? [
{ label: "from cache", count: st.cached },
{ label: "resolved", count: st.recursive },
{ label: "own zones", count: st.authoritative },
{ label: "blocked", count: st.blocked },
{ label: "dropped", count: st.dropped },
].filter((d) => d.count > 0)
: [];
return (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="DNS answers" value={s.probe === null ? "—" : s.probe.ok ? `${s.probe.ms ?? "?"} ms` : "No"} accent={s.probe && !s.probe.ok ? "#f87171" : undefined} />
</div>
<div className="col-4">
<MiniStat label="Queries, 24 h" value={st ? st.queries.toLocaleString() : "—"} />
</div>
<div className="col-4">
<MiniStat label="Blocked" value={st?.blockedPercent != null ? `${st.blockedPercent}%` : "—"} accent={!s.blockingEnabled && s.settings.blockLists.count > 0 ? "#f59e0b" : undefined} />
</div>
</div>
{how.length > 0 && <BreakdownBar data={how} colors={TECHNITIUM_HOW_COLORS} compact />}
{!s.blockingEnabled && s.settings.blockLists.count > 0 && <div className="small text-yellow mt-2">Blocking is switched off.</div>}
{!instance.fresh && <div className="small text-yellow mt-2">The last read is old, so this may be out of date.</div>}
{instance.problems.slice(0, 2).map((p) => (
<div key={p.key} className={`small mt-1 ${p.severity === "critical" ? "text-red" : "text-yellow"}`}>
{p.message}
</div>
))}
{instance.problems.length > 2 && <div className="small text-secondary mt-1">and {instance.problems.length - 2} more</div>}
{open}
</>
);
}
/** What each group of integrations is, in a line — the groups are the sidebar's. */
const GROUP_HINTS: Record<string, string> = {
infrastructure: "The systems your servers and containers run on.",
apps: "The apps you run, and whether each is working.",
backups: "Where backups are kept and checked.",
network: "Network equipment, proxies and address records.",
monitoring: "What watches the rest.",
automation: "Runs, tickets and workflows.",
};
const WIDGETS: { type: IntegrationType; label: string }[] = [
{ type: "proxmox", label: "Proxmox" },
{ type: "synology", label: "Synology NAS" },
{ type: "semaphore", label: "Semaphore" },
{ type: "tailscale", label: "Tailscale" },
{ type: "gitea", label: "Gitea" },
{ type: "dockhand", label: "Dockhand / Docker" },
{ type: "uptimekuma", label: "Uptime Kuma" },
{ type: "pbs", label: "Proxmox Backup Server" },
{ type: "osticket", label: "osTicket" },
];
interface UptimeKumaSummary {
up: number;
down: number;
total: number;
matched: number;
statusBreakdown: { label: string; count: number }[];
}
interface OsTicketSummary {
total: number;
overdue: number;
awaitingReply: number;
}
interface PbsSummary {
datastoreCount: number;
failedSnapshotCount: number;
unverifiedSnapshotCount: number;
}
interface GiteaSummary {
repoCount: number;
privateCount: number;
failing: number;
statusBreakdown: { label: string; count: number }[];
}
interface DockhandSummary {
running: number;
total: number;
hostCount: number;
updatesAvailable: number;
stateBreakdown: { label: string; count: number }[];
}
interface SemaphoreSummary {
total: number;
failing: number;
statusBreakdown: { label: string; count: number }[];
}
interface ProxmoxSummary {
running: number;
total: number;
vmCount: number;
lxcCount: number;
nodeBreakdown: { label: string; count: number }[];
}
interface SynologySummary {
volumeCount: number;
volumesNotNormal: number;
disksNotNormal: number;
cpuLoadPercent: number | null;
memUsedBytes: number | null;
memTotalBytes: number | null;
diskStatusBreakdown: { label: string; count: number }[];
}
interface TailscaleExtra {
osBreakdown: { label: string; count: number }[];
}
function formatBytes(bytes: number | null): string {
if (bytes === null) return "—";
const units = ["B", "KB", "MB", "GB", "TB", "PB"];
let value = bytes;
let unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
unit++;
}
return `${value.toFixed(1)} ${units[unit]}`;
}
/** One line above the cards for those who follow things: how many of theirs want a look, and where to see them. Says nothing when none do. */
function MyWorkStrip() {
const { work } = useMyWork();
if (!work || work.needsAttention === 0) return null;
return (
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2 py-2" role="status">
<span>
<strong>{work.needsAttention}</strong> {work.needsAttention === 1 ? "thing" : "things"} of yours {work.needsAttention === 1 ? "wants" : "want"} a look — alerts handed to you or about to run out, maintenance about to end, update runs still going, jobs that are due.
</span>
<Link to="/my-work" className="btn btn-sm btn-primary ms-auto">
My work
</Link>
</div>
);
}
/** The cards down the left of the top of the dashboard, and the to-do list on the right: the names the person hides them by. */
const TOP_LEFT_CARDS = ["Needs attention", "My work", "Since you last looked", "Getting started"];
const TODO_CARD = "To do list";
export default function Dashboard({ user }: { user: CurrentUser }) {
const { editing, layout: arranged } = useDashboardLayout();
// The top of the dashboard is two columns while both have something to show; when the person has hidden every card of one, the other takes the whole width.
const showTopLeft = editing || TOP_LEFT_CARDS.some((c) => !arranged.hidden.includes(c));
const todoCard = useCardState(TODO_CARD);
const problemsFirst = useProblemsFirst();
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
// How many alerts each integration has open that nobody has put aside, for the tiles of the integrations that have no widget of their own.
const [integrationAlerts, setIntegrationAlerts] = useState<Map<number, { count: number; critical: boolean }>>(new Map());
// What each Technitium DNS Server says (the same as its page), read once there is one and then every minute.
const [technitium, setTechnitium] = useState<TechnitiumInstance[] | null>(null);
const [tailscaleSummary, setTailscaleSummary] = useState<TailscaleDevicesResponse["summary"] | null>(null);
const [tailscaleExtra, setTailscaleExtra] = useState<TailscaleExtra | null>(null);
const [giteaSummary, setGiteaSummary] = useState<GiteaSummary | null>(null);
const [dockhandSummary, setDockhandSummary] = useState<DockhandSummary | null>(null);
const [semaphoreSummary, setSemaphoreSummary] = useState<SemaphoreSummary | null>(null);
const [proxmoxSummary, setProxmoxSummary] = useState<ProxmoxSummary | null>(null);
const [synologySummary, setSynologySummary] = useState<SynologySummary | null>(null);
const [uptimeKumaSummary, setUptimeKumaSummary] = useState<UptimeKumaSummary | null>(null);
const [pbsSummary, setPbsSummary] = useState<PbsSummary | null>(null);
const [osTicketSummary, setOsTicketSummary] = useState<OsTicketSummary | null>(null);
// For the getting-started guide; only an admin can read these, and only an admin has these steps to do.
const isAdmin = user.role === "admin";
const [notifyConfigured, setNotifyConfigured] = useState<boolean | null>(null);
const [userCount, setUserCount] = useState<number | null>(null);
useEffect(() => {
if (!isAdmin) return;
api.settings
.get()
.then((res) => {
const s = res.settings;
setNotifyConfigured(s.gotify.enabled || s.ntfy.enabled || s.telegram.enabled || s.pushover.enabled || s.smtp.enabled || s.webhook.enabled || !!s.webPush?.enabled);
})
.catch(() => setNotifyConfigured(null));
api.users
.list()
.then((res) => setUserCount(res.users.length))
.catch(() => setUserCount(null));
}, [isAdmin]);
const [dnsStats, setDnsStats] = useState<Awaited<ReturnType<typeof api.dns.stats>> | null>(null);
const [dnsError, setDnsError] = useState<string | null>(null);
const [secrets, setSecrets] = useState<SecretRecord[] | null>(null);
const [serverSummary, setServerSummary] = useState<ServerSummary | null>(null);
const [serverError, setServerError] = useState<string | null>(null);
const [domainList, setDomainList] = useState<DomainList | null>(null);
const [endpointChecks, setEndpointChecks] = useState<EndpointCheck[] | null>(null);
const [agenda, setAgenda] = useState<Agenda | null>(null);
const [heartbeatList, setHeartbeatList] = useState<Heartbeat[] | null>(null);
const [domainError, setDomainError] = useState<string | null>(null);
useEffect(() => {
api.endpoints
.list()
.then((res) => setEndpointChecks(res.checks))
.catch(() => setEndpointChecks([]));
api.agenda
.get(30)
.then(setAgenda)
.catch(() => setAgenda({ generatedAt: "", today: "", items: [], notes: [] }));
api.heartbeats
.list()
.then((res) => setHeartbeatList(res.heartbeats))
.catch(() => setHeartbeatList([]));
api.domains
.list()
.then(setDomainList)
.catch((err) => setDomainError(err instanceof Error ? err.message : String(err)));
api.servers
.summary()
.then(setServerSummary)
.catch((err) => setServerError(err instanceof Error ? err.message : String(err)));
api.dns
.stats()
.then(setDnsStats)
.catch((err) => setDnsError(err instanceof Error ? err.message : String(err)));
api.secrets
.list()
.then((res) => setSecrets(res.secrets))
.catch(() => setSecrets([]));
}, []);
useEffect(() => {
api.integrations.list().then((res) => setIntegrations(res.integrations));
api.alerts
.list()
.then((report) => {
const found = new Map<number, { count: number; critical: boolean }>();
for (const a of report.alerts) {
if (a.silenced || a.severity === "info" || a.target?.type !== "integration") continue;
const entry = found.get(a.target.id) ?? { count: 0, critical: false };
entry.count++;
if (a.severity === "critical") entry.critical = true;
found.set(a.target.id, entry);
}
setIntegrationAlerts(found);
})
.catch(() => {});
}, []);
const hasTechnitium = integrations?.some((i) => i.type === "technitium") ?? false;
useEffect(() => {
if (!hasTechnitium) return;
const load = () =>
api.technitium
.list()
.then((r) => setTechnitium(r.instances))
.catch(() => setTechnitium((current) => current ?? []));
void load();
const t = setInterval(load, 60_000);
return () => clearInterval(t);
}, [hasTechnitium]);
useEffect(() => {
const tailscale = integrations?.find((i) => i.type === "tailscale" && i.enabled);
if (!tailscale) {
setTailscaleSummary(null);
return;
}
api.integrations.tailscale
.devices(tailscale.id)
.then((res) => {
setTailscaleSummary(res.summary);
setTailscaleExtra({ osBreakdown: breakdownFrom(res.devices, (d) => d.os || "unknown") });
})
.catch(() => {
setTailscaleSummary(null);
setTailscaleExtra(null);
});
}, [integrations]);
useEffect(() => {
const gitea = integrations?.find((i) => i.type === "gitea" && i.enabled);
if (!gitea) {
setGiteaSummary(null);
return;
}
api.integrations.gitea
.repos(gitea.id)
.then((res) =>
setGiteaSummary({
repoCount: res.repos.length,
privateCount: res.repos.filter((r) => r.private).length,
failing: res.repos.filter((r) => r.latestRun?.conclusion === "failure" || r.latestRun?.status === "failure").length,
statusBreakdown: breakdownFrom(res.repos, (r) => (r.latestRun ? r.latestRun.conclusion || r.latestRun.status : "no runs")),
}),
)
.catch(() => setGiteaSummary(null));
}, [integrations]);
useEffect(() => {
const dockhand = integrations?.find((i) => i.type === "dockhand" && i.enabled);
if (!dockhand) {
setDockhandSummary(null);
return;
}
api.integrations.dockhand
.containers(dockhand.id)
.then((res) =>
setDockhandSummary({
running: res.summary.running,
total: res.summary.total,
hostCount: new Set(res.containers.map((c) => c.environmentName)).size,
updatesAvailable: res.containers.filter((c) => c.updateAvailable).length,
stateBreakdown: breakdownFrom(res.containers, (c) => c.state),
}),
)
.catch(() => setDockhandSummary(null));
}, [integrations]);
useEffect(() => {
const semaphore = integrations?.find((i) => i.type === "semaphore" && i.enabled);
if (!semaphore) {
setSemaphoreSummary(null);
return;
}
api.integrations.semaphore
.templates(semaphore.id)
.then((res) =>
setSemaphoreSummary({
...res.summary,
statusBreakdown: breakdownFrom(res.templates, (t) => t.lastTask?.status ?? "never run"),
}),
)
.catch(() => setSemaphoreSummary(null));
}, [integrations]);
useEffect(() => {
const proxmox = integrations?.find((i) => i.type === "proxmox" && i.enabled);
if (!proxmox) {
setProxmoxSummary(null);
return;
}
api.integrations.proxmox
.guests(proxmox.id)
.then((res) =>
setProxmoxSummary({
running: res.summary.running,
total: res.summary.total,
vmCount: res.guests.filter((g) => g.type === "qemu").length,
lxcCount: res.guests.filter((g) => g.type === "lxc").length,
nodeBreakdown: breakdownFrom(res.guests, (g) => g.node),
}),
)
.catch(() => setProxmoxSummary(null));
}, [integrations]);
useEffect(() => {
const synology = integrations?.find((i) => i.type === "synology" && i.enabled);
if (!synology) {
setSynologySummary(null);
return;
}
api.integrations.synology
.system(synology.id)
.then((sys) =>
setSynologySummary((prev) => ({
volumeCount: prev?.volumeCount ?? 0,
volumesNotNormal: prev?.volumesNotNormal ?? 0,
disksNotNormal: prev?.disksNotNormal ?? 0,
diskStatusBreakdown: prev?.diskStatusBreakdown ?? [],
cpuLoadPercent: sys.cpu.loadPercent,
memUsedBytes: sys.memory.usedBytes,
memTotalBytes: sys.memory.totalBytes,
})),
)
.catch(() => {});
api.integrations.synology
.storage(synology.id)
.then((res) =>
setSynologySummary((prev) => ({
cpuLoadPercent: prev?.cpuLoadPercent ?? null,
memUsedBytes: prev?.memUsedBytes ?? null,
memTotalBytes: prev?.memTotalBytes ?? null,
volumeCount: res.summary.volumeCount,
volumesNotNormal: res.summary.volumesNotNormal,
disksNotNormal: res.summary.disksNotNormal,
diskStatusBreakdown: breakdownFrom(res.disks, (d) => d.status),
})),
)
.catch(() => setSynologySummary(null));
}, [integrations]);
useEffect(() => {
const uptimeKuma = integrations?.find((i) => i.type === "uptimekuma" && i.enabled);
if (!uptimeKuma) {
setUptimeKumaSummary(null);
return;
}
api.integrations.uptimekuma
.monitors(uptimeKuma.id)
.then((res) => {
const labelFor = (s: string) => s.charAt(0).toUpperCase() + s.slice(1);
setUptimeKumaSummary({
up: res.summary.up,
down: res.summary.down,
total: res.summary.total,
matched: res.monitors.filter((m) => m.matchedServer).length,
statusBreakdown: breakdownFrom(res.monitors, (m) => labelFor(m.status)),
});
})
.catch(() => setUptimeKumaSummary(null));
}, [integrations]);
useEffect(() => {
const pbs = integrations?.find((i) => i.type === "pbs" && i.enabled);
if (!pbs) {
setPbsSummary(null);
return;
}
api.integrations.pbs
.datastores(pbs.id)
.then((res: PbsDatastoresResponse) =>
setPbsSummary({
datastoreCount: res.summary.datastoreCount,
failedSnapshotCount: res.summary.failedSnapshotCount,
unverifiedSnapshotCount: res.summary.unverifiedSnapshotCount,
}),
)
.catch(() => setPbsSummary(null));
}, [integrations]);
useEffect(() => {
const osticket = integrations?.find((i) => i.type === "osticket" && i.enabled);
if (!osticket) {
setOsTicketSummary(null);
return;
}
api.integrations.osticket
.tickets(osticket.id)
.then((res: OsTicketTicketsResponse) =>
setOsTicketSummary({
total: res.summary.total,
overdue: res.summary.overdue,
awaitingReply: res.summary.awaitingReply,
}),
)
.catch(() => setOsTicketSummary(null));
}, [integrations]);
const domains = domainList?.domains ?? [];
const expiredDomains = domains.filter((d) => d.status === "expired");
const expiringDomains = domains.filter((d) => d.status === "expiring");
const okDomains = domains.filter((d) => d.status === "ok").length;
const undatedDomains = domains.filter((d) => d.status === "unknown").length;
// A registry that simply doesn't publish expiry dates isn't a failure; anything else that stopped a refresh is.
const failingDomainChecks = domains.filter((d) => d.lastCheckError && !/doesn't publish/i.test(d.lastCheckError)).length;
const nextDomain = domains
.filter((d) => d.expiresAt && d.daysLeft !== null && d.daysLeft >= 0)
.sort((a, b) => a.daysLeft! - b.daysLeft!)[0];
const totalSecrets = secrets?.length ?? 0;
const expiredSecrets = secrets?.filter((s) => s.status === "expired").length ?? 0;
const expiringSecrets = secrets?.filter((s) => s.status === "expiring").length ?? 0;
const secretsByType = Object.entries(
(secrets ?? []).reduce<Record<string, number>>((acc, s) => {
acc[s.type] = (acc[s.type] ?? 0) + 1;
return acc;
}, {}),
).map(([type, count]) => ({ label: SECRET_TYPE_LABELS[type as SecretRecord["type"]] ?? type, count }));
const setupSteps: SetupStep[] = [
{ id: "integration", title: "Connect an integration", description: "Proxmox, Synology, Tailscale, Docker, Uptime Kuma… each gets its own page and shows up in alerts.", to: "/integrations", action: "Add one", done: (integrations?.length ?? 0) > 0 },
{ id: "server", title: "Add a server and install its agent", description: "The agent reports scheduled tasks, disks, memory and open ports, and lets the app tell when a server goes quiet.", to: "/servers", action: "Add a server", done: (serverSummary?.total ?? 0) > 0 },
{ id: "dns", title: "Connect a DNS provider", description: "See your zones and records, and have names matched to servers.", to: "/dns", action: "Connect", done: (dnsStats?.totalProviders ?? 0) > 0 },
{ id: "secret", title: "Track something that expires", description: "An API token, a certificate or a password — you're warned before it runs out.", to: "/secrets", action: "Add one", done: (secrets?.length ?? 0) > 0 },
{ id: "notify", title: "Choose how you'll be told about problems", description: "Gotify, ntfy, Telegram, Pushover, email, a webhook or push to your phone, with the checks you want.", to: "/settings/notifications", action: "Set up", done: notifyConfigured === true },
{ id: "people", title: "Let someone else in (optional)", description: "Others sign in with Authentik and appear under Users; you decide their role.", to: "/users", action: "Open Users", done: (userCount ?? 0) > 1 },
];
// What the endpoint checks say: the ones that keep failing, and the certificates that are running out.
const endpointsDown = (endpointChecks ?? []).filter((c) => c.enabled && c.lastOk === false && c.consecutiveFailures >= c.failuresBeforeAlert);
const endpointCerts = (endpointChecks ?? []).filter((c) => c.enabled && c.certExpiresAt && Math.floor((Date.parse(c.certExpiresAt) - Date.now()) / 86_400_000) <= c.warnDays).length;
// What is coming up: the nearest dated things (not "updates waiting", which has its own card), and whether any has already passed.
// A schedule that repeats weekly is one line (its next time), not one a week.
const seenSchedules = new Set<string>();
const soon = (agenda?.items ?? []).filter((i) => {
if (i.kind === "updates") return false;
const m = /^(schedule|plan):(\d+):/.exec(i.id);
const schedule = m ? `${m[1]}:${m[2]}` : null;
if (!schedule) return true;
if (seenSchedules.has(schedule)) return false;
seenSchedules.add(schedule);
return true;
});
const soonPast = soon.filter((i) => i.daysLeft < 0).length;
const soonWeek = soon.filter((i) => i.daysLeft >= 0 && i.daysLeft <= 7).length;
// The jobs that report in: late, or said they failed.
const beatsWrong = (heartbeatList ?? []).filter((h) => h.state === "late" || h.state === "failed");
// What has nothing set up yet. These get one list at the bottom instead of a grey "Not configured" card each.
const notSetUp: { label: string; to: string; what: string }[] = [];
if (dnsStats?.totalProviders === 0) notSetUp.push({ label: "DNS", to: "/dns", what: "connect a DNS provider to see zones and records" });
if (secrets !== null && totalSecrets === 0) notSetUp.push({ label: "Secrets", to: "/secrets", what: "track when a token, certificate or password expires" });
if (serverSummary?.total === 0) notSetUp.push({ label: "Servers", to: "/servers", what: "add a server and install its agent" });
if (heartbeatList !== null && heartbeatList.length === 0) notSetUp.push({ label: "Heartbeats", to: "/heartbeats", what: "have a backup or cron job report in, so you hear when it doesn't run" });
if (endpointChecks !== null && endpointChecks.length === 0) notSetUp.push({ label: "Endpoints", to: "/endpoints", what: "ask a web address, a port or a certificate whether it is fine" });
if (domainList !== null && domains.length === 0) notSetUp.push({ label: "Domains", to: "/dns?view=domains", what: "appear after a DNS zone is added and the daily check has run" });
if (integrations !== null) {
for (const { type, label } of WIDGETS) {
if (!integrations.some((i) => i.type === type)) notSetUp.push({ label, to: "/integrations", what: "connect it under Integrations" });
}
}
return (
<>
<div className="row row-cards mb-3">
<div className="col-12">
<div className="d-flex flex-wrap align-items-center gap-2 mb-3">
<h2 className="page-title mb-0">Dashboard</h2>
<div className="ms-auto d-flex gap-2">
<button type="button" className={`btn btn-sm ${editing ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={editing} onClick={() => setEditingDashboard(!editing)}>
{editing ? "Done" : "Customise"}
</button>
<Link to="/wall" className="btn btn-sm btn-outline-secondary" title="A full-screen status board for a spare monitor or tablet">
Wall display
</Link>
</div>
</div>
{editing && (
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2" role="status">
<span>Move the Overview cards with the arrows, and hide any card you don't use — the ones at the top too. It saves as you go, for you only, and follows you to other browsers.</span>
<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>
)}
<p className="text-secondary">
Welcome back, {user.name ?? user.email ?? user.sub}.
</p>
</div>
</div>
{(showTopLeft || todoCard.shown) && (
<div className="row row-cards mb-3">
{showTopLeft && (
<div className={showTopLeft && todoCard.shown ? "col-xl-6" : "col-12"}>
<Hideable label="Needs attention">
<StatusStrip />
</Hideable>
{(user.role === "admin" || user.role === "operator") && (
<Hideable label="My work">
<MyWorkStrip />
</Hideable>
)}
<Hideable label="Since you last looked">
<WhatChanged role={user.role} />
</Hideable>
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
<Hideable label="Getting started">
<SetupGuide steps={setupSteps} />
</Hideable>
)}
</div>
)}
{todoCard.shown &&
(showTopLeft ? (
<div className="col-xl-6 dash-side-col">
{todoCard.editing && <HideBar label={TODO_CARD} hidden={todoCard.hidden} />}
<div className={`dash-side ${todoCard.hidden ? "card-hidden" : ""}`}>
<DashboardTodos canEdit={user.role === "admin" || user.role === "operator"} />
</div>
</div>
) : (
<div className="col-12">
{todoCard.editing && <HideBar label={TODO_CARD} hidden={todoCard.hidden} />}
<div className={todoCard.hidden ? "card-hidden" : ""}>
<DashboardTodos canEdit={user.role === "admin" || user.role === "operator"} />
</div>
</div>
))}
</div>
)}
<SectionHeader title="Overview" hint="DNS, Secrets, Servers and Domains are built into this app rather than connected integrations, but get the same at-a-glance treatment." />
<div className="row row-cards mb-3">
<WidgetCard
label="DNS"
hide={dnsStats?.totalProviders === 0}
badge={
!dnsStats ? undefined : dnsStats.totalProviders === 0 ? (
<span className="badge bg-secondary-lt text-secondary">Not configured</span>
) : (
<span className="badge bg-green-lt text-green">
{dnsStats.enabledProviders} enabled
</span>
)
}
>
<ErrorNotice error={dnsError} className="mb-2" />
{!dnsStats ? (
<WidgetSkeleton />
) : dnsStats.totalProviders === 0 ? (
<div className="text-secondary">
Configure a DNS provider from the <Link to="/dns">DNS</Link> page.
</div>
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Domains" value={dnsStats.totalZones} />
</div>
<div className="col-4">
<MiniStat label="Records" value={dnsStats.totalRecords} />
</div>
<div className="col-4">
<MiniStat label="Providers" value={`${dnsStats.enabledProviders}/${dnsStats.totalProviders}`} />
</div>
</div>
{dnsStats.perProvider.some((p) => p.error) && (
<div className="text-red small mb-2">
{dnsStats.perProvider
.filter((p) => p.error)
.map((p) => `${p.name}: ${p.error}`)
.join("; ")}
</div>
)}
{dnsStats.recordsByType.length > 0 && (
<BreakdownBar data={dnsStats.recordsByType.map((r) => ({ label: r.type, count: r.count }))} colors={DNS_TYPE_COLORS} compact />
)}
</>
)}
</WidgetCard>
<WidgetCard
label="Secrets"
hide={secrets !== null && totalSecrets === 0}
badge={
!secrets ? undefined : totalSecrets === 0 ? (
<span className="badge bg-secondary-lt text-secondary">Not configured</span>
) : expiredSecrets > 0 ? (
<span className="badge bg-red-lt text-red">{expiredSecrets} expired</span>
) : expiringSecrets > 0 ? (
<span className="badge bg-yellow-lt text-yellow">{expiringSecrets} expiring</span>
) : (
<span className="badge bg-green-lt text-green">All OK</span>
)
}
>
{!secrets ? (
<WidgetSkeleton />
) : totalSecrets === 0 ? (
<div className="text-secondary">
Configure a secret from the <Link to="/secrets">Secrets</Link> page.
</div>
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Monitored" value={totalSecrets} />
</div>
<div className="col-4">
<MiniStat label="Expiring" value={expiringSecrets} accent={expiringSecrets > 0 ? "#f59e0b" : undefined} />
</div>
<div className="col-4">
<MiniStat label="Expired" value={expiredSecrets} accent={expiredSecrets > 0 ? "#ef4444" : undefined} />
</div>
</div>
<BreakdownBar data={secretsByType} colors={SECRET_TYPE_COLORS} compact />
</>
)}
</WidgetCard>
<WidgetCard
label="Servers"
hide={serverSummary?.total === 0}
badge={
!serverSummary ? undefined : serverSummary.total === 0 ? (
<span className="badge bg-secondary-lt text-secondary">Not configured</span>
) : serverSummary.offline.length > 0 ? (
<span className="badge bg-red-lt text-red">{serverSummary.offline.length} offline</span>
) : serverSummary.fullDisks.length > 0 ? (
<span className="badge bg-yellow-lt text-yellow">
{serverSummary.fullDisks.length} disk{serverSummary.fullDisks.length === 1 ? "" : "s"} nearly full
</span>
) : serverSummary.online > 0 ? (
<span className="badge bg-green-lt text-green">All online</span>
) : (
<span className="badge bg-secondary-lt text-secondary">No agent data</span>
)
}
>
<ErrorNotice error={serverError} className="mb-2" />
{!serverSummary ? (
!serverError && <WidgetSkeleton />
) : serverSummary.total === 0 ? (
<div className="text-secondary">
Add a server from the <Link to="/servers">Servers</Link> page.
</div>
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Servers" value={<Link to="/servers" className="text-reset text-decoration-none">{serverSummary.total}</Link>} />
</div>
<div className="col-4">
<MiniStat
label="Online"
value={serverSummary.online + serverSummary.offline.length === 0 ? "—" : `${serverSummary.online}/${serverSummary.online + serverSummary.offline.length}`}
/>
</div>
<div className="col-4">
<MiniStat
label="Offline"
value={serverSummary.offline.length}
accent={serverSummary.offline.length > 0 ? "#ef4444" : undefined}
/>
</div>
</div>
<BreakdownBar
data={[
{ label: "Online", count: serverSummary.online },
{ label: "Offline", count: serverSummary.offline.length },
{ label: "No data", count: serverSummary.noData },
].filter((d) => d.count > 0)}
colors={SERVER_STATE_COLORS}
compact
/>
{serverSummary.offline.length > 0 && (
<div className="small mt-2">
<span className="text-red">Offline:</span>{" "}
{serverSummary.offline.slice(0, 3).map((s, i) => (
<span key={s.id}>
{i > 0 && ", "}
<Link to={`/servers/${s.id}`}>{s.name}</Link>{" "}
<span className="text-secondary">
(<TimeAgo value={s.lastSeenAt} empty="never seen" />
{s.inMaintenance ? ", in maintenance" : ""})
</span>
</span>
))}
{serverSummary.offline.length > 3 && (
<>
{" "}
<Link to="/servers?status=offline">+{serverSummary.offline.length - 3} more</Link>
</>
)}
</div>
)}
{serverSummary.fullDisks.length > 0 && (
<div className="small mt-2">
<span className="text-yellow">Disk ≥ {serverSummary.thresholds.diskPercent}%:</span>{" "}
{serverSummary.fullDisks.slice(0, 3).map((d, i) => (
<span key={`${d.id}:${d.mount}`}>
{i > 0 && ", "}
<Link to={`/servers/${d.id}`}>{d.name}</Link>{" "}
<span className="text-secondary">
{d.mount} {d.percent}%
</span>
</span>
))}
{serverSummary.fullDisks.length > 3 && <span className="text-secondary"> +{serverSummary.fullDisks.length - 3} more</span>}
</div>
)}
{serverSummary.byOs.windows > 0 && (
<div className="text-secondary small mt-2">
{serverSummary.byOs.linux} Linux · {serverSummary.byOs.windows} Windows
</div>
)}
</>
)}
</WidgetCard>
<WidgetCard
label="Domains"
hide={domainList !== null && domains.length === 0}
badge={
!domainList ? undefined : domains.length === 0 ? (
<span className="badge bg-secondary-lt text-secondary">Not configured</span>
) : expiredDomains.length > 0 ? (
<span className="badge bg-red-lt text-red">{expiredDomains.length} expired</span>
) : expiringDomains.length > 0 ? (
<span className="badge bg-yellow-lt text-yellow">{expiringDomains.length} expiring</span>
) : okDomains > 0 ? (
<span className="badge bg-green-lt text-green">All OK</span>
) : (
<span className="badge bg-secondary-lt text-secondary">No expiry dates</span>
)
}
>
<ErrorNotice error={domainError} className="mb-2" />
{!domainList ? (
!domainError && <WidgetSkeleton />
) : domains.length === 0 ? (
<div className="text-secondary">
Domains for your DNS zones appear on the <Link to="/dns?view=domains">Domains</Link> page after the next daily check, or add one there.
</div>
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Tracked" value={<Link to="/dns?view=domains" className="text-reset text-decoration-none">{domains.length}</Link>} />
</div>
<div className="col-4">
<MiniStat label="Expiring" value={expiringDomains.length} accent={expiringDomains.length > 0 ? "#f59e0b" : undefined} />
</div>
<div className="col-4">
<MiniStat label="Expired" value={expiredDomains.length} accent={expiredDomains.length > 0 ? "#ef4444" : undefined} />
</div>
</div>
<BreakdownBar
data={[
{ label: "OK", count: okDomains },
{ label: "Expiring", count: expiringDomains.length },
{ label: "Expired", count: expiredDomains.length },
{ label: "No date", count: undatedDomains },
].filter((d) => d.count > 0)}
colors={DOMAIN_STATE_COLORS}
compact
/>
{expiredDomains.length > 0 && (
<div className="small mt-2">
<span className="text-red">Expired:</span>{" "}
{expiredDomains.slice(0, 3).map((d, i) => (
<span key={d.id}>
{i > 0 && ", "}
<Link to="/dns?view=domains">{d.name}</Link> <span className="text-secondary">({Math.abs(d.daysLeft ?? 0)} d ago)</span>
</span>
))}
{expiredDomains.length > 3 && <span className="text-secondary"> +{expiredDomains.length - 3} more</span>}
</div>
)}
{expiringDomains.length > 0 && (
<div className="small mt-2">
<span className="text-yellow">Expiring:</span>{" "}
{expiringDomains
.slice()
.sort((a, b) => a.daysLeft! - b.daysLeft!)
.slice(0, 3)
.map((d, i) => (
<span key={d.id}>
{i > 0 && ", "}
<Link to="/dns?view=domains">{d.name}</Link> <span className="text-secondary">({d.daysLeft} d)</span>
</span>
))}
{expiringDomains.length > 3 && <span className="text-secondary"> +{expiringDomains.length - 3} more</span>}
</div>
)}
{nextDomain && nextDomain.status === "ok" && (
<div className="text-secondary small mt-2">
Next to expire: {nextDomain.name} in {nextDomain.daysLeft} days ({nextDomain.expiresAt})
</div>
)}
{failingDomainChecks > 0 && (
<div className="text-secondary small mt-2">
{failingDomainChecks} domain{failingDomainChecks === 1 ? "" : "s"} couldn't be refreshed — see the <Link to="/dns?view=domains">Domains</Link> page.
</div>
)}
</>
)}
</WidgetCard>
<WidgetCard
label="Endpoints"
hide={endpointChecks !== null && endpointChecks.length === 0}
badge={
!endpointChecks ? undefined : endpointsDown.length > 0 ? (
<span className="badge bg-red-lt text-red">{endpointsDown.length} not answering</span>
) : endpointCerts > 0 ? (
<span className="badge bg-yellow-lt text-yellow">
{endpointCerts} certificate{endpointCerts === 1 ? "" : "s"} to renew
</span>
) : (
<span className="badge bg-green-lt text-green">All answering</span>
)
}
>
{!endpointChecks ? (
<WidgetSkeleton />
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Checks" value={endpointChecks.filter((c) => c.enabled).length} />
</div>
<div className="col-4">
<MiniStat label="Up" value={endpointChecks.filter((c) => c.enabled && c.lastOk === true).length} />
</div>
<div className="col-4">
<MiniStat label="Down" value={endpointsDown.length} accent={endpointsDown.length > 0 ? "#ef4444" : undefined} />
</div>
</div>
{endpointsDown.slice(0, 3).map((c) => (
<div key={c.id} className="text-red small">
{c.name} — {c.lastMessage}
</div>
))}
<div className="text-secondary small mt-2">
<Link to="/endpoints">All checks</Link>
</div>
</>
)}
</WidgetCard>
<WidgetCard
label="Coming up"
badge={
!agenda ? undefined : soonPast > 0 ? (
<span className="badge bg-red-lt text-red">{soonPast} past their date</span>
) : soonWeek > 0 ? (
<span className="badge bg-yellow-lt text-yellow">{soonWeek} this week</span>
) : (
<span className="badge bg-green-lt text-green">Nothing soon</span>
)
}
>
{!agenda ? (
<WidgetSkeleton />
) : soon.length === 0 ? (
<div className="text-secondary small">Nothing expires, ends or is planned in the next 30 days.</div>
) : (
<>
{soon.slice(0, 5).map((i) => (
<div key={i.id} className="d-flex gap-2 small mb-1">
<span className={`flex-shrink-0 ${i.daysLeft < 0 ? "text-red" : i.daysLeft <= 7 ? "text-yellow" : "text-secondary"}`} style={{ minWidth: "5.5rem" }}>
{i.daysLeft === 0 ? "today" : i.daysLeft === 1 ? "tomorrow" : i.daysLeft === -1 ? "yesterday" : i.daysLeft > 0 ? `in ${i.daysLeft} days` : `${-i.daysLeft} days ago`}
</span>
<Link to={i.link} className="text-break">
{i.title}
</Link>
</div>
))}
{soon.length > 5 && <div className="text-secondary small">+{soon.length - 5} more</div>}
</>
)}
<div className="text-secondary small mt-2">
<Link to="/coming-up">Everything coming up</Link>
</div>
</WidgetCard>
<WidgetCard
label="Heartbeats"
hide={heartbeatList !== null && heartbeatList.length === 0}
badge={
!heartbeatList ? undefined : beatsWrong.length > 0 ? (
<span className="badge bg-red-lt text-red">{beatsWrong.length} not reporting</span>
) : (
<span className="badge bg-green-lt text-green">All reporting</span>
)
}
>
{!heartbeatList ? (
<WidgetSkeleton />
) : (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Jobs" value={heartbeatList.filter((h) => h.enabled).length} />
</div>
<div className="col-4">
<MiniStat label="On time" value={heartbeatList.filter((h) => h.state === "up" || h.state === "running").length} />
</div>
<div className="col-4">
<MiniStat label="Late or failed" value={beatsWrong.length} accent={beatsWrong.length > 0 ? "#ef4444" : undefined} />
</div>
</div>
{beatsWrong.slice(0, 3).map((h) => (
<div key={h.id} className="text-red small">
{h.name} — {h.state === "failed" ? `said it failed${h.lastMessage ? `: ${h.lastMessage}` : ""}` : "hasn't reported in time"}
</div>
))}
<div className="text-secondary small mt-2">
<Link to="/heartbeats">All heartbeats</Link>
</div>
</>
)}
</WidgetCard>
</div>
{TYPE_GROUPS.filter((group) => integrations?.some((i) => group.types.includes(i.type))).map((group) => (
<Fragment key={group.id}>
<SectionHeader title={group.label} hint={GROUP_HINTS[group.id]} />
<div className="row row-cards">
{WIDGETS.filter(({ type }) => group.types.includes(type)).map(({ type, label }) => {
const integration = integrations?.find((i) => i.type === type && i.enabled);
const isLiveTailscale = type === "tailscale" && integration && tailscaleSummary;
const isLiveGitea = type === "gitea" && integration && giteaSummary;
const isLiveDockhand = type === "dockhand" && integration && dockhandSummary;
const isLiveSemaphore = type === "semaphore" && integration && semaphoreSummary;
const isLiveProxmox = type === "proxmox" && integration && proxmoxSummary;
const isLiveSynology = type === "synology" && integration && synologySummary;
const isLiveUptimeKuma = type === "uptimekuma" && integration && uptimeKumaSummary;
const isLivePbs = type === "pbs" && integration && pbsSummary;
const isLiveOsTicket = type === "osticket" && integration && osTicketSummary;
const isLive =
isLiveTailscale ||
isLiveGitea ||
isLiveDockhand ||
isLiveSemaphore ||
isLiveProxmox ||
isLiveSynology ||
isLiveUptimeKuma ||
isLivePbs ||
isLiveOsTicket;
return (
<WidgetCard
key={type}
label={label}
hide={integrations === null || !integrations.some((i) => i.type === type)}
badge={
isLive ? (
<span className="badge bg-green-lt text-green">Connected</span>
) : integration ? (
<span className="badge bg-yellow-lt text-yellow">Connecting…</span>
) : (
<span className="badge bg-secondary-lt text-secondary">Not connected</span>
)
}
>
{isLiveTailscale ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Online / Total" value={`${tailscaleSummary!.online}/${tailscaleSummary!.total}`} />
</div>
<div className="col-4">
<MiniStat
label="Unauthorized"
value={tailscaleSummary!.unauthorized}
accent={tailscaleSummary!.unauthorized > 0 ? "#f59e0b" : undefined}
/>
</div>
<div className="col-4">
<MiniStat
label="Keys expiring"
value={tailscaleSummary!.expiringSoon}
accent={tailscaleSummary!.expiringSoon > 0 ? "#f59e0b" : undefined}
/>
</div>
</div>
{tailscaleExtra && tailscaleExtra.osBreakdown.length > 0 && (
<BreakdownBar
data={tailscaleExtra.osBreakdown}
colors={paletteColors(tailscaleExtra.osBreakdown.map((d) => d.label))}
compact
/>
)}
</>
) : isLiveGitea ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Repositories" value={giteaSummary!.repoCount} />
</div>
<div className="col-4">
<MiniStat label="Private" value={giteaSummary!.privateCount} />
</div>
<div className="col-4">
<MiniStat
label="Failing builds"
value={giteaSummary!.failing}
accent={giteaSummary!.failing > 0 ? "#ef4444" : undefined}
/>
</div>
</div>
{giteaSummary!.statusBreakdown.length > 0 && (
<BreakdownBar data={giteaSummary!.statusBreakdown} colors={REPO_STATUS_COLORS} compact />
)}
</>
) : isLiveDockhand ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Running / Total" value={`${dockhandSummary!.running}/${dockhandSummary!.total}`} />
</div>
<div className="col-4">
<MiniStat label="Hosts" value={dockhandSummary!.hostCount} />
</div>
<div className="col-4">
<MiniStat
label="Updates"
value={dockhandSummary!.updatesAvailable}
accent={dockhandSummary!.updatesAvailable > 0 ? "#f59e0b" : undefined}
/>
</div>
</div>
{dockhandSummary!.stateBreakdown.length > 0 && (
<BreakdownBar data={dockhandSummary!.stateBreakdown} colors={CONTAINER_STATE_COLORS} compact />
)}
</>
) : isLiveSemaphore ? (
<>
<div className="row g-2 mb-3">
<div className="col-6">
<MiniStat label="Templates" value={semaphoreSummary!.total} />
</div>
<div className="col-6">
<MiniStat
label="Last failed"
value={semaphoreSummary!.failing}
accent={semaphoreSummary!.failing > 0 ? "#ef4444" : undefined}
/>
</div>
</div>
{semaphoreSummary!.statusBreakdown.length > 0 && (
<BreakdownBar data={semaphoreSummary!.statusBreakdown} colors={TASK_STATUS_COLORS} compact />
)}
</>
) : isLiveProxmox ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Running / Total" value={`${proxmoxSummary!.running}/${proxmoxSummary!.total}`} />
</div>
<div className="col-4">
<MiniStat label="VMs" value={proxmoxSummary!.vmCount} />
</div>
<div className="col-4">
<MiniStat label="LXCs" value={proxmoxSummary!.lxcCount} />
</div>
</div>
{proxmoxSummary!.nodeBreakdown.length > 1 && (
<BreakdownBar
data={proxmoxSummary!.nodeBreakdown}
colors={paletteColors(proxmoxSummary!.nodeBreakdown.map((d) => d.label))}
compact
/>
)}
</>
) : isLiveSynology ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Volumes" value={synologySummary!.volumeCount} />
</div>
<div className="col-4">
<MiniStat
label="Unhealthy"
value={synologySummary!.volumesNotNormal + synologySummary!.disksNotNormal}
accent={synologySummary!.volumesNotNormal + synologySummary!.disksNotNormal > 0 ? "#ef4444" : undefined}
/>
</div>
<div className="col-4">
<MiniStat
label="CPU load"
value={synologySummary!.cpuLoadPercent !== null ? `${synologySummary!.cpuLoadPercent.toFixed(0)}%` : "—"}
/>
</div>
</div>
{synologySummary!.memTotalBytes !== null && (
<div className="text-secondary small mb-2">
RAM: {formatBytes(synologySummary!.memUsedBytes)} / {formatBytes(synologySummary!.memTotalBytes)}
</div>
)}
{synologySummary!.diskStatusBreakdown.length > 0 && (
<BreakdownBar
data={synologySummary!.diskStatusBreakdown}
colors={healthColors(synologySummary!.diskStatusBreakdown.map((d) => d.label))}
compact
/>
)}
</>
) : isLiveUptimeKuma ? (
<>
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Monitors" value={uptimeKumaSummary!.total} />
</div>
<div className="col-4">
<MiniStat label="Down" value={uptimeKumaSummary!.down} accent={uptimeKumaSummary!.down > 0 ? "#ef4444" : undefined} />
</div>
<div className="col-4">
<MiniStat label="Matched to a server" value={`${uptimeKumaSummary!.matched}/${uptimeKumaSummary!.total}`} />
</div>
</div>
{uptimeKumaSummary!.statusBreakdown.length > 0 && (
<BreakdownBar data={uptimeKumaSummary!.statusBreakdown} colors={MONITOR_STATE_COLORS} compact />
)}
</>
) : isLivePbs ? (
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Datastores" value={pbsSummary!.datastoreCount} />
</div>
<div className="col-4">
<MiniStat
label="Failed"
value={pbsSummary!.failedSnapshotCount}
accent={pbsSummary!.failedSnapshotCount > 0 ? "#ef4444" : undefined}
/>
</div>
<div className="col-4">
<MiniStat
label="Unverified"
value={pbsSummary!.unverifiedSnapshotCount}
accent={pbsSummary!.unverifiedSnapshotCount > 0 ? "#f59e0b" : undefined}
/>
</div>
</div>
) : isLiveOsTicket ? (
<div className="row g-2 mb-3">
<div className="col-4">
<MiniStat label="Open" value={osTicketSummary!.total} />
</div>
<div className="col-4">
<MiniStat
label="Overdue"
value={osTicketSummary!.overdue}
accent={osTicketSummary!.overdue > 0 ? "#ef4444" : undefined}
/>
</div>
<div className="col-4">
<MiniStat
label="Awaiting reply"
value={osTicketSummary!.awaitingReply}
accent={osTicketSummary!.awaitingReply > 0 ? "#f59e0b" : undefined}
/>
</div>
</div>
) : (
<div className="text-secondary mt-2">
{integration ? (
<WidgetSkeleton />
) : (
<>
Configure this integration from the <Link to="/integrations">Integrations</Link> page.
</>
)}
</div>
)}
</WidgetCard>
);
})}
{/* The integrations with no widget of their own get a small tile: whether they work, how many alerts are open, and where to look. */}
{(integrations ?? [])
.filter((i) => group.types.includes(i.type) && !WIDGETS.some((w) => w.type === i.type) && i.type !== "technitium")
.sort((a, b) => a.name.localeCompare(b.name))
.map((i) => {
const alerts = integrationAlerts.get(i.id);
const failing = i.enabled && i.health?.status === "failing";
const badge = !i.enabled ? (
<span className="badge bg-secondary-lt text-secondary">Disabled</span>
) : failing || alerts?.critical ? (
<span className="badge bg-red-lt text-red">{failing ? "Failing" : "Needs a look"}</span>
) : alerts ? (
<span className="badge bg-yellow-lt text-yellow">Needs a look</span>
) : i.health?.status === "ok" ? (
<span className="badge bg-green-lt text-green">Working</span>
) : (
<span className="badge bg-secondary-lt text-secondary">Not checked yet</span>
);
return (
<WidgetCard key={i.id} label={i.name === TYPE_LABELS[i.type] ? i.name : `${TYPE_LABELS[i.type]}: ${i.name}`} badge={badge}>
<div className="text-secondary">
{failing
? `Its last ${i.health?.consecutiveFailures ?? 0} calls failed.`
: alerts
? `${alerts.count} open ${alerts.count === 1 ? "alert" : "alerts"}.`
: i.enabled
? "Nothing open."
: "Switched off under Integrations."}
</div>
{i.enabled && (
<div className="mt-2">
<Link to={TYPE_PAGES[i.type]}>Open {TYPE_LABELS[i.type]}</Link>
</div>
)}
</WidgetCard>
);
})}
{/* Technitium DNS Server has a widget of its own: the DNS test, the last day's queries and how they were answered, and what is wrong. */}
{(integrations ?? [])
.filter((i) => group.types.includes(i.type) && i.type === "technitium")
.sort((a, b) => a.name.localeCompare(b.name))
.map((i) => {
const instance = technitium?.find((x) => x.id === i.id) ?? null;
return (
<WidgetCard key={i.id} label={i.name === TYPE_LABELS[i.type] ? i.name : `${TYPE_LABELS[i.type]}: ${i.name}`} badge={technitiumBadge(i.enabled, instance)}>
<TechnitiumBody enabled={i.enabled} instance={instance} loading={technitium === null} />
</WidgetCard>
);
})}
</div>
</Fragment>
))}
{notSetUp.length > 0 && (
<div className="card mt-4">
<div className="card-header">
<h3 className="card-title">Not set up yet</h3>
</div>
<div className="list-group list-group-flush">
{notSetUp.map((n) => (
<Link key={n.label} to={n.to} className="list-group-item list-group-item-action d-flex align-items-center gap-3">
<span className="fw-medium">{n.label}</span>
<span className="text-secondary small">{n.what}</span>
</Link>
))}
</div>
</div>
)}
</>
);
}