Put alert rules, service levels, notifications and alert tickets on one Alert settings page, in four tabs

Old addresses (/alert-rules, /service-levels, /settings/notifications) lead to the right tab.
Notifications and Alert tickets stay administrator-only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-11-03 20:38:15 +01:00
1 parent 07ce2b0305
commit 4269213275
40 files changed
+212 -188

No files matched your search

+1 -1
View File
@@ -239,7 +239,7 @@ export function agendaFromData(data: AgendaData, now: Date, tz: string, days: nu
day(`renewal:${r.id}`, "renewal", r.nextRenewal, () => ({ title: `${r.name} is billed — ${money}`, link: "/costs" }));
}
// A restore test is due a set time after the last good one — only if a time limit is set (Settings → Notifications).
// A restore test is due a set time after the last good one — only if a time limit is set (Alert settings → Notifications).
if (data.restoreLimitDays > 0) {
for (const t of data.restoreTests) {
if ((t.result !== "ok" && t.result !== "partial") || !isYmd(t.testedAt)) continue;
+1 -1
View File
@@ -1,6 +1,6 @@
/**
* The links behind buttons on a notification (see services/alertActions.ts for what they do): Acknowledge, Silence for an hour, Snooze until tomorrow morning — from the phone push, an ntfy message, a link in an email or a Gotify message,
* without signing in to the app. A switch an administrator turns on (Settings → Notifications → Who hears what); off, no link works.
* without signing in to the app. A switch an administrator turns on (Alert settings → Notifications → Who hears what); off, no link works.
*
* What makes it safe enough to have is how little each link can do:
*
+3 -3
View File
@@ -74,15 +74,15 @@ export function mostWithin(times: number[], windowMs: number): number {
/** What to try, from the kind of alert and the key it has. Plain advice; nothing it says is done for anyone. */
export function hintFor(category: string, alertId: string): string {
const key = keyOfAlertId(alertId, category);
if (key.startsWith("rule:")) return "A limit of your own (Monitoring → Alert rules): if it keeps coming back, raise the limit or make it hold for longer before it raises.";
if (key.startsWith("rule:")) return "A limit of your own (Alert settings → Alert rules): if it keeps coming back, raise the limit or make it hold for longer before it raises.";
if (key.startsWith("new-port:")) return "If this port should be listening, mark it as expected on the server's Ports card.";
if (key.startsWith("heartbeat")) return "If the job is just sometimes late, give its heartbeat more grace; if it fails, look at what it printed.";
if (key.startsWith("endpoint:")) return "Raise “Alert after … failures in a row” on the check, or its timeout or interval — or fix what is making it fail.";
if (key.startsWith("endpoint-cert:")) return "Renew the certificate, or lower how early the check warns.";
if (key.startsWith("failed-units:")) return "If a service is expected to fail, add it to “Services to ignore” on the server's Host health card; otherwise fix the service.";
if (key.startsWith("disk-forecast:") || category === "disk") return "Raise the limit for this disk (a server can have its own, per disk), or leave it alone on the server's page if it is meant to be full.";
if (category === "offline") return "If the server is just slow to report, raise “Server offline after” under Settings → Notifications, or give this server its own limit.";
if (category === "integration") return "Raise “Alert after … consecutive failures” under Settings → Notifications; the Call log (Integrations) shows what is failing.";
if (category === "offline") return "If the server is just slow to report, raise “Server offline after” under Alert settings → Notifications, or give this server its own limit.";
if (category === "integration") return "Raise “Alert after … consecutive failures” under Alert settings → Notifications; the Call log (Integrations) shows what is failing.";
if (category === "backup") return "A guest that is backed up late each time may need its “too old” limit raised on its server, or its job moved.";
return "Acknowledge it with a note, silence it with maintenance while you work on it, or fix what raises it.";
}
+1 -1
View File
@@ -360,7 +360,7 @@ export async function sendTestTicket(actor: CurrentUser): Promise<CreatedTicket>
topicId: settings.topicId,
priorityId: settings.priorityId,
subject: "[Homelab] Test ticket from Homelab Manager",
message: `This is a test. ${actor.name ?? actor.email ?? "An administrator"} asked Homelab Manager to open it from Settings → Notifications → Alert tickets, to check that tickets can be created here.\n\nNothing is wrong. You can close this ticket.\n\n${absolute("/settings/alert-tickets")}`,
message: `This is a test. ${actor.name ?? actor.email ?? "An administrator"} asked Homelab Manager to open it from Alert settings → Alert tickets, to check that tickets can be created here.\n\nNothing is wrong. You can close this ticket.\n\n${absolute("/settings/alert-tickets")}`,
});
await recordAudit({ actor, category: "alert_ticket", action: "test", targetType: "integration", targetId: settings.integrationId ?? undefined, detail: { ticket: created.number } });
return created;
+1 -1
View File
@@ -73,7 +73,7 @@ const SOURCES: Record<string, { label: string; link: string }> = {
npm: { label: "Nginx Proxy Manager", link: "/proxy-hosts" },
homeassistant: { label: "Home Assistant", link: "/home-assistant" },
ups: { label: "UPS", link: "/ups" },
slo: { label: "Service level", link: "/service-levels" },
slo: { label: "Service level", link: "/alert-settings?view=levels" },
duplicati: { label: "Duplicati", link: "/duplicati" },
jellyfin: { label: "Jellyfin", link: "/jellyfin" },
authentik: { label: "Authentik", link: "/authentik" },
+1 -1
View File
@@ -5,7 +5,7 @@
* Nothing here starts a scan: Dockhand scans when it is told to (by hand, after a pull, or for a whole host), and this only reads what it kept. So an image that was never scanned is
* not known to be clean — the page says how many of a host's images have a scan — and an environment whose summary could not be read is *unknown*, never *none*.
*
* What is raised is **critical** findings only (a host with one or more is a warning), and only while the setting for it is on (Settings → Notifications). Dockhand can also notify
* What is raised is **critical** findings only (a host with one or more is a warning), and only while the setting for it is on (Alert settings → Notifications). Dockhand can also notify
* about vulnerabilities itself; if both are switched on you hear twice.
*/
import { and, eq, notInArray } from "drizzle-orm";
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Event webhooks: tell another system when something happens. Each webhook is a URL with the events it wants; when one happens it is
* sent a JSON message, signed with the webhook's secret so the receiver can tell it came from here. This is separate from the chat-style
* webhook under Settings → Notifications, which carries the same sentence a person would read.
* webhook under Alert settings → Notifications, which carries the same sentence a person would read.
*
* alert.opened / alert.resolved a problem began or ended — on the same terms as a notification (a problem under maintenance,
* or folded under another, isn't announced until it stands alone)
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Restore tests: a backup nobody has ever restored is a hope, not a backup. Somebody records when they tried to restore a guest (or anything else
* — a share, a database) and how it went, and the app keeps the history, shows each guest's newest test beside its backups, and speaks up
* when a test failed (always) or when none has been done in too long (if a time limit is set under Settings → Notifications).
* when a test failed (always) or when none has been done in too long (if a time limit is set under Alert settings → Notifications).
*/
import { desc } from "drizzle-orm";
import { db } from "../db/client.js";
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Per-server alert thresholds. The ones in Settings → Notifications apply to every server; some machines are different — a NAS that sits at
* Per-server alert thresholds. The ones in Alert settings → Notifications apply to every server; some machines are different — a NAS that sits at
* 92% by design, a database host that should speak up at 80%, a laptop that is meant to be off at night. Each server may override the
* server-offline time, the disk-usage percentage, the disk forecast window and (for the Proxmox guest it is linked to) how old a backup may
* be, and may set a limit for one disk or say not to alert about that disk at all. Anything not overridden follows the global setting, so
+3 -3
View File
@@ -165,7 +165,7 @@ export interface MonthlyReportSettings {
time: string;
}
/** The weekly digest: one message a week through the notification channels. Off until an admin switches it on under Settings → Notifications. */
/** The weekly digest: one message a week through the notification channels. Off until an admin switches it on under Alert settings → Notifications. */
export interface DigestSettings {
enabled: boolean;
/** 0 = Sunday … 6 = Saturday, in notifications.timezone. */
@@ -235,7 +235,7 @@ export interface NameGeneratorSettings {
export type AlertTicketSeverity = "critical" | "warning" | "info";
/** Opening an osTicket ticket for an alert. Off until an admin sets it up under Settings → Notifications → Alert tickets. */
/** Opening an osTicket ticket for an alert. Off until an admin sets it up under Alert settings → Alert tickets. */
export interface AlertTicketSettings {
enabled: boolean;
/** The osTicket integration whose API (address and key) is used. */
@@ -397,7 +397,7 @@ function openValue(section: string, field: string, stored: unknown): unknown {
const name = `${section}.${field}`;
if (!warnedUnreadable.has(name)) {
warnedUnreadable.add(name);
console.warn(`Can't decrypt the stored ${name} — CREDENTIALS_ENCRYPTION_KEY has changed or is missing. Enter it again under Settings → Notifications.`);
console.warn(`Can't decrypt the stored ${name} — CREDENTIALS_ENCRYPTION_KEY has changed or is missing. Enter it again under Alert settings → Notifications.`);
}
return "";
}