Accessibility pass, command palette actions, row detail panel, server activity, map, wall display and setup guide
Accessibility: skip link, labelled landmarks, visible focus, page-change announcements, sortable headings as real buttons, every label tied to its field, named row checkboxes, and text contrast raised to 4.5:1 in both themes. Command palette: also runs actions (silence/end maintenance, theme, density, wall display, sign out) and is a proper dialog; g-then-letter shortcuts, "/" and "?". Row detail panel for six tables. Server Activity card, with the health check now recording offline/back-online and disk events in the audit log. Map page of hosts, servers, DNS names and monitors. Full-screen wall display. A getting-started checklist on the admin dashboard. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f7f5e1cd41
commit
57fd4f8c52
36 files changed
+2787
-207
No files matched your search
+1
-1
@@ -97,7 +97,7 @@ Who changed what. Written by the app on every change (see
|
|||||||
| `id` | integer PK | |
|
| `id` | integer PK | |
|
||||||
| `actor_user_id` | integer → `users.id`, **set null** on delete | Null for automatic actions, and for entries whose user was deleted. |
|
| `actor_user_id` | integer → `users.id`, **set null** on delete | Null for automatic actions, and for entries whose user was deleted. |
|
||||||
| `actor_label` | text | The user's name/email as it was at the time (or `system`), so an entry still reads correctly after the account is gone. |
|
| `actor_label` | text | The user's name/email as it was at the time (or `system`), so an entry still reads correctly after the account is gone. |
|
||||||
| `category` | text NOT NULL | Free text. In use: `server`, `integration`, `dns`, `settings`, `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`. |
|
| `category` | text NOT NULL | Free text. In use: `server` (including the health check's own `went_offline`, `back_online`, `disk_full` and `disk_ok`, written as `system` and shown on a server's Activity card), `integration`, `dns`, `settings`, `ipam`, `secret`, `domain`, `tag`, `task`, `session`, `network`, `maintenance`, `consistency`, `user`, `privacy`, `diag_log`, `alert_ticket`. |
|
||||||
| `action` | text NOT NULL | `create`, `update`, `delete`, `start`, `stop`, … — free text. |
|
| `action` | text NOT NULL | `create`, `update`, `delete`, `start`, `stop`, … — free text. |
|
||||||
| `target_type`, `target_id` | text | What it happened to. `target_id` is text so it can hold any kind of ID; there's no foreign key. |
|
| `target_type`, `target_id` | text | What it happened to. `target_id` is text so it can hold any kind of ID; there's no foreign key. |
|
||||||
| `detail` | text | JSON, free-form context (what changed, names, counts). Secrets are never put here. |
|
| `detail` | text | JSON, free-form context (what changed, names, counts). Secrets are never put here. |
|
||||||
|
|||||||
@@ -355,6 +355,48 @@ schedule needs a login on the Uptime Kuma integration (see INTEGRATIONS.md).
|
|||||||
"Import now" is the older, simpler route: it only looks at what is in
|
"Import now" is the older, simpler route: it only looks at what is in
|
||||||
maintenance this moment and starts a window for a duration you choose.
|
maintenance this moment and starts a window for a duration you choose.
|
||||||
|
|
||||||
|
**Getting around.** Ctrl/Cmd+K opens a search that also runs actions: go to any
|
||||||
|
page, switch light/dark or the density, start (or end) a maintenance window on
|
||||||
|
a server, integration or DNS provider ("silence elsa"), open the wall display,
|
||||||
|
sign out. "g" then a letter goes to a page (`g d` dashboard, `g a` alerts,
|
||||||
|
`g s` servers, `g m` maintenance, `g i` integrations, `g k` secrets, `g p` map,
|
||||||
|
`g w` wall display), "/" jumps to the page's table search, and "?" lists them
|
||||||
|
all. Shortcuts for pages your role can't open are ignored, and none fire while
|
||||||
|
you are typing. On a table of Proxmox guests, Docker containers, Tailscale
|
||||||
|
devices, Uptime Kuma monitors, Gitea repositories or Semaphore templates, a
|
||||||
|
click (or Enter) on a row opens a panel with everything known about it, without
|
||||||
|
leaving the table.
|
||||||
|
|
||||||
|
**Map** (Infrastructure → Map) draws how things connect: which Proxmox host each
|
||||||
|
linked server runs on, which DNS names point at it (an A or AAAA record holding
|
||||||
|
one of the server's own addresses — nothing is guessed from names), and which
|
||||||
|
Uptime Kuma monitors watch it. Hover or tab to a box to light up its
|
||||||
|
connections; each box links to its page. A monitor Uptime Kuma can't be read for
|
||||||
|
leaves a note rather than a silent gap.
|
||||||
|
|
||||||
|
**Wall display** (`/wall`, also on the dashboard and the user menu) is a
|
||||||
|
full-screen status board for a spare monitor or tablet: the overall state in
|
||||||
|
large type, servers online, alerts, maintenance windows and failing integrations,
|
||||||
|
the problems themselves, and each integration's status, refreshing every 30
|
||||||
|
seconds with the screen kept awake where the browser allows. Esc returns to the
|
||||||
|
app.
|
||||||
|
|
||||||
|
**Activity.** Operators and admins see an Activity card on each server's page:
|
||||||
|
what changed on it and who changed it, the moments the health check saw it stop
|
||||||
|
reporting (and report again) or a disk fill (and recover) — now written to the
|
||||||
|
audit log as they happen — and its maintenance windows, including ones set up by
|
||||||
|
the Uptime Kuma sync. **Getting started**: until the basics are in place, an
|
||||||
|
admin's dashboard shows a checklist (an integration, a server and agent, DNS, a
|
||||||
|
secret, notifications, a second user) whose ticks come from what actually
|
||||||
|
exists; it can be hidden, and brought back from the search box.
|
||||||
|
|
||||||
|
**Accessibility.** There is a skip-to-content link, labelled landmarks, visible
|
||||||
|
keyboard focus, and page changes are announced to screen readers; sortable table
|
||||||
|
headings are real buttons; every form field is tied to its label; status is
|
||||||
|
never colour alone; the search box and dialogs are proper dialogs (keyboard
|
||||||
|
trapped and restored); and the text colours were checked against the contrast
|
||||||
|
minimum in both themes. Motion is turned down for those who ask the system to.
|
||||||
|
|
||||||
**Ports** — each server's detail page has a Ports card for finding free ports
|
**Ports** — each server's detail page has a Ports card for finding free ports
|
||||||
and remembering what each one is for. "Scan…" runs a TCP scan of a port range
|
and remembering what each one is for. "Scan…" runs a TCP scan of a port range
|
||||||
from the app against the server's address (private addresses only, up to
|
from the app against the server's address (private addresses only, up to
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { privacyRouter } from "./routes/privacy.js";
|
|||||||
import { tagsRouter } from "./routes/tags.js";
|
import { tagsRouter } from "./routes/tags.js";
|
||||||
import { portsRouter } from "./routes/ports.js";
|
import { portsRouter } from "./routes/ports.js";
|
||||||
import { alertsRouter } from "./routes/alerts.js";
|
import { alertsRouter } from "./routes/alerts.js";
|
||||||
|
import { mapRouter } from "./routes/map.js";
|
||||||
import { generatorRouter } from "./routes/generator.js";
|
import { generatorRouter } from "./routes/generator.js";
|
||||||
import { alertTicketsRouter } from "./routes/alertTickets.js";
|
import { alertTicketsRouter } from "./routes/alertTickets.js";
|
||||||
import { apiErrorHandler } from "./utils/apiErrorHandler.js";
|
import { apiErrorHandler } from "./utils/apiErrorHandler.js";
|
||||||
@@ -105,6 +106,7 @@ export function createApp() {
|
|||||||
app.use("/api/tags", tagsRouter);
|
app.use("/api/tags", tagsRouter);
|
||||||
app.use("/api/ports", portsRouter);
|
app.use("/api/ports", portsRouter);
|
||||||
app.use("/api/alerts", alertsRouter);
|
app.use("/api/alerts", alertsRouter);
|
||||||
|
app.use("/api/map", mapRouter);
|
||||||
app.use("/api/generator", generatorRouter);
|
app.use("/api/generator", generatorRouter);
|
||||||
app.use("/api/alert-tickets", alertTicketsRouter);
|
app.use("/api/alert-tickets", alertTicketsRouter);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { Router } from "express";
|
||||||
|
import { requireAuth } from "../auth/middleware.js";
|
||||||
|
import { buildTopology } from "../services/topology.js";
|
||||||
|
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||||
|
|
||||||
|
export const mapRouter = Router();
|
||||||
|
|
||||||
|
mapRouter.use(requireAuth);
|
||||||
|
|
||||||
|
// How servers, Proxmox hosts, DNS names and monitors connect. Everyone signed in can see it: it is the same information the pages
|
||||||
|
// it links to already show.
|
||||||
|
mapRouter.get("/", asyncHandler(async (_req, res) => {
|
||||||
|
res.json(await buildTopology());
|
||||||
|
}));
|
||||||
@@ -7,6 +7,7 @@ import { requireAuth, requireRole } from "../auth/middleware.js";
|
|||||||
import { generateApiToken } from "../services/tokens.js";
|
import { generateApiToken } from "../services/tokens.js";
|
||||||
import { recordAudit } from "../services/audit.js";
|
import { recordAudit } from "../services/audit.js";
|
||||||
import { getServerMetrics, RETENTION_DAYS } from "../services/serverMetrics.js";
|
import { getServerMetrics, RETENTION_DAYS } from "../services/serverMetrics.js";
|
||||||
|
import { getServerActivity } from "../services/serverActivity.js";
|
||||||
import { asyncHandler } from "../utils/asyncHandler.js";
|
import { asyncHandler } from "../utils/asyncHandler.js";
|
||||||
import { ID_PATTERNS } from "../utils/pathSegment.js";
|
import { ID_PATTERNS } from "../utils/pathSegment.js";
|
||||||
import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
|
import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
|
||||||
@@ -201,6 +202,16 @@ serversRouter.get("/:id/metrics", asyncHandler(async (req, res) => {
|
|||||||
res.json({ days, series: await getServerMetrics(id, days) });
|
res.json({ days, series: await getServerMetrics(id, days) });
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// What has happened to a server: changes to it, the health check seeing it stop reporting or a disk fill, and its maintenance
|
||||||
|
// windows. Operators and above — the audit log it draws on is theirs to read.
|
||||||
|
serversRouter.get("/:id/activity", requireRole("operator"), asyncHandler(async (req, res) => {
|
||||||
|
const id = Number(req.params.id);
|
||||||
|
if (!Number.isInteger(id)) return res.status(400).json({ error: "invalid_id" });
|
||||||
|
const [server] = await db.select({ id: servers.id }).from(servers).where(eq(servers.id, id)).limit(1);
|
||||||
|
if (!server) return res.status(404).json({ error: "not_found" });
|
||||||
|
res.json({ events: await getServerActivity(id) });
|
||||||
|
}));
|
||||||
|
|
||||||
serversRouter.get("/:id/detail", asyncHandler(async (req, res) => {
|
serversRouter.get("/:id/detail", asyncHandler(async (req, res) => {
|
||||||
const id = Number(req.params.id);
|
const id = Number(req.params.id);
|
||||||
if (!Number.isInteger(id)) return res.status(400).json({ error: "invalid_id" });
|
if (!Number.isInteger(id)) return res.status(400).json({ error: "invalid_id" });
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
|
|||||||
import { createProxmoxAdapter, type ProxmoxNodeStats } from "../integrations/proxmox/adapter.js";
|
import { createProxmoxAdapter, type ProxmoxNodeStats } from "../integrations/proxmox/adapter.js";
|
||||||
import { createSynologyAdapter, type SynologyStorageInfo } from "../integrations/synology/adapter.js";
|
import { createSynologyAdapter, type SynologyStorageInfo } from "../integrations/synology/adapter.js";
|
||||||
import { notifyHealthIssues, notifyHealthRecovered } from "./notify.js";
|
import { notifyHealthIssues, notifyHealthRecovered } from "./notify.js";
|
||||||
|
import { recordAudit } from "./audit.js";
|
||||||
import { getInternalFlag, getSettings, setInternalFlag } from "./settingsStore.js";
|
import { getInternalFlag, getSettings, setInternalFlag } from "./settingsStore.js";
|
||||||
import { activeSubjects, subjectOfConditionKey } from "./maintenance.js";
|
import { activeSubjects, subjectOfConditionKey } from "./maintenance.js";
|
||||||
|
|
||||||
@@ -318,6 +319,33 @@ async function loadState(): Promise<ActiveState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes down, in the audit log, the moments a server stopped reporting or a disk filled up — and when they ended — so a server's
|
||||||
|
* page can tell the story afterwards. Only for problems that are about a server; never allowed to hold up the check itself.
|
||||||
|
*/
|
||||||
|
export async function recordServerTransitions(added: { key: string; message: string }[], resolved: { key: string; message: string }[]): Promise<void> {
|
||||||
|
const about = (key: string) => /^(offline|disk):server:(\d+)(?::(.*))?$/.exec(key);
|
||||||
|
const write = async (items: { key: string; message: string }[], names: { offline: string; disk: string }, withMessage: boolean) => {
|
||||||
|
for (const item of items) {
|
||||||
|
const m = about(item.key);
|
||||||
|
if (!m) continue;
|
||||||
|
try {
|
||||||
|
await recordAudit({
|
||||||
|
category: "server",
|
||||||
|
action: m[1] === "offline" ? names.offline : names.disk,
|
||||||
|
targetType: "server",
|
||||||
|
targetId: m[2],
|
||||||
|
detail: withMessage ? { message: item.message, ...(m[3] ? { mount: m[3] } : {}) } : m[3] ? { mount: m[3] } : undefined,
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error("[health] couldn't record a server event:", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
await write(added, { offline: "went_offline", disk: "disk_full" }, true);
|
||||||
|
await write(resolved, { offline: "back_online", disk: "disk_ok" }, false);
|
||||||
|
}
|
||||||
|
|
||||||
export async function runHealthCheck(now: number = Date.now()): Promise<{ added: number; resolved: number }> {
|
export async function runHealthCheck(now: number = Date.now()): Promise<{ added: number; resolved: number }> {
|
||||||
const { healthChecks } = await getSettings();
|
const { healthChecks } = await getSettings();
|
||||||
const { snapshot, held } = await collectSnapshot();
|
const { snapshot, held } = await collectSnapshot();
|
||||||
@@ -331,6 +359,7 @@ export async function runHealthCheck(now: number = Date.now()): Promise<{ added:
|
|||||||
|
|
||||||
// State is tracked even when the alert toggle is off (the notify functions check it),
|
// State is tracked even when the alert toggle is off (the notify functions check it),
|
||||||
// so turning alerts back on doesn't dump every long-standing condition at once.
|
// so turning alerts back on doesn't dump every long-standing condition at once.
|
||||||
|
await recordServerTransitions(added, resolved);
|
||||||
if (added.length > 0) await notifyHealthIssues(added);
|
if (added.length > 0) await notifyHealthIssues(added);
|
||||||
if (resolved.length > 0) await notifyHealthRecovered(resolved);
|
if (resolved.length > 0) await notifyHealthRecovered(resolved);
|
||||||
return { added: added.length, resolved: resolved.length };
|
return { added: added.length, resolved: resolved.length };
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/**
|
||||||
|
* What has happened to one server, newest first: changes people made to it, the moments the health check saw it stop reporting or
|
||||||
|
* a disk fill (and recover), and its maintenance windows. Built from the audit log and the maintenance windows, so it needs
|
||||||
|
* nothing of its own — except that the health check now writes down those moments when they happen.
|
||||||
|
*/
|
||||||
|
import { and, desc, eq } from "drizzle-orm";
|
||||||
|
import { db } from "../db/client.js";
|
||||||
|
import { auditLog, maintenanceWindows } from "../db/schema.js";
|
||||||
|
|
||||||
|
export type ActivityTone = "good" | "bad" | "neutral" | "info";
|
||||||
|
|
||||||
|
export interface ActivityEvent {
|
||||||
|
/** ISO. */
|
||||||
|
at: string;
|
||||||
|
kind: "change" | "health" | "maintenance";
|
||||||
|
tone: ActivityTone;
|
||||||
|
title: string;
|
||||||
|
detail: string | null;
|
||||||
|
/** Who did it; "system" for the app's own checks. Null when it isn't a person's doing. */
|
||||||
|
actor: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The audit log stores SQLite's "2026-10-03 14:05:09" (UTC); the rest of the app speaks ISO. */
|
||||||
|
export function auditTimeToIso(value: string): string {
|
||||||
|
return /T|Z$/.test(value) ? new Date(value).toISOString() : new Date(`${value.replace(" ", "T")}Z`).toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
const humanize = (s: string) => {
|
||||||
|
const t = s.replace(/[_-]+/g, " ");
|
||||||
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseDetail(detail: string | null): Record<string, unknown> {
|
||||||
|
if (!detail) return {};
|
||||||
|
try {
|
||||||
|
const v = JSON.parse(detail);
|
||||||
|
return v && typeof v === "object" ? (v as Record<string, unknown>) : {};
|
||||||
|
} catch {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A readable line for one audit entry about a server. */
|
||||||
|
export function describeAudit(category: string, action: string, detail: Record<string, unknown>): { title: string; tone: ActivityTone; kind: ActivityEvent["kind"]; detail: string | null } {
|
||||||
|
const message = typeof detail.message === "string" ? detail.message : null;
|
||||||
|
const label = typeof detail.label === "string" ? detail.label : null;
|
||||||
|
if (category === "server") {
|
||||||
|
switch (action) {
|
||||||
|
case "went_offline":
|
||||||
|
return { title: "Stopped reporting — marked offline", tone: "bad", kind: "health", detail: message };
|
||||||
|
case "back_online":
|
||||||
|
return { title: "Reporting again", tone: "good", kind: "health", detail: null };
|
||||||
|
case "disk_full":
|
||||||
|
return { title: "A disk got nearly full", tone: "bad", kind: "health", detail: message };
|
||||||
|
case "disk_ok":
|
||||||
|
return { title: "A disk is no longer nearly full", tone: "good", kind: "health", detail: null };
|
||||||
|
case "create":
|
||||||
|
return { title: "Server added", tone: "neutral", kind: "change", detail: null };
|
||||||
|
case "update":
|
||||||
|
return { title: "Details changed", tone: "neutral", kind: "change", detail: null };
|
||||||
|
case "rotate_token":
|
||||||
|
return { title: "Agent token replaced", tone: "neutral", kind: "change", detail: null };
|
||||||
|
case "set_tags":
|
||||||
|
return { title: "Tags changed", tone: "neutral", kind: "change", detail: null };
|
||||||
|
case "add_link":
|
||||||
|
return { title: "Admin link added", tone: "neutral", kind: "change", detail: label };
|
||||||
|
case "update_link":
|
||||||
|
return { title: "Admin link changed", tone: "neutral", kind: "change", detail: label };
|
||||||
|
case "remove_link":
|
||||||
|
return { title: "Admin link removed", tone: "neutral", kind: "change", detail: label };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { title: `${humanize(category)}: ${action.replace(/_/g, " ")}`, tone: "neutral", kind: "change", detail: message ?? label };
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getServerActivity(serverId: number, now: Date = new Date(), limit = 60): Promise<ActivityEvent[]> {
|
||||||
|
const events: ActivityEvent[] = [];
|
||||||
|
|
||||||
|
const audits = await db
|
||||||
|
.select()
|
||||||
|
.from(auditLog)
|
||||||
|
.where(and(eq(auditLog.targetType, "server"), eq(auditLog.targetId, String(serverId))))
|
||||||
|
.orderBy(desc(auditLog.createdAt))
|
||||||
|
.limit(limit);
|
||||||
|
for (const a of audits) {
|
||||||
|
// Maintenance is shown from the windows themselves below, which also cover the ones nobody started by hand.
|
||||||
|
if (a.category === "maintenance") continue;
|
||||||
|
const d = describeAudit(a.category, a.action, parseDetail(a.detail));
|
||||||
|
events.push({ at: auditTimeToIso(a.createdAt), kind: d.kind, tone: d.tone, title: d.title, detail: d.detail, actor: a.actorLabel });
|
||||||
|
}
|
||||||
|
|
||||||
|
const windows = await db
|
||||||
|
.select()
|
||||||
|
.from(maintenanceWindows)
|
||||||
|
.where(and(eq(maintenanceWindows.targetType, "server"), eq(maintenanceWindows.targetId, serverId)))
|
||||||
|
.orderBy(desc(maintenanceWindows.startedAt))
|
||||||
|
.limit(20);
|
||||||
|
const nowIso = now.toISOString();
|
||||||
|
for (const w of windows) {
|
||||||
|
const cancelled = w.endsAt <= w.startedAt;
|
||||||
|
if (cancelled) continue; // set up and withdrawn before it began: nothing happened
|
||||||
|
const until = `until ${w.endsAt.slice(0, 16).replace("T", " ")} UTC`;
|
||||||
|
events.push({
|
||||||
|
at: w.startedAt,
|
||||||
|
kind: "maintenance",
|
||||||
|
tone: "info",
|
||||||
|
title: w.startedAt > nowIso ? "Maintenance scheduled" : "Maintenance started — alerts silenced",
|
||||||
|
detail: [w.reason, until].filter(Boolean).join(" · "),
|
||||||
|
actor: w.createdBy,
|
||||||
|
});
|
||||||
|
if (w.endsAt <= nowIso) {
|
||||||
|
events.push({ at: w.endsAt, kind: "maintenance", tone: "info", title: "Maintenance ended", detail: null, actor: null });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return events.sort((a, b) => b.at.localeCompare(a.at)).slice(0, limit);
|
||||||
|
}
|
||||||
@@ -0,0 +1,136 @@
|
|||||||
|
/**
|
||||||
|
* How the things in the app connect, as a graph for the Map page: which Proxmox host each server runs on, which DNS names point
|
||||||
|
* at it, and which Uptime Kuma monitors watch it. Everything here is already known elsewhere in the app; this only puts it side
|
||||||
|
* by side. Nothing is guessed: a DNS name is a server's only when an A or AAAA record holds one of the server's own addresses,
|
||||||
|
* and a monitor only when its target is the server's (the same matching the Uptime Kuma page uses).
|
||||||
|
*/
|
||||||
|
import { and, eq, inArray } from "drizzle-orm";
|
||||||
|
import { db } from "../db/client.js";
|
||||||
|
import { dnsRecordsCache, dnsZonesCache, integrations, servers } from "../db/schema.js";
|
||||||
|
import { loadIntegrationConfig } from "../integrations/loadIntegration.js";
|
||||||
|
import { createUptimeKumaAdapter } from "../integrations/uptimekuma/adapter.js";
|
||||||
|
import { getSettings } from "./settingsStore.js";
|
||||||
|
import { attachMatchedServers, toMatchableServers } from "./uptimeKumaMatch.js";
|
||||||
|
|
||||||
|
export type MapStatus = "ok" | "bad" | "warn" | "unknown";
|
||||||
|
|
||||||
|
export interface MapNode {
|
||||||
|
id: string;
|
||||||
|
kind: "host" | "server" | "dns" | "monitor";
|
||||||
|
label: string;
|
||||||
|
sub: string | null;
|
||||||
|
status: MapStatus;
|
||||||
|
/** Where in the app to find out more. */
|
||||||
|
href: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MapEdge {
|
||||||
|
from: string;
|
||||||
|
to: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MapData {
|
||||||
|
nodes: MapNode[];
|
||||||
|
edges: MapEdge[];
|
||||||
|
/** Things that couldn't be read, so the picture is incomplete. */
|
||||||
|
notes: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** More than this many DNS names on the map and it stops being a map. */
|
||||||
|
const MAX_DNS_NAMES = 60;
|
||||||
|
const KUMA_TIMEOUT_MS = 8_000;
|
||||||
|
|
||||||
|
function withTimeout<T>(work: Promise<T>, ms: number): Promise<T> {
|
||||||
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
|
const limit = new Promise<never>((_, reject) => {
|
||||||
|
timer = setTimeout(() => reject(new Error(`timed out after ${ms / 1000}s`)), ms);
|
||||||
|
});
|
||||||
|
return Promise.race([work, limit]).finally(() => clearTimeout(timer));
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseIps(stored: string | null): string[] {
|
||||||
|
if (!stored) return [];
|
||||||
|
try {
|
||||||
|
const v = JSON.parse(stored);
|
||||||
|
return Array.isArray(v) ? v.filter((x): x is string => typeof x === "string") : [];
|
||||||
|
} catch {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function buildTopology(now: Date = new Date()): Promise<MapData> {
|
||||||
|
const nodes: MapNode[] = [];
|
||||||
|
const edges: MapEdge[] = [];
|
||||||
|
const notes: string[] = [];
|
||||||
|
|
||||||
|
const { healthChecks } = await getSettings();
|
||||||
|
const offlineAfterMs = healthChecks.serverOfflineMinutes * 60_000;
|
||||||
|
const serverRows = await db.select().from(servers);
|
||||||
|
const integrationRows = await db.select({ id: integrations.id, name: integrations.name, type: integrations.type, enabled: integrations.enabled }).from(integrations);
|
||||||
|
const integrationName = new Map(integrationRows.map((i) => [i.id, i.name]));
|
||||||
|
|
||||||
|
// Servers, and the Proxmox hosts they run on.
|
||||||
|
const hostIds = new Set<string>();
|
||||||
|
for (const s of serverRows) {
|
||||||
|
const lastSeen = s.lastSeenAt ? Date.parse(s.lastSeenAt) : null;
|
||||||
|
const status: MapStatus = lastSeen === null ? "unknown" : now.getTime() - lastSeen > offlineAfterMs ? "bad" : "ok";
|
||||||
|
nodes.push({ id: `server:${s.id}`, kind: "server", label: s.name, sub: s.hostname, status, href: `/servers/${s.id}` });
|
||||||
|
if (s.proxmoxIntegrationId && s.proxmoxNode) {
|
||||||
|
const hostId = `host:${s.proxmoxIntegrationId}:${s.proxmoxNode}`;
|
||||||
|
if (!hostIds.has(hostId)) {
|
||||||
|
hostIds.add(hostId);
|
||||||
|
nodes.push({ id: hostId, kind: "host", label: s.proxmoxNode, sub: integrationName.get(s.proxmoxIntegrationId) ?? "Proxmox", status: "unknown", href: "/proxmox" });
|
||||||
|
}
|
||||||
|
edges.push({ from: hostId, to: `server:${s.id}` });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DNS names that point at a server's own address.
|
||||||
|
const serversByIp = new Map<string, number[]>();
|
||||||
|
for (const s of serverRows) for (const ip of parseIps(s.ipAddresses)) serversByIp.set(ip, [...(serversByIp.get(ip) ?? []), s.id]);
|
||||||
|
if (serversByIp.size > 0) {
|
||||||
|
const records = await db
|
||||||
|
.select({ name: dnsRecordsCache.name, content: dnsRecordsCache.content, zoneName: dnsZonesCache.zoneName })
|
||||||
|
.from(dnsRecordsCache)
|
||||||
|
.leftJoin(dnsZonesCache, and(eq(dnsZonesCache.providerId, dnsRecordsCache.providerId), eq(dnsZonesCache.zoneId, dnsRecordsCache.zoneId)))
|
||||||
|
.where(and(inArray(dnsRecordsCache.type, ["A", "AAAA"]), inArray(dnsRecordsCache.content, [...serversByIp.keys()])));
|
||||||
|
const seen = new Set<string>();
|
||||||
|
for (const r of records) {
|
||||||
|
const zone = r.zoneName?.replace(/\.$/, "") ?? "";
|
||||||
|
const name = r.name === "@" ? zone : zone && !r.name.replace(/\.$/, "").endsWith(zone) ? `${r.name}.${zone}` : r.name.replace(/\.$/, "");
|
||||||
|
const id = `dns:${name}`;
|
||||||
|
if (!seen.has(id)) {
|
||||||
|
if (seen.size >= MAX_DNS_NAMES) {
|
||||||
|
if (!notes.some((n) => n.startsWith("Only the first"))) notes.push(`Only the first ${MAX_DNS_NAMES} DNS names are shown.`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
seen.add(id);
|
||||||
|
nodes.push({ id, kind: "dns", label: name, sub: null, status: "unknown", href: "/dns" });
|
||||||
|
}
|
||||||
|
for (const serverId of serversByIp.get(r.content) ?? []) {
|
||||||
|
if (!edges.some((e) => e.from === `server:${serverId}` && e.to === id)) edges.push({ from: `server:${serverId}`, to: id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uptime Kuma monitors watching a server.
|
||||||
|
const matchable = toMatchableServers(serverRows.map((s) => ({ id: s.id, name: s.name, hostname: s.hostname, ips: s.ipAddresses })));
|
||||||
|
for (const row of integrationRows.filter((i) => i.type === "uptimekuma" && i.enabled)) {
|
||||||
|
try {
|
||||||
|
const loaded = await loadIntegrationConfig(row.id);
|
||||||
|
if (!loaded) continue;
|
||||||
|
const monitors = await withTimeout(createUptimeKumaAdapter(loaded.config as never).listMonitors(), KUMA_TIMEOUT_MS);
|
||||||
|
for (const m of attachMatchedServers(monitors, matchable)) {
|
||||||
|
if (!m.matchedServer) continue;
|
||||||
|
const id = `monitor:${row.id}:${m.id}`;
|
||||||
|
const status: MapStatus = m.status === "up" ? "ok" : m.status === "down" ? "bad" : m.status === "unknown" ? "unknown" : "warn";
|
||||||
|
nodes.push({ id, kind: "monitor", label: m.name, sub: row.name, status, href: "/uptime-kuma" });
|
||||||
|
edges.push({ from: `server:${m.matchedServer.id}`, to: id });
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
notes.push(`Couldn't read Uptime Kuma “${row.name}” (${err instanceof Error ? err.message : String(err)}), so its monitors are missing.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { nodes, edges, notes };
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* A server's activity timeline: what the health check wrote down, what people changed, and its maintenance windows.
|
||||||
|
*
|
||||||
|
* Run with: npm test --workspace server
|
||||||
|
*/
|
||||||
|
import { test, describe, before, after } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { mkdtempSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import type { AddressInfo } from "node:net";
|
||||||
|
import type { Server } from "node:http";
|
||||||
|
|
||||||
|
const dir = mkdtempSync(join(tmpdir(), "hm-activity-"));
|
||||||
|
process.env.DATABASE_PATH = join(dir, "test.sqlite");
|
||||||
|
process.env.SESSION_DIR = join(dir, "sessions");
|
||||||
|
process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32);
|
||||||
|
|
||||||
|
const express = (await import("express")).default;
|
||||||
|
const { db } = await import("../src/db/client.js");
|
||||||
|
const { users, servers, maintenanceWindows, auditLog } = await import("../src/db/schema.js");
|
||||||
|
const { runMigrations } = await import("../src/db/migrate.js");
|
||||||
|
const { recordAudit } = await import("../src/services/audit.js");
|
||||||
|
const { recordServerTransitions } = await import("../src/services/healthMonitor.js");
|
||||||
|
const { getServerActivity, describeAudit, auditTimeToIso } = await import("../src/services/serverActivity.js");
|
||||||
|
const { serversRouter } = await import("../src/routes/servers.js");
|
||||||
|
|
||||||
|
await runMigrations();
|
||||||
|
|
||||||
|
describe("reading audit entries", () => {
|
||||||
|
test("SQLite's UTC timestamp becomes ISO", () => {
|
||||||
|
assert.equal(auditTimeToIso("2026-10-03 14:05:09"), "2026-10-03T14:05:09.000Z");
|
||||||
|
assert.equal(auditTimeToIso("2026-10-03T14:05:09.123Z"), "2026-10-03T14:05:09.123Z");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("known actions read as sentences, unknown ones still say something", () => {
|
||||||
|
assert.equal(describeAudit("server", "went_offline", { message: "x" }).tone, "bad");
|
||||||
|
assert.equal(describeAudit("server", "back_online", {}).tone, "good");
|
||||||
|
assert.equal(describeAudit("server", "rotate_token", {}).title, "Agent token replaced");
|
||||||
|
assert.equal(describeAudit("server", "add_link", { label: "Cockpit" }).detail, "Cockpit");
|
||||||
|
assert.equal(describeAudit("task", "run_now", {}).title, "Task: run now");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("the timeline", () => {
|
||||||
|
let serverId = 0;
|
||||||
|
let otherId = 0;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
serverId = (await db.insert(servers).values({ name: "elsa", apiTokenHash: "a", apiTokenPrefix: "a" }).returning())[0].id;
|
||||||
|
otherId = (await db.insert(servers).values({ name: "other", apiTokenHash: "b", apiTokenPrefix: "b" }).returning())[0].id;
|
||||||
|
});
|
||||||
|
|
||||||
|
test("the health check's moments are written down for the server they are about, and only server ones", async () => {
|
||||||
|
await recordServerTransitions(
|
||||||
|
[
|
||||||
|
{ key: `offline:server:${serverId}`, message: "elsa hasn't reported for 2 hours" },
|
||||||
|
{ key: `disk:server:${serverId}:/data`, message: "/data is 93% full" },
|
||||||
|
{ key: "disk:proxmox:4:local", message: "not a server" },
|
||||||
|
{ key: `offline:server:${otherId}`, message: "other is quiet" },
|
||||||
|
],
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
await recordServerTransitions([], [{ key: `offline:server:${serverId}`, message: "back" }]);
|
||||||
|
|
||||||
|
const events = await getServerActivity(serverId);
|
||||||
|
const titles = events.map((e) => e.title);
|
||||||
|
assert.ok(titles.includes("Stopped reporting — marked offline"));
|
||||||
|
assert.ok(titles.includes("A disk got nearly full"));
|
||||||
|
assert.ok(titles.includes("Reporting again"));
|
||||||
|
assert.equal(events.find((e) => e.title === "A disk got nearly full")!.detail, "/data is 93% full");
|
||||||
|
assert.equal(events.find((e) => e.title === "Reporting again")!.tone, "good");
|
||||||
|
assert.equal(events.every((e) => e.actor === "system"), true, "the app's own doing is marked as such");
|
||||||
|
assert.equal((await getServerActivity(otherId)).length, 1, "the other server has only its own");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("changes people made appear with who made them", async () => {
|
||||||
|
const [tobias] = await db.insert(users).values({ oidcSub: "tobias", name: "Tobias", role: "admin" }).returning();
|
||||||
|
await recordAudit({ category: "server", action: "rotate_token", targetType: "server", targetId: serverId, actor: tobias });
|
||||||
|
const found = (await getServerActivity(serverId)).find((e) => e.title === "Agent token replaced")!;
|
||||||
|
assert.equal(found.actor, "Tobias");
|
||||||
|
assert.equal(found.kind, "change");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("maintenance windows appear as a start and, once over, an end; maintenance audit entries are not doubled", async () => {
|
||||||
|
const now = new Date();
|
||||||
|
const H = 3600_000;
|
||||||
|
await db.insert(maintenanceWindows).values([
|
||||||
|
{ targetType: "server", targetId: serverId, reason: "patching", startedAt: new Date(now.getTime() - 5 * H).toISOString(), endsAt: new Date(now.getTime() - 4 * H).toISOString(), createdBy: "Tobias" },
|
||||||
|
{ targetType: "server", targetId: serverId, reason: "tonight", startedAt: new Date(now.getTime() + 5 * H).toISOString(), endsAt: new Date(now.getTime() + 6 * H).toISOString(), createdBy: "Uptime Kuma sync" },
|
||||||
|
// Set up, then cancelled before it began.
|
||||||
|
{ targetType: "server", targetId: serverId, reason: "cancelled", startedAt: new Date(now.getTime() + 9 * H).toISOString(), endsAt: new Date(now.getTime() + 9 * H).toISOString() },
|
||||||
|
]);
|
||||||
|
await recordAudit({ category: "maintenance", action: "start", targetType: "server", targetId: serverId, detail: { minutes: 60 } });
|
||||||
|
|
||||||
|
const events = await getServerActivity(serverId);
|
||||||
|
const maint = events.filter((e) => e.kind === "maintenance");
|
||||||
|
assert.deepEqual(maint.map((e) => e.title).sort(), ["Maintenance ended", "Maintenance scheduled", "Maintenance started — alerts silenced"]);
|
||||||
|
assert.ok(!events.some((e) => e.detail?.includes("cancelled")), "a cancelled window is not an event");
|
||||||
|
assert.equal(events.filter((e) => e.title.toLowerCase().includes("maintenance")).length, 3, "the audit entry did not add a fourth");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("newest first", async () => {
|
||||||
|
const events = await getServerActivity(serverId);
|
||||||
|
const sorted = [...events].sort((a, b) => b.at.localeCompare(a.at));
|
||||||
|
assert.deepEqual(events.map((e) => e.at), sorted.map((e) => e.at));
|
||||||
|
// the scheduled window is in the future, so it leads
|
||||||
|
assert.equal(events[0].title, "Maintenance scheduled");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("GET /api/servers/:id/activity", () => {
|
||||||
|
let app: Server;
|
||||||
|
let base = "";
|
||||||
|
let serverId = 0;
|
||||||
|
let role: "viewer" | "operator" = "viewer";
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
await db.insert(users).values([
|
||||||
|
{ oidcSub: "viewer", name: "Viewer", role: "viewer" },
|
||||||
|
{ oidcSub: "operator", name: "Operator", role: "operator" },
|
||||||
|
]);
|
||||||
|
serverId = (await db.insert(servers).values({ name: "route", apiTokenHash: "r", apiTokenPrefix: "r" }).returning())[0].id;
|
||||||
|
await db.insert(auditLog).values({ category: "server", action: "create", targetType: "server", targetId: String(serverId), actorLabel: "Someone" });
|
||||||
|
const a = express();
|
||||||
|
a.use(express.json());
|
||||||
|
a.use((req, _res, next) => {
|
||||||
|
(req as unknown as { session: unknown }).session = { user: { sub: role } };
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
a.use("/api/servers", serversRouter);
|
||||||
|
app = await new Promise<Server>((resolve) => {
|
||||||
|
const s = a.listen(0, "127.0.0.1", () => resolve(s));
|
||||||
|
});
|
||||||
|
base = `http://127.0.0.1:${(app.address() as AddressInfo).port}/api/servers`;
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
app.close();
|
||||||
|
try {
|
||||||
|
rmSync(dir, { recursive: true, force: true });
|
||||||
|
} catch {
|
||||||
|
// Windows keeps the database file locked until the process exits.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a viewer is refused; an operator gets the timeline", async () => {
|
||||||
|
role = "viewer";
|
||||||
|
assert.equal((await fetch(`${base}/${serverId}/activity`)).status, 403);
|
||||||
|
role = "operator";
|
||||||
|
const res = await fetch(`${base}/${serverId}/activity`);
|
||||||
|
assert.equal(res.status, 200);
|
||||||
|
const body = await res.json();
|
||||||
|
assert.equal(body.events[0].title, "Server added");
|
||||||
|
assert.equal(body.events[0].actor, "Someone");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an unknown server is a 404 and a bad id a 400", async () => {
|
||||||
|
role = "operator";
|
||||||
|
assert.equal((await fetch(`${base}/99999/activity`)).status, 404);
|
||||||
|
assert.equal((await fetch(`${base}/abc/activity`)).status, 400);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
/**
|
||||||
|
* The Map page's graph: Proxmox hosts → servers → DNS names and monitors, with nothing guessed.
|
||||||
|
*
|
||||||
|
* Run with: npm test --workspace server
|
||||||
|
*/
|
||||||
|
import { test, describe, before, after } from "node:test";
|
||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { mkdtempSync, rmSync } from "node:fs";
|
||||||
|
import { tmpdir } from "node:os";
|
||||||
|
import { join } from "node:path";
|
||||||
|
import http from "node:http";
|
||||||
|
import type { AddressInfo } from "node:net";
|
||||||
|
|
||||||
|
const dir = mkdtempSync(join(tmpdir(), "hm-topology-"));
|
||||||
|
process.env.DATABASE_PATH = join(dir, "test.sqlite");
|
||||||
|
process.env.SESSION_DIR = join(dir, "sessions");
|
||||||
|
process.env.CREDENTIALS_ENCRYPTION_KEY = "ab".repeat(32);
|
||||||
|
|
||||||
|
const { db } = await import("../src/db/client.js");
|
||||||
|
const { servers, integrations, dnsProviders, dnsZonesCache, dnsRecordsCache } = await import("../src/db/schema.js");
|
||||||
|
const { runMigrations } = await import("../src/db/migrate.js");
|
||||||
|
const { buildTopology } = await import("../src/services/topology.js");
|
||||||
|
|
||||||
|
await runMigrations();
|
||||||
|
|
||||||
|
const metric = (id: number, host: string, status: number) =>
|
||||||
|
`monitor_status{monitor_id="${id}",monitor_name="m${id}",monitor_type="ping",monitor_url="",monitor_hostname="${host}",monitor_port=""} ${status}`;
|
||||||
|
|
||||||
|
describe("buildTopology", () => {
|
||||||
|
let kuma: http.Server;
|
||||||
|
let kumaStatus = 200;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
kuma = await new Promise<http.Server>((resolve) => {
|
||||||
|
const s = http.createServer((req, res) => {
|
||||||
|
res.statusCode = kumaStatus;
|
||||||
|
res.end(req.url === "/metrics" ? [metric(1, "elsa.lab.example", 1), metric(2, "elsa.lab.example", 0), metric(3, "unknown.example", 1)].join("\n") : "");
|
||||||
|
});
|
||||||
|
s.listen(0, "127.0.0.1", () => resolve(s));
|
||||||
|
});
|
||||||
|
const kumaUrl = `http://127.0.0.1:${(kuma.address() as AddressInfo).port}`;
|
||||||
|
|
||||||
|
const [pve] = await db.insert(integrations).values({ type: "proxmox", name: "Felicia", baseUrl: "https://pve.lab", config: "{}" }).returning();
|
||||||
|
await db.insert(integrations).values({ type: "uptimekuma", name: "Kuma", baseUrl: kumaUrl, config: JSON.stringify({ url: kumaUrl, password: "k" }) });
|
||||||
|
|
||||||
|
const recent = new Date().toISOString();
|
||||||
|
await db.insert(servers).values([
|
||||||
|
{ name: "elsa", hostname: "elsa.lab.example", apiTokenHash: "a", apiTokenPrefix: "a", lastSeenAt: recent, ipAddresses: JSON.stringify(["10.0.0.5"]), proxmoxIntegrationId: pve.id, proxmoxNode: "pve1", proxmoxGuestType: "qemu", proxmoxVmid: 100 },
|
||||||
|
{ name: "anna", hostname: null, apiTokenHash: "b", apiTokenPrefix: "b", lastSeenAt: new Date(Date.now() - 5 * 24 * 3600_000).toISOString(), ipAddresses: JSON.stringify(["10.0.0.6"]) },
|
||||||
|
{ name: "never", hostname: null, apiTokenHash: "c", apiTokenPrefix: "c" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const [provider] = await db.insert(dnsProviders).values({ providerType: "technitium", name: "Ginny", config: "{}" }).returning();
|
||||||
|
await db.insert(dnsZonesCache).values({ providerId: provider.id, zoneId: "z1", zoneName: "lab.example" });
|
||||||
|
await db.insert(dnsRecordsCache).values([
|
||||||
|
{ providerId: provider.id, zoneId: "z1", recordId: "1", type: "A", name: "elsa", content: "10.0.0.5" },
|
||||||
|
{ providerId: provider.id, zoneId: "z1", recordId: "2", type: "A", name: "www.lab.example", content: "10.0.0.5" },
|
||||||
|
{ providerId: provider.id, zoneId: "z1", recordId: "3", type: "A", name: "@", content: "10.0.0.6" },
|
||||||
|
{ providerId: provider.id, zoneId: "z1", recordId: "4", type: "A", name: "stranger", content: "10.9.9.9" },
|
||||||
|
{ providerId: provider.id, zoneId: "z1", recordId: "5", type: "TXT", name: "txt", content: "10.0.0.5" },
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
kuma.close();
|
||||||
|
try {
|
||||||
|
rmSync(dir, { recursive: true, force: true });
|
||||||
|
} catch {
|
||||||
|
// Windows keeps the database file locked until the process exits.
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const has = (map: { edges: { from: string; to: string }[] }, from: string, to: string) => map.edges.some((e) => e.from === from && e.to === to);
|
||||||
|
|
||||||
|
test("every server is a node, with its state; a Proxmox link adds the host above it", async () => {
|
||||||
|
const map = await buildTopology();
|
||||||
|
const status = (label: string) => map.nodes.find((n) => n.kind === "server" && n.label === label)!.status;
|
||||||
|
assert.equal(status("elsa"), "ok");
|
||||||
|
assert.equal(status("anna"), "bad", "last heard from five days ago");
|
||||||
|
assert.equal(status("never"), "unknown", "never reported");
|
||||||
|
const host = map.nodes.find((n) => n.kind === "host")!;
|
||||||
|
assert.equal(host.label, "pve1");
|
||||||
|
assert.equal(host.sub, "Felicia");
|
||||||
|
const elsa = map.nodes.find((n) => n.label === "elsa" && n.kind === "server")!;
|
||||||
|
assert.ok(has(map, host.id, elsa.id));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("a DNS name is shown only where an A or AAAA record holds the server's own address, written out in full", async () => {
|
||||||
|
const map = await buildTopology();
|
||||||
|
const dns = map.nodes.filter((n) => n.kind === "dns").map((n) => n.label).sort();
|
||||||
|
assert.deepEqual(dns, ["elsa.lab.example", "lab.example", "www.lab.example"]);
|
||||||
|
const elsa = map.nodes.find((n) => n.kind === "server" && n.label === "elsa")!;
|
||||||
|
assert.ok(has(map, elsa.id, "dns:elsa.lab.example"));
|
||||||
|
assert.ok(has(map, elsa.id, "dns:www.lab.example"));
|
||||||
|
assert.ok(has(map, map.nodes.find((n) => n.kind === "server" && n.label === "anna")!.id, "dns:lab.example"), "an apex record is the zone's own name");
|
||||||
|
assert.ok(!map.nodes.some((n) => n.label.includes("stranger")), "an address no server has is left out");
|
||||||
|
});
|
||||||
|
|
||||||
|
test("monitors watching a server hang off it, with their status; ones watching nothing known are left out", async () => {
|
||||||
|
const map = await buildTopology();
|
||||||
|
const monitors = map.nodes.filter((n) => n.kind === "monitor");
|
||||||
|
assert.deepEqual(monitors.map((m) => [m.label, m.status]).sort(), [["m1", "ok"], ["m2", "bad"]]);
|
||||||
|
for (const m of monitors) assert.ok(map.edges.some((e) => e.to === m.id && e.from.startsWith("server:")));
|
||||||
|
});
|
||||||
|
|
||||||
|
test("when Uptime Kuma can't be read the rest of the map is still there, with a note", async () => {
|
||||||
|
kumaStatus = 500;
|
||||||
|
const map = await buildTopology();
|
||||||
|
assert.equal(map.nodes.filter((n) => n.kind === "monitor").length, 0);
|
||||||
|
assert.ok(map.nodes.filter((n) => n.kind === "server").length === 3);
|
||||||
|
assert.match(map.notes.join(" "), /Couldn't read Uptime Kuma “Kuma”/);
|
||||||
|
kumaStatus = 200;
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -42,6 +42,8 @@ import NameSettings from "./pages/settings/NameSettings";
|
|||||||
import AlertTicketSettings from "./pages/settings/AlertTicketSettings";
|
import AlertTicketSettings from "./pages/settings/AlertTicketSettings";
|
||||||
import AppShell from "./layout/AppShell";
|
import AppShell from "./layout/AppShell";
|
||||||
import DialogHost from "./components/DialogHost";
|
import DialogHost from "./components/DialogHost";
|
||||||
|
import Wall from "./pages/Wall";
|
||||||
|
import MapPage from "./pages/Map";
|
||||||
import { setDateTimeSettings } from "./utils/date";
|
import { setDateTimeSettings } from "./utils/date";
|
||||||
import { setPageSize } from "./utils/pageSize";
|
import { setPageSize } from "./utils/pageSize";
|
||||||
import ToastHost from "./components/ToastHost";
|
import ToastHost from "./components/ToastHost";
|
||||||
@@ -92,10 +94,21 @@ export default function App() {
|
|||||||
return <Login />;
|
return <Login />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The wall display is a screen of its own, with none of the app's menu around it; everything else sits inside the shell.
|
||||||
|
return (
|
||||||
|
<Routes>
|
||||||
|
<Route path="/wall" element={<Wall />} />
|
||||||
|
<Route path="*" element={<Shelled user={user} />} />
|
||||||
|
</Routes>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Shelled({ user }: { user: CurrentUser }) {
|
||||||
return (
|
return (
|
||||||
<AppShell user={user}>
|
<AppShell user={user}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<Dashboard user={user} />} />
|
<Route path="/" element={<Dashboard user={user} />} />
|
||||||
|
<Route path="/map" element={<MapPage />} />
|
||||||
<Route path="/servers" element={<Servers user={user} />} />
|
<Route path="/servers" element={<Servers user={user} />} />
|
||||||
<Route path="/servers/:id" element={<ServerDetail user={user} />} />
|
<Route path="/servers/:id" element={<ServerDetail user={user} />} />
|
||||||
<Route path="/dns" element={<Dns user={user} />} />
|
<Route path="/dns" element={<Dns user={user} />} />
|
||||||
|
|||||||
@@ -126,6 +126,33 @@ export interface SecretInput {
|
|||||||
checkPort?: number | null;
|
checkPort?: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MapNode {
|
||||||
|
id: string;
|
||||||
|
kind: "host" | "server" | "dns" | "monitor";
|
||||||
|
label: string;
|
||||||
|
sub: string | null;
|
||||||
|
status: "ok" | "bad" | "warn" | "unknown";
|
||||||
|
href: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MapData {
|
||||||
|
nodes: MapNode[];
|
||||||
|
edges: { from: string; to: string }[];
|
||||||
|
/** Things that couldn't be read, so the picture is incomplete. */
|
||||||
|
notes: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServerActivityEvent {
|
||||||
|
/** ISO. */
|
||||||
|
at: string;
|
||||||
|
kind: "change" | "health" | "maintenance";
|
||||||
|
tone: "good" | "bad" | "neutral" | "info";
|
||||||
|
title: string;
|
||||||
|
detail: string | null;
|
||||||
|
/** Who did it; "system" for the app's own checks. */
|
||||||
|
actor: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
export interface ServerMetricSeries {
|
export interface ServerMetricSeries {
|
||||||
metric: string;
|
metric: string;
|
||||||
kind: "cpu" | "mem" | "disk";
|
kind: "cpu" | "mem" | "disk";
|
||||||
@@ -1154,6 +1181,9 @@ export const api = {
|
|||||||
importNames: (sex: "girls" | "boys", years: number, count: number) =>
|
importNames: (sex: "girls" | "boys", years: number, count: number) =>
|
||||||
request<NameImportPreview>("/api/generator/themes/import", { method: "POST", body: JSON.stringify({ sex, years, count }) }),
|
request<NameImportPreview>("/api/generator/themes/import", { method: "POST", body: JSON.stringify({ sex, years, count }) }),
|
||||||
},
|
},
|
||||||
|
map: {
|
||||||
|
get: () => request<MapData>("/api/map"),
|
||||||
|
},
|
||||||
alerts: {
|
alerts: {
|
||||||
list: (refresh = false) => request<AlertsReport>(`/api/alerts${refresh ? "?refresh=1" : ""}`),
|
list: (refresh = false) => request<AlertsReport>(`/api/alerts${refresh ? "?refresh=1" : ""}`),
|
||||||
},
|
},
|
||||||
@@ -1251,6 +1281,7 @@ export const api = {
|
|||||||
request<{ server: ServerRecord }>(`/api/servers/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
request<{ server: ServerRecord }>(`/api/servers/${id}`, { method: "PATCH", body: JSON.stringify(data) }),
|
||||||
summary: () => request<ServerSummary>("/api/servers/summary"),
|
summary: () => request<ServerSummary>("/api/servers/summary"),
|
||||||
detail: (id: number) => request<ServerDetail>(`/api/servers/${id}/detail`),
|
detail: (id: number) => request<ServerDetail>(`/api/servers/${id}/detail`),
|
||||||
|
activity: (id: number) => request<{ events: ServerActivityEvent[] }>(`/api/servers/${id}/activity`),
|
||||||
metrics: (id: number, days: number) => request<{ days: number; series: ServerMetricSeries[] }>(`/api/servers/${id}/metrics?days=${days}`),
|
metrics: (id: number, days: number) => request<{ days: number; series: ServerMetricSeries[] }>(`/api/servers/${id}/metrics?days=${days}`),
|
||||||
remove: (id: number) => request<void>(`/api/servers/${id}`, { method: "DELETE" }),
|
remove: (id: number) => request<void>(`/api/servers/${id}`, { method: "DELETE" }),
|
||||||
setTags: (id: number, tags: string[]) =>
|
setTags: (id: number, tags: string[]) =>
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
import { useEffect, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
|
import { useEffect, useMemo, useRef, useState, type KeyboardEvent as ReactKeyboardEvent } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { IconSearch } from "@tabler/icons-react";
|
import { IconSearch } from "@tabler/icons-react";
|
||||||
import { api, type SearchResponse, type IntegrationType, type DnsProviderType, type SecretType } from "../api/client";
|
import {
|
||||||
|
api,
|
||||||
|
type CurrentUser,
|
||||||
|
type DnsProviderType,
|
||||||
|
type IntegrationType,
|
||||||
|
type MaintenanceTargetType,
|
||||||
|
type MaintenanceTargets,
|
||||||
|
type MaintenanceWindow,
|
||||||
|
type SearchResponse,
|
||||||
|
type SecretType,
|
||||||
|
} from "../api/client";
|
||||||
|
import { isGroup, visibleNav } from "../layout/nav";
|
||||||
|
import { SHOW_SHORTCUTS_EVENT, shortcutHintFor } from "../layout/shortcuts";
|
||||||
|
import { DENSITIES, type Density } from "../utils/density";
|
||||||
|
import { readableError } from "../utils/errors";
|
||||||
|
import { toast } from "../utils/toast";
|
||||||
|
import { SHOW_SETUP_EVENT } from "./SetupGuide";
|
||||||
|
|
||||||
const SECRET_TYPE_LABELS: Record<SecretType, string> = {
|
const SECRET_TYPE_LABELS: Record<SecretType, string> = {
|
||||||
api_token: "API Token",
|
api_token: "API Token",
|
||||||
@@ -37,10 +53,17 @@ interface PaletteItem {
|
|||||||
category: string;
|
category: string;
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string;
|
subtitle: string;
|
||||||
path: string;
|
/** A shortcut to show beside it, e.g. "g s". */
|
||||||
|
hint?: string;
|
||||||
|
/** Go to a page… */
|
||||||
|
path?: string;
|
||||||
|
/** …or do something. */
|
||||||
|
run?: () => void | Promise<void>;
|
||||||
|
/** Extra words it can be found by. */
|
||||||
|
keywords?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildItems(res: SearchResponse): PaletteItem[] {
|
function buildSearchItems(res: SearchResponse): PaletteItem[] {
|
||||||
const items: PaletteItem[] = [];
|
const items: PaletteItem[] = [];
|
||||||
for (const s of res.servers) {
|
for (const s of res.servers) {
|
||||||
items.push({ key: `server-${s.id}`, category: "Servers", title: s.name, subtitle: s.hostname ?? "", path: `/servers/${s.id}` });
|
items.push({ key: `server-${s.id}`, category: "Servers", title: s.name, subtitle: s.hostname ?? "", path: `/servers/${s.id}` });
|
||||||
@@ -109,21 +132,45 @@ function buildItems(res: SearchResponse): PaletteItem[] {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CommandPalette() {
|
/** Every word typed must appear somewhere in the item's title, subtitle or keywords. */
|
||||||
|
function matches(item: PaletteItem, terms: string[]): boolean {
|
||||||
|
if (terms.length === 0) return true;
|
||||||
|
const hay = `${item.title} ${item.subtitle} ${item.keywords ?? ""}`.toLowerCase();
|
||||||
|
return terms.every((t) => hay.includes(t));
|
||||||
|
}
|
||||||
|
|
||||||
|
const SUGGESTED_LIMIT = 9;
|
||||||
|
|
||||||
|
export default function CommandPalette({
|
||||||
|
user,
|
||||||
|
onToggleTheme,
|
||||||
|
onSetDensity,
|
||||||
|
}: {
|
||||||
|
user: CurrentUser;
|
||||||
|
onToggleTheme: () => void;
|
||||||
|
onSetDensity: (density: Density) => void;
|
||||||
|
}) {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [items, setItems] = useState<PaletteItem[]>([]);
|
const [found, setFound] = useState<PaletteItem[]>([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [searching, setSearching] = useState(false);
|
||||||
const [activeIndex, setActiveIndex] = useState(0);
|
const [activeIndex, setActiveIndex] = useState(0);
|
||||||
|
const [targets, setTargets] = useState<MaintenanceTargets | null>(null);
|
||||||
|
const [windows, setWindows] = useState<MaintenanceWindow[]>([]);
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
const opener = useRef<HTMLElement | null>(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const canAct = user.role === "admin" || user.role === "operator";
|
||||||
|
|
||||||
// Global Ctrl/Cmd+K opens the palette from anywhere in the app; Escape closes it.
|
// Ctrl/Cmd+K opens it from anywhere in the app; Escape closes it.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function onKeyDown(e: KeyboardEvent) {
|
function onKeyDown(e: KeyboardEvent) {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "k") {
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "k") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setOpen((o) => !o);
|
setOpen((o) => {
|
||||||
|
if (!o) opener.current = document.activeElement as HTMLElement | null;
|
||||||
|
return !o;
|
||||||
|
});
|
||||||
} else if (e.key === "Escape") {
|
} else if (e.key === "Escape") {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
}
|
}
|
||||||
@@ -132,37 +179,158 @@ export default function CommandPalette() {
|
|||||||
return () => window.removeEventListener("keydown", onKeyDown);
|
return () => window.removeEventListener("keydown", onKeyDown);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// On open: start clean, focus the box, and fetch what the maintenance actions need; on close: hand the focus back.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (open) {
|
if (!open) {
|
||||||
setQuery("");
|
opener.current?.focus?.();
|
||||||
setItems([]);
|
|
||||||
setActiveIndex(0);
|
|
||||||
setTimeout(() => inputRef.current?.focus(), 0);
|
|
||||||
}
|
|
||||||
}, [open]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!open || query.trim().length < 2) {
|
|
||||||
setItems([]);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setQuery("");
|
||||||
|
setFound([]);
|
||||||
|
setActiveIndex(0);
|
||||||
|
setTimeout(() => inputRef.current?.focus(), 0);
|
||||||
|
api.maintenance
|
||||||
|
.list()
|
||||||
|
.then((res) => {
|
||||||
|
setTargets(res.targets);
|
||||||
|
setWindows(res.windows);
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
// The commands: pages to go to, and things to do.
|
||||||
|
const commands = useMemo<PaletteItem[]>(() => {
|
||||||
|
const items: PaletteItem[] = [];
|
||||||
|
const pages: { to: string; label: string; group: string }[] = [];
|
||||||
|
for (const entry of visibleNav(user.role)) {
|
||||||
|
if (isGroup(entry)) entry.items.forEach((i) => pages.push({ to: i.to, label: i.label, group: entry.label }));
|
||||||
|
else pages.push({ to: entry.to, label: entry.label, group: "" });
|
||||||
|
}
|
||||||
|
pages.push({ to: "/wall", label: "Wall display", group: "" });
|
||||||
|
for (const p of pages) {
|
||||||
|
items.push({ key: `page-${p.to}`, category: "Go to", title: p.label, subtitle: p.group, hint: shortcutHintFor(p.to) ?? undefined, path: p.to, keywords: "go open page" });
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push({ key: "act-theme", category: "Actions", title: "Switch between light and dark mode", subtitle: "", run: onToggleTheme, keywords: "theme dark light mode appearance" });
|
||||||
|
for (const d of DENSITIES) {
|
||||||
|
items.push({ key: `act-density-${d.value}`, category: "Actions", title: `Density: ${d.label}`, subtitle: "How tightly pages are packed", run: () => onSetDensity(d.value), keywords: "density compact roomy spacing size" });
|
||||||
|
}
|
||||||
|
items.push({
|
||||||
|
key: "act-refresh-alerts",
|
||||||
|
category: "Actions",
|
||||||
|
title: "Check alerts again",
|
||||||
|
subtitle: "",
|
||||||
|
run: () => {
|
||||||
|
window.dispatchEvent(new Event("maintenance-changed"));
|
||||||
|
toast.info("Checking alerts again…");
|
||||||
|
},
|
||||||
|
keywords: "refresh reload alerts",
|
||||||
|
});
|
||||||
|
items.push({ key: "act-shortcuts", category: "Actions", title: "Show keyboard shortcuts", subtitle: "", hint: "?", run: () => void window.dispatchEvent(new Event(SHOW_SHORTCUTS_EVENT)), keywords: "keys help" });
|
||||||
|
if (user.role === "admin") {
|
||||||
|
items.push({
|
||||||
|
key: "act-setup",
|
||||||
|
category: "Actions",
|
||||||
|
title: "Show the getting started guide",
|
||||||
|
subtitle: "on the dashboard",
|
||||||
|
run: () => {
|
||||||
|
window.dispatchEvent(new Event(SHOW_SETUP_EVENT));
|
||||||
|
navigate("/");
|
||||||
|
},
|
||||||
|
keywords: "setup onboarding checklist first run",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
items.push({ key: "act-signout", category: "Actions", title: "Sign out", subtitle: "", run: () => void (window.location.href = "/auth/logout"), keywords: "log out logout" });
|
||||||
|
|
||||||
|
if (canAct && targets) {
|
||||||
|
const start = (type: MaintenanceTargetType, id: number, name: string, minutes: number, words: string) => async () => {
|
||||||
|
try {
|
||||||
|
await api.maintenance.start({ targetType: type, targetId: id, minutes, reason: "Started from the command palette" });
|
||||||
|
toast.success(`${name} is silenced for ${words}. End it early under Maintenance.`);
|
||||||
|
window.dispatchEvent(new Event("maintenance-changed"));
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(readableError(err));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const targetList: { type: MaintenanceTargetType; id: number; name: string; kind: string }[] = [
|
||||||
|
...targets.servers.map((s) => ({ type: "server" as const, id: s.id, name: s.name, kind: "server" })),
|
||||||
|
...targets.integrations.map((i) => ({ type: "integration" as const, id: i.id, name: i.name, kind: i.type })),
|
||||||
|
...targets.dnsProviders.map((p) => ({ type: "dns_provider" as const, id: p.id, name: p.name, kind: "DNS provider" })),
|
||||||
|
];
|
||||||
|
for (const t of targetList) {
|
||||||
|
for (const [minutes, words] of [
|
||||||
|
[60, "1 hour"],
|
||||||
|
[240, "4 hours"],
|
||||||
|
] as const) {
|
||||||
|
items.push({
|
||||||
|
key: `maint-${t.type}-${t.id}-${minutes}`,
|
||||||
|
category: "Maintenance",
|
||||||
|
title: `Silence ${t.name} for ${words}`,
|
||||||
|
subtitle: `${t.kind} · starts a maintenance window`,
|
||||||
|
run: start(t.type, t.id, t.name, minutes, words),
|
||||||
|
keywords: "maintenance silence mute window",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const w of windows) {
|
||||||
|
items.push({
|
||||||
|
key: `maint-end-${w.id}`,
|
||||||
|
category: "Maintenance",
|
||||||
|
title: `End maintenance on ${w.targetName}`,
|
||||||
|
subtitle: "alerts about it become active again",
|
||||||
|
run: async () => {
|
||||||
|
try {
|
||||||
|
await api.maintenance.end(w.id);
|
||||||
|
toast.success(`Maintenance on ${w.targetName} ended.`);
|
||||||
|
window.dispatchEvent(new Event("maintenance-changed"));
|
||||||
|
} catch (err) {
|
||||||
|
toast.error(readableError(err));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
keywords: "maintenance end stop silence window",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [user.role, canAct, targets, windows, onToggleTheme, onSetDensity]);
|
||||||
|
|
||||||
|
const terms = query.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||||
|
|
||||||
|
// Data search, for two characters or more.
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open || query.trim().length < 2) {
|
||||||
|
setFound([]);
|
||||||
|
setSearching(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setSearching(true);
|
||||||
const handle = setTimeout(() => {
|
const handle = setTimeout(() => {
|
||||||
api.search
|
api.search
|
||||||
.query(query.trim())
|
.query(query.trim())
|
||||||
.then((res) => {
|
.then((res) => setFound(buildSearchItems(res)))
|
||||||
setItems(buildItems(res));
|
.catch(() => setFound([]))
|
||||||
setActiveIndex(0);
|
.finally(() => setSearching(false));
|
||||||
})
|
|
||||||
.catch(() => setItems([]))
|
|
||||||
.finally(() => setLoading(false));
|
|
||||||
}, 200);
|
}, 200);
|
||||||
return () => clearTimeout(handle);
|
return () => clearTimeout(handle);
|
||||||
}, [query, open]);
|
}, [query, open]);
|
||||||
|
|
||||||
|
// What is listed: with nothing typed, a few suggestions; otherwise every command that matches, then the data search results.
|
||||||
|
const items = useMemo(() => {
|
||||||
|
if (terms.length === 0) {
|
||||||
|
const wanted = ["page-/", "page-/alerts", "page-/servers", "page-/maintenance", "page-/wall", "act-theme", "act-shortcuts"];
|
||||||
|
return wanted.map((k) => commands.find((c) => c.key === k)).filter((c): c is PaletteItem => !!c).slice(0, SUGGESTED_LIMIT);
|
||||||
|
}
|
||||||
|
return [...commands.filter((c) => matches(c, terms)).slice(0, 14), ...found];
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [commands, found, query]);
|
||||||
|
|
||||||
|
useEffect(() => setActiveIndex(0), [items.length, query]);
|
||||||
|
|
||||||
function go(item: PaletteItem) {
|
function go(item: PaletteItem) {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
navigate(item.path);
|
if (item.run) void item.run();
|
||||||
|
else if (item.path) navigate(item.path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleInputKeyDown(e: ReactKeyboardEvent<HTMLInputElement>) {
|
function handleInputKeyDown(e: ReactKeyboardEvent<HTMLInputElement>) {
|
||||||
@@ -175,16 +343,28 @@ export default function CommandPalette() {
|
|||||||
} else if (e.key === "Enter") {
|
} else if (e.key === "Enter") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (items[activeIndex]) go(items[activeIndex]);
|
if (items[activeIndex]) go(items[activeIndex]);
|
||||||
|
} else if (e.key === "Tab") {
|
||||||
|
// Nothing else in here is worth tabbing to: the list is driven from the box.
|
||||||
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Keep the highlighted row in view as the arrows move it.
|
||||||
|
useEffect(() => {
|
||||||
|
document.getElementById(`palette-opt-${activeIndex}`)?.scrollIntoView({ block: "nearest" });
|
||||||
|
}, [activeIndex]);
|
||||||
|
|
||||||
if (!open) {
|
if (!open) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-outline-secondary btn-sm w-100 d-flex align-items-center justify-content-center gap-2"
|
className="btn btn-outline-secondary btn-sm w-100 d-flex align-items-center justify-content-center gap-2"
|
||||||
onClick={() => setOpen(true)}
|
onClick={() => {
|
||||||
title="Search (Ctrl/Cmd+K)"
|
opener.current = document.activeElement as HTMLElement | null;
|
||||||
|
setOpen(true);
|
||||||
|
}}
|
||||||
|
title="Search and actions (Ctrl/Cmd+K)"
|
||||||
|
aria-keyshortcuts="Control+K Meta+K"
|
||||||
>
|
>
|
||||||
<IconSearch size={16} />
|
<IconSearch size={16} />
|
||||||
Search
|
Search
|
||||||
@@ -194,6 +374,7 @@ export default function CommandPalette() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let lastCategory = "";
|
let lastCategory = "";
|
||||||
|
const empty = terms.length > 0 && items.length === 0 && !searching;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -204,7 +385,7 @@ export default function CommandPalette() {
|
|||||||
for a result row. */}
|
for a result row. */}
|
||||||
<div className="modal-backdrop show"></div>
|
<div className="modal-backdrop show"></div>
|
||||||
<div className="modal modal-blur show" style={{ display: "block" }} onClick={() => setOpen(false)}>
|
<div className="modal modal-blur show" style={{ display: "block" }} onClick={() => setOpen(false)}>
|
||||||
<div className="modal-dialog modal-dialog-centered" style={{ maxWidth: 600 }} onClick={(e) => e.stopPropagation()}>
|
<div className="modal-dialog modal-dialog-centered" role="dialog" aria-modal="true" aria-label="Search and actions" style={{ maxWidth: 640 }} onClick={(e) => e.stopPropagation()}>
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body p-0">
|
<div className="modal-body p-0">
|
||||||
<div className="p-2 border-bottom">
|
<div className="p-2 border-bottom">
|
||||||
@@ -215,41 +396,53 @@ export default function CommandPalette() {
|
|||||||
<input
|
<input
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
type="text"
|
type="text"
|
||||||
|
role="combobox"
|
||||||
|
aria-expanded="true"
|
||||||
|
aria-controls="palette-list"
|
||||||
|
aria-activedescendant={items[activeIndex] ? `palette-opt-${activeIndex}` : undefined}
|
||||||
|
aria-autocomplete="list"
|
||||||
|
aria-label="Search, or type a command"
|
||||||
className="form-control form-control-lg border-0"
|
className="form-control form-control-lg border-0"
|
||||||
placeholder="Search servers, DNS, secrets, IPs, integrations…"
|
placeholder="Search, or type a command: silence, theme, wall…"
|
||||||
value={query}
|
value={query}
|
||||||
onChange={(e) => setQuery(e.target.value)}
|
onChange={(e) => setQuery(e.target.value)}
|
||||||
onKeyDown={handleInputKeyDown}
|
onKeyDown={handleInputKeyDown}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ maxHeight: "60vh", overflowY: "auto" }}>
|
<div id="palette-list" role="listbox" aria-label="Results" style={{ maxHeight: "60vh", overflowY: "auto" }}>
|
||||||
{loading && <div className="p-3 text-secondary">Searching…</div>}
|
|
||||||
{!loading && query.trim().length >= 2 && items.length === 0 && <div className="p-3 text-secondary">No matches.</div>}
|
|
||||||
{!loading && query.trim().length < 2 && <div className="p-3 text-secondary">Type at least 2 characters…</div>}
|
|
||||||
{items.map((item, index) => {
|
{items.map((item, index) => {
|
||||||
const showHeader = item.category !== lastCategory;
|
const showHeader = item.category !== lastCategory;
|
||||||
lastCategory = item.category;
|
lastCategory = item.category;
|
||||||
return (
|
return (
|
||||||
<div key={item.key}>
|
<div key={item.key} role="presentation">
|
||||||
{showHeader && (
|
{showHeader && (
|
||||||
<div className="px-3 pt-2 pb-1 text-uppercase text-secondary" style={{ fontSize: "0.7rem" }}>
|
<div role="presentation" className="px-3 pt-2 pb-1 text-uppercase text-secondary" style={{ fontSize: "0.7rem" }}>
|
||||||
{item.category}
|
{item.category}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div
|
<div
|
||||||
|
id={`palette-opt-${index}`}
|
||||||
|
role="option"
|
||||||
|
aria-selected={index === activeIndex}
|
||||||
className={`px-3 py-2 d-flex justify-content-between align-items-center gap-3 ${index === activeIndex ? "bg-secondary-lt" : ""}`}
|
className={`px-3 py-2 d-flex justify-content-between align-items-center gap-3 ${index === activeIndex ? "bg-secondary-lt" : ""}`}
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onMouseEnter={() => setActiveIndex(index)}
|
onMouseEnter={() => setActiveIndex(index)}
|
||||||
onClick={() => go(item)}
|
onClick={() => go(item)}
|
||||||
>
|
>
|
||||||
<div className="text-truncate">{item.title}</div>
|
<div className="text-truncate">{item.title}</div>
|
||||||
{item.subtitle && <div className="text-secondary small text-truncate">{item.subtitle}</div>}
|
<div className="d-flex align-items-center gap-2 flex-shrink-0">
|
||||||
|
{item.subtitle && <span className="text-secondary small text-truncate">{item.subtitle}</span>}
|
||||||
|
{item.hint && <kbd>{item.hint}</kbd>}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="px-3 py-2 border-top text-secondary small" role="status" aria-live="polite">
|
||||||
|
{searching ? "Searching…" : empty ? "No matches." : terms.length === 0 ? "Type to search servers, DNS, secrets and more — or a command." : `${items.length} result${items.length === 1 ? "" : "s"}`}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import { useEffect, useId, useRef, type ReactNode } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import { IconX } from "@tabler/icons-react";
|
||||||
|
import { formatDateTime } from "../utils/date";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A panel that slides in from the right with everything about one row, so the table stays where it was. Mount it only while a row
|
||||||
|
* is selected. Escape or a click outside closes it, the keyboard stays inside while it is open, and the focus goes back to the
|
||||||
|
* row it came from.
|
||||||
|
*/
|
||||||
|
export default function DetailDrawer({ title, subtitle, onClose, children }: { title: string; subtitle?: string; onClose: () => void; children: ReactNode }) {
|
||||||
|
const titleId = useId();
|
||||||
|
const closeRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const panelRef = useRef<HTMLDivElement>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const opener = document.activeElement as HTMLElement | null;
|
||||||
|
closeRef.current?.focus();
|
||||||
|
const onKey = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
e.stopPropagation();
|
||||||
|
onClose();
|
||||||
|
} else if (e.key === "Tab" && panelRef.current) {
|
||||||
|
const focusable = panelRef.current.querySelectorAll<HTMLElement>('a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"])');
|
||||||
|
if (focusable.length === 0) return;
|
||||||
|
const first = focusable[0];
|
||||||
|
const last = focusable[focusable.length - 1];
|
||||||
|
if (e.shiftKey && document.activeElement === first) {
|
||||||
|
e.preventDefault();
|
||||||
|
last.focus();
|
||||||
|
} else if (!e.shiftKey && document.activeElement === last) {
|
||||||
|
e.preventDefault();
|
||||||
|
first.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener("keydown", onKey, true);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", onKey, true);
|
||||||
|
opener?.focus?.();
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return createPortal(
|
||||||
|
<>
|
||||||
|
<div className="detail-backdrop" onClick={onClose} />
|
||||||
|
<div ref={panelRef} className="detail-drawer" role="dialog" aria-modal="true" aria-labelledby={titleId}>
|
||||||
|
<div className="detail-drawer-header">
|
||||||
|
<div className="flex-fill" style={{ minWidth: 0 }}>
|
||||||
|
<h3 className="mb-0 text-truncate" id={titleId}>
|
||||||
|
{title}
|
||||||
|
</h3>
|
||||||
|
{subtitle && <div className="text-secondary small text-truncate">{subtitle}</div>}
|
||||||
|
</div>
|
||||||
|
<button ref={closeRef} type="button" className="btn btn-icon btn-ghost-secondary" aria-label="Close" onClick={onClose}>
|
||||||
|
<IconX size={18} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div className="detail-drawer-body">{children}</div>
|
||||||
|
</div>
|
||||||
|
</>,
|
||||||
|
document.body,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ─── Showing every field of a record ────────────────────────────────────────
|
||||||
|
|
||||||
|
/** "environmentName" → "Environment name". */
|
||||||
|
function humanize(key: string): string {
|
||||||
|
const spaced = key
|
||||||
|
.replace(/([a-z])([A-Z])/g, "$1 $2")
|
||||||
|
.replace(/([a-zA-Z])(\d)/g, "$1 $2")
|
||||||
|
.replace(/[_-]+/g, " ")
|
||||||
|
.toLowerCase()
|
||||||
|
// A trailing unit reads better in brackets: "Response time (ms)".
|
||||||
|
.replace(/ (ms|kb|mb|gb|tb)$/, " ($1)");
|
||||||
|
return spaced.charAt(0).toUpperCase() + spaced.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatBytes(bytes: number): string {
|
||||||
|
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(unit === 0 ? 0 : 1)} ${units[unit]}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ISO_DATE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
|
||||||
|
|
||||||
|
function formatValue(key: string, value: unknown): ReactNode {
|
||||||
|
if (value === null || value === undefined || value === "") return <span className="text-secondary">—</span>;
|
||||||
|
if (typeof value === "boolean") return value ? "Yes" : "No";
|
||||||
|
if (typeof value === "number") return /bytes?$/i.test(key) ? `${formatBytes(value)} (${value.toLocaleString()} bytes)` : value.toLocaleString();
|
||||||
|
if (typeof value === "string") {
|
||||||
|
if (ISO_DATE.test(value) && !Number.isNaN(Date.parse(value))) return formatDateTime(new Date(value));
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Every field of a record as a labelled list: dates and sizes made readable, lists joined, nested records indented. */
|
||||||
|
export function ObjectDetails({ data, omit = [], labels = {}, depth = 0 }: { data: object; omit?: string[]; labels?: Record<string, string>; depth?: number }) {
|
||||||
|
const entries = Object.entries(data).filter(([k]) => !omit.includes(k));
|
||||||
|
return (
|
||||||
|
<dl className={`detail-list ${depth > 0 ? "detail-list-nested" : ""}`}>
|
||||||
|
{entries.map(([key, value]) => {
|
||||||
|
const label = labels[key] ?? humanize(key);
|
||||||
|
let shown: ReactNode = formatValue(key, value);
|
||||||
|
if (shown === null) {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
if (value.length === 0) shown = <span className="text-secondary">—</span>;
|
||||||
|
else if (value.every((v) => v === null || typeof v !== "object")) shown = value.map((v) => String(v)).join(", ");
|
||||||
|
else if (depth < 2) shown = value.map((v, i) => <ObjectDetails key={i} data={v as object} depth={depth + 1} />);
|
||||||
|
else shown = `${value.length} items`;
|
||||||
|
} else if (typeof value === "object" && depth < 2) {
|
||||||
|
shown = <ObjectDetails data={value as object} depth={depth + 1} />;
|
||||||
|
} else {
|
||||||
|
shown = String(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div key={key}>
|
||||||
|
<dt>{label}</dt>
|
||||||
|
<dd>{shown}</dd>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</dl>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { IconAlertTriangle, IconCircleCheck, IconEdit, IconTool } from "@tabler/icons-react";
|
||||||
|
import { api, type ServerActivityEvent } from "../api/client";
|
||||||
|
import { formatDateTime } from "../utils/date";
|
||||||
|
import { formatAgo } from "../utils/duration";
|
||||||
|
import { BlockSkeleton } from "./Skeleton";
|
||||||
|
|
||||||
|
const TONE_CLASS: Record<ServerActivityEvent["tone"], string> = {
|
||||||
|
good: "text-green",
|
||||||
|
bad: "text-red",
|
||||||
|
info: "text-blue",
|
||||||
|
neutral: "text-secondary",
|
||||||
|
};
|
||||||
|
|
||||||
|
function EventIcon({ event }: { event: ServerActivityEvent }) {
|
||||||
|
const cls = TONE_CLASS[event.tone];
|
||||||
|
if (event.kind === "maintenance") return <IconTool size={18} className={cls} aria-hidden="true" />;
|
||||||
|
if (event.kind === "health") return event.tone === "good" ? <IconCircleCheck size={18} className={cls} aria-hidden="true" /> : <IconAlertTriangle size={18} className={cls} aria-hidden="true" />;
|
||||||
|
return <IconEdit size={18} className={cls} aria-hidden="true" />;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What has happened to a server, newest first. For operators and admins, since it draws on the audit log. */
|
||||||
|
export default function ServerActivity({ serverId }: { serverId: number }) {
|
||||||
|
const [events, setEvents] = useState<ServerActivityEvent[] | null>(null);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let alive = true;
|
||||||
|
api.servers
|
||||||
|
.activity(serverId)
|
||||||
|
.then((res) => alive && setEvents(res.events))
|
||||||
|
.catch(() => alive && setFailed(true));
|
||||||
|
return () => {
|
||||||
|
alive = false;
|
||||||
|
};
|
||||||
|
}, [serverId]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card mb-3">
|
||||||
|
<div className="card-header">
|
||||||
|
<h3 className="card-title">Activity</h3>
|
||||||
|
</div>
|
||||||
|
<div className="card-body">
|
||||||
|
{failed ? (
|
||||||
|
<div className="text-secondary">Couldn't load the activity.</div>
|
||||||
|
) : events === null ? (
|
||||||
|
<BlockSkeleton lines={4} />
|
||||||
|
) : events.length === 0 ? (
|
||||||
|
<div className="text-secondary">Nothing recorded yet. Changes to this server, times it stopped reporting, and its maintenance windows will be listed here.</div>
|
||||||
|
) : (
|
||||||
|
<ol className="activity-list">
|
||||||
|
{events.map((e, i) => (
|
||||||
|
<li key={`${e.at}-${i}`}>
|
||||||
|
<EventIcon event={e} />
|
||||||
|
<div className="flex-fill" style={{ minWidth: 0 }}>
|
||||||
|
<div>
|
||||||
|
{e.title}
|
||||||
|
{e.actor && <span className="text-secondary"> · {e.actor === "system" ? "automatic" : e.actor}</span>}
|
||||||
|
</div>
|
||||||
|
{e.detail && <div className="text-secondary small">{e.detail}</div>}
|
||||||
|
</div>
|
||||||
|
<time className="text-secondary small text-nowrap" dateTime={e.at} title={formatDateTime(new Date(e.at))}>
|
||||||
|
{Date.parse(e.at) > Date.now() ? `at ${formatDateTime(new Date(e.at))}` : formatAgo(e.at)}
|
||||||
|
</time>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { IconCircle, IconCircleCheck, IconX } from "@tabler/icons-react";
|
||||||
|
|
||||||
|
export interface SetupStep {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
to: string;
|
||||||
|
/** What to call the button that goes there. */
|
||||||
|
action: string;
|
||||||
|
done: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const DISMISSED_KEY = "hlm-setup-dismissed";
|
||||||
|
export const SHOW_SETUP_EVENT = "show-setup-guide";
|
||||||
|
|
||||||
|
function wasDismissed(): boolean {
|
||||||
|
try {
|
||||||
|
return localStorage.getItem(DISMISSED_KEY) === "1";
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A checklist for a new installation, at the top of the dashboard: what to set up, which steps are already done (worked out from
|
||||||
|
* what exists, never ticked by hand), and a way to put it away. It goes by itself once everything is done.
|
||||||
|
*/
|
||||||
|
export default function SetupGuide({ steps }: { steps: SetupStep[] }) {
|
||||||
|
const [dismissed, setDismissed] = useState(wasDismissed);
|
||||||
|
|
||||||
|
// The command palette can bring it back.
|
||||||
|
useEffect(() => {
|
||||||
|
const show = () => {
|
||||||
|
try {
|
||||||
|
localStorage.removeItem(DISMISSED_KEY);
|
||||||
|
} catch {
|
||||||
|
// not remembered; it shows for this visit anyway
|
||||||
|
}
|
||||||
|
setDismissed(false);
|
||||||
|
};
|
||||||
|
window.addEventListener(SHOW_SETUP_EVENT, show);
|
||||||
|
return () => window.removeEventListener(SHOW_SETUP_EVENT, show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const done = steps.filter((s) => s.done).length;
|
||||||
|
if (dismissed || steps.length === 0 || done === steps.length) return null;
|
||||||
|
|
||||||
|
const dismiss = () => {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(DISMISSED_KEY, "1");
|
||||||
|
} catch {
|
||||||
|
// not remembered; it is gone for this visit anyway
|
||||||
|
}
|
||||||
|
setDismissed(true);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card mb-3" role="region" aria-labelledby="setup-guide-title">
|
||||||
|
<div className="card-header">
|
||||||
|
<div>
|
||||||
|
<h3 className="card-title" id="setup-guide-title">
|
||||||
|
Getting started
|
||||||
|
</h3>
|
||||||
|
<div className="text-secondary small">
|
||||||
|
{done} of {steps.length} done
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="card-actions">
|
||||||
|
<button type="button" className="btn btn-sm btn-ghost-secondary" onClick={dismiss} aria-label="Hide the getting started guide" title="Hide this guide (bring it back from the search box: Ctrl K)">
|
||||||
|
<IconX size={16} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="progress progress-sm rounded-0" role="progressbar" aria-label="Setup progress" aria-valuemin={0} aria-valuemax={steps.length} aria-valuenow={done}>
|
||||||
|
<div className="progress-bar bg-green" style={{ width: `${(done / steps.length) * 100}%` }} />
|
||||||
|
</div>
|
||||||
|
<ul className="list-group list-group-flush">
|
||||||
|
{steps.map((s) => (
|
||||||
|
<li key={s.id} className="list-group-item d-flex align-items-center gap-3">
|
||||||
|
{s.done ? <IconCircleCheck size={22} className="text-green flex-shrink-0" aria-label="Done" /> : <IconCircle size={22} className="text-secondary flex-shrink-0" aria-label="Not done yet" />}
|
||||||
|
<div className="flex-fill" style={{ minWidth: 0 }}>
|
||||||
|
<div className={s.done ? "text-secondary" : "fw-medium"}>{s.title}</div>
|
||||||
|
{!s.done && <div className="text-secondary small">{s.description}</div>}
|
||||||
|
</div>
|
||||||
|
{!s.done && (
|
||||||
|
<Link to={s.to} className="btn btn-sm btn-primary flex-shrink-0">
|
||||||
|
{s.action}
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import { useEffect, useId, useRef, useState } from "react";
|
||||||
|
import { createPortal } from "react-dom";
|
||||||
|
import { GO_SHORTCUTS, OTHER_SHORTCUTS, SHOW_SHORTCUTS_EVENT } from "../layout/shortcuts";
|
||||||
|
|
||||||
|
/** The keyboard shortcuts, listed. Opens on "?", from the command palette, or when asked for by event. Mount once, near the root. */
|
||||||
|
export default function ShortcutHelp() {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const titleId = useId();
|
||||||
|
const closeRef = useRef<HTMLButtonElement>(null);
|
||||||
|
const opener = useRef<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const show = () => {
|
||||||
|
opener.current = document.activeElement as HTMLElement | null;
|
||||||
|
setOpen(true);
|
||||||
|
};
|
||||||
|
window.addEventListener(SHOW_SHORTCUTS_EVENT, show);
|
||||||
|
return () => window.removeEventListener(SHOW_SHORTCUTS_EVENT, show);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!open) return;
|
||||||
|
closeRef.current?.focus();
|
||||||
|
const onKey = (e: KeyboardEvent) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
e.stopPropagation();
|
||||||
|
setOpen(false);
|
||||||
|
} else if (e.key === "Tab") {
|
||||||
|
// The only thing to reach is the close button, so keep the keyboard on it.
|
||||||
|
e.preventDefault();
|
||||||
|
closeRef.current?.focus();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
document.addEventListener("keydown", onKey, true);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", onKey, true);
|
||||||
|
opener.current?.focus?.();
|
||||||
|
};
|
||||||
|
}, [open]);
|
||||||
|
|
||||||
|
if (!open) return null;
|
||||||
|
return createPortal(
|
||||||
|
<>
|
||||||
|
<div className="modal-backdrop show" />
|
||||||
|
<div className="modal modal-blur show" style={{ display: "block" }} onClick={() => setOpen(false)}>
|
||||||
|
<div className="modal-dialog modal-dialog-centered" role="dialog" aria-modal="true" aria-labelledby={titleId} onClick={(e) => e.stopPropagation()}>
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-header">
|
||||||
|
<h3 className="modal-title" id={titleId}>
|
||||||
|
Keyboard shortcuts
|
||||||
|
</h3>
|
||||||
|
<button ref={closeRef} type="button" className="btn-close" aria-label="Close" onClick={() => setOpen(false)} />
|
||||||
|
</div>
|
||||||
|
<div className="modal-body">
|
||||||
|
<div className="fw-bold mb-2">Go to a page — press g, then…</div>
|
||||||
|
<dl className="shortcut-list mb-3">
|
||||||
|
{GO_SHORTCUTS.map((s) => (
|
||||||
|
<div key={s.key}>
|
||||||
|
<dt>
|
||||||
|
<kbd>g</kbd> <kbd>{s.key}</kbd>
|
||||||
|
</dt>
|
||||||
|
<dd>{s.label}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
<div className="fw-bold mb-2">Anywhere</div>
|
||||||
|
<dl className="shortcut-list mb-0">
|
||||||
|
{OTHER_SHORTCUTS.map((s) => (
|
||||||
|
<div key={s.keys}>
|
||||||
|
<dt>
|
||||||
|
<kbd>{s.keys}</kbd>
|
||||||
|
</dt>
|
||||||
|
<dd>{s.label}</dd>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</dl>
|
||||||
|
<div className="text-secondary small mt-3">Shortcuts for pages you can't open are ignored. They don't fire while you are typing in a box.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>,
|
||||||
|
document.body,
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import type { SortDirection } from "../hooks/useSortable";
|
import type { SortDirection } from "../hooks/useSortable";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A column heading that sorts the table. The button inside is what the keyboard reaches and a screen reader announces ("Name,
|
||||||
|
* sorted ascending"); the heading itself stays a real column header, so the table keeps its meaning for assistive technology.
|
||||||
|
*/
|
||||||
export default function SortableTh<T>({
|
export default function SortableTh<T>({
|
||||||
label,
|
label,
|
||||||
sortKeyName,
|
sortKeyName,
|
||||||
@@ -18,16 +22,13 @@ export default function SortableTh<T>({
|
|||||||
}) {
|
}) {
|
||||||
const active = activeKey === sortKeyName;
|
const active = activeKey === sortKeyName;
|
||||||
return (
|
return (
|
||||||
<th
|
<th className={className} scope="col" aria-sort={active ? (direction === "asc" ? "ascending" : "descending") : "none"}>
|
||||||
className={className}
|
<button type="button" className="th-sort" onClick={() => onSort(sortKeyName)}>
|
||||||
role="button"
|
|
||||||
style={{ cursor: "pointer", userSelect: "none", whiteSpace: "nowrap" }}
|
|
||||||
onClick={() => onSort(sortKeyName)}
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
<span className={active ? "" : "text-secondary"} style={{ marginLeft: 4, opacity: active ? 1 : 0.4 }}>
|
<span aria-hidden="true" className={active ? "" : "text-secondary"} style={{ marginLeft: 4, opacity: active ? 1 : 0.4 }}>
|
||||||
{active ? (direction === "asc" ? "▲" : "▼") : "↕"}
|
{active ? (direction === "asc" ? "▲" : "▼") : "↕"}
|
||||||
</span>
|
</span>
|
||||||
|
</button>
|
||||||
</th>
|
</th>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
|
||||||
|
const CONTROL = "input:not([type=hidden]), select, textarea";
|
||||||
|
let counter = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tabler's forms put a <label class="form-label"> beside its field without tying the two together, so a screen reader reaches
|
||||||
|
* the field and hears nothing. This ties each such label to the first field after it (inside the same block), by giving the
|
||||||
|
* field an id and the label a "for". Fields that are already labelled are left alone.
|
||||||
|
*/
|
||||||
|
function associate(label: HTMLLabelElement): void {
|
||||||
|
if (label.htmlFor || label.querySelector(CONTROL)) return;
|
||||||
|
let sibling = label.nextElementSibling as HTMLElement | null;
|
||||||
|
while (sibling && !sibling.matches("label")) {
|
||||||
|
const control = sibling.matches(CONTROL) ? sibling : sibling.querySelector<HTMLElement>(CONTROL);
|
||||||
|
if (control) {
|
||||||
|
if (!control.id) control.id = `fld-${++counter}`;
|
||||||
|
label.htmlFor = control.id;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sibling = sibling.nextElementSibling as HTMLElement | null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The tick-boxes that select rows have no text of their own; say what they are. */
|
||||||
|
function nameRowCheckboxes(root: ParentNode): void {
|
||||||
|
root.querySelectorAll<HTMLInputElement>("input[type=checkbox].form-check-input").forEach((box) => {
|
||||||
|
if (box.getAttribute("aria-label") || box.closest("label") || box.labels?.length) return;
|
||||||
|
box.setAttribute("aria-label", box.closest("thead") ? "Select all rows on this page" : "Select this row");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keeps every form in the app readable to assistive technology as pages load and change, without each form doing it. */
|
||||||
|
export function useFormLabels(): void {
|
||||||
|
useEffect(() => {
|
||||||
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
const run = () => {
|
||||||
|
timer = null;
|
||||||
|
document.querySelectorAll<HTMLLabelElement>("label.form-label").forEach(associate);
|
||||||
|
nameRowCheckboxes(document);
|
||||||
|
};
|
||||||
|
const observer = new MutationObserver(() => {
|
||||||
|
if (!timer) timer = setTimeout(run, 30);
|
||||||
|
});
|
||||||
|
observer.observe(document.body, { childList: true, subtree: true });
|
||||||
|
run();
|
||||||
|
return () => {
|
||||||
|
observer.disconnect();
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { useState, type KeyboardEvent, type MouseEvent } from "react";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes the rows of a table open a detail panel. Spread `rowProps(item)` onto the row: a click or Enter on the row opens it, but
|
||||||
|
* a click on a button, link or tick-box inside the row does its own thing and leaves the panel alone.
|
||||||
|
*/
|
||||||
|
export function useRowDetail<T>() {
|
||||||
|
const [selected, setSelected] = useState<T | null>(null);
|
||||||
|
|
||||||
|
function rowProps(item: T) {
|
||||||
|
return {
|
||||||
|
className: "row-clickable",
|
||||||
|
tabIndex: 0,
|
||||||
|
"aria-haspopup": "dialog" as const,
|
||||||
|
onClick: (e: MouseEvent<HTMLElement>) => {
|
||||||
|
if ((e.target as HTMLElement).closest("a, button, input, select, textarea, label, summary")) return;
|
||||||
|
// The row takes the focus, so it is what the keyboard comes back to when the panel closes.
|
||||||
|
e.currentTarget.focus({ preventScroll: true });
|
||||||
|
setSelected(item);
|
||||||
|
},
|
||||||
|
onKeyDown: (e: KeyboardEvent<HTMLElement>) => {
|
||||||
|
if (e.key === "Enter" && e.target === e.currentTarget) {
|
||||||
|
e.preventDefault();
|
||||||
|
setSelected(item);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return { selected, close: () => setSelected(null), rowProps };
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import type { CurrentUser } from "../api/client";
|
||||||
|
import { visibleNav, isGroup } from "../layout/nav";
|
||||||
|
import { GO_SHORTCUTS, SHOW_SHORTCUTS_EVENT } from "../layout/shortcuts";
|
||||||
|
|
||||||
|
/** Whether the keyboard is typing into something, in which case a letter is a letter and not a shortcut. */
|
||||||
|
function isTyping(target: EventTarget | null): boolean {
|
||||||
|
const el = target as HTMLElement | null;
|
||||||
|
if (!el || !el.tagName) return false;
|
||||||
|
return el.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(el.tagName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Page shortcuts for anyone signed in: "g" then a letter goes to a page they are allowed to see, "/" jumps to the table's
|
||||||
|
* search box, "?" shows the list. Ignored while typing, while a dialog is open, and with Ctrl/Alt/Cmd held (those are the
|
||||||
|
* browser's and the command palette's).
|
||||||
|
*/
|
||||||
|
export function useShortcuts(user: CurrentUser): void {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const allowed = new Set<string>(["/", "/wall"]);
|
||||||
|
for (const entry of visibleNav(user.role)) {
|
||||||
|
if (isGroup(entry)) entry.items.forEach((i) => allowed.add(i.to));
|
||||||
|
else allowed.add(entry.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
let waitingForSecondKey = false;
|
||||||
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
const reset = () => {
|
||||||
|
waitingForSecondKey = false;
|
||||||
|
if (timer) clearTimeout(timer);
|
||||||
|
timer = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
function onKeyDown(e: KeyboardEvent) {
|
||||||
|
if (e.ctrlKey || e.metaKey || e.altKey || isTyping(e.target)) return;
|
||||||
|
if (document.querySelector('[role="dialog"][aria-modal="true"]')) return;
|
||||||
|
|
||||||
|
if (waitingForSecondKey) {
|
||||||
|
reset();
|
||||||
|
const hit = GO_SHORTCUTS.find((s) => s.key === e.key.toLowerCase());
|
||||||
|
if (hit && allowed.has(hit.to)) {
|
||||||
|
e.preventDefault();
|
||||||
|
navigate(hit.to);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.key === "g") {
|
||||||
|
waitingForSecondKey = true;
|
||||||
|
timer = setTimeout(reset, 1200);
|
||||||
|
} else if (e.key === "?") {
|
||||||
|
e.preventDefault();
|
||||||
|
window.dispatchEvent(new Event(SHOW_SHORTCUTS_EVENT));
|
||||||
|
} else if (e.key === "/") {
|
||||||
|
const box = document.querySelector<HTMLInputElement>(".table-search input");
|
||||||
|
if (box) {
|
||||||
|
e.preventDefault();
|
||||||
|
box.focus();
|
||||||
|
box.select();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener("keydown", onKeyDown);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("keydown", onKeyDown);
|
||||||
|
reset();
|
||||||
|
};
|
||||||
|
}, [user.role, navigate]);
|
||||||
|
}
|
||||||
+65
-151
@@ -1,42 +1,8 @@
|
|||||||
import { useEffect, useRef, useState, type ReactNode } from "react";
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
||||||
import { Link, NavLink, useLocation } from "react-router-dom";
|
import { Link, NavLink, useLocation } from "react-router-dom";
|
||||||
import {
|
import { IconMenu2, IconSun, IconMoon, IconShieldLock, IconTool, IconChevronUp, IconLogout, IconDeviceDesktop } from "@tabler/icons-react";
|
||||||
IconLayoutDashboard,
|
|
||||||
IconServer2,
|
|
||||||
IconWorld,
|
|
||||||
IconNetwork,
|
|
||||||
IconKey,
|
|
||||||
IconPlugConnected,
|
|
||||||
IconBrandDocker,
|
|
||||||
IconAffiliate,
|
|
||||||
IconPlayerPlay,
|
|
||||||
IconBrandGit,
|
|
||||||
IconServerCog,
|
|
||||||
IconDatabase,
|
|
||||||
IconUsers,
|
|
||||||
IconDevices,
|
|
||||||
IconHistory,
|
|
||||||
IconStethoscope,
|
|
||||||
IconSettings,
|
|
||||||
IconMenu2,
|
|
||||||
IconSun,
|
|
||||||
IconMoon,
|
|
||||||
IconWand,
|
|
||||||
IconTool,
|
|
||||||
IconWorldWww,
|
|
||||||
IconListCheck,
|
|
||||||
IconShieldLock,
|
|
||||||
IconRefresh,
|
|
||||||
IconActivityHeartbeat,
|
|
||||||
IconShieldCheck,
|
|
||||||
IconTicket,
|
|
||||||
IconPlug,
|
|
||||||
IconExternalLink,
|
|
||||||
IconAlertTriangle,
|
|
||||||
IconChevronUp,
|
|
||||||
IconLogout,
|
|
||||||
} from "@tabler/icons-react";
|
|
||||||
import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
import { api, type CurrentUser, type MaintenanceWindow } from "../api/client";
|
||||||
|
import { isCurrent, isGroup, visibleNav, type NavGroup } from "./nav";
|
||||||
import { formatRemaining } from "../utils/duration";
|
import { formatRemaining } from "../utils/duration";
|
||||||
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
import { getTheme, setTheme, type Theme } from "../utils/theme";
|
||||||
import { DENSITIES, getDensity, setDensity, type Density } from "../utils/density";
|
import { DENSITIES, getDensity, setDensity, type Density } from "../utils/density";
|
||||||
@@ -44,6 +10,9 @@ import CommandPalette from "../components/CommandPalette";
|
|||||||
import { isLightColor, useEnvironment } from "../utils/environment";
|
import { isLightColor, useEnvironment } from "../utils/environment";
|
||||||
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||||
import { useStackedTables } from "../hooks/useStackedTables";
|
import { useStackedTables } from "../hooks/useStackedTables";
|
||||||
|
import { useShortcuts } from "../hooks/useShortcuts";
|
||||||
|
import { useFormLabels } from "../hooks/useFormLabels";
|
||||||
|
import ShortcutHelp from "../components/ShortcutHelp";
|
||||||
import { useBreadcrumbTailValue } from "../utils/breadcrumb";
|
import { useBreadcrumbTailValue } from "../utils/breadcrumb";
|
||||||
|
|
||||||
interface NavBadge {
|
interface NavBadge {
|
||||||
@@ -58,110 +27,6 @@ function initialsOf(name: string): string {
|
|||||||
return (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? "?").slice(0, 2)).toUpperCase();
|
return (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? "?").slice(0, 2)).toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
type Role = "operator" | "admin";
|
|
||||||
|
|
||||||
interface NavLeaf {
|
|
||||||
to: string;
|
|
||||||
label: string;
|
|
||||||
/** Shown for top-level links, and when a group is left with a single visible page and so is drawn as that page's own link. */
|
|
||||||
icon: ReactNode;
|
|
||||||
minRole?: Role;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NavGroup {
|
|
||||||
id: string;
|
|
||||||
label: string;
|
|
||||||
icon: ReactNode;
|
|
||||||
items: NavLeaf[];
|
|
||||||
}
|
|
||||||
|
|
||||||
type NavEntry = NavLeaf | NavGroup;
|
|
||||||
|
|
||||||
const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry;
|
|
||||||
|
|
||||||
const NAV: NavEntry[] = [
|
|
||||||
{ to: "/", label: "Dashboard", icon: <IconLayoutDashboard size={20} /> },
|
|
||||||
{
|
|
||||||
id: "infrastructure",
|
|
||||||
label: "Infrastructure",
|
|
||||||
icon: <IconServer2 size={20} />,
|
|
||||||
items: [
|
|
||||||
{ to: "/servers", label: "Servers", icon: <IconServer2 size={20} /> },
|
|
||||||
{ to: "/proxmox", label: "Proxmox", icon: <IconServerCog size={20} /> },
|
|
||||||
{ to: "/synology", label: "Synology", icon: <IconDatabase size={20} /> },
|
|
||||||
{ to: "/pbs", label: "Proxmox Backup", icon: <IconShieldCheck size={20} /> },
|
|
||||||
{ to: "/docker", label: "Docker", icon: <IconBrandDocker size={20} /> },
|
|
||||||
{ to: "/tailscale", label: "Tailscale", icon: <IconAffiliate size={20} /> },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "network",
|
|
||||||
label: "Network",
|
|
||||||
icon: <IconWorld size={20} />,
|
|
||||||
items: [
|
|
||||||
{ to: "/dns", label: "DNS", icon: <IconWorld size={20} /> },
|
|
||||||
{ to: "/domains", label: "Domains", icon: <IconWorldWww size={20} /> },
|
|
||||||
{ to: "/ipam", label: "IP Addresses", icon: <IconNetwork size={20} /> },
|
|
||||||
{ to: "/ports", label: "Ports", icon: <IconPlug size={20} /> },
|
|
||||||
{ to: "/consistency", label: "Consistency", icon: <IconListCheck size={20} /> },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "automation",
|
|
||||||
label: "Automation",
|
|
||||||
icon: <IconRefresh size={20} />,
|
|
||||||
items: [
|
|
||||||
{ to: "/semaphore", label: "Semaphore", icon: <IconPlayerPlay size={20} /> },
|
|
||||||
{ to: "/gitea", label: "Gitea", icon: <IconBrandGit size={20} /> },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{ to: "/secrets", label: "Secrets", icon: <IconKey size={20} /> },
|
|
||||||
{
|
|
||||||
id: "operations",
|
|
||||||
label: "Operations",
|
|
||||||
icon: <IconTool size={20} />,
|
|
||||||
items: [
|
|
||||||
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
|
|
||||||
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
|
|
||||||
{ to: "/uptime-kuma", label: "Uptime Kuma", icon: <IconActivityHeartbeat size={20} /> },
|
|
||||||
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
|
|
||||||
{ to: "/admin-links", label: "Admin Links", icon: <IconExternalLink size={20} /> },
|
|
||||||
{ to: "/generator", label: "Generator", icon: <IconWand size={20} /> },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "administration",
|
|
||||||
label: "Administration",
|
|
||||||
icon: <IconSettings size={20} />,
|
|
||||||
items: [
|
|
||||||
{ to: "/integrations", label: "Integrations", icon: <IconPlugConnected size={20} /> },
|
|
||||||
{ to: "/users", label: "Users", icon: <IconUsers size={20} />, minRole: "admin" },
|
|
||||||
{ to: "/sessions", label: "Sessions", icon: <IconDevices size={20} />, minRole: "admin" },
|
|
||||||
{ to: "/audit-log", label: "Audit Log", icon: <IconHistory size={20} />, minRole: "operator" },
|
|
||||||
{ to: "/diag-log", label: "Diagnostic Log", icon: <IconStethoscope size={20} />, minRole: "admin" },
|
|
||||||
{ to: "/settings", label: "Settings", icon: <IconSettings size={20} />, minRole: "admin" },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const roleRank: Record<CurrentUser["role"], number> = { viewer: 0, operator: 1, admin: 2 };
|
|
||||||
|
|
||||||
/** What this role can see: pages it isn't allowed are dropped, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
|
||||||
function visibleNav(role: CurrentUser["role"]): NavEntry[] {
|
|
||||||
const allowed = (leaf: NavLeaf) => !leaf.minRole || roleRank[role] >= roleRank[leaf.minRole];
|
|
||||||
const out: NavEntry[] = [];
|
|
||||||
for (const entry of NAV) {
|
|
||||||
if (!isGroup(entry)) {
|
|
||||||
if (allowed(entry)) out.push(entry);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const items = entry.items.filter(allowed);
|
|
||||||
if (items.length === 1) out.push(items[0]);
|
|
||||||
else if (items.length > 1) out.push({ ...entry, items });
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
const OPEN_GROUPS_KEY = "hlm-nav-open-groups";
|
const OPEN_GROUPS_KEY = "hlm-nav-open-groups";
|
||||||
|
|
||||||
function loadOpenGroups(): Set<string> {
|
function loadOpenGroups(): Set<string> {
|
||||||
@@ -173,11 +38,6 @@ function loadOpenGroups(): Set<string> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Is this the current page (or a page beneath it, like /servers/3 under /servers)? */
|
|
||||||
function isCurrent(pathname: string, to: string): boolean {
|
|
||||||
return to === "/" ? pathname === "/" : pathname === to || pathname.startsWith(`${to}/`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) {
|
export default function AppShell({ user, children }: { user: CurrentUser; children: ReactNode }) {
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
const [theme, setThemeState] = useState<Theme>(() => getTheme());
|
||||||
@@ -185,6 +45,11 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
const [maintenance, setMaintenance] = useState<MaintenanceWindow[]>([]);
|
||||||
const environment = useEnvironment();
|
const environment = useEnvironment();
|
||||||
useStackedTables();
|
useStackedTables();
|
||||||
|
useShortcuts(user);
|
||||||
|
useFormLabels();
|
||||||
|
const mainRef = useRef<HTMLElement>(null);
|
||||||
|
const [announcement, setAnnouncement] = useState("");
|
||||||
|
const firstRoute = useRef(true);
|
||||||
const breadcrumbTail = useBreadcrumbTailValue();
|
const breadcrumbTail = useBreadcrumbTailValue();
|
||||||
const { report } = useAlertsReport();
|
const { report } = useAlertsReport();
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
@@ -228,6 +93,18 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
const nav = visibleNav(user.role);
|
const nav = visibleNav(user.role);
|
||||||
const { pathname } = useLocation();
|
const { pathname } = useLocation();
|
||||||
|
|
||||||
|
// A page change in a single-page app is silent: tell screen readers where they are, and move the keyboard to the new page's start
|
||||||
|
// (not on the first load, where the browser has already done its own thing).
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
const title = document.querySelector(".page-title")?.textContent?.trim() || document.title;
|
||||||
|
setAnnouncement(title);
|
||||||
|
if (!firstRoute.current) mainRef.current?.focus({ preventScroll: true });
|
||||||
|
firstRoute.current = false;
|
||||||
|
}, 200);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
// Where this page sits in the menu: "Infrastructure › Servers", and on a page about one thing, that thing's name as well.
|
// Where this page sits in the menu: "Infrastructure › Servers", and on a page about one thing, that thing's name as well.
|
||||||
const crumbs: { label: string; to?: string }[] = [];
|
const crumbs: { label: string; to?: string }[] = [];
|
||||||
for (const entry of nav) {
|
for (const entry of nav) {
|
||||||
@@ -285,7 +162,8 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
const b = badges[to];
|
const b = badges[to];
|
||||||
return b ? (
|
return b ? (
|
||||||
<span className={`badge ms-auto ${b.className}`} title={b.title}>
|
<span className={`badge ms-auto ${b.className}`} title={b.title}>
|
||||||
{b.text}
|
<span aria-hidden="true">{b.text}</span>
|
||||||
|
<span className="visually-hidden">{b.title}</span>
|
||||||
</span>
|
</span>
|
||||||
) : null;
|
) : null;
|
||||||
};
|
};
|
||||||
@@ -298,7 +176,21 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
<aside className="navbar navbar-vertical navbar-expand-lg" data-bs-theme={environment && isLightColor(environment.color) ? "light" : "dark"}>
|
<a
|
||||||
|
className="skip-link"
|
||||||
|
href="#main"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
mainRef.current?.focus();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Skip to content
|
||||||
|
</a>
|
||||||
|
<div className="visually-hidden" role="status" aria-live="polite" aria-atomic="true">
|
||||||
|
{announcement}
|
||||||
|
</div>
|
||||||
|
<ShortcutHelp />
|
||||||
|
<aside aria-label="Homelab Manager" className="navbar navbar-vertical navbar-expand-lg" data-bs-theme={environment && isLightColor(environment.color) ? "light" : "dark"}>
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -318,8 +210,16 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
</h1>
|
</h1>
|
||||||
<div className={`navbar-collapse collapse ${sidebarOpen ? "show" : ""}`}>
|
<div className={`navbar-collapse collapse ${sidebarOpen ? "show" : ""}`}>
|
||||||
<div className="px-3 pt-3 pt-lg-0">
|
<div className="px-3 pt-3 pt-lg-0">
|
||||||
<CommandPalette />
|
<CommandPalette
|
||||||
|
user={user}
|
||||||
|
onToggleTheme={toggleTheme}
|
||||||
|
onSetDensity={(d) => {
|
||||||
|
setDensity(d);
|
||||||
|
setDensityState(d);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<nav aria-label="Main menu">
|
||||||
<ul className="navbar-nav pt-lg-3">
|
<ul className="navbar-nav pt-lg-3">
|
||||||
{nav.map((entry) => {
|
{nav.map((entry) => {
|
||||||
if (!isGroup(entry)) {
|
if (!isGroup(entry)) {
|
||||||
@@ -353,7 +253,8 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
const worst = inside.find((b) => b.className.includes("bg-red")) ?? inside.find((b) => b.className.includes("bg-yellow")) ?? inside[0];
|
const worst = inside.find((b) => b.className.includes("bg-red")) ?? inside.find((b) => b.className.includes("bg-yellow")) ?? inside[0];
|
||||||
return (
|
return (
|
||||||
<span className={`badge ms-auto me-4 ${worst.className}`} title={inside.map((b) => b.title).join(", ")}>
|
<span className={`badge ms-auto me-4 ${worst.className}`} title={inside.map((b) => b.title).join(", ")}>
|
||||||
{inside.reduce((n, b) => n + Number(b.text), 0)}
|
<span aria-hidden="true">{inside.reduce((n, b) => n + Number(b.text), 0)}</span>
|
||||||
|
<span className="visually-hidden">{inside.map((b) => b.title).join(", ")}</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
})()}
|
})()}
|
||||||
@@ -375,6 +276,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
|
</nav>
|
||||||
<div className="navbar-footer px-3 user-menu" ref={menuRef}>
|
<div className="navbar-footer px-3 user-menu" ref={menuRef}>
|
||||||
{menuOpen && (
|
{menuOpen && (
|
||||||
<div className="user-menu-list" role="menu">
|
<div className="user-menu-list" role="menu">
|
||||||
@@ -413,6 +315,18 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
<IconShieldLock size={16} />
|
<IconShieldLock size={16} />
|
||||||
Privacy
|
Privacy
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
<NavLink
|
||||||
|
to="/wall"
|
||||||
|
className="user-menu-item"
|
||||||
|
role="menuitem"
|
||||||
|
onClick={() => {
|
||||||
|
setMenuOpen(false);
|
||||||
|
setSidebarOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconDeviceDesktop size={16} />
|
||||||
|
Wall display
|
||||||
|
</NavLink>
|
||||||
<a className="user-menu-item" role="menuitem" href="/auth/logout">
|
<a className="user-menu-item" role="menuitem" href="/auth/logout">
|
||||||
<IconLogout size={16} />
|
<IconLogout size={16} />
|
||||||
Sign out
|
Sign out
|
||||||
@@ -440,7 +354,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<div className="page-wrapper">
|
<div className="page-wrapper">
|
||||||
<div className="page-body">
|
<main className="page-body" id="main" tabIndex={-1} ref={mainRef}>
|
||||||
<div className="container-xl">
|
<div className="container-xl">
|
||||||
{maintenance.length > 0 && (
|
{maintenance.length > 0 && (
|
||||||
<div className="alert alert-warning d-flex align-items-center gap-2">
|
<div className="alert alert-warning d-flex align-items-center gap-2">
|
||||||
@@ -465,7 +379,7 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
|||||||
)}
|
)}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,147 @@
|
|||||||
|
import type { ReactNode } from "react";
|
||||||
|
import {
|
||||||
|
IconLayoutDashboard,
|
||||||
|
IconServer2,
|
||||||
|
IconWorld,
|
||||||
|
IconNetwork,
|
||||||
|
IconKey,
|
||||||
|
IconPlugConnected,
|
||||||
|
IconBrandDocker,
|
||||||
|
IconAffiliate,
|
||||||
|
IconPlayerPlay,
|
||||||
|
IconBrandGit,
|
||||||
|
IconServerCog,
|
||||||
|
IconDatabase,
|
||||||
|
IconUsers,
|
||||||
|
IconDevices,
|
||||||
|
IconHistory,
|
||||||
|
IconStethoscope,
|
||||||
|
IconSettings,
|
||||||
|
IconWand,
|
||||||
|
IconTool,
|
||||||
|
IconWorldWww,
|
||||||
|
IconListCheck,
|
||||||
|
IconRefresh,
|
||||||
|
IconActivityHeartbeat,
|
||||||
|
IconShieldCheck,
|
||||||
|
IconTicket,
|
||||||
|
IconPlug,
|
||||||
|
IconExternalLink,
|
||||||
|
IconAlertTriangle,
|
||||||
|
IconSitemap,
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import type { CurrentUser } from "../api/client";
|
||||||
|
|
||||||
|
// The menu: what pages there are, how they are grouped, and which role is needed to see each. Used by the sidebar, the command
|
||||||
|
// palette, the keyboard shortcuts and the breadcrumbs, so they always agree.
|
||||||
|
|
||||||
|
type Role = "operator" | "admin";
|
||||||
|
|
||||||
|
export interface NavLeaf {
|
||||||
|
to: string;
|
||||||
|
label: string;
|
||||||
|
/** Shown for top-level links, and when a group is left with a single visible page and so is drawn as that page's own link. */
|
||||||
|
icon: ReactNode;
|
||||||
|
minRole?: Role;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NavGroup {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
icon: ReactNode;
|
||||||
|
items: NavLeaf[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type NavEntry = NavLeaf | NavGroup;
|
||||||
|
|
||||||
|
export const isGroup = (entry: NavEntry): entry is NavGroup => "items" in entry;
|
||||||
|
|
||||||
|
export const NAV: NavEntry[] = [
|
||||||
|
{ to: "/", label: "Dashboard", icon: <IconLayoutDashboard size={20} /> },
|
||||||
|
{
|
||||||
|
id: "infrastructure",
|
||||||
|
label: "Infrastructure",
|
||||||
|
icon: <IconServer2 size={20} />,
|
||||||
|
items: [
|
||||||
|
{ to: "/servers", label: "Servers", icon: <IconServer2 size={20} /> },
|
||||||
|
{ to: "/proxmox", label: "Proxmox", icon: <IconServerCog size={20} /> },
|
||||||
|
{ to: "/synology", label: "Synology", icon: <IconDatabase size={20} /> },
|
||||||
|
{ to: "/pbs", label: "Proxmox Backup", icon: <IconShieldCheck size={20} /> },
|
||||||
|
{ to: "/docker", label: "Docker", icon: <IconBrandDocker size={20} /> },
|
||||||
|
{ to: "/tailscale", label: "Tailscale", icon: <IconAffiliate size={20} /> },
|
||||||
|
{ to: "/map", label: "Map", icon: <IconSitemap size={20} /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "network",
|
||||||
|
label: "Network",
|
||||||
|
icon: <IconWorld size={20} />,
|
||||||
|
items: [
|
||||||
|
{ to: "/dns", label: "DNS", icon: <IconWorld size={20} /> },
|
||||||
|
{ to: "/domains", label: "Domains", icon: <IconWorldWww size={20} /> },
|
||||||
|
{ to: "/ipam", label: "IP Addresses", icon: <IconNetwork size={20} /> },
|
||||||
|
{ to: "/ports", label: "Ports", icon: <IconPlug size={20} /> },
|
||||||
|
{ to: "/consistency", label: "Consistency", icon: <IconListCheck size={20} /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "automation",
|
||||||
|
label: "Automation",
|
||||||
|
icon: <IconRefresh size={20} />,
|
||||||
|
items: [
|
||||||
|
{ to: "/semaphore", label: "Semaphore", icon: <IconPlayerPlay size={20} /> },
|
||||||
|
{ to: "/gitea", label: "Gitea", icon: <IconBrandGit size={20} /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ to: "/secrets", label: "Secrets", icon: <IconKey size={20} /> },
|
||||||
|
{
|
||||||
|
id: "operations",
|
||||||
|
label: "Operations",
|
||||||
|
icon: <IconTool size={20} />,
|
||||||
|
items: [
|
||||||
|
{ to: "/alerts", label: "Alerts", icon: <IconAlertTriangle size={20} /> },
|
||||||
|
{ to: "/maintenance", label: "Maintenance", icon: <IconTool size={20} /> },
|
||||||
|
{ to: "/uptime-kuma", label: "Uptime Kuma", icon: <IconActivityHeartbeat size={20} /> },
|
||||||
|
{ to: "/osticket", label: "osTicket", icon: <IconTicket size={20} /> },
|
||||||
|
{ to: "/admin-links", label: "Admin Links", icon: <IconExternalLink size={20} /> },
|
||||||
|
{ to: "/generator", label: "Generator", icon: <IconWand size={20} /> },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "administration",
|
||||||
|
label: "Administration",
|
||||||
|
icon: <IconSettings size={20} />,
|
||||||
|
items: [
|
||||||
|
{ to: "/integrations", label: "Integrations", icon: <IconPlugConnected size={20} /> },
|
||||||
|
{ to: "/users", label: "Users", icon: <IconUsers size={20} />, minRole: "admin" },
|
||||||
|
{ to: "/sessions", label: "Sessions", icon: <IconDevices size={20} />, minRole: "admin" },
|
||||||
|
{ to: "/audit-log", label: "Audit Log", icon: <IconHistory size={20} />, minRole: "operator" },
|
||||||
|
{ to: "/diag-log", label: "Diagnostic Log", icon: <IconStethoscope size={20} />, minRole: "admin" },
|
||||||
|
{ to: "/settings", label: "Settings", icon: <IconSettings size={20} />, minRole: "admin" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const roleRank: Record<CurrentUser["role"], number> = { viewer: 0, operator: 1, admin: 2 };
|
||||||
|
|
||||||
|
/** What this role can see: pages it isn't allowed are dropped, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
||||||
|
export function visibleNav(role: CurrentUser["role"]): NavEntry[] {
|
||||||
|
const allowed = (leaf: NavLeaf) => !leaf.minRole || roleRank[role] >= roleRank[leaf.minRole];
|
||||||
|
const out: NavEntry[] = [];
|
||||||
|
for (const entry of NAV) {
|
||||||
|
if (!isGroup(entry)) {
|
||||||
|
if (allowed(entry)) out.push(entry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const items = entry.items.filter(allowed);
|
||||||
|
if (items.length === 1) out.push(items[0]);
|
||||||
|
else if (items.length > 1) out.push({ ...entry, items });
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Is this the current page (or a page beneath it, like /servers/3 under /servers)? */
|
||||||
|
export function isCurrent(pathname: string, to: string): boolean {
|
||||||
|
return to === "/" ? pathname === "/" : pathname === to || pathname.startsWith(`${to}/`);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
// The keyboard shortcuts: "g" then a letter goes to a page (like GitHub's), "/" jumps to the search box, "?" lists them all.
|
||||||
|
// One list, so the handler, the help dialog and the command palette's hints can't drift apart.
|
||||||
|
|
||||||
|
export interface GoShortcut {
|
||||||
|
/** The letter after "g". */
|
||||||
|
key: string;
|
||||||
|
to: string;
|
||||||
|
label: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GO_SHORTCUTS: GoShortcut[] = [
|
||||||
|
{ key: "d", to: "/", label: "Dashboard" },
|
||||||
|
{ key: "a", to: "/alerts", label: "Alerts" },
|
||||||
|
{ key: "s", to: "/servers", label: "Servers" },
|
||||||
|
{ key: "m", to: "/maintenance", label: "Maintenance" },
|
||||||
|
{ key: "i", to: "/integrations", label: "Integrations" },
|
||||||
|
{ key: "k", to: "/secrets", label: "Secrets" },
|
||||||
|
{ key: "p", to: "/map", label: "Map" },
|
||||||
|
{ key: "w", to: "/wall", label: "Wall display" },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const OTHER_SHORTCUTS: { keys: string; label: string }[] = [
|
||||||
|
{ keys: "Ctrl K", label: "Search, and run actions (silence a server, switch theme…)" },
|
||||||
|
{ keys: "/", label: "Jump to the search box of the table on this page" },
|
||||||
|
{ keys: "?", label: "Show this list" },
|
||||||
|
{ keys: "Esc", label: "Close a dialog, the search or this list" },
|
||||||
|
];
|
||||||
|
|
||||||
|
/** The "g x" hint for a page, if it has one — shown beside it in the command palette. */
|
||||||
|
export function shortcutHintFor(to: string): string | null {
|
||||||
|
const found = GO_SHORTCUTS.find((s) => s.to === to);
|
||||||
|
return found ? `g ${found.key}` : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SHOW_SHORTCUTS_EVENT = "show-shortcuts";
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "../api/client";
|
} from "../api/client";
|
||||||
import { formatAgo } from "../utils/duration";
|
import { formatAgo } from "../utils/duration";
|
||||||
import StatusStrip from "../components/StatusStrip";
|
import StatusStrip from "../components/StatusStrip";
|
||||||
|
import SetupGuide, { type SetupStep } from "../components/SetupGuide";
|
||||||
import { ErrorNotice } from "../components/Notice";
|
import { ErrorNotice } from "../components/Notice";
|
||||||
import { WidgetSkeleton } from "../components/Skeleton";
|
import { WidgetSkeleton } from "../components/Skeleton";
|
||||||
|
|
||||||
@@ -299,6 +300,25 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
|||||||
const [uptimeKumaSummary, setUptimeKumaSummary] = useState<UptimeKumaSummary | null>(null);
|
const [uptimeKumaSummary, setUptimeKumaSummary] = useState<UptimeKumaSummary | null>(null);
|
||||||
const [pbsSummary, setPbsSummary] = useState<PbsSummary | null>(null);
|
const [pbsSummary, setPbsSummary] = useState<PbsSummary | null>(null);
|
||||||
const [osTicketSummary, setOsTicketSummary] = useState<OsTicketSummary | 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 [dnsStats, setDnsStats] = useState<Awaited<ReturnType<typeof api.dns.stats>> | null>(null);
|
||||||
const [dnsError, setDnsError] = useState<string | null>(null);
|
const [dnsError, setDnsError] = useState<string | null>(null);
|
||||||
@@ -539,6 +559,15 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
|||||||
}, {}),
|
}, {}),
|
||||||
).map(([type, count]) => ({ label: SECRET_TYPE_LABELS[type as SecretRecord["type"]] ?? type, count }));
|
).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.
|
// 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 }[] = [];
|
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 (dnsStats?.totalProviders === 0) notSetUp.push({ label: "DNS", to: "/dns", what: "connect a DNS provider to see zones and records" });
|
||||||
@@ -555,11 +584,19 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
|||||||
<>
|
<>
|
||||||
<div className="row row-cards mb-3">
|
<div className="row row-cards mb-3">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<h2 className="page-title mb-3">Dashboard</h2>
|
<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">
|
<p className="text-secondary">
|
||||||
Welcome back, {user.name ?? user.email ?? user.sub}.
|
Welcome back, {user.name ?? user.email ?? user.sub}.
|
||||||
</p>
|
</p>
|
||||||
<StatusStrip />
|
<StatusStrip />
|
||||||
|
{isAdmin && integrations !== null && dnsStats !== null && serverSummary !== null && secrets !== null && notifyConfigured !== null && (
|
||||||
|
<SetupGuide steps={setupSteps} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import { ErrorNotice } from "../components/Notice";
|
|||||||
import { toast } from "../utils/toast";
|
import { toast } from "../utils/toast";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
function updateBadge(c: DockhandContainer) {
|
function updateBadge(c: DockhandContainer) {
|
||||||
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
|
if (c.updateAvailable === null) return <span className="text-secondary">—</span>;
|
||||||
@@ -98,6 +100,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
const tableSearch = useTableSearch(filteredContainers);
|
const tableSearch = useTableSearch(filteredContainers);
|
||||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof pageItems>[number]>();
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -259,7 +262,7 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pageItems?.map((c) => (
|
{pageItems?.map((c) => (
|
||||||
<tr key={`${c.environmentId}:${c.id}`}>
|
<tr key={`${c.environmentId}:${c.id}`} {...detail.rowProps(c)}>
|
||||||
{/* text-break: a long name or a digest-pinned image (name@sha256:…) has no spaces to wrap at, and would otherwise make the
|
{/* text-break: a long name or a digest-pinned image (name@sha256:…) has no spaces to wrap at, and would otherwise make the
|
||||||
table wider than the page and push the action buttons out of sight. */}
|
table wider than the page and push the action buttons out of sight. */}
|
||||||
<td className="text-break">{c.name}</td>
|
<td className="text-break">{c.name}</td>
|
||||||
@@ -319,6 +322,11 @@ export default function Docker({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((c) => c.name)(detail.selected)} subtitle={((c) => c.environmentName)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -116,7 +116,7 @@ export default function Generator({ user }: { user: CurrentUser }) {
|
|||||||
</select>
|
</select>
|
||||||
<div className="form-hint mb-3">{themes ? `${pool.length} name${pool.length === 1 ? "" : "s"} to pick from.` : "Loading the lists…"}</div>
|
<div className="form-hint mb-3">{themes ? `${pool.length} name${pool.length === 1 ? "" : "s"} to pick from.` : "Loading the lists…"}</div>
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<input type="text" className="form-control" readOnly value={serverName} placeholder="Click Generate…" />
|
<input type="text" className="form-control" readOnly value={serverName} placeholder="Click Generate…" aria-label="Generated server name" />
|
||||||
{serverName && <CopyButton text={serverName} />}
|
{serverName && <CopyButton text={serverName} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -162,7 +162,7 @@ export default function Generator({ user }: { user: CurrentUser }) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<input type="text" className="form-control" readOnly value={username} placeholder="Click Generate…" />
|
<input type="text" className="form-control" readOnly value={username} placeholder="Click Generate…" aria-label="Generated username" />
|
||||||
{username && <CopyButton text={username} />}
|
{username && <CopyButton text={username} />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -227,6 +227,7 @@ export default function Generator({ user }: { user: CurrentUser }) {
|
|||||||
className="form-control font-monospace"
|
className="form-control font-monospace"
|
||||||
readOnly
|
readOnly
|
||||||
value={password}
|
value={password}
|
||||||
|
aria-label="Generated password"
|
||||||
placeholder="Click Generate…"
|
placeholder="Click Generate…"
|
||||||
/>
|
/>
|
||||||
{password && (
|
{password && (
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import { formatAgo } from "../utils/duration";
|
|||||||
import { ErrorNotice } from "../components/Notice";
|
import { ErrorNotice } from "../components/Notice";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
function runStatusBadge(repo: GiteaRepo) {
|
function runStatusBadge(repo: GiteaRepo) {
|
||||||
const run = repo.latestRun;
|
const run = repo.latestRun;
|
||||||
@@ -99,6 +101,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
|||||||
const tableSearch = useTableSearch(repos);
|
const tableSearch = useTableSearch(repos);
|
||||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof pageItems>[number]>();
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -185,7 +188,7 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pageItems?.map((r) => (
|
{pageItems?.map((r) => (
|
||||||
<tr key={r.fullName}>
|
<tr key={r.fullName} {...detail.rowProps(r)}>
|
||||||
<td>
|
<td>
|
||||||
<a href={r.htmlUrl} target="_blank" rel="noopener noreferrer">
|
<a href={r.htmlUrl} target="_blank" rel="noopener noreferrer">
|
||||||
{r.fullName}
|
{r.fullName}
|
||||||
@@ -245,6 +248,11 @@ export default function Gitea({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((r) => r.fullName)(detail.selected)} subtitle={((r) => undefined)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,187 @@
|
|||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { Link } from "react-router-dom";
|
||||||
|
import { api, type MapData, type MapNode } from "../api/client";
|
||||||
|
import { ErrorNotice } from "../components/Notice";
|
||||||
|
import { PageSkeleton } from "../components/Skeleton";
|
||||||
|
import { readableError } from "../utils/errors";
|
||||||
|
|
||||||
|
const NODE_W = 210;
|
||||||
|
const NODE_H = 46;
|
||||||
|
const GAP_Y = 12;
|
||||||
|
const COL_GAP = 130;
|
||||||
|
|
||||||
|
const STATUS_SYMBOL: Record<MapNode["status"], string> = { ok: "✓", bad: "✕", warn: "▲", unknown: "·" };
|
||||||
|
const STATUS_WORD: Record<MapNode["status"], string> = { ok: "working", bad: "problem", warn: "check", unknown: "no status" };
|
||||||
|
const KIND_WORD: Record<MapNode["kind"], string> = { host: "Proxmox host", server: "Server", dns: "DNS name", monitor: "Uptime Kuma monitor" };
|
||||||
|
|
||||||
|
interface Placed extends MapNode {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Places each node: hosts, then servers, then names and monitors, each column ordered so the lines cross as little as is easy. */
|
||||||
|
function layout(data: MapData): { placed: Map<string, Placed>; width: number; height: number; columns: { x: number; title: string }[] } {
|
||||||
|
const neighbours = new Map<string, string[]>();
|
||||||
|
for (const e of data.edges) {
|
||||||
|
neighbours.set(e.from, [...(neighbours.get(e.from) ?? []), e.to]);
|
||||||
|
neighbours.set(e.to, [...(neighbours.get(e.to) ?? []), e.from]);
|
||||||
|
}
|
||||||
|
const byKind = (kinds: MapNode["kind"][]) => data.nodes.filter((n) => kinds.includes(n.kind));
|
||||||
|
const hosts = byKind(["host"]).sort((a, b) => a.label.localeCompare(b.label));
|
||||||
|
const serverNodes = byKind(["server"]);
|
||||||
|
const rightNodes = byKind(["dns", "monitor"]);
|
||||||
|
|
||||||
|
// Servers grouped under their host, then those with none.
|
||||||
|
const hostOf = (s: MapNode) => (neighbours.get(s.id) ?? []).find((id) => id.startsWith("host:"));
|
||||||
|
const servers: MapNode[] = [];
|
||||||
|
for (const h of hosts) servers.push(...serverNodes.filter((s) => hostOf(s) === h.id).sort((a, b) => a.label.localeCompare(b.label)));
|
||||||
|
servers.push(...serverNodes.filter((s) => !hostOf(s)).sort((a, b) => a.label.localeCompare(b.label)));
|
||||||
|
|
||||||
|
const step = NODE_H + GAP_Y;
|
||||||
|
const placed = new Map<string, Placed>();
|
||||||
|
const hasHosts = hosts.length > 0;
|
||||||
|
const hasRight = rightNodes.length > 0;
|
||||||
|
const colX = [0, hasHosts ? NODE_W + COL_GAP : 0, 0];
|
||||||
|
colX[2] = colX[1] + (servers.length > 0 ? NODE_W + COL_GAP : 0);
|
||||||
|
servers.forEach((s, i) => placed.set(s.id, { ...s, x: colX[1], y: i * step }));
|
||||||
|
|
||||||
|
// A column of nodes sits at the average height of the servers it connects to, pushed down as needed so none overlap.
|
||||||
|
const stack = (nodes: MapNode[], x: number) => {
|
||||||
|
const wanted = nodes.map((n) => {
|
||||||
|
const ys = (neighbours.get(n.id) ?? []).map((id) => placed.get(id)?.y).filter((y): y is number => y !== undefined);
|
||||||
|
return { n, y: ys.length ? ys.reduce((a, b) => a + b, 0) / ys.length : Number.MAX_SAFE_INTEGER / 2 };
|
||||||
|
});
|
||||||
|
wanted.sort((a, b) => a.y - b.y || a.n.label.localeCompare(b.n.label));
|
||||||
|
let next = 0;
|
||||||
|
for (const { n, y } of wanted) {
|
||||||
|
const at = Math.max(next, y >= Number.MAX_SAFE_INTEGER / 4 ? next : y);
|
||||||
|
placed.set(n.id, { ...n, x, y: at });
|
||||||
|
next = at + step;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
stack(hosts, colX[0]);
|
||||||
|
stack(rightNodes, colX[2]);
|
||||||
|
|
||||||
|
const all = [...placed.values()];
|
||||||
|
const height = all.length ? Math.max(...all.map((p) => p.y)) + NODE_H : 0;
|
||||||
|
const width = Math.max(...all.map((p) => p.x), 0) + NODE_W;
|
||||||
|
const columns = [
|
||||||
|
...(hasHosts ? [{ x: colX[0], title: "Proxmox hosts" }] : []),
|
||||||
|
...(servers.length > 0 ? [{ x: colX[1], title: "Servers" }] : []),
|
||||||
|
...(hasRight ? [{ x: colX[2], title: "DNS names & monitors" }] : []),
|
||||||
|
];
|
||||||
|
return { placed, width, height, columns };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The picture: how the servers, their Proxmox hosts, DNS names and monitors connect. Hover or tab to a box to light up its connections. */
|
||||||
|
export default function MapPage() {
|
||||||
|
const [data, setData] = useState<MapData | null>(null);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [focus, setFocus] = useState<string | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
api.map
|
||||||
|
.get()
|
||||||
|
.then(setData)
|
||||||
|
.catch((err) => setError(readableError(err)));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const view = useMemo(() => (data ? layout(data) : null), [data]);
|
||||||
|
const lit = useMemo(() => {
|
||||||
|
if (!data || !focus) return null;
|
||||||
|
const set = new Set<string>([focus]);
|
||||||
|
for (const e of data.edges) {
|
||||||
|
if (e.from === focus) set.add(e.to);
|
||||||
|
if (e.to === focus) set.add(e.from);
|
||||||
|
}
|
||||||
|
return set;
|
||||||
|
}, [data, focus]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<h2 className="page-title mb-1">Map</h2>
|
||||||
|
<p className="text-secondary">
|
||||||
|
How things connect: which Proxmox host a server runs on, which DNS names point at it, and which Uptime Kuma monitors watch it. Hover or tab to a box to light up what it is
|
||||||
|
connected to.
|
||||||
|
</p>
|
||||||
|
<ErrorNotice error={error} />
|
||||||
|
{data?.notes.map((n) => (
|
||||||
|
<div key={n} className="alert alert-warning">
|
||||||
|
{n}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{!data && !error && <PageSkeleton />}
|
||||||
|
{data && view && data.nodes.length === 0 && <div className="card"><div className="card-body text-secondary">Nothing to draw yet — add a server first.</div></div>}
|
||||||
|
{data && view && data.nodes.length > 0 && (
|
||||||
|
<div className="card">
|
||||||
|
<div className="card-body map-scroll">
|
||||||
|
<div className="map-columns" style={{ width: view.width }}>
|
||||||
|
{view.columns.map((c) => (
|
||||||
|
<div key={c.title} className="map-column-title" style={{ left: c.x, width: NODE_W }}>
|
||||||
|
{c.title}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
<div className="map-canvas" style={{ width: view.width, height: view.height }}>
|
||||||
|
<svg className="map-lines" width={view.width} height={view.height} aria-hidden="true">
|
||||||
|
{data.edges.map((e) => {
|
||||||
|
const a = view.placed.get(e.from);
|
||||||
|
const b = view.placed.get(e.to);
|
||||||
|
if (!a || !b) return null;
|
||||||
|
// Always drawn from the node on the left to the one on the right.
|
||||||
|
const [l, r] = a.x <= b.x ? [a, b] : [b, a];
|
||||||
|
const x1 = l.x + NODE_W;
|
||||||
|
const y1 = l.y + NODE_H / 2;
|
||||||
|
const x2 = r.x;
|
||||||
|
const y2 = r.y + NODE_H / 2;
|
||||||
|
const mid = (x1 + x2) / 2;
|
||||||
|
const active = !lit || (lit.has(e.from) && lit.has(e.to) && (e.from === focus || e.to === focus));
|
||||||
|
return <path key={`${e.from}>${e.to}`} d={`M${x1},${y1} C${mid},${y1} ${mid},${y2} ${x2},${y2}`} className={active ? "map-edge" : "map-edge map-dim"} fill="none" />;
|
||||||
|
})}
|
||||||
|
</svg>
|
||||||
|
{[...view.placed.values()].map((n) => {
|
||||||
|
const dim = lit && !lit.has(n.id);
|
||||||
|
const body = (
|
||||||
|
<>
|
||||||
|
<span className={`map-status map-status-${n.status}`} aria-hidden="true">
|
||||||
|
{STATUS_SYMBOL[n.status]}
|
||||||
|
</span>
|
||||||
|
<span className="map-label">
|
||||||
|
<span className="map-title">{n.label}</span>
|
||||||
|
{n.sub && <span className="map-sub">{n.sub}</span>}
|
||||||
|
</span>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
const props = {
|
||||||
|
className: `map-node map-node-${n.kind} ${dim ? "map-dim" : ""}`,
|
||||||
|
style: { left: n.x, top: n.y, width: NODE_W, height: NODE_H },
|
||||||
|
onMouseEnter: () => setFocus(n.id),
|
||||||
|
onMouseLeave: () => setFocus((f) => (f === n.id ? null : f)),
|
||||||
|
onFocus: () => setFocus(n.id),
|
||||||
|
onBlur: () => setFocus((f) => (f === n.id ? null : f)),
|
||||||
|
"aria-label": `${KIND_WORD[n.kind]}: ${n.label}${n.sub ? `, ${n.sub}` : ""}, ${STATUS_WORD[n.status]}`,
|
||||||
|
};
|
||||||
|
return n.href ? (
|
||||||
|
<Link key={n.id} to={n.href} {...props}>
|
||||||
|
{body}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div key={n.id} {...props}>
|
||||||
|
{body}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="card-footer text-secondary small d-flex flex-wrap gap-3">
|
||||||
|
<span>✓ working</span>
|
||||||
|
<span>✕ problem or not reporting</span>
|
||||||
|
<span>▲ needs a look</span>
|
||||||
|
<span>· no status</span>
|
||||||
|
<span className="ms-auto">DNS names appear where a record holds a server's own address; monitors where their target is the server's.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -21,6 +21,8 @@ import { ErrorNotice } from "../components/Notice";
|
|||||||
import { toast } from "../utils/toast";
|
import { toast } from "../utils/toast";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
function proxmoxStatusBadge(status: string) {
|
function proxmoxStatusBadge(status: string) {
|
||||||
return status === "running" ? (
|
return status === "running" ? (
|
||||||
@@ -198,6 +200,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
const { sorted: sortedGuests, sortKey: guestSortKey, sortDir: guestSortDir, requestSort: requestGuestSort } = useSortable(tableSearch.filtered);
|
const { sorted: sortedGuests, sortKey: guestSortKey, sortDir: guestSortDir, requestSort: requestGuestSort } = useSortable(tableSearch.filtered);
|
||||||
const { pageItems: guestPageItems, page: guestPage, setPage: setGuestPage, pageCount: guestPageCount, totalCount: guestTotalCount } =
|
const { pageItems: guestPageItems, page: guestPage, setPage: setGuestPage, pageCount: guestPageCount, totalCount: guestTotalCount } =
|
||||||
usePagination(sortedGuests);
|
usePagination(sortedGuests);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof guestPageItems>[number]>();
|
||||||
|
|
||||||
function exportGuestsCsv() {
|
function exportGuestsCsv() {
|
||||||
if (!sortedGuests) return;
|
if (!sortedGuests) return;
|
||||||
@@ -523,7 +526,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{guestPageItems?.map((g) => (
|
{guestPageItems?.map((g) => (
|
||||||
<tr key={`${g.node}:${g.type}:${g.vmid}`}>
|
<tr key={`${g.node}:${g.type}:${g.vmid}`} {...detail.rowProps(g)}>
|
||||||
<td>
|
<td>
|
||||||
{g.name} <span className="text-secondary">#{g.vmid}</span>
|
{g.name} <span className="text-secondary">#{g.vmid}</span>
|
||||||
</td>
|
</td>
|
||||||
@@ -590,6 +593,11 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((g) => g.name)(detail.selected)} subtitle={((g) => `${g.type === "qemu" ? "Virtual machine" : "Container"} ${g.vmid} on ${g.node}`)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,8 @@ import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
|||||||
import { ErrorNotice } from "../components/Notice";
|
import { ErrorNotice } from "../components/Notice";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
function semaphoreStatusBadge(template: SemaphoreTemplate) {
|
||||||
const status = template.lastTask?.status;
|
const status = template.lastTask?.status;
|
||||||
@@ -106,6 +108,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
|||||||
const tableSearch = useTableSearch(data?.templates);
|
const tableSearch = useTableSearch(data?.templates);
|
||||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof pageItems>[number]>();
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -201,7 +204,7 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pageItems?.map((t) => (
|
{pageItems?.map((t) => (
|
||||||
<tr key={`${t.projectId}:${t.id}`}>
|
<tr key={`${t.projectId}:${t.id}`} {...detail.rowProps(t)}>
|
||||||
<td>{t.name}</td>
|
<td>{t.name}</td>
|
||||||
<td className="text-secondary">{t.projectName}</td>
|
<td className="text-secondary">{t.projectName}</td>
|
||||||
<td className="text-secondary">
|
<td className="text-secondary">
|
||||||
@@ -238,6 +241,11 @@ export default function Semaphore({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((t) => t.name)(detail.selected)} subtitle={((t) => t.projectName)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
} from "../api/client";
|
} from "../api/client";
|
||||||
import ServerPorts from "../components/ServerPorts";
|
import ServerPorts from "../components/ServerPorts";
|
||||||
import ServerTrends from "../components/ServerTrends";
|
import ServerTrends from "../components/ServerTrends";
|
||||||
|
import ServerActivity from "../components/ServerActivity";
|
||||||
import ServerTags from "../components/ServerTags";
|
import ServerTags from "../components/ServerTags";
|
||||||
import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskTable";
|
import ServerTaskTable, { SCHEDULE_TYPE_LABELS } from "../components/ServerTaskTable";
|
||||||
import { formatDateTime } from "../utils/date";
|
import { formatDateTime } from "../utils/date";
|
||||||
@@ -755,6 +756,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{hardware.source === "agent" && <ServerTrends serverId={serverId} />}
|
{hardware.source === "agent" && <ServerTrends serverId={serverId} />}
|
||||||
|
{(user.role === "admin" || user.role === "operator") && <ServerActivity serverId={serverId} />}
|
||||||
|
|
||||||
<ServerPorts
|
<ServerPorts
|
||||||
serverId={serverId}
|
serverId={serverId}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import { ErrorNotice } from "../components/Notice";
|
|||||||
import { toast } from "../utils/toast";
|
import { toast } from "../utils/toast";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
const KEY_EXPIRY_WARN_DAYS = 30;
|
const KEY_EXPIRY_WARN_DAYS = 30;
|
||||||
|
|
||||||
@@ -144,6 +146,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
const tableSearch = useTableSearch(data?.devices);
|
const tableSearch = useTableSearch(data?.devices);
|
||||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered);
|
||||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof pageItems>[number]>();
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -287,7 +290,7 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pageItems?.map((d) => (
|
{pageItems?.map((d) => (
|
||||||
<tr key={d.id}>
|
<tr key={d.id} {...detail.rowProps(d)}>
|
||||||
{canEdit && (
|
{canEdit && (
|
||||||
<td>
|
<td>
|
||||||
<input
|
<input
|
||||||
@@ -349,6 +352,11 @@ export default function Tailscale({ user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((d) => d.label || d.hostname)(detail.selected)} subtitle={((d) => d.hostname)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,8 @@ import IntegrationPageTitle from "../components/IntegrationPageTitle";
|
|||||||
import { ErrorNotice } from "../components/Notice";
|
import { ErrorNotice } from "../components/Notice";
|
||||||
import { SearchBox } from "../components/TableToolbar";
|
import { SearchBox } from "../components/TableToolbar";
|
||||||
import { useTableSearch } from "../hooks/useTableSearch";
|
import { useTableSearch } from "../hooks/useTableSearch";
|
||||||
|
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
|
||||||
|
import { useRowDetail } from "../hooks/useRowDetail";
|
||||||
|
|
||||||
function statusBadge(monitor: UptimeKumaMonitor) {
|
function statusBadge(monitor: UptimeKumaMonitor) {
|
||||||
switch (monitor.status) {
|
switch (monitor.status) {
|
||||||
@@ -80,6 +82,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
|||||||
const tableSearch = useTableSearch(data?.monitors);
|
const tableSearch = useTableSearch(data?.monitors);
|
||||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "name");
|
const { sorted, sortKey, sortDir, requestSort } = useSortable(tableSearch.filtered, "name");
|
||||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||||
|
const detail = useRowDetail<NonNullable<typeof pageItems>[number]>();
|
||||||
|
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
if (!sorted) return;
|
if (!sorted) return;
|
||||||
@@ -173,7 +176,7 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{pageItems?.map((m) => (
|
{pageItems?.map((m) => (
|
||||||
<tr key={m.id}>
|
<tr key={m.id} {...detail.rowProps(m)}>
|
||||||
<td>
|
<td>
|
||||||
{m.name}
|
{m.name}
|
||||||
<div className="text-secondary small">{m.type}</div>
|
<div className="text-secondary small">{m.type}</div>
|
||||||
@@ -219,6 +222,11 @@ export default function UptimeKuma({ user: _user }: { user: CurrentUser }) {
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{detail.selected && (
|
||||||
|
<DetailDrawer title={((m) => m.name)(detail.selected)} subtitle={((m) => m.type)(detail.selected)} onClose={detail.close}>
|
||||||
|
<ObjectDetails data={detail.selected} />
|
||||||
|
</DetailDrawer>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
|
import { api, type IntegrationSummary, type MaintenanceWindow, type ServerSummary } from "../api/client";
|
||||||
|
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||||
|
import { useEnvironment } from "../utils/environment";
|
||||||
|
import { formatRemaining } from "../utils/duration";
|
||||||
|
|
||||||
|
const REFRESH_MS = 30_000;
|
||||||
|
|
||||||
|
const TYPE_LABELS: Record<IntegrationSummary["type"], string> = {
|
||||||
|
tailscale: "Tailscale",
|
||||||
|
proxmox: "Proxmox",
|
||||||
|
synology: "Synology",
|
||||||
|
semaphore: "Semaphore",
|
||||||
|
gitea: "Gitea",
|
||||||
|
dockhand: "Docker",
|
||||||
|
uptimekuma: "Uptime Kuma",
|
||||||
|
phpipam: "phpIPAM",
|
||||||
|
pbs: "Proxmox Backup",
|
||||||
|
osticket: "osTicket",
|
||||||
|
};
|
||||||
|
|
||||||
|
function useClock(): Date {
|
||||||
|
const [now, setNow] = useState(() => new Date());
|
||||||
|
useEffect(() => {
|
||||||
|
const t = setInterval(() => setNow(new Date()), 1000);
|
||||||
|
return () => clearInterval(t);
|
||||||
|
}, []);
|
||||||
|
return now;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Keeps the screen awake while the page is open, where the browser allows it. */
|
||||||
|
function useWakeLock() {
|
||||||
|
useEffect(() => {
|
||||||
|
let lock: { release: () => Promise<void> } | null = null;
|
||||||
|
let gone = false;
|
||||||
|
const request = async () => {
|
||||||
|
try {
|
||||||
|
const nav = navigator as Navigator & { wakeLock?: { request: (type: "screen") => Promise<{ release: () => Promise<void> }> } };
|
||||||
|
if (nav.wakeLock && !gone) lock = await nav.wakeLock.request("screen");
|
||||||
|
} catch {
|
||||||
|
// not allowed (battery saver, no permission): the screen may sleep like any other
|
||||||
|
}
|
||||||
|
};
|
||||||
|
void request();
|
||||||
|
const onVisible = () => document.visibilityState === "visible" && void request();
|
||||||
|
document.addEventListener("visibilitychange", onVisible);
|
||||||
|
return () => {
|
||||||
|
gone = true;
|
||||||
|
document.removeEventListener("visibilitychange", onVisible);
|
||||||
|
void lock?.release().catch(() => {});
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A full-screen status board for a spare monitor or tablet: how things are, in type big enough to read across a room, refreshing
|
||||||
|
* by itself. Nothing on it can be clicked into, so it can be left alone; Esc (or the corner link) goes back to the app.
|
||||||
|
*/
|
||||||
|
export default function Wall() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const environment = useEnvironment();
|
||||||
|
const now = useClock();
|
||||||
|
const { report, failed, reload } = useAlertsReport();
|
||||||
|
const [servers, setServers] = useState<ServerSummary | null>(null);
|
||||||
|
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||||
|
const [windows, setWindows] = useState<MaintenanceWindow[]>([]);
|
||||||
|
const [updatedAt, setUpdatedAt] = useState<Date | null>(null);
|
||||||
|
const [idle, setIdle] = useState(false);
|
||||||
|
useWakeLock();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let alive = true;
|
||||||
|
const load = () => {
|
||||||
|
reload();
|
||||||
|
Promise.allSettled([api.servers.summary(), api.integrations.list(), api.maintenance.list()]).then(([s, i, m]) => {
|
||||||
|
if (!alive) return;
|
||||||
|
if (s.status === "fulfilled") setServers(s.value);
|
||||||
|
if (i.status === "fulfilled") setIntegrations(i.value.integrations);
|
||||||
|
if (m.status === "fulfilled") setWindows(m.value.windows);
|
||||||
|
setUpdatedAt(new Date());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
load();
|
||||||
|
const t = setInterval(load, REFRESH_MS);
|
||||||
|
return () => {
|
||||||
|
alive = false;
|
||||||
|
clearInterval(t);
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
// Esc leaves; the pointer hides itself when nobody is using it.
|
||||||
|
useEffect(() => {
|
||||||
|
const onKey = (e: KeyboardEvent) => e.key === "Escape" && !document.fullscreenElement && navigate("/");
|
||||||
|
let timer: ReturnType<typeof setTimeout>;
|
||||||
|
const onMove = () => {
|
||||||
|
setIdle(false);
|
||||||
|
clearTimeout(timer);
|
||||||
|
timer = setTimeout(() => setIdle(true), 5000);
|
||||||
|
};
|
||||||
|
onMove();
|
||||||
|
window.addEventListener("keydown", onKey);
|
||||||
|
window.addEventListener("mousemove", onMove);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("keydown", onKey);
|
||||||
|
window.removeEventListener("mousemove", onMove);
|
||||||
|
clearTimeout(timer);
|
||||||
|
};
|
||||||
|
}, [navigate]);
|
||||||
|
|
||||||
|
const badge = alertBadge(report);
|
||||||
|
const blind = report?.couldntCheck.length ?? 0;
|
||||||
|
const level: "critical" | "warning" | "ok" | "unsure" = !report ? "unsure" : badge ? badge.level : blind > 0 ? "unsure" : "ok";
|
||||||
|
const active = (report?.alerts ?? []).filter((a) => !a.silenced && a.severity !== "info").sort((a, b) => (a.severity === b.severity ? 0 : a.severity === "critical" ? -1 : 1));
|
||||||
|
const failing = (integrations ?? []).filter((i) => i.enabled && i.health?.status === "failing");
|
||||||
|
const offline = servers?.offline.length ?? 0;
|
||||||
|
|
||||||
|
const headline =
|
||||||
|
level === "critical" || level === "warning"
|
||||||
|
? `${badge!.count} ${badge!.count === 1 ? "thing needs" : "things need"} attention`
|
||||||
|
: level === "unsure"
|
||||||
|
? report
|
||||||
|
? "No alerts — but some checks couldn't run"
|
||||||
|
: failed
|
||||||
|
? "Can't reach the server"
|
||||||
|
: "Checking…"
|
||||||
|
: "All clear";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={`wall ${idle ? "wall-idle" : ""}`} data-bs-theme="dark">
|
||||||
|
<header className="wall-header">
|
||||||
|
<img src="/logo.webp" alt="Homelab Manager" width={901} height={460} className="wall-logo" />
|
||||||
|
{environment?.name && <span className="badge env-badge">{environment.name}</span>}
|
||||||
|
<div className="wall-clock" aria-label="Time">
|
||||||
|
<div className="wall-time">{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</div>
|
||||||
|
<div className="wall-date">{now.toLocaleDateString([], { weekday: "long", day: "numeric", month: "long" })}</div>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section className={`wall-status wall-status-${level}`} role="status" aria-live="polite">
|
||||||
|
<span className="wall-status-symbol" aria-hidden="true">
|
||||||
|
{level === "critical" ? "✕" : level === "warning" ? "▲" : level === "ok" ? "✓" : "?"}
|
||||||
|
</span>
|
||||||
|
<span>{headline}</span>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="wall-tiles" aria-label="Summary">
|
||||||
|
<div className={`wall-tile ${offline > 0 ? "wall-tile-bad" : ""}`}>
|
||||||
|
<div className="wall-tile-figure">{servers ? (servers.online + offline === 0 ? "—" : `${servers.online}/${servers.online + offline}`) : "…"}</div>
|
||||||
|
<div className="wall-tile-label">servers online</div>
|
||||||
|
</div>
|
||||||
|
<div className={`wall-tile ${(report?.counts.critical ?? 0) > 0 ? "wall-tile-bad" : (report?.counts.warning ?? 0) > 0 ? "wall-tile-warn" : ""}`}>
|
||||||
|
<div className="wall-tile-figure">{report ? report.counts.critical + report.counts.warning : "…"}</div>
|
||||||
|
<div className="wall-tile-label">
|
||||||
|
alerts{report && report.counts.critical + report.counts.warning > 0 ? ` (${report.counts.critical} critical, ${report.counts.warning} warning)` : ""}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className={`wall-tile ${windows.length > 0 ? "wall-tile-info" : ""}`}>
|
||||||
|
<div className="wall-tile-figure">{windows.length}</div>
|
||||||
|
<div className="wall-tile-label">in maintenance</div>
|
||||||
|
</div>
|
||||||
|
<div className={`wall-tile ${failing.length > 0 ? "wall-tile-bad" : ""}`}>
|
||||||
|
<div className="wall-tile-figure">{integrations ? failing.length : "…"}</div>
|
||||||
|
<div className="wall-tile-label">integrations failing</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section className="wall-columns">
|
||||||
|
<div>
|
||||||
|
<h2 className="wall-heading">Needs attention</h2>
|
||||||
|
{active.length === 0 ? (
|
||||||
|
<div className="wall-empty">Nothing right now.</div>
|
||||||
|
) : (
|
||||||
|
<ul className="wall-list">
|
||||||
|
{active.slice(0, 7).map((a) => (
|
||||||
|
<li key={a.id} className={a.severity === "critical" ? "wall-bad" : "wall-warn"}>
|
||||||
|
<span aria-hidden="true">{a.severity === "critical" ? "✕" : "▲"}</span> <span className="visually-hidden">{a.severity}: </span>
|
||||||
|
{a.message}
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
{active.length > 7 && <li className="wall-more">and {active.length - 7} more</li>}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
{windows.length > 0 && (
|
||||||
|
<>
|
||||||
|
<h2 className="wall-heading mt-4">In maintenance</h2>
|
||||||
|
<ul className="wall-list wall-list-small">
|
||||||
|
{windows.map((w) => (
|
||||||
|
<li key={w.id}>
|
||||||
|
{w.targetName} <span className="wall-dim">· {formatRemaining(w.endsAt, now.getTime())} left</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h2 className="wall-heading">Integrations</h2>
|
||||||
|
{(integrations ?? []).filter((i) => i.enabled).length === 0 ? (
|
||||||
|
<div className="wall-empty">None connected.</div>
|
||||||
|
) : (
|
||||||
|
<ul className="wall-list wall-list-small">
|
||||||
|
{[...(integrations ?? [])]
|
||||||
|
.filter((i) => i.enabled)
|
||||||
|
.sort((a, b) => Number(b.health?.status === "failing") - Number(a.health?.status === "failing") || a.name.localeCompare(b.name))
|
||||||
|
.map((i) => {
|
||||||
|
const status = i.health?.status;
|
||||||
|
return (
|
||||||
|
<li key={i.id} className={status === "failing" ? "wall-bad" : status === "ok" ? "wall-good" : "wall-dim"}>
|
||||||
|
<span aria-hidden="true">{status === "failing" ? "✕" : status === "ok" ? "✓" : "·"}</span> {i.name}{" "}
|
||||||
|
<span className="wall-dim">
|
||||||
|
{TYPE_LABELS[i.type]} — {status === "failing" ? "failing" : status === "ok" ? "working" : "not checked yet"}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<footer className="wall-footer">
|
||||||
|
<span>
|
||||||
|
{updatedAt ? `Updated ${updatedAt.toLocaleTimeString()}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s
|
||||||
|
</span>
|
||||||
|
<span className="wall-footer-actions">
|
||||||
|
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
|
||||||
|
Full screen
|
||||||
|
</button>
|
||||||
|
<Link to="/" className="wall-link">
|
||||||
|
Exit (Esc)
|
||||||
|
</Link>
|
||||||
|
</span>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -291,6 +291,568 @@ html[data-env] .navbar-vertical {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ── Accessibility ── */
|
||||||
|
/* A link that appears when the keyboard first reaches the page, to jump past the menu. */
|
||||||
|
.skip-link {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.5rem;
|
||||||
|
left: 0.5rem;
|
||||||
|
z-index: 3000;
|
||||||
|
padding: 0.5rem 0.9rem;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
background: #1d4ed8;
|
||||||
|
border-radius: 0.3rem;
|
||||||
|
transform: translateY(-200%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.skip-link:focus {
|
||||||
|
color: #fff;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The page's own start takes keyboard focus on navigation; it is not a control, so it needs no ring. */
|
||||||
|
main:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A clear ring wherever the keyboard is, and only for the keyboard (a mouse click shows none). */
|
||||||
|
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
|
||||||
|
outline: 2px solid var(--tblr-primary, #2563eb);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On the coloured sidebar the blue ring would vanish, so use white there. */
|
||||||
|
.navbar-vertical :where(a, button, input, select):focus-visible {
|
||||||
|
outline-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A sortable column heading is a button that looks like the heading it sits in. */
|
||||||
|
.th-sort {
|
||||||
|
padding: 0;
|
||||||
|
font: inherit;
|
||||||
|
color: inherit;
|
||||||
|
letter-spacing: inherit;
|
||||||
|
text-align: inherit;
|
||||||
|
text-transform: inherit;
|
||||||
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
background: none;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The keyboard-shortcut list: a key on the left, what it does on the right. */
|
||||||
|
.shortcut-list > div {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 0.2rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-list dt {
|
||||||
|
flex: 0 0 8rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shortcut-list dd {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── A row that opens a detail panel, and the panel. ── */
|
||||||
|
.row-clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.row-clickable:hover > td {
|
||||||
|
background-color: color-mix(in srgb, currentColor 5%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-backdrop {
|
||||||
|
position: fixed;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 1040;
|
||||||
|
background: rgba(0, 0, 0, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-drawer {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
z-index: 1045;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: min(30rem, 100vw);
|
||||||
|
color: var(--tblr-body-color);
|
||||||
|
background: var(--tblr-bg-surface, #fff);
|
||||||
|
border-left: 1px solid var(--tblr-border-color);
|
||||||
|
box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
|
||||||
|
animation: drawer-in 0.18s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-drawer-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
border-bottom: 1px solid var(--tblr-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-drawer-body {
|
||||||
|
flex: 1;
|
||||||
|
padding: 1rem 1.25rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-list > div {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 9.5rem 1fr;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.4rem 0;
|
||||||
|
border-bottom: 1px solid var(--tblr-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-list dt {
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--tblr-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-list dd {
|
||||||
|
margin: 0;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
.detail-list-nested > div {
|
||||||
|
grid-template-columns: 7rem 1fr;
|
||||||
|
border-bottom: 0;
|
||||||
|
padding: 0.15rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes drawer-in {
|
||||||
|
from {
|
||||||
|
transform: translateX(2rem);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.detail-drawer {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── A server's activity: an icon, what happened, and when. ── */
|
||||||
|
.activity-list {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-list > li {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
align-items: flex-start;
|
||||||
|
padding: 0.5rem 0;
|
||||||
|
border-bottom: 1px solid var(--tblr-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.activity-list > li:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── The wall display: a full-screen status board, big enough to read across a room. ── */
|
||||||
|
.wall {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: clamp(1rem, 2.2vw, 2rem);
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: clamp(1rem, 3vw, 3rem);
|
||||||
|
color: #e6edf7;
|
||||||
|
font-size: clamp(1rem, 1.6vw, 1.6rem);
|
||||||
|
background: #0b1220;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-idle {
|
||||||
|
cursor: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-header {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-logo {
|
||||||
|
width: auto;
|
||||||
|
height: clamp(3.5rem, 8vw, 7rem);
|
||||||
|
object-fit: contain;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-clock {
|
||||||
|
margin-left: auto;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-time {
|
||||||
|
font-size: clamp(2.5rem, 6vw, 6rem);
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-date {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
align-items: center;
|
||||||
|
padding: clamp(0.8rem, 2vw, 1.8rem) clamp(1rem, 2.5vw, 2.5rem);
|
||||||
|
font-size: clamp(1.6rem, 4.2vw, 4.2rem);
|
||||||
|
font-weight: 700;
|
||||||
|
border-radius: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status-symbol {
|
||||||
|
display: inline-grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 1.4em;
|
||||||
|
height: 1.4em;
|
||||||
|
font-size: 0.8em;
|
||||||
|
border: 0.12em solid currentColor;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status-ok {
|
||||||
|
color: #7ee2a0;
|
||||||
|
background: #12351f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status-critical {
|
||||||
|
color: #ff9aa2;
|
||||||
|
background: #4a1519;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status-warning {
|
||||||
|
color: #ffd27a;
|
||||||
|
background: #4a3510;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-status-unsure {
|
||||||
|
color: #c4d0e4;
|
||||||
|
background: #1f2a3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tiles {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
|
||||||
|
gap: clamp(0.75rem, 1.6vw, 1.5rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile {
|
||||||
|
padding: clamp(0.8rem, 1.6vw, 1.6rem);
|
||||||
|
background: #121c2f;
|
||||||
|
border-radius: 0.8rem;
|
||||||
|
box-shadow: inset 0 0 0 2px transparent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile-figure {
|
||||||
|
font-size: clamp(2.5rem, 6vw, 5.5rem);
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.05;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile-label {
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile-bad {
|
||||||
|
box-shadow: inset 0 0 0 3px #ff6b6b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile-warn {
|
||||||
|
box-shadow: inset 0 0 0 3px #ffc247;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-tile-info {
|
||||||
|
box-shadow: inset 0 0 0 3px #4dabf7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-columns {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 3fr 2fr;
|
||||||
|
gap: clamp(1rem, 3vw, 3rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.wall-columns {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-heading {
|
||||||
|
margin: 0 0 0.5em;
|
||||||
|
font-size: 0.8em;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-list {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 1.25em;
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-list li {
|
||||||
|
padding: 0.3em 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-list-small {
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-bad {
|
||||||
|
color: #ff9aa2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-warn {
|
||||||
|
color: #ffd27a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-good {
|
||||||
|
color: #7ee2a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-dim,
|
||||||
|
.wall-more,
|
||||||
|
.wall-empty {
|
||||||
|
opacity: 0.65;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-footer {
|
||||||
|
display: flex;
|
||||||
|
gap: 1rem;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: auto;
|
||||||
|
font-size: 0.8em;
|
||||||
|
opacity: 0.65;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wall-link {
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: underline;
|
||||||
|
cursor: pointer;
|
||||||
|
background: none;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── The map: boxes in columns with lines between them. ── */
|
||||||
|
.map-scroll {
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-columns {
|
||||||
|
position: relative;
|
||||||
|
height: 1.6rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-column-title {
|
||||||
|
position: absolute;
|
||||||
|
font-size: 0.72rem;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.06em;
|
||||||
|
color: var(--tblr-secondary);
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-canvas {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-lines {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-edge {
|
||||||
|
stroke: var(--tblr-secondary);
|
||||||
|
stroke-width: 1.6;
|
||||||
|
stroke-opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-edge.map-dim {
|
||||||
|
stroke-opacity: 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node {
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
gap: 0.55rem;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 0.7rem;
|
||||||
|
color: var(--tblr-body-color);
|
||||||
|
text-decoration: none;
|
||||||
|
background: var(--tblr-bg-surface-secondary, var(--tblr-bg-surface));
|
||||||
|
border: 1px solid var(--tblr-border-color);
|
||||||
|
border-left-width: 4px;
|
||||||
|
border-radius: 0.4rem;
|
||||||
|
transition: opacity 0.12s;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.map-node:hover,
|
||||||
|
a.map-node:focus-visible {
|
||||||
|
color: var(--tblr-body-color);
|
||||||
|
border-color: var(--tblr-primary, #2563eb);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node.map-dim {
|
||||||
|
opacity: 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node-host {
|
||||||
|
border-left-color: #a78bfa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node-server {
|
||||||
|
border-left-color: #4299e1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node-dns {
|
||||||
|
border-left-color: #38b2ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-node-monitor {
|
||||||
|
border-left-color: #f6ad55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-label {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 0;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-title,
|
||||||
|
.map-sub {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-sub {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
color: var(--tblr-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-status {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: 1.3rem;
|
||||||
|
height: 1.3rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.3rem;
|
||||||
|
text-align: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-status-ok {
|
||||||
|
color: #5fe07a;
|
||||||
|
background: rgba(47, 179, 68, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-status-bad {
|
||||||
|
color: #ff9a9a;
|
||||||
|
background: rgba(214, 57, 57, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-status-warn {
|
||||||
|
color: #ffc85a;
|
||||||
|
background: rgba(245, 165, 36, 0.18);
|
||||||
|
}
|
||||||
|
|
||||||
|
.map-status-unknown {
|
||||||
|
color: #b3bcc9;
|
||||||
|
background: rgba(128, 138, 150, 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On a light page the same symbols need darker colours to be read. */
|
||||||
|
[data-bs-theme="light"] .map-status-ok {
|
||||||
|
color: #17692b;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="light"] .map-status-bad {
|
||||||
|
color: #a82323;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="light"] .map-status-warn {
|
||||||
|
color: #7a4f00;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="light"] .map-status-unknown {
|
||||||
|
color: #566170;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
.map-node {
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Dark mode: reds and blues Tabler uses for text are a little dim on the dark background; these are brighter, for the text only
|
||||||
|
(the solid red and blue of badges and buttons is unchanged, since white text sits on those). ── */
|
||||||
|
[data-bs-theme="dark"] .text-red,
|
||||||
|
[data-bs-theme="dark"] .alert-danger,
|
||||||
|
[data-bs-theme="dark"] .alert-danger .alert-link {
|
||||||
|
color: #f5a0a0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="dark"] .btn-outline-danger {
|
||||||
|
--tblr-btn-color: #f5a0a0;
|
||||||
|
--tblr-btn-border-color: #f5a0a0;
|
||||||
|
--tblr-btn-hover-color: #fff;
|
||||||
|
--tblr-btn-hover-bg: #d63939;
|
||||||
|
--tblr-btn-hover-border-color: #d63939;
|
||||||
|
color: #f5a0a0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="dark"] .btn-link {
|
||||||
|
--tblr-btn-color: #74bbff;
|
||||||
|
color: #74bbff;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="dark"] .input-group-text {
|
||||||
|
color: #a8b0bd;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ── Light mode: the same, the other way round — Tabler's red, amber and blue text are a little pale on a light background. ── */
|
||||||
|
[data-bs-theme="light"] .alert-danger,
|
||||||
|
[data-bs-theme="light"] .alert-danger .alert-link {
|
||||||
|
color: #a82323;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="light"] .alert-warning,
|
||||||
|
[data-bs-theme="light"] .alert-warning .alert-link {
|
||||||
|
color: #7a4f00;
|
||||||
|
}
|
||||||
|
|
||||||
|
[data-bs-theme="light"] .btn-link {
|
||||||
|
--tblr-btn-color: #0b5cad;
|
||||||
|
color: #0b5cad;
|
||||||
|
}
|
||||||
|
|
||||||
/* Sidebar submenus: a little tighter than Tabler's dropdown rows, so several open groups still fit on one screen. */
|
/* Sidebar submenus: a little tighter than Tabler's dropdown rows, so several open groups still fit on one screen. */
|
||||||
.navbar-vertical .dropdown-menu .dropdown-item {
|
.navbar-vertical .dropdown-menu .dropdown-item {
|
||||||
padding-top: 0.3rem;
|
padding-top: 0.3rem;
|
||||||
|
|||||||
Reference in new issue
Block a user