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:
1 parent
ec9c2f73f0
commit
9caa414829
19 files changed
+944
-40
No files matched your search
+54
-12
@@ -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 = (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user