Dependencies beyond servers, web push, inventory auto-fill with QR labels, Windows agent health
- Dependencies: servers and integrations can depend on each other; alerts are folded under the root cause, and a failure explained by something down isn't announced - Web push: hand-written VAPID and RFC 8291 encryption, per-device subscriptions, a fifth notification channel, service worker handlers - Inventory: maker/model/serial from the agents fill blank fields, "Refresh from agent", QR label printing and ?asset= deep links - Windows agent (v4) reports failed services, disk health, Storage Spaces pools and hardware identity; Linux agent (v5) reports hardware identity Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5cc51c57de
commit
ec9c2f73f0
55 files changed
+12553
-65
No files matched your search
@@ -32,6 +32,8 @@ import Updates from "./pages/Updates";
|
||||
import Incidents from "./pages/Incidents";
|
||||
import IncidentDetail from "./pages/IncidentDetail";
|
||||
import Inventory from "./pages/Inventory";
|
||||
import InventoryLabels from "./pages/InventoryLabels";
|
||||
import Dependencies from "./pages/Dependencies";
|
||||
import Backups from "./pages/Backups";
|
||||
import Domains from "./pages/Domains";
|
||||
import Consistency from "./pages/Consistency";
|
||||
@@ -147,6 +149,8 @@ function Shelled({ user }: { user: CurrentUser }) {
|
||||
<Route path="/maintenance" element={<Maintenance user={user} />} />
|
||||
<Route path="/updates" element={<Updates user={user} />} />
|
||||
<Route path="/inventory" element={<Inventory user={user} />} />
|
||||
<Route path="/inventory/labels" element={<InventoryLabels />} />
|
||||
<Route path="/dependencies" element={<Dependencies user={user} />} />
|
||||
<Route path="/backups" element={<Backups />} />
|
||||
<Route path="/docker" element={<Docker user={user} />} />
|
||||
<Route path="/tailscale" element={<Tailscale user={user} />} />
|
||||
|
||||
+48
-1
@@ -409,6 +409,22 @@ export interface WebhookSettings {
|
||||
secret: string;
|
||||
}
|
||||
|
||||
export interface WebPushSettings {
|
||||
enabled: boolean;
|
||||
/** An email address or https address a push service can reach whoever runs this on. Blank is fine. */
|
||||
contact: string;
|
||||
}
|
||||
|
||||
/** A browser or phone that has asked for push notifications. */
|
||||
export interface PushDevice {
|
||||
id: number;
|
||||
label: string | null;
|
||||
host: string;
|
||||
endpoint: string;
|
||||
createdAt: string;
|
||||
lastSuccessAt: string | null;
|
||||
}
|
||||
|
||||
export interface NotificationEvents {
|
||||
dnsAdd: boolean;
|
||||
dnsUpdate: boolean;
|
||||
@@ -473,6 +489,7 @@ export interface AppSettings {
|
||||
ntfy: NtfySettings;
|
||||
smtp: SmtpSettings;
|
||||
webhook: WebhookSettings;
|
||||
webPush: WebPushSettings;
|
||||
notifications: NotificationEvents;
|
||||
providerColors: Record<string, string>;
|
||||
integrationColors: Record<string, string>;
|
||||
@@ -760,6 +777,21 @@ export interface BackupCoverage {
|
||||
|
||||
export type AssetKind = "server" | "storage" | "network" | "power" | "client" | "other";
|
||||
|
||||
export type DependencyNodeType = "server" | "integration";
|
||||
export interface DependencyNode {
|
||||
key: string;
|
||||
type: DependencyNodeType;
|
||||
id: number;
|
||||
name: string;
|
||||
}
|
||||
export interface DependenciesResponse {
|
||||
/** "A needs B", written here. */
|
||||
dependencies: { id: number; from: { type: DependencyNodeType; id: number; name: string }; to: { type: DependencyNodeType; id: number; name: string }; createdAt: string }[];
|
||||
/** The "runs on" links of servers, set on the server itself. */
|
||||
runsOn: { from: { key: string; name: string }; to: { key: string; name: string } }[];
|
||||
nodes: DependencyNode[];
|
||||
}
|
||||
|
||||
/** A piece of hardware in the inventory. */
|
||||
export interface Asset {
|
||||
id: number;
|
||||
@@ -780,6 +812,8 @@ export interface Asset {
|
||||
updatedAt: string;
|
||||
/** The server it is, when it is one and that server still exists. */
|
||||
server: { id: number; name: string } | null;
|
||||
/** What that server's agent says the machine is, and the fields where that differs from what is written here. Null with no agent word. */
|
||||
agent: { manufacturer: string | null; model: string | null; serial: string | null; differs: { manufacturer?: string; model?: string; serial?: string } } | null;
|
||||
}
|
||||
|
||||
/** What an entry is saved from: blank text and nulls mean "no value". */
|
||||
@@ -1263,7 +1297,7 @@ export interface PrivacyOverview {
|
||||
tlsCertificateChecks: number;
|
||||
servers: number;
|
||||
serversWithAgent: number;
|
||||
channels: Record<"gotify" | "ntfy" | "smtp" | "webhook", { enabled: boolean; host: string | null }>;
|
||||
channels: Record<"gotify" | "ntfy" | "smtp" | "webhook" | "webPush", { enabled: boolean; host: string | null }>;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1651,11 +1685,24 @@ export const api = {
|
||||
backups: {
|
||||
coverage: (staleDays: number, refresh = false) => request<BackupCoverage>(`/api/backups/coverage?staleDays=${staleDays}${refresh ? "&refresh=1" : ""}`),
|
||||
},
|
||||
push: {
|
||||
key: () => request<{ publicKey: string }>("/api/push/key"),
|
||||
mine: () => request<{ enabled: boolean; subscriptions: PushDevice[] }>("/api/push/mine"),
|
||||
subscribe: (data: { endpoint: string; keys: { p256dh: string; auth: string }; label?: string }) => request<{ id: number }>("/api/push/subscribe", { method: "POST", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/push/${id}`, { method: "DELETE" }),
|
||||
test: () => request<{ sent: number; removed: number; failed: number }>("/api/push/test", { method: "POST" }),
|
||||
},
|
||||
dependencies: {
|
||||
list: () => request<DependenciesResponse>("/api/dependencies"),
|
||||
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" }),
|
||||
},
|
||||
inventory: {
|
||||
list: () => request<{ assets: Asset[]; config: InventoryConfig; servers: { id: number; name: string }[] }>("/api/inventory"),
|
||||
create: (data: AssetInput) => request<{ asset: Asset }>("/api/inventory", { method: "POST", body: JSON.stringify(data) }),
|
||||
update: (id: number, data: AssetInput) => request<{ asset: Asset }>(`/api/inventory/${id}`, { method: "PUT", body: JSON.stringify(data) }),
|
||||
remove: (id: number) => request<void>(`/api/inventory/${id}`, { method: "DELETE" }),
|
||||
refreshFromAgent: (id: number) => request<{ asset: Asset; changed: string[] }>(`/api/inventory/${id}/refresh-from-agent`, { method: "POST" }),
|
||||
setConfig: (data: InventoryConfig) => request<{ config: InventoryConfig }>("/api/inventory/config", { method: "PUT", body: JSON.stringify(data) }),
|
||||
},
|
||||
runbooks: {
|
||||
|
||||
@@ -6,7 +6,7 @@ const poolFine = (health: string) => health.toUpperCase() === "ONLINE";
|
||||
|
||||
/**
|
||||
* What the agent says about the machine itself: services that have failed, whether each disk's SMART check passes and how worn it is, and
|
||||
* whether each ZFS pool is online. Each part appears only if the agent reported it (no smartctl or no ZFS on the host means no part),
|
||||
* whether each storage pool (ZFS, or Storage Spaces on Windows) is online. Each part appears only if the agent reported it (no smartctl or no ZFS on the host means no part),
|
||||
* and the card is left out when it has nothing to say.
|
||||
*/
|
||||
export default function HostHealthCard({ health }: { health: HostHealth | null }) {
|
||||
@@ -88,7 +88,7 @@ export default function HostHealthCard({ health }: { health: HostHealth | null }
|
||||
|
||||
{hasZfs && (
|
||||
<div>
|
||||
<div className="text-secondary small mb-1">ZFS pools</div>
|
||||
<div className="text-secondary small mb-1">Storage pools (ZFS or Storage Spaces)</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-sm table-vcenter mb-0">
|
||||
<thead>
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { api, type PushDevice } from "../api/client";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const supported = typeof window !== "undefined" && "serviceWorker" in navigator && "PushManager" in window && "Notification" in window;
|
||||
|
||||
/** The key as the bytes `subscribe` wants. */
|
||||
function keyBytes(base64url: string): Uint8Array<ArrayBuffer> {
|
||||
const padded = base64url.replace(/-/g, "+").replace(/_/g, "/").padEnd(Math.ceil(base64url.length / 4) * 4, "=");
|
||||
const raw = atob(padded);
|
||||
const out = new Uint8Array(new ArrayBuffer(raw.length));
|
||||
for (let i = 0; i < raw.length; i++) out[i] = raw.charCodeAt(i);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** A short name for this browser, to tell the devices apart in the list. */
|
||||
function browserLabel(): string {
|
||||
const ua = navigator.userAgent;
|
||||
const browser = /Edg\//.test(ua) ? "Edge" : /Firefox\//.test(ua) ? "Firefox" : /Chrome\//.test(ua) ? "Chrome" : /Safari\//.test(ua) ? "Safari" : "Browser";
|
||||
const os = /Android/.test(ua) ? "Android" : /iPhone|iPad/.test(ua) ? "iOS" : /Windows/.test(ua) ? "Windows" : /Mac OS/.test(ua) ? "macOS" : /Linux/.test(ua) ? "Linux" : "";
|
||||
return os ? `${browser} on ${os}` : browser;
|
||||
}
|
||||
|
||||
async function registration(): Promise<ServiceWorkerRegistration> {
|
||||
// (The production build registers the worker on load; a development server doesn't, so it is registered here if need be.)
|
||||
if (!(await navigator.serviceWorker.getRegistration("/"))) await navigator.serviceWorker.register("/sw.js");
|
||||
return navigator.serviceWorker.ready;
|
||||
}
|
||||
|
||||
/**
|
||||
* The browsers this person has asked to be notified on, and the button that makes this one of them. A browser can only be notified
|
||||
* when the page is served over https (or from localhost), and has to be asked by a click, so it can't be done for anyone.
|
||||
*/
|
||||
export default function PushDevices({ serverEnabled }: { serverEnabled: boolean }) {
|
||||
const [devices, setDevices] = useState<PushDevice[] | null>(null);
|
||||
const [thisEndpoint, setThisEndpoint] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [permission, setPermission] = useState<NotificationPermission>(supported ? Notification.permission : "denied");
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
setDevices((await api.push.mine()).subscriptions);
|
||||
if (supported) {
|
||||
const reg = await navigator.serviceWorker.getRegistration("/");
|
||||
setThisEndpoint((await reg?.pushManager.getSubscription())?.endpoint ?? null);
|
||||
}
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
void load();
|
||||
}, [load]);
|
||||
|
||||
async function subscribe() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const { publicKey } = await api.push.key();
|
||||
const result = await Notification.requestPermission();
|
||||
setPermission(result);
|
||||
if (result !== "granted") throw new Error("The browser wasn't allowed to show notifications. Allow them for this site in the browser's settings, then try again.");
|
||||
const reg = await registration();
|
||||
// A subscription made for another key (the server's was made again) is no use: start over.
|
||||
const existing = await reg.pushManager.getSubscription();
|
||||
if (existing) await existing.unsubscribe();
|
||||
const sub = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: keyBytes(publicKey) });
|
||||
const json = sub.toJSON();
|
||||
await api.push.subscribe({ endpoint: sub.endpoint, keys: { p256dh: json.keys?.p256dh ?? "", auth: json.keys?.auth ?? "" }, label: browserLabel() });
|
||||
toast.success("This browser will be notified.");
|
||||
await load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(d: PushDevice) {
|
||||
if (!(await confirmDialog({ title: "Stop notifying a browser", message: `Stop sending notifications to ${d.label || d.host}?`, confirmLabel: "Stop", danger: true }))) return;
|
||||
try {
|
||||
await api.push.remove(d.id);
|
||||
if (d.endpoint === thisEndpoint && supported) {
|
||||
const reg = await navigator.serviceWorker.getRegistration("/");
|
||||
await (await reg?.pushManager.getSubscription())?.unsubscribe();
|
||||
}
|
||||
await load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
async function test() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const r = await api.push.test();
|
||||
if (r.sent > 0) toast.success(`Sent to ${r.sent} browser${r.sent === 1 ? "" : "s"}.`);
|
||||
else setError("It could not be delivered. See the server's log for what the push service said.");
|
||||
await load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!serverEnabled) {
|
||||
return <div className="text-secondary small">Switch this on and save, and then each person can add the browsers they want to be notified on.</div>;
|
||||
}
|
||||
|
||||
const secure = typeof window !== "undefined" && window.isSecureContext;
|
||||
const thisSubscribed = thisEndpoint !== null && (devices ?? []).some((d) => d.endpoint === thisEndpoint);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="fw-bold mb-1">Your browsers</div>
|
||||
{!supported || !secure ? (
|
||||
<div className="alert alert-warning py-2">
|
||||
This browser can’t receive push notifications here. {secure ? "It doesn't support them." : "They need the page to be opened over https (or from localhost)."}
|
||||
</div>
|
||||
) : (
|
||||
<div className="d-flex gap-2 mb-2 flex-wrap">
|
||||
{!thisSubscribed && (
|
||||
<button type="button" className="btn btn-primary" onClick={() => void subscribe()} disabled={busy || permission === "denied"}>
|
||||
{busy ? "Working…" : "Notify this browser"}
|
||||
</button>
|
||||
)}
|
||||
{(devices?.length ?? 0) > 0 && (
|
||||
<button type="button" className="btn btn-outline-secondary" onClick={() => void test()} disabled={busy}>
|
||||
Send a test to my browsers
|
||||
</button>
|
||||
)}
|
||||
{permission === "denied" && <span className="text-secondary small align-self-center">Notifications are blocked for this site in the browser.</span>}
|
||||
</div>
|
||||
)}
|
||||
{error && <div className="text-danger small mb-2">{error}</div>}
|
||||
{devices && devices.length === 0 && <div className="text-secondary small">None yet.</div>}
|
||||
{devices && devices.length > 0 && (
|
||||
<ul className="list-unstyled mb-0">
|
||||
{devices.map((d) => (
|
||||
<li key={d.id} className="d-flex align-items-center gap-2 py-1">
|
||||
<span>{d.label || d.host}</span>
|
||||
{d.endpoint === thisEndpoint && <span className="badge bg-blue-lt text-blue">this browser</span>}
|
||||
<span className="text-secondary small">via {d.host}</span>
|
||||
<button type="button" className="btn btn-sm btn-outline-danger ms-auto" onClick={() => void remove(d)}>
|
||||
Remove
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { useMemo } from "react";
|
||||
import qrcode from "qrcode-generator";
|
||||
|
||||
/**
|
||||
* A QR code drawn as one SVG path, black on white with the quiet zone the scanners want. It takes its size from the box it is put in, and
|
||||
* is made here in the browser: what it says never leaves the page.
|
||||
*/
|
||||
export default function QrCode({ text, label }: { text: string; label: string }) {
|
||||
const { path, size } = useMemo(() => {
|
||||
const qr = qrcode(0, "M");
|
||||
qr.addData(text);
|
||||
qr.make();
|
||||
const n = qr.getModuleCount();
|
||||
let d = "";
|
||||
for (let r = 0; r < n; r++) {
|
||||
for (let c = 0; c < n; c++) {
|
||||
if (qr.isDark(r, c)) d += `M${c + 4} ${r + 4}h1v1h-1z`;
|
||||
}
|
||||
}
|
||||
return { path: d, size: n + 8 };
|
||||
}, [text]);
|
||||
|
||||
return (
|
||||
<svg viewBox={`0 0 ${size} ${size}`} role="img" aria-label={label} shapeRendering="crispEdges" style={{ display: "block", width: "100%", height: "100%" }}>
|
||||
<rect width={size} height={size} fill="#fff" />
|
||||
<path d={path} fill="#000" />
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
IconRefresh,
|
||||
IconDownload,
|
||||
IconBox,
|
||||
IconHierarchy2,
|
||||
IconShieldCheck,
|
||||
IconActivityHeartbeat,
|
||||
IconCopyCheck,
|
||||
@@ -76,6 +77,7 @@ export const NAV: NavEntry[] = [
|
||||
{ to: "/backups", label: "Backup coverage", icon: <IconCopyCheck size={20} /> },
|
||||
{ to: "/map", label: "Map", icon: <IconSitemap size={20} /> },
|
||||
{ to: "/inventory", label: "Inventory", icon: <IconBox size={20} /> },
|
||||
{ to: "/dependencies", label: "Dependencies", icon: <IconHierarchy2 size={20} /> },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -336,7 +336,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
.get()
|
||||
.then((res) => {
|
||||
const s = res.settings;
|
||||
setNotifyConfigured(s.gotify.enabled || s.ntfy.enabled || s.smtp.enabled || s.webhook.enabled);
|
||||
setNotifyConfigured(s.gotify.enabled || s.ntfy.enabled || s.smtp.enabled || s.webhook.enabled || !!s.webPush?.enabled);
|
||||
})
|
||||
.catch(() => setNotifyConfigured(null));
|
||||
api.users
|
||||
@@ -589,7 +589,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
{ 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: "notify", title: "Choose how you'll be told about problems", description: "Gotify, ntfy, email, a webhook or push to your phone, with the checks you want.", to: "/settings/notifications", action: "Set up", done: notifyConfigured === true },
|
||||
{ id: "people", title: "Let someone else in (optional)", description: "Others sign in with Authentik and appear under Users; you decide their role.", to: "/users", action: "Open Users", done: (userCount ?? 0) > 1 },
|
||||
];
|
||||
|
||||
|
||||
@@ -0,0 +1,199 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type CurrentUser, type DependenciesResponse, type DependencyNode } from "../api/client";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const TYPE_LABELS = { server: "Server", integration: "Integration" } as const;
|
||||
|
||||
const linkTo = (type: string, id: number) => (type === "server" ? `/servers/${id}` : "/integrations");
|
||||
|
||||
/** The options of a node picker, grouped by what they are. */
|
||||
function NodeSelect({ id, label, nodes, value, onChange }: { id: string; label: string; nodes: DependencyNode[]; value: string; onChange: (key: string) => void }) {
|
||||
return (
|
||||
<>
|
||||
<label className="form-label" htmlFor={id}>
|
||||
{label}
|
||||
</label>
|
||||
<select id={id} className="form-select" value={value} onChange={(e) => onChange(e.target.value)}>
|
||||
<option value="">— choose —</option>
|
||||
{(["server", "integration"] as const).map((type) => (
|
||||
<optgroup key={type} label={`${TYPE_LABELS[type]}s`}>
|
||||
{nodes
|
||||
.filter((n) => n.type === type)
|
||||
.map((n) => (
|
||||
<option key={n.key} value={n.key}>
|
||||
{n.name}
|
||||
</option>
|
||||
))}
|
||||
</optgroup>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* What needs what. When something is down, whatever depends on it is down too, and only the one that matters should raise the alarm — so the
|
||||
* alerts of the things that need it are folded under it, like a guest under its host.
|
||||
*/
|
||||
export default function Dependencies({ user }: { user: CurrentUser }) {
|
||||
const canEdit = user.role === "admin" || user.role === "operator";
|
||||
const [data, setData] = useState<DependenciesResponse | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [from, setFrom] = useState("");
|
||||
const [to, setTo] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
function load() {
|
||||
api.dependencies
|
||||
.list()
|
||||
.then(setData)
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}
|
||||
useEffect(load, []);
|
||||
|
||||
const parse = (key: string) => {
|
||||
const [type, id] = key.split(":");
|
||||
return { type: type as "server" | "integration", id: Number(id) };
|
||||
};
|
||||
|
||||
async function add(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!from || !to) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const f = parse(from);
|
||||
const t = parse(to);
|
||||
await api.dependencies.create({ fromType: f.type, fromId: f.id, toType: t.type, toId: t.id });
|
||||
toast.success("Saved.");
|
||||
setFrom("");
|
||||
setTo("");
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(d: DependenciesResponse["dependencies"][number]) {
|
||||
if (!(await confirmDialog({ title: "Remove a dependency", message: `${d.from.name} no longer needs ${d.to.name}?`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.dependencies.remove(d.id);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="d-flex align-items-center mb-3">
|
||||
<h2 className="page-title mb-0">Dependencies</h2>
|
||||
</div>
|
||||
<p className="text-secondary">
|
||||
Say what needs what: Gitea needs the server it is installed on; a Proxmox guest needs the Proxmox it runs on. When the thing that is needed is down, what needs it is down too — and its alert is
|
||||
held back under the first one on the Alerts page instead of adding to the noise. A service that was down for its own reasons still alerts once what it needs is back.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{canEdit && (
|
||||
<form className="card mb-3" onSubmit={add}>
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Add a dependency</h3>
|
||||
</div>
|
||||
<div className="card-body row g-3 align-items-end">
|
||||
<div className="col-md-5">
|
||||
<NodeSelect id="dep-from" label="This…" nodes={data?.nodes ?? []} value={from} onChange={setFrom} />
|
||||
</div>
|
||||
<div className="col-md-5">
|
||||
<NodeSelect id="dep-to" label="…needs this" nodes={(data?.nodes ?? []).filter((n) => n.key !== from)} value={to} onChange={setTo} />
|
||||
</div>
|
||||
<div className="col-md-2">
|
||||
<button type="submit" className="btn btn-primary w-100" disabled={busy || !from || !to}>
|
||||
{busy ? "Saving…" : "Add"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Written here</h3>
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>This</th>
|
||||
<th>needs</th>
|
||||
{canEdit && <th className="w-1">Actions</th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{data === null && !error && (
|
||||
<tr>
|
||||
<td colSpan={canEdit ? 3 : 2}>
|
||||
<BlockSkeleton lines={2} />
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
{data?.dependencies.map((d) => (
|
||||
<tr key={d.id}>
|
||||
<td>
|
||||
<Link to={linkTo(d.from.type, d.from.id)}>{d.from.name}</Link> <span className="text-secondary small">{TYPE_LABELS[d.from.type].toLowerCase()}</span>
|
||||
</td>
|
||||
<td>
|
||||
<Link to={linkTo(d.to.type, d.to.id)}>{d.to.name}</Link> <span className="text-secondary small">{TYPE_LABELS[d.to.type].toLowerCase()}</span>
|
||||
</td>
|
||||
{canEdit && (
|
||||
<td>
|
||||
<button className="btn btn-sm btn-outline-danger" onClick={() => void remove(d)}>
|
||||
Remove
|
||||
</button>
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
{data && data.dependencies.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={canEdit ? 3 : 2} className="text-secondary text-center">
|
||||
Nothing written yet.{canEdit ? " Add the first above." : ""}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{data && data.runsOn.length > 0 && (
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Servers that run on servers</h3>
|
||||
</div>
|
||||
<div className="card-body text-secondary small pb-0">These are set on each server (“runs on”), or worked out from the Proxmox node it is a guest of. They count here too.</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<tbody>
|
||||
{data.runsOn.map((r) => (
|
||||
<tr key={`${r.from.key}>${r.to.key}`}>
|
||||
<td>{r.from.name}</td>
|
||||
<td className="text-secondary">runs on</td>
|
||||
<td>{r.to.name}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -102,6 +102,9 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
|
||||
const [params, setParams] = useSearchParams();
|
||||
const kind = (KINDS as string[]).includes(params.get("kind") ?? "") ? (params.get("kind") as AssetKind) : "";
|
||||
// A scanned label comes here with ?asset=ID: that one piece of hardware is shown first.
|
||||
const focusId = /^\d+$/.test(params.get("asset") ?? "") ? Number(params.get("asset")) : null;
|
||||
const focused = focusId === null ? null : (assets ?? []).find((a) => a.id === focusId) ?? null;
|
||||
|
||||
function load() {
|
||||
api.inventory
|
||||
@@ -158,6 +161,19 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshFromAgent(a: Asset) {
|
||||
const d = a.agent?.differs ?? {};
|
||||
const lines = (Object.keys(d) as (keyof typeof d)[]).map((k) => `${k}: "${a[k] ?? ""}" becomes "${d[k]}"`);
|
||||
if (!(await confirmDialog({ title: "Take over what the agent says", message: `${a.name}: ${lines.join("; ")}.`, confirmLabel: "Replace" }))) return;
|
||||
try {
|
||||
await api.inventory.refreshFromAgent(a.id);
|
||||
toast.success("Updated from the agent.");
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
async function saveConfig(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
setError(null);
|
||||
@@ -180,6 +196,13 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
);
|
||||
}
|
||||
|
||||
// A name that is a server's name (or holds it) is probably that server.
|
||||
const suggestion = (() => {
|
||||
const n = draft?.name.trim().toLowerCase();
|
||||
if (!n) return null;
|
||||
return servers.find((s) => s.name.toLowerCase() === n) ?? servers.find((s) => s.name.length >= 3 && n.includes(s.name.toLowerCase())) ?? null;
|
||||
})();
|
||||
|
||||
const set = <K extends keyof Draft>(key: K, value: Draft[K]) => setDraft((d) => (d ? { ...d, [key]: value } : d));
|
||||
|
||||
const cards: { label: string; value: string; note?: string; color: string }[] = [
|
||||
@@ -198,14 +221,60 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
<>
|
||||
<div className="d-flex align-items-center mb-3">
|
||||
<h2 className="page-title mb-0">Inventory</h2>
|
||||
{canEdit && !draft && (
|
||||
<button className="btn btn-primary ms-auto" onClick={() => setDraft({ ...EMPTY })}>
|
||||
Add hardware
|
||||
</button>
|
||||
)}
|
||||
<div className="ms-auto d-flex gap-2">
|
||||
<Link to="/inventory/labels" className="btn">
|
||||
Print labels
|
||||
</Link>
|
||||
{canEdit && !draft && (
|
||||
<button className="btn btn-primary" onClick={() => setDraft({ ...EMPTY })}>
|
||||
Add hardware
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{focused && (
|
||||
<div className="card mb-3 border-primary">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">{focused.name}</h3>
|
||||
<div className="card-actions">
|
||||
<button className="btn btn-sm" onClick={() => setParams((p) => { const n = new URLSearchParams(p); n.delete("asset"); return n; }, { replace: true })}>
|
||||
Close
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
<dl className="row mb-0">
|
||||
{([
|
||||
["Kind", KIND_LABELS[focused.kind]],
|
||||
["Maker and model", [focused.manufacturer, focused.model].filter(Boolean).join(" ") || null],
|
||||
["Serial number", focused.serial],
|
||||
["Where", [focused.location, focused.rackUnit].filter(Boolean).join(" · ") || null],
|
||||
["Bought", focused.purchaseDate],
|
||||
["Warranty until", focused.warrantyUntil],
|
||||
["Power draw", focused.powerWatts === null ? null : `${focused.powerWatts} W`],
|
||||
["Notes", focused.notes],
|
||||
] as [string, string | null][]).map(([label, value]) => (
|
||||
<div className="col-md-6 d-flex" key={label}>
|
||||
<dt className="col-5 text-secondary fw-normal">{label}</dt>
|
||||
<dd className="col-7">{value ?? "—"}</dd>
|
||||
</div>
|
||||
))}
|
||||
{focused.server && (
|
||||
<div className="col-md-6 d-flex">
|
||||
<dt className="col-5 text-secondary fw-normal">Is the server</dt>
|
||||
<dd className="col-7">
|
||||
<Link to={`/servers/${focused.server.id}`}>{focused.server.name}</Link>
|
||||
</dd>
|
||||
</div>
|
||||
)}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{focusId !== null && assets !== null && !focused && <div className="alert alert-warning">That piece of hardware isn't in the inventory any more.</div>}
|
||||
|
||||
<div className="row row-cards mb-3">
|
||||
{cards.map((c) => (
|
||||
<div className="col-6 col-lg-3" key={c.label}>
|
||||
@@ -256,6 +325,15 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{draft.serverId === "" && suggestion && (
|
||||
<div className="form-hint small mt-1">
|
||||
Looks like <strong>{suggestion.name}</strong>.{" "}
|
||||
<button type="button" className="btn btn-link btn-sm p-0 align-baseline" onClick={() => set("serverId", String(suggestion.id))}>
|
||||
Link it
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
{draft.serverId !== "" && <div className="form-hint text-secondary small mt-1">Blank maker, model and serial number are filled in from the server's agent when you save.</div>}
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="inv-maker">
|
||||
@@ -398,6 +476,14 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
is <Link to={`/servers/${a.server.id}`}>{a.server.name}</Link>
|
||||
</div>
|
||||
)}
|
||||
{canEdit && a.agent && Object.keys(a.agent.differs).length > 0 && (
|
||||
<div className="small text-secondary">
|
||||
The agent says {Object.entries(a.agent.differs).map(([k, v]) => `${k === "manufacturer" ? "maker" : k === "serial" ? "serial number" : k} ${v}`).join(", ")}.{" "}
|
||||
<button type="button" className="btn btn-link btn-sm p-0 align-baseline" onClick={() => void refreshFromAgent(a)}>
|
||||
Refresh from agent
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>{KIND_LABELS[a.kind]}</td>
|
||||
<td>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type Asset } from "../api/client";
|
||||
import QrCode from "../components/QrCode";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { KIND_LABELS } from "../utils/inventory";
|
||||
|
||||
/** Label sizes, in millimetres, as they are stuck on: a rack-mount sticker, a standard address label, a larger one for a shelf. */
|
||||
const SIZES = {
|
||||
small: { label: "Small (50 × 25 mm)", w: 50, h: 25, qr: 21 },
|
||||
medium: { label: "Medium (70 × 35 mm)", w: 70, h: 35, qr: 29 },
|
||||
large: { label: "Large (90 × 50 mm)", w: 90, h: 50, qr: 42 },
|
||||
} as const;
|
||||
type SizeKey = keyof typeof SIZES;
|
||||
|
||||
/** What a label's code opens: that piece of hardware in the inventory. */
|
||||
export const labelUrl = (id: number) => `${window.location.origin}/inventory?asset=${id}`;
|
||||
|
||||
/**
|
||||
* Labels for the hardware, to print on a sheet of stickers (or plain paper and cut out): a QR code that opens the entry in the inventory,
|
||||
* and the name, what it is, its serial number and where it sits in words for when a phone isn't to hand.
|
||||
*/
|
||||
export default function InventoryLabels() {
|
||||
const [assets, setAssets] = useState<Asset[] | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [chosen, setChosen] = useState<Set<number>>(new Set());
|
||||
const [size, setSize] = useState<SizeKey>("medium");
|
||||
const [showBorder, setShowBorder] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
api.inventory
|
||||
.list()
|
||||
.then((res) => {
|
||||
setAssets(res.assets);
|
||||
setChosen(new Set(res.assets.map((a) => a.id)));
|
||||
})
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}, []);
|
||||
|
||||
const picked = useMemo(() => (assets ?? []).filter((a) => chosen.has(a.id)), [assets, chosen]);
|
||||
const dims = SIZES[size];
|
||||
|
||||
const toggle = (id: number) =>
|
||||
setChosen((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="d-flex align-items-center mb-3 no-print">
|
||||
<h2 className="page-title mb-0">Labels</h2>
|
||||
<div className="ms-auto d-flex gap-2">
|
||||
<Link to="/inventory" className="btn">
|
||||
Back to the inventory
|
||||
</Link>
|
||||
<button className="btn btn-primary" disabled={picked.length === 0} onClick={() => window.print()}>
|
||||
Print {picked.length} label{picked.length === 1 ? "" : "s"}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ErrorNotice error={error} />
|
||||
{/* The page's size is the label sheet's own: set here so the print dialog starts out right. */}
|
||||
<style>{`@media print { @page { margin: 8mm; } }`}</style>
|
||||
|
||||
<div className="row g-3 no-print mb-3">
|
||||
<div className="col-lg-4">
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<label className="form-label" htmlFor="label-size">
|
||||
Size
|
||||
</label>
|
||||
<select id="label-size" className="form-select mb-3" value={size} onChange={(e) => setSize(e.target.value as SizeKey)}>
|
||||
{(Object.keys(SIZES) as SizeKey[]).map((k) => (
|
||||
<option key={k} value={k}>
|
||||
{SIZES[k].label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<label className="form-check">
|
||||
<input type="checkbox" className="form-check-input" checked={showBorder} onChange={(e) => setShowBorder(e.target.checked)} />
|
||||
<span className="form-check-label">Draw a border (handy for cutting plain paper)</span>
|
||||
</label>
|
||||
<div className="text-secondary small mt-3">Each code opens the entry in the inventory, so whoever scans it must be signed in here. Printed sizes are exact only with "Scale: 100%" in the print dialog.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-lg-8">
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Which hardware</h3>
|
||||
<div className="card-actions btn-list">
|
||||
<button className="btn btn-sm" onClick={() => setChosen(new Set((assets ?? []).map((a) => a.id)))}>
|
||||
All
|
||||
</button>
|
||||
<button className="btn btn-sm" onClick={() => setChosen(new Set())}>
|
||||
None
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-body" style={{ maxHeight: "16rem", overflowY: "auto" }}>
|
||||
{assets === null && !error && <BlockSkeleton lines={3} />}
|
||||
{assets?.length === 0 && <div className="text-secondary">Nothing in the inventory yet.</div>}
|
||||
<div className="row">
|
||||
{assets?.map((a) => (
|
||||
<div className="col-md-6" key={a.id}>
|
||||
<label className="form-check">
|
||||
<input type="checkbox" className="form-check-input" checked={chosen.has(a.id)} onChange={() => toggle(a.id)} />
|
||||
<span className="form-check-label">
|
||||
{a.name} <span className="text-secondary small">{KIND_LABELS[a.kind]}</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="label-sheet" aria-label="Labels to print">
|
||||
{picked.map((a) => (
|
||||
<div key={a.id} className={`asset-label ${showBorder ? "asset-label-border" : ""}`} style={{ width: `${dims.w}mm`, height: `${dims.h}mm` }}>
|
||||
<div className="asset-label-qr" style={{ width: `${dims.qr}mm`, height: `${dims.qr}mm` }}>
|
||||
<QrCode text={labelUrl(a.id)} label={`Opens ${a.name} in the inventory`} />
|
||||
</div>
|
||||
<div className="asset-label-text">
|
||||
<div className="asset-label-name">{a.name}</div>
|
||||
{(a.manufacturer || a.model) && <div>{[a.manufacturer, a.model].filter(Boolean).join(" ")}</div>}
|
||||
{a.serial && <div>S/N {a.serial}</div>}
|
||||
{(a.location || a.rackUnit) && <div>{[a.location, a.rackUnit].filter(Boolean).join(" · ")}</div>}
|
||||
<div className="asset-label-id">#{a.id}</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import { formatAgo } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
|
||||
const CHANNEL_LABELS = { gotify: "Gotify", ntfy: "ntfy", smtp: "email (SMTP)", webhook: "webhook" } as const;
|
||||
const CHANNEL_LABELS = { gotify: "Gotify", ntfy: "ntfy", smtp: "email (SMTP)", webhook: "webhook", webPush: "web push" } as const;
|
||||
|
||||
/** SQLite timestamps ("2026-09-26 04:07:21") are UTC without a zone marker. */
|
||||
function parseTime(value: string): Date {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
type NtfySettings,
|
||||
type SmtpSettings,
|
||||
type WebhookSettings,
|
||||
type WebPushSettings,
|
||||
type NotificationEvents,
|
||||
type DigestSettings,
|
||||
type QuietHoursSettings,
|
||||
@@ -15,6 +16,7 @@ import {
|
||||
import { readableError } from "../../utils/errors";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
import PushDevices from "../../components/PushDevices";
|
||||
|
||||
const TIMEZONES = [
|
||||
"UTC",
|
||||
@@ -43,6 +45,7 @@ const DEFAULT_GOTIFY: GotifySettings = { enabled: false, url: "", token: "", pri
|
||||
const DEFAULT_NTFY: NtfySettings = { enabled: false, url: "https://ntfy.sh", topic: "", token: "", priority: 3 };
|
||||
const DEFAULT_SMTP: SmtpSettings = { enabled: false, host: "", port: 587, secure: false, username: "", password: "", from: "", to: "" };
|
||||
const DEFAULT_WEBHOOK: WebhookSettings = { enabled: false, url: "", secret: "" };
|
||||
const DEFAULT_WEBPUSH: WebPushSettings = { enabled: false, contact: "" };
|
||||
const DEFAULT_NOTIFICATIONS: NotificationEvents = {
|
||||
dnsAdd: true,
|
||||
dnsUpdate: true,
|
||||
@@ -219,6 +222,9 @@ export default function NotificationSettings() {
|
||||
const [ntfy, setNtfy] = useState<NtfySettings>(DEFAULT_NTFY);
|
||||
const [smtp, setSmtp] = useState<SmtpSettings>(DEFAULT_SMTP);
|
||||
const [webhook, setWebhook] = useState<WebhookSettings>(DEFAULT_WEBHOOK);
|
||||
const [webPush, setWebPush] = useState<WebPushSettings>(DEFAULT_WEBPUSH);
|
||||
// Whether push is on as saved: people can only add their browsers once the server knows it is on.
|
||||
const [webPushSaved, setWebPushSaved] = useState(false);
|
||||
const [notifications, setNotifications] = useState<NotificationEvents>(DEFAULT_NOTIFICATIONS);
|
||||
const [quietHours, setQuietHours] = useState<QuietHoursSettings>(DEFAULT_QUIET_HOURS);
|
||||
const [healthChecks, setHealthChecks] = useState<HealthCheckSettings>(DEFAULT_HEALTH_CHECKS);
|
||||
@@ -239,7 +245,7 @@ export default function NotificationSettings() {
|
||||
const [testingWebhook, setTestingWebhook] = useState(false);
|
||||
const [testWebhookResult, setTestWebhookResult] = useState<TestResult>(null);
|
||||
|
||||
const snapshot = JSON.stringify({ gotify, ntfy, smtp, webhook, notifications, quietHours, healthChecks, digest });
|
||||
const snapshot = JSON.stringify({ gotify, ntfy, smtp, webhook, webPush, notifications, quietHours, healthChecks, digest });
|
||||
const dirty = baseline !== null && snapshot !== baseline;
|
||||
|
||||
useEffect(() => {
|
||||
@@ -251,12 +257,15 @@ export default function NotificationSettings() {
|
||||
setNtfy(s.ntfy);
|
||||
setSmtp(s.smtp);
|
||||
setWebhook(s.webhook);
|
||||
const wp = s.webPush ?? DEFAULT_WEBPUSH;
|
||||
setWebPush(wp);
|
||||
setWebPushSaved(wp.enabled);
|
||||
setNotifications(s.notifications);
|
||||
setQuietHours(s.quietHours);
|
||||
setHealthChecks(s.healthChecks);
|
||||
const d = s.digest ?? DEFAULT_DIGEST;
|
||||
setDigest(d);
|
||||
setBaseline(JSON.stringify({ gotify: s.gotify, ntfy: s.ntfy, smtp: s.smtp, webhook: s.webhook, notifications: s.notifications, quietHours: s.quietHours, healthChecks: s.healthChecks, digest: d }));
|
||||
setBaseline(JSON.stringify({ gotify: s.gotify, ntfy: s.ntfy, smtp: s.smtp, webhook: s.webhook, webPush: wp, notifications: s.notifications, quietHours: s.quietHours, healthChecks: s.healthChecks, digest: d }));
|
||||
})
|
||||
.catch((err) => setLoadError(err instanceof Error ? err.message : String(err)))
|
||||
.finally(() => setLoading(false));
|
||||
@@ -303,8 +312,9 @@ export default function NotificationSettings() {
|
||||
setSaveError(null);
|
||||
setSaved(false);
|
||||
try {
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, notifications, quietHours, healthChecks, digest });
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, webPush, notifications, quietHours, healthChecks, digest });
|
||||
setBaseline(snapshot);
|
||||
setWebPushSaved(webPush.enabled);
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 3000);
|
||||
} catch (err) {
|
||||
@@ -412,7 +422,7 @@ export default function NotificationSettings() {
|
||||
const ntfyComplete = !!(ntfy.url && ntfy.topic);
|
||||
const smtpComplete = !!(smtp.host && smtp.from && smtp.to);
|
||||
const webhookComplete = !!webhook.url;
|
||||
const channelsOn = [gotify.enabled && gotifyComplete, ntfy.enabled && ntfyComplete, smtp.enabled && smtpComplete, webhook.enabled && webhookComplete].filter(Boolean).length;
|
||||
const channelsOn = [gotify.enabled && gotifyComplete, ntfy.enabled && ntfyComplete, smtp.enabled && smtpComplete, webhook.enabled && webhookComplete, webPush.enabled].filter(Boolean).length;
|
||||
|
||||
const toggle = (key: EventKey, label: string) => <EventToggle key={key} label={label} checked={notifications[key]} onChange={(on) => setNotifications((n) => ({ ...n, [key]: on }))} />;
|
||||
const dailyChecksEnabled = notifications.secretCheck || notifications.tailscaleKeyCheck || notifications.dockerUpdateCheck || notifications.proxmoxBackupCheck || notifications.pbsVerificationCheck || notifications.domainExpiryCheck;
|
||||
@@ -614,6 +624,30 @@ export default function NotificationSettings() {
|
||||
</button>
|
||||
<TestBadge result={testWebhookResult} />
|
||||
</ChannelRow>
|
||||
|
||||
<ChannelRow
|
||||
name="Phone and browser"
|
||||
description={<>Push notifications to a phone or browser that asks for them, with no app or account. They need this page to be opened over https.</>}
|
||||
enabled={webPush.enabled}
|
||||
onToggle={(on) => setWebPush((w) => ({ ...w, enabled: on }))}
|
||||
complete
|
||||
summary="Web push"
|
||||
open={openChannel === "webpush"}
|
||||
onOpen={() => setOpenChannel(openChannel === "webpush" ? null : "webpush")}
|
||||
>
|
||||
<div className="mb-3">
|
||||
<label className="form-label">Contact (optional)</label>
|
||||
<input
|
||||
className="form-control"
|
||||
maxLength={200}
|
||||
placeholder="you@example.com"
|
||||
value={webPush.contact}
|
||||
onChange={(e) => setWebPush((w) => ({ ...w, contact: e.target.value }))}
|
||||
/>
|
||||
<div className="form-hint text-secondary small">Given to the browsers’ push services (Google, Mozilla, Apple) so they can reach you if this misbehaves. An email address or an https address.</div>
|
||||
</div>
|
||||
<PushDevices serverEnabled={webPushSaved} />
|
||||
</ChannelRow>
|
||||
</div>
|
||||
|
||||
{/* ── What to send ── */}
|
||||
|
||||
@@ -1477,3 +1477,62 @@ html[data-density="roomy"] .table > :not(caption) > * > * {
|
||||
height: auto;
|
||||
color: var(--tblr-body-color);
|
||||
}
|
||||
|
||||
/* ── Labels for the hardware: cut out or stuck on, so they print alone, at their real size. ── */
|
||||
.label-sheet {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 3mm;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.asset-label {
|
||||
display: flex;
|
||||
gap: 2mm;
|
||||
padding: 2mm;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font-size: 7pt;
|
||||
line-height: 1.25;
|
||||
break-inside: avoid;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.asset-label-border {
|
||||
border: 0.3mm solid #000;
|
||||
}
|
||||
|
||||
.asset-label-qr {
|
||||
flex: none;
|
||||
}
|
||||
|
||||
.asset-label-text {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.asset-label-name {
|
||||
font-size: 9pt;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.asset-label-id {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
@media print {
|
||||
.no-print,
|
||||
.navbar-vertical {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.page-wrapper {
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
.page-body {
|
||||
margin: 0 !important;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user