Dependency map, impact preview in maintenance, and a calmer Alerts page

- Map: a Dependencies view showing what would go down with a picked box and what it relies on
- Maintenance: lists what depends on a target and can silence those too (same time, audited); the recurring form and update drawer show the same note
- Alerts: a headline on where things stand, held-back alerts nested under their cause, severity edge on rows; caused-by now carries the explaining alert's id

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-18 19:17:09 +02:00
1 parent ec9c2f73f0
commit 9caa414829
19 files changed
+944 -40

No files matched your search

+33 -3
View File
@@ -778,6 +778,34 @@ export interface BackupCoverage {
export type AssetKind = "server" | "storage" | "network" | "power" | "client" | "other";
export type DependencyNodeType = "server" | "integration";
/** Something that would be affected if another went down (or that it needs): `distance` 1 is directly, 2 through one other, and so on. */
export interface DependencyImpactItem {
key: string;
type: DependencyNodeType;
id: number;
name: string;
distance: number;
silenced: boolean;
}
export interface DependencyImpact {
target: { key: string; type: DependencyNodeType; id: number; name: string };
dependents: DependencyImpactItem[];
needs: DependencyImpactItem[];
}
export interface DependencyGraphNode {
key: string;
type: DependencyNodeType;
id: number;
name: string;
status: "ok" | "bad" | "warn" | "unknown";
href: string;
}
export interface DependencyGraph {
nodes: DependencyGraphNode[];
/** From the thing that is needed to the thing that needs it. */
edges: { from: string; to: string; kind: "written" | "runs-on" }[];
}
export interface DependencyNode {
key: string;
type: DependencyNodeType;
@@ -871,7 +899,7 @@ export interface AlertItem {
/** What a maintenance window would go on to silence it — what the Silence button acts on. Null when nothing can silence it. */
target?: { type: MaintenanceTargetType; id: number; name: string } | null;
/** Held back because another problem explains it (a guest down because its host is): the host's alert says so too. */
causedBy?: { name: string };
causedBy?: { name: string; alertId?: string };
/** On a host's alert: the servers on it whose own alerts are folded under this one. */
affects?: string[];
/** The osTicket ticket opened for it, if one was. */
@@ -1694,6 +1722,8 @@ export const api = {
},
dependencies: {
list: () => request<DependenciesResponse>("/api/dependencies"),
impact: (type: DependencyNodeType, id: number) => request<DependencyImpact>(`/api/dependencies/impact?type=${type}&id=${id}`),
graph: () => request<DependencyGraph>("/api/dependencies/graph"),
create: (data: { fromType: DependencyNodeType; fromId: number; toType: DependencyNodeType; toId: number }) => request<{ id: number }>("/api/dependencies", { method: "POST", body: JSON.stringify(data) }),
remove: (id: number) => request<void>(`/api/dependencies/${id}`, { method: "DELETE" }),
},
@@ -1759,8 +1789,8 @@ export const api = {
addAlias: (data: { address: string; targetType: MaintenanceTargetType; targetId: number }) =>
request<{ alias: MaintenanceAlias }>("/api/maintenance/aliases", { method: "POST", body: JSON.stringify(data) }),
removeAlias: (id: number) => request<void>(`/api/maintenance/aliases/${id}`, { method: "DELETE" }),
start: (data: { targetType: MaintenanceTargetType; targetId: number; minutes: number; reason?: string }) =>
request<{ window: MaintenanceWindow }>("/api/maintenance", { method: "POST", body: JSON.stringify(data) }),
start: (data: { targetType: MaintenanceTargetType; targetId: number; minutes: number; reason?: string; withDependents?: boolean }) =>
request<{ window: MaintenanceWindow; alsoSilenced: { type: DependencyNodeType; id: number; name: string }[] }>("/api/maintenance", { method: "POST", body: JSON.stringify(data) }),
end: (id: number) => request<void>(`/api/maintenance/${id}`, { method: "DELETE" }),
startBulk: (data: { scope: MaintenanceBulkScope; minutes: number; reason?: string }) =>
request<{ started: number; extended: number; total: number }>("/api/maintenance/bulk", { method: "POST", body: JSON.stringify(data) }),
+195
View File
@@ -0,0 +1,195 @@
import { useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DependencyGraph, type DependencyGraphNode } from "../api/client";
import { ErrorNotice } from "./Notice";
import { PageSkeleton } from "./Skeleton";
import { readableError } from "../utils/errors";
const NODE_W = 200;
const NODE_H = 46;
const GAP_Y = 12;
const COL_GAP = 120;
const STATUS_SYMBOL: Record<DependencyGraphNode["status"], string> = { ok: "✓", bad: "✕", warn: "▲", unknown: "·" };
const STATUS_WORD: Record<DependencyGraphNode["status"], string> = { ok: "working", bad: "problem", warn: "check", unknown: "no status" };
interface Placed extends DependencyGraphNode {
x: number;
y: number;
layer: number;
}
/**
* Columns by how deep each thing sits: what needs nothing on the left, then what needs only those, and so on. A column is ordered by where the
* things it needs sit, so the lines cross as little as is easy. (A loop can't be made, but if one ever got in the layering gives up rather than spin.)
*/
function layout(graph: DependencyGraph): { placed: Map<string, Placed>; width: number; height: number } {
const needs = new Map<string, string[]>();
for (const e of graph.edges) needs.set(e.to, [...(needs.get(e.to) ?? []), e.from]);
const layer = new Map<string, number>(graph.nodes.map((n) => [n.key, 0]));
for (let pass = 0; pass < graph.nodes.length; pass++) {
let moved = false;
for (const n of graph.nodes) {
const want = Math.max(-1, ...(needs.get(n.key) ?? []).map((k) => layer.get(k) ?? 0)) + 1;
if (want > (layer.get(n.key) ?? 0)) {
layer.set(n.key, want);
moved = true;
}
}
if (!moved) break;
}
const columns = new Map<number, DependencyGraphNode[]>();
for (const n of graph.nodes) columns.set(layer.get(n.key) ?? 0, [...(columns.get(layer.get(n.key) ?? 0) ?? []), n]);
const placed = new Map<string, Placed>();
const step = NODE_H + GAP_Y;
let height = 0;
for (const depth of [...columns.keys()].sort((a, b) => a - b)) {
const wanted = columns.get(depth)!.map((n) => {
const ys = (needs.get(n.key) ?? []).map((k) => placed.get(k)?.y).filter((y): y is number => y !== undefined);
return { n, y: ys.length ? ys.reduce((a, b) => a + b, 0) / ys.length : 0 };
});
wanted.sort((a, b) => a.y - b.y || a.n.name.localeCompare(b.n.name));
let next = 0;
for (const { n, y } of wanted) {
const at = Math.max(next, depth === 0 ? next : y);
placed.set(n.key, { ...n, x: depth * (NODE_W + COL_GAP), y: at, layer: depth });
next = at + step;
height = Math.max(height, at + NODE_H);
}
}
const maxLayer = Math.max(0, ...[...placed.values()].map((p) => p.layer));
return { placed, width: maxLayer * (NODE_W + COL_GAP) + NODE_W, height };
}
/** Everything reached from `start` by following edges one way (`forward`: to what needs it; otherwise to what it needs). */
function reach(graph: DependencyGraph, start: string, forward: boolean): Set<string> {
const out = new Set<string>();
const queue = [start];
while (queue.length) {
const cur = queue.shift()!;
for (const e of graph.edges) {
const [a, b] = forward ? [e.from, e.to] : [e.to, e.from];
if (a === cur && !out.has(b) && b !== start) {
out.add(b);
queue.push(b);
}
}
}
return out;
}
const names = (graph: DependencyGraph, keys: Iterable<string>) => [...keys].map((k) => graph.nodes.find((n) => n.key === k)?.name ?? k).sort((a, b) => a.localeCompare(b));
/**
* What needs what, drawn with the foundations on the left. Pick a box to see what would go down with it (red) and what it relies on (blue);
* hovering does the same for a moment. This is the answer to "what breaks if I reboot this?" before doing it.
*/
export default function DependencyMap() {
const [graph, setGraph] = useState<DependencyGraph | null>(null);
const [error, setError] = useState<string | null>(null);
const [selected, setSelected] = useState<string | null>(null);
const [hover, setHover] = useState<string | null>(null);
useEffect(() => {
api.dependencies
.graph()
.then(setGraph)
.catch((err) => setError(readableError(err)));
}, []);
const view = useMemo(() => (graph ? layout(graph) : null), [graph]);
const active = hover ?? selected;
const sets = useMemo(() => {
if (!graph || !active) return null;
return { down: reach(graph, active, true), up: reach(graph, active, false) };
}, [graph, active]);
const activeNode = graph?.nodes.find((n) => n.key === active) ?? null;
if (error) return <ErrorNotice error={error} />;
if (!graph || !view) return <PageSkeleton />;
if (graph.nodes.length === 0) {
return (
<div className="card">
<div className="card-body text-secondary">
Nothing depends on anything yet. Say what needs what on the <Link to="/dependencies">Dependencies</Link> page, or set which server another runs on, and it is drawn here.
</div>
</div>
);
}
const state = (key: string) => (!sets || !active ? "" : key === active ? "map-active" : sets.down.has(key) ? "map-down" : sets.up.has(key) ? "map-up" : "map-dim");
return (
<div className="card">
<div className="card-body map-scroll">
<div className="map-canvas" style={{ width: view.width, height: view.height }}>
<svg className="map-lines" width={view.width} height={view.height} aria-hidden="true">
{graph.edges.map((e) => {
const a = view.placed.get(e.from);
const b = view.placed.get(e.to);
if (!a || !b) return null;
const x1 = a.x + NODE_W;
const y1 = a.y + NODE_H / 2;
const x2 = b.x;
const y2 = b.y + NODE_H / 2;
const mid = (x1 + x2) / 2;
let cls = "map-edge";
if (sets && active) {
const downPath = (e.from === active || sets.down.has(e.from)) && sets.down.has(e.to);
const upPath = (e.to === active || sets.up.has(e.to)) && sets.up.has(e.from);
cls = downPath ? "map-edge map-edge-down" : upPath ? "map-edge map-edge-up" : "map-edge map-dim";
}
return <path key={`${e.from}>${e.to}`} d={`M${x1},${y1} C${mid},${y1} ${mid},${y2} ${x2},${y2}`} className={cls} fill="none" strokeDasharray={e.kind === "runs-on" ? "5 4" : undefined} />;
})}
</svg>
{[...view.placed.values()].map((n) => (
<button
key={n.key}
type="button"
className={`map-node map-node-${n.type === "server" ? "server" : "monitor"} ${state(n.key)}`}
style={{ left: n.x, top: n.y, width: NODE_W, height: NODE_H, textAlign: "left" }}
aria-pressed={selected === n.key}
aria-label={`${n.type === "server" ? "Server" : "Integration"}: ${n.name}, ${STATUS_WORD[n.status]}. Show what depends on it.`}
onClick={() => setSelected((s) => (s === n.key ? null : n.key))}
onMouseEnter={() => setHover(n.key)}
onMouseLeave={() => setHover((h) => (h === n.key ? null : h))}
onFocus={() => setHover(n.key)}
onBlur={() => setHover((h) => (h === n.key ? null : h))}
>
<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.name}</span>
<span className="map-sub">{n.type === "server" ? "Server" : "Integration"}</span>
</span>
</button>
))}
</div>
</div>
<div className="card-footer" aria-live="polite">
{activeNode && sets ? (
<div>
<div className="mb-1">
<strong>{activeNode.name}</strong>{" "}
<Link to={activeNode.href} className="small">
open
</Link>
{selected !== active && <span className="text-secondary small ms-2">(click to keep this)</span>}
</div>
<div className={sets.down.size ? "text-red" : "text-secondary"}>
{sets.down.size ? `If it goes down, ${sets.down.size} ${sets.down.size === 1 ? "thing goes" : "things go"} with it: ${names(graph, sets.down).join(", ")}.` : "Nothing depends on it."}
</div>
<div className="text-secondary">{sets.up.size ? `It relies on ${names(graph, sets.up).join(", ")}.` : "It relies on nothing here."}</div>
</div>
) : (
<div className="text-secondary small d-flex flex-wrap gap-3">
<span>Lines run from what is needed (left) to what needs it (right). Dashed: &ldquo;runs on&rdquo;, set on the server.</span>
<span className="ms-auto">Pick a box to see what would go down with it.</span>
</div>
)}
</div>
</div>
);
}
+86
View File
@@ -0,0 +1,86 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import { api, type DependencyImpactItem } from "../api/client";
export interface ImpactTarget {
type: string;
id: number;
}
/**
* Before something is worked on: what depends on it and will look down while it is. Says nothing when nothing does. With `silence` given it
* also offers to put those under maintenance too, and with `onAdd` to add them to the selection being made.
*/
export default function ImpactNote({
targets,
silence,
onAdd,
verb = "will look down while it is",
}: {
targets: ImpactTarget[];
silence?: { value: boolean; onChange: (on: boolean) => void };
onAdd?: (items: DependencyImpactItem[]) => void;
verb?: string;
}) {
const [items, setItems] = useState<DependencyImpactItem[] | null>(null);
const keyOf = targets.map((t) => `${t.type}:${t.id}`).sort().join(",");
useEffect(() => {
const own = targets.filter((t) => t.type === "server" || t.type === "integration");
if (own.length === 0) {
setItems([]);
return;
}
let alive = true;
setItems(null);
Promise.all(own.map((t) => api.dependencies.impact(t.type as "server" | "integration", t.id).catch(() => null)))
.then((all) => {
if (!alive) return;
const selected = new Set(own.map((t) => `${t.type}:${t.id}`));
const seen = new Map<string, DependencyImpactItem>();
for (const impact of all) for (const d of impact?.dependents ?? []) if (!selected.has(d.key) && !seen.has(d.key)) seen.set(d.key, d);
setItems([...seen.values()].sort((a, b) => a.distance - b.distance || a.name.localeCompare(b.name)));
})
.catch(() => alive && setItems([]));
return () => {
alive = false;
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [keyOf]);
if (!items || items.length === 0) return null;
const shown = items.slice(0, 8);
return (
<div className="alert alert-warning mb-0" role="note">
<div className="fw-bold mb-1">
{items.length} {items.length === 1 ? "thing depends" : "things depend"} on {targets.length === 1 ? "this" : "these"} and {verb}
</div>
<div className="mb-1">
{shown.map((d) => (
<span key={d.key} className="badge bg-yellow-lt text-yellow me-1" title={d.distance > 1 ? "Through something else that needs it" : "Needs it directly"}>
{d.name}
{d.silenced ? " · already silenced" : ""}
</span>
))}
{items.length > shown.length && <span className="text-secondary small">and {items.length - shown.length} more</span>}
</div>
{silence && (
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={silence.value} onChange={(e) => silence.onChange(e.target.checked)} />
<span className="form-check-label">Silence {items.length === 1 ? "it" : "them"} too, for the same time</span>
</label>
)}
{onAdd && (
<button type="button" className="btn btn-sm btn-outline-secondary mt-1" onClick={() => onAdd(items)}>
Add {items.length === 1 ? "it" : "them"} to the selection
</button>
)}
{!silence && !onAdd && (
<div className="small text-secondary">
To silence {items.length === 1 ? "it" : "them"} too, start maintenance on <Link to="/maintenance">the Maintenance page</Link> with that option.
</div>
)}
</div>
);
}
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import ImpactNote from "./ImpactNote";
import { api, type MaintenanceSchedule, type MaintenanceTargetType, type MaintenanceTargets } from "../api/client";
import { confirmDialog } from "../utils/dialogs";
import { readableError } from "../utils/errors";
@@ -271,6 +272,15 @@ export default function RecurringMaintenance({ canEdit, targets, onChanged }: {
)}
</div>
</div>
{picked.size > 0 && (
<div className="col-12">
<ImpactNote
targets={[...picked].map((k) => ({ type: k.split(":")[0], id: Number(k.split(":")[1]) }))}
verb="will look down while they are"
onAdd={(items) => setPicked((prev) => new Set([...prev, ...items.map((i) => key(i.type, i.id))]))}
/>
</div>
)}
<div className="col-12">
<ErrorNotice error={error} />
</div>
+4
View File
@@ -1,5 +1,6 @@
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import ImpactNote from "./ImpactNote";
import { api, type IntegrationSummary, type SemaphoreTemplate, type UpdatesServer } from "../api/client";
import { confirmDialog } from "../utils/dialogs";
import { readableError } from "../utils/errors";
@@ -108,6 +109,9 @@ export default function UpdateRunDrawer({ server, onClose, onStarted }: { server
<div className="text-secondary">No templates found in Semaphore.</div>
) : (
<>
<div className="mb-3">
<ImpactNote targets={[{ type: "server", id: server.id }]} verb="may look down while it restarts" />
</div>
<ol className="text-secondary small ps-3 mb-3">
<li>Alerts for this server are silenced (a maintenance window).</li>
<li>The playbook runs in Semaphore, for this server only.</li>
+120 -8
View File
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from "react";
import { Fragment, useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { api, type AlertCategory, type AlertItem, type AlertSeverity, type AlertsReport, type CurrentUser } from "../api/client";
import { useSortable } from "../hooks/useSortable";
@@ -52,6 +52,23 @@ export default function Alerts({ user }: { user: CurrentUser }) {
// Which alerts to show by whether somebody is on them, and the one whose acknowledgement is being edited.
const [attention, setAttention] = useState<"all" | "unacknowledged" | "acknowledged" | "mine">("all");
const [acking, setAcking] = useState<AlertItem | null>(null);
// Held-back alerts are nested under the one that explains them (on by default; remembered), and each parent opens to show them.
const [grouped, setGrouped] = useState(() => {
try {
return localStorage.getItem("alerts.grouped") !== "0";
} catch {
return true;
}
});
const [open, setOpen] = useState<Set<string>>(new Set());
function chooseGrouped(on: boolean) {
setGrouped(on);
try {
localStorage.setItem("alerts.grouped", on ? "1" : "0");
} catch {
// a remembered choice is only a convenience
}
}
function load(refresh = false) {
setLoading(true);
@@ -69,18 +86,47 @@ export default function Alerts({ user }: { user: CurrentUser }) {
void load();
}, []);
const rows: Row[] = useMemo(() => {
if (!report) return [];
const { rows, childrenOf } = useMemo(() => {
const none = new Map<string, Row[]>();
if (!report) return { rows: [] as Row[], childrenOf: none };
const q = search.trim().toLowerCase();
return report.alerts
.filter((a) => (severity === "all" || a.severity === severity) && (category === "all" || a.category === category) && (showSilenced || !a.silenced))
const base: Row[] = report.alerts
.filter((a) => (severity === "all" || a.severity === severity) && (category === "all" || a.category === category))
.filter((a) => {
const on = !!a.ack?.active;
return attention === "all" || (attention === "unacknowledged" ? !on : attention === "acknowledged" ? on : on && a.ack?.assignee?.id === user.id);
})
.filter((a) => !q || [a.message, a.source, CATEGORY_LABELS[a.category]].some((v) => v.toLowerCase().includes(q)))
.map((a) => ({ ...a, rank: SEVERITY[a.severity].rank }));
}, [report, severity, category, search, showSilenced, attention, user.id]);
// An alert held back by another is nested under it when that one is on the list too; otherwise it stands on its own.
const ids = new Set(base.map((a) => a.id));
const children = new Map<string, Row[]>();
const nested = new Set<string>();
if (grouped) {
for (const a of base) {
const parent = a.causedBy?.alertId;
if (parent && parent !== a.id && ids.has(parent)) {
children.set(parent, [...(children.get(parent) ?? []), a]);
nested.add(a.id);
}
}
}
return { rows: base.filter((a) => !nested.has(a.id) && (showSilenced || !a.silenced)), childrenOf: children };
}, [report, severity, category, search, showSilenced, attention, user.id, grouped]);
// One line on where things stand: how many need someone, and which problems explain the rest.
const headline = useMemo(() => {
if (!report || report.alerts.length === 0) return null;
const standing = report.alerts.filter((a) => !a.silenced);
const acknowledged = standing.filter((a) => a.ack?.active).length;
const held = report.alerts.filter((a) => a.causedBy).length;
const roots = standing
.filter((a) => (a.affects?.length ?? 0) > 0)
.map((a) => ({ name: a.target?.name ?? a.source, count: report.alerts.filter((x) => x.causedBy?.alertId === a.id).length }))
.filter((r) => r.count > 0);
const critical = standing.some((a) => a.severity === "critical");
return { standing: standing.length, acknowledged, held, roots, tone: standing.length === 0 ? "green" : critical ? "red" : "yellow" };
}, [report]);
// No initial sort: the server already puts active problems first, worst first.
const { sorted, sortKey, sortDir, requestSort } = useSortable(rows);
@@ -143,6 +189,33 @@ export default function Alerts({ user }: { user: CurrentUser }) {
{report && (
<>
{headline && (
<div className={`card mb-3 alerts-headline alerts-headline-${headline.tone}`} role="status">
<div className="card-body py-3">
<div className="h3 mb-1">
{headline.standing === 0 ? "Nothing needs attention" : `${headline.standing} ${headline.standing === 1 ? "problem needs" : "problems need"} attention`}
{headline.acknowledged > 0 && headline.standing > 0 && <span className="text-secondary fw-normal fs-4"> · {headline.acknowledged} acknowledged</span>}
</div>
{headline.held > 0 && (
<div className="text-secondary">
{headline.held} more {headline.held === 1 ? "is" : "are"} held back because something they depend on is down
{headline.roots.length > 0 && (
<>
{" "}
— {headline.roots.map((r, i) => (
<span key={r.name}>
{i > 0 && ", "}
<strong>{r.name}</strong> accounts for {r.count}
</span>
))}
</>
)}
.
</div>
)}
</div>
</div>
)}
<div className="row g-3 mb-3">
{cards.map((c) => (
<div className="col-6 col-md-3" key={c.label}>
@@ -220,6 +293,12 @@ export default function Alerts({ user }: { user: CurrentUser }) {
<option value="mine">Handed to me</option>
</select>
)}
{(counts?.grouped ?? 0) > 0 && (
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={grouped} onChange={(e) => chooseGrouped(e.target.checked)} />
<span className="form-check-label">Group under their cause</span>
</label>
)}
{(counts?.silenced ?? 0) + (counts?.grouped ?? 0) > 0 && (
<label className="form-check mb-0">
<input type="checkbox" className="form-check-input" checked={showSilenced} onChange={(e) => setShowSilenced(e.target.checked)} />
@@ -246,7 +325,8 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</thead>
<tbody>
{(pageItems ?? []).map((a) => (
<tr key={a.id} className={a.silenced ? "text-secondary" : undefined} style={a.silenced ? { opacity: 0.65 } : undefined}>
<Fragment key={a.id}>
<tr className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`} style={a.silenced ? { opacity: 0.65 } : undefined}>
<td>
<span className={`badge ${SEVERITY[a.severity].badge}`}>{SEVERITY[a.severity].label}</span>
</td>
@@ -288,9 +368,26 @@ export default function Alerts({ user }: { user: CurrentUser }) {
)}
{a.affects && a.affects.length > 0 && (
<div className="text-secondary small">
Also takes down {a.affects.length} {a.affects.length === 1 ? "server" : "servers"}: {a.affects.join(", ")}
Also takes down {a.affects.length} {a.affects.length === 1 ? "thing" : "things"}: {a.affects.join(", ")}
</div>
)}
{(childrenOf.get(a.id)?.length ?? 0) > 0 && (
<button
type="button"
className="btn btn-link btn-sm p-0 mt-1"
aria-expanded={open.has(a.id)}
onClick={() =>
setOpen((prev) => {
const next = new Set(prev);
if (next.has(a.id)) next.delete(a.id);
else next.add(a.id);
return next;
})
}
>
{open.has(a.id) ? "Hide" : "Show"} the {childrenOf.get(a.id)!.length} {childrenOf.get(a.id)!.length === 1 ? "alert" : "alerts"} held back under this
</button>
)}
{a.ticket &&
(() => {
const label = a.ticket.number ? `Ticket #${a.ticket.number}` : "Ticket opened";
@@ -320,6 +417,21 @@ export default function Alerts({ user }: { user: CurrentUser }) {
</td>
)}
</tr>
{open.has(a.id) &&
(childrenOf.get(a.id) ?? []).map((c) => (
<tr key={c.id} className="alert-row alert-row-child text-secondary">
<td>
<span className={`badge ${SEVERITY[c.severity].badge}`}>{SEVERITY[c.severity].label}</span>
</td>
<td>{CATEGORY_LABELS[c.category]}</td>
<td>{c.link ? <Link to={c.link}>{c.source}</Link> : c.source}</td>
<td colSpan={canSilence ? 2 : 1}>
<span aria-hidden="true">↳ </span>
{c.message}
</td>
</tr>
))}
</Fragment>
))}
{(sorted ?? []).length === 0 && (
<tr>
+12 -2
View File
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import ImpactNote from "../components/ImpactNote";
import {
api,
type CurrentUser,
@@ -46,6 +47,8 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
const [aliasBusy, setAliasBusy] = useState(false);
const [aliasError, setAliasError] = useState<string | null>(null);
const [targets, setTargets] = useState<MaintenanceTargets | null>(null);
// Whether what depends on the chosen target is silenced along with it (offered once the target is known to have dependents).
const [withDependents, setWithDependents] = useState(true);
const [error, setError] = useState<string | null>(null);
const [now, setNow] = useState(() => Date.now());
@@ -144,15 +147,17 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
setError(null);
setBusy(true);
try {
await api.maintenance.start({
const res = await api.maintenance.start({
targetType: targetType as MaintenanceTargetType,
targetId: Number(id),
minutes,
reason: reason.trim() || undefined,
withDependents: withDependents || undefined,
});
setTarget("");
setReason("");
toast.success("Maintenance started. Alerts for it are silenced until it ends.");
const also = res.alsoSilenced?.length ?? 0;
toast.success(also > 0 ? `Maintenance started, and on ${also} thing${also === 1 ? "" : "s"} that depend on it. Alerts for them are silenced until it ends.` : "Maintenance started. Alerts for it are silenced until it ends.");
load();
announceChange();
} catch (err) {
@@ -316,6 +321,11 @@ export default function Maintenance({ user }: { user: CurrentUser }) {
onChange={(e) => setReason(e.target.value)}
/>
</div>
{(target.startsWith("server:") || target.startsWith("integration:")) && (
<div className="col-12">
<ImpactNote targets={[{ type: target.split(":")[0], id: Number(target.split(":")[1]) }]} silence={{ value: withDependents, onChange: setWithDependents }} />
</div>
)}
</div>
<div className="card-footer">
<button type="submit" className="btn btn-primary" disabled={busy || !target}>
+54 -12
View File
@@ -1,5 +1,6 @@
import { useEffect, useMemo, useState } from "react";
import { Link } from "react-router-dom";
import { Link, useSearchParams } from "react-router-dom";
import DependencyMap from "../components/DependencyMap";
import { api, type MapData, type MapNode } from "../api/client";
import { ErrorNotice } from "../components/Notice";
import { PageSkeleton } from "../components/Skeleton";
@@ -75,6 +76,48 @@ function layout(data: MapData): { placed: Map<string, Placed>; width: number; he
/** 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 [params, setParams] = useSearchParams();
const view = params.get("view") === "dependencies" ? "dependencies" : "connections";
const choose = (v: "connections" | "dependencies") =>
setParams(
(prev) => {
const next = new URLSearchParams(prev);
if (v === "connections") next.delete("view");
else next.set("view", v);
return next;
},
{ replace: true },
);
return (
<>
<div className="d-flex flex-wrap align-items-center gap-2 mb-1">
<h2 className="page-title mb-0">Map</h2>
<div className="btn-group ms-auto" role="group" aria-label="What to draw">
<button type="button" className={`btn btn-sm ${view === "connections" ? "active" : ""}`} aria-pressed={view === "connections"} onClick={() => choose("connections")}>
Connections
</button>
<button type="button" className={`btn btn-sm ${view === "dependencies" ? "active" : ""}`} aria-pressed={view === "dependencies"} onClick={() => choose("dependencies")}>
Dependencies
</button>
</div>
</div>
{view === "connections" ? (
<ConnectionsMap />
) : (
<>
<p className="text-secondary">
What needs what: a server that runs on another, a service that needs the server it is installed on. Pick a box to see what would go down with it before you reboot it.{" "}
<Link to="/dependencies">Edit dependencies</Link>
</p>
<DependencyMap />
</>
)}
</>
);
}
function ConnectionsMap() {
const [data, setData] = useState<MapData | null>(null);
const [error, setError] = useState<string | null>(null);
const [focus, setFocus] = useState<string | null>(null);
@@ -86,7 +129,7 @@ export default function MapPage() {
.catch((err) => setError(readableError(err)));
}, []);
const view = useMemo(() => (data ? layout(data) : null), [data]);
const drawing = useMemo(() => (data ? layout(data) : null), [data]);
const lit = useMemo(() => {
if (!data || !focus) return null;
const set = new Set<string>([focus]);
@@ -99,7 +142,6 @@ export default function MapPage() {
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.
@@ -111,22 +153,22 @@ export default function MapPage() {
</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 && (
{data && drawing && data.nodes.length === 0 && <div className="card"><div className="card-body text-secondary">Nothing to draw yet — add a server first.</div></div>}
{data && drawing && 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 className="map-columns" style={{ width: drawing.width }}>
{drawing.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">
<div className="map-canvas" style={{ width: drawing.width, height: drawing.height }}>
<svg className="map-lines" width={drawing.width} height={drawing.height} aria-hidden="true">
{data.edges.map((e) => {
const a = view.placed.get(e.from);
const b = view.placed.get(e.to);
const a = drawing.placed.get(e.from);
const b = drawing.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];
@@ -139,7 +181,7 @@ export default function MapPage() {
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) => {
{[...drawing.placed.values()].map((n) => {
const dim = lit && !lit.has(n.id);
const body = (
<>
+77
View File
@@ -1536,3 +1536,80 @@ html[data-density="roomy"] .table > :not(caption) > * > * {
margin: 0 !important;
}
}
/* ── The dependency map: what would go down with the box that is picked (red) and what it relies on (blue). ── */
button.map-node {
font: inherit;
cursor: pointer;
}
button.map-node:hover,
button.map-node:focus-visible {
border-color: var(--tblr-primary, #2563eb);
}
.map-node.map-active {
border-color: var(--tblr-primary, #2563eb);
box-shadow: 0 0 0 2px var(--tblr-primary, #2563eb);
}
.map-node.map-down {
border-color: #e05252;
box-shadow: 0 0 0 1px #e05252;
}
.map-node.map-up {
border-color: #4299e1;
box-shadow: 0 0 0 1px #4299e1;
}
.map-edge.map-edge-down {
stroke: #e05252;
stroke-opacity: 0.9;
stroke-width: 2.2;
}
.map-edge.map-edge-up {
stroke: #4299e1;
stroke-opacity: 0.9;
stroke-width: 2.2;
}
/* ── The Alerts page: a headline on where things stand, a coloured edge by severity, and held-back alerts nested under their cause. ── */
.alerts-headline {
border-left: 4px solid var(--tblr-border-color);
}
.alerts-headline-red {
border-left-color: #e05252;
}
.alerts-headline-yellow {
border-left-color: #f0a82c;
}
.alerts-headline-green {
border-left-color: #2fb344;
}
tr.alert-row > td:first-child {
box-shadow: inset 3px 0 0 transparent;
}
tr.alert-row-critical > td:first-child {
box-shadow: inset 3px 0 0 #e05252;
}
tr.alert-row-warning > td:first-child {
box-shadow: inset 3px 0 0 #f0a82c;
}
tr.alert-row-child > td {
background: var(--tblr-bg-surface-secondary, transparent);
font-size: 0.9em;
}
tr.alert-row-child > td:first-child {
box-shadow: none;
padding-left: 1.5rem;
}