Files
Homelab-manager/web/src/pages/Dashboard.tsx
T
bobbanandClaude Sonnet 5.5 906220040e Add a since-you-last-looked summary, 30-day uptime ribbons, a maintenance timeline and hover timestamps
- Dashboard card on what changed since the user pressed Got it (users.last_looked_at,
  migration 0021), folding each problem and its recovery into one line.
- Uptime ribbons on servers and integrations, built from the audit log; integrations'
  failing/working-again moments are now recorded.
- Timeline of running and scheduled maintenance windows on the Maintenance page.
- TimeAgo component: relative times with the exact time in the chosen format on hover.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-16 21:55:04 +02:00

1156 lines
46 KiB
TypeScript

import { useEffect, useState, type ReactNode } from "react";
import TimeAgo from "../components/TimeAgo";
import WhatChanged from "../components/WhatChanged";
import { Link } from "react-router-dom";
import {
api,
type CurrentUser,
type DomainList,
type IntegrationSummary,
type IntegrationType,
type OsTicketTicketsResponse,
type PbsDatastoresResponse,
type SecretRecord,
type ServerSummary,
type TailscaleDevicesResponse,
} 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";
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. */
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 }) {
if (hide) return null;
return (
<div className="col-md-6">
<div className="card h-100">
<div className="card-body">
<div className="d-flex align-items-center mb-2">
<div className="subheader">{label}</div>
{badge && <div className="ms-auto">{badge}</div>}
</div>
{children}
</div>
</div>
</div>
);
}
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]}`;
}
export default function Dashboard({ user }: { user: CurrentUser }) {
const [integrations, setIntegrations] = useState<IntegrationSummary[] | 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.smtp.enabled || s.webhook.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 [domainError, setDomainError] = useState<string | null>(null);
useEffect(() => {
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));
}, []);
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, email or a webhook, 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 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 (domainList !== null && domains.length === 0) notSetUp.push({ label: "Domains", to: "/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>
<Link to="/wall" className="btn btn-sm btn-outline-secondary ms-auto" title="A full-screen status board for a spare monitor or tablet">
Wall display
</Link>
</div>
<p className="text-secondary">
Welcome back, {user.name ?? user.email ?? user.sub}.
</p>
<StatusStrip />
<WhatChanged role={user.role} />
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
<SetupGuide steps={setupSteps} />
)}
</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 && <span className="text-secondary"> +{serverSummary.offline.length - 3} more</span>}
</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="/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="/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="/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="/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="/domains">Domains</Link> page.
</div>
)}
</>
)}
</WidgetCard>
</div>
<SectionHeader
title="Integrations"
hint="Live status widgets for Proxmox, Synology, Semaphore, Tailscale, Gitea, Dockhand, Uptime Kuma, Proxmox Backup Server, and osTicket will appear here as each integration is connected."
/>
<div className="row row-cards">
{WIDGETS.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>
);
})}
</div>
{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>
)}
</>
);
}