The Start maintenance list gets a "Many at once" group: Everything, All servers, All integrations, All DNS providers (enabled ones only). Each target still gets its own window, existing ones are extended, and the action is one audit entry. "Everything" asks for confirmation first, and "End all" on the Active list ends every running window together. The top banner and the wall display summarise long lists instead of printing every name. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
708 lines
30 KiB
TypeScript
708 lines
30 KiB
TypeScript
import { useEffect, useState } from "react";
|
||
import {
|
||
api,
|
||
type CurrentUser,
|
||
type IntegrationSummary,
|
||
type MaintenanceAlias,
|
||
type MaintenanceBulkScope,
|
||
type MaintenanceTargets,
|
||
type MaintenanceTargetType,
|
||
type MaintenanceWindow,
|
||
type UptimeKumaImportResult,
|
||
type UptimeKumaSyncResult,
|
||
} from "../api/client";
|
||
import { formatDateTime } from "../utils/date";
|
||
import { formatRemaining } from "../utils/duration";
|
||
import { readableError } from "../utils/errors";
|
||
import { ErrorNotice } from "../components/Notice";
|
||
import { toast } from "../utils/toast";
|
||
import { confirmDialog } from "../utils/dialogs";
|
||
|
||
const DURATIONS: { minutes: number; label: string }[] = [
|
||
{ minutes: 30, label: "30 minutes" },
|
||
{ minutes: 60, label: "1 hour" },
|
||
{ minutes: 120, label: "2 hours" },
|
||
{ minutes: 240, label: "4 hours" },
|
||
{ minutes: 480, label: "8 hours" },
|
||
{ minutes: 1440, label: "24 hours" },
|
||
{ minutes: 4320, label: "3 days" },
|
||
];
|
||
|
||
// Tells the app shell's banner to refetch right away instead of waiting for its next poll.
|
||
function announceChange() {
|
||
window.dispatchEvent(new Event("maintenance-changed"));
|
||
}
|
||
|
||
export default function Maintenance({ user }: { user: CurrentUser }) {
|
||
const canEdit = user.role === "admin" || user.role === "operator";
|
||
const [windows, setWindows] = useState<MaintenanceWindow[] | null>(null);
|
||
const [upcoming, setUpcoming] = useState<MaintenanceWindow[]>([]);
|
||
const [aliases, setAliases] = useState<MaintenanceAlias[]>([]);
|
||
const [aliasAddress, setAliasAddress] = useState("");
|
||
const [aliasTarget, setAliasTarget] = useState("");
|
||
const [aliasBusy, setAliasBusy] = useState(false);
|
||
const [aliasError, setAliasError] = useState<string | null>(null);
|
||
const [targets, setTargets] = useState<MaintenanceTargets | null>(null);
|
||
const [error, setError] = useState<string | null>(null);
|
||
const [now, setNow] = useState(() => Date.now());
|
||
|
||
const [target, setTarget] = useState("");
|
||
const [minutes, setMinutes] = useState(60);
|
||
const [reason, setReason] = useState("");
|
||
const [busy, setBusy] = useState(false);
|
||
|
||
const [kumaIntegrations, setKumaIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||
const [kumaIntegrationId, setKumaIntegrationId] = useState<number | "">("");
|
||
const [kumaMinutes, setKumaMinutes] = useState(60);
|
||
const [kumaBusy, setKumaBusy] = useState(false);
|
||
const [kumaError, setKumaError] = useState<string | null>(null);
|
||
const [kumaResult, setKumaResult] = useState<UptimeKumaImportResult | null>(null);
|
||
const [syncBusy, setSyncBusy] = useState(false);
|
||
const [syncError, setSyncError] = useState<string | null>(null);
|
||
const [syncResult, setSyncResult] = useState<UptimeKumaSyncResult | null>(null);
|
||
|
||
useEffect(() => {
|
||
api.integrations
|
||
.list()
|
||
.then((res) => {
|
||
const found = res.integrations.filter((i) => i.type === "uptimekuma");
|
||
setKumaIntegrations(found);
|
||
const firstEnabled = found.find((i) => i.enabled);
|
||
if (firstEnabled) setKumaIntegrationId(firstEnabled.id);
|
||
})
|
||
.catch(() => setKumaIntegrations([]));
|
||
}, []);
|
||
|
||
function load() {
|
||
api.maintenance
|
||
.list()
|
||
.then((res) => {
|
||
setWindows(res.windows);
|
||
setUpcoming(res.upcoming ?? []);
|
||
setAliases(res.aliases ?? []);
|
||
setTargets(res.targets);
|
||
})
|
||
.catch((err) => setError(readableError(err)));
|
||
}
|
||
|
||
useEffect(() => {
|
||
load();
|
||
const tick = setInterval(() => setNow(Date.now()), 30_000);
|
||
return () => clearInterval(tick);
|
||
}, []);
|
||
|
||
async function startBulk(scope: MaintenanceBulkScope) {
|
||
const words = DURATIONS.find((d) => d.minutes === minutes)?.label ?? `${minutes} minutes`;
|
||
// Everything is the one choice that can hide a real outage, so it asks first.
|
||
if (
|
||
scope === "everything" &&
|
||
!(await confirmDialog({
|
||
title: "Silence everything?",
|
||
message: `This silences every alert about every server, integration and DNS provider for ${words}. Anything still wrong when it ends alerts then.`,
|
||
confirmLabel: "Silence everything",
|
||
danger: true,
|
||
}))
|
||
)
|
||
return;
|
||
setError(null);
|
||
setBusy(true);
|
||
try {
|
||
const res = await api.maintenance.startBulk({ scope, minutes, reason: reason.trim() || undefined });
|
||
setTarget("");
|
||
setReason("");
|
||
toast.success(`Maintenance started on ${res.total} item${res.total === 1 ? "" : "s"} for ${words}. End them all from the Active list.`);
|
||
load();
|
||
announceChange();
|
||
} catch (err) {
|
||
setError(readableError(err));
|
||
} finally {
|
||
setBusy(false);
|
||
}
|
||
}
|
||
|
||
async function endAll() {
|
||
if (!(await confirmDialog({ title: "End all maintenance", message: `End all ${windows?.length ?? 0} windows now? Alerts about them become active again.`, confirmLabel: "End all", danger: true }))) return;
|
||
setError(null);
|
||
try {
|
||
const res = await api.maintenance.endAll();
|
||
toast.success(`Ended ${res.ended} maintenance window${res.ended === 1 ? "" : "s"}. Alerts are active again.`);
|
||
load();
|
||
announceChange();
|
||
} catch (err) {
|
||
setError(readableError(err));
|
||
}
|
||
}
|
||
|
||
async function start(e: React.FormEvent) {
|
||
e.preventDefault();
|
||
if (target.startsWith("all:")) return startBulk(target.slice(4) as MaintenanceBulkScope);
|
||
const [targetType, id] = target.split(":");
|
||
if (!targetType || !id) return;
|
||
setError(null);
|
||
setBusy(true);
|
||
try {
|
||
await api.maintenance.start({
|
||
targetType: targetType as MaintenanceTargetType,
|
||
targetId: Number(id),
|
||
minutes,
|
||
reason: reason.trim() || undefined,
|
||
});
|
||
setTarget("");
|
||
setReason("");
|
||
toast.success("Maintenance started. Alerts for it are silenced until it ends.");
|
||
load();
|
||
announceChange();
|
||
} catch (err) {
|
||
setError(readableError(err));
|
||
} finally {
|
||
setBusy(false);
|
||
}
|
||
}
|
||
|
||
async function addAlias(e: React.FormEvent) {
|
||
e.preventDefault();
|
||
const [targetType, id] = aliasTarget.split(":");
|
||
if (!targetType || !id) return;
|
||
setAliasError(null);
|
||
setAliasBusy(true);
|
||
try {
|
||
await api.maintenance.addAlias({ address: aliasAddress.trim(), targetType: targetType as MaintenanceTargetType, targetId: Number(id) });
|
||
setAliasAddress("");
|
||
setAliasTarget("");
|
||
load();
|
||
} catch (err) {
|
||
setAliasError(readableError(err));
|
||
} finally {
|
||
setAliasBusy(false);
|
||
}
|
||
}
|
||
|
||
async function removeAlias(a: MaintenanceAlias) {
|
||
setAliasError(null);
|
||
try {
|
||
await api.maintenance.removeAlias(a.id);
|
||
load();
|
||
} catch (err) {
|
||
setAliasError(readableError(err));
|
||
}
|
||
}
|
||
|
||
async function end(w: MaintenanceWindow) {
|
||
setError(null);
|
||
try {
|
||
await api.maintenance.end(w.id);
|
||
toast.success(w.startedAt > new Date().toISOString() ? "Scheduled window cancelled." : "Maintenance ended. Alerts for it are active again.");
|
||
load();
|
||
announceChange();
|
||
} catch (err) {
|
||
setError(readableError(err));
|
||
}
|
||
}
|
||
|
||
async function syncFromUptimeKuma() {
|
||
if (kumaIntegrationId === "") return;
|
||
setSyncError(null);
|
||
setSyncResult(null);
|
||
setSyncBusy(true);
|
||
try {
|
||
const result = await api.maintenance.syncUptimeKuma({ integrationId: kumaIntegrationId });
|
||
setSyncResult(result);
|
||
load();
|
||
announceChange();
|
||
} catch (err) {
|
||
setSyncError(readableError(err));
|
||
} finally {
|
||
setSyncBusy(false);
|
||
}
|
||
}
|
||
|
||
async function importFromUptimeKuma(e: React.FormEvent) {
|
||
e.preventDefault();
|
||
if (kumaIntegrationId === "") return;
|
||
setKumaError(null);
|
||
setKumaResult(null);
|
||
setKumaBusy(true);
|
||
try {
|
||
const result = await api.maintenance.importUptimeKuma({ integrationId: kumaIntegrationId, minutes: kumaMinutes });
|
||
setKumaResult(result);
|
||
if (result.imported.length > 0) {
|
||
load();
|
||
announceChange();
|
||
}
|
||
} catch (err) {
|
||
setKumaError(readableError(err));
|
||
} finally {
|
||
setKumaBusy(false);
|
||
}
|
||
}
|
||
|
||
return (
|
||
<>
|
||
<h2 className="page-title mb-3">Maintenance</h2>
|
||
<div className="text-secondary mb-3">
|
||
Silence alerts about one server or integration while you work on it. Every window ends on its own — anything
|
||
still wrong when it ends alerts then, so nothing stays hidden.
|
||
</div>
|
||
<ErrorNotice error={error} />
|
||
|
||
{canEdit && (
|
||
<div className="card mb-3">
|
||
<div className="card-header">
|
||
<h3 className="card-title">Start maintenance</h3>
|
||
</div>
|
||
<form onSubmit={start}>
|
||
<div className="card-body row g-3">
|
||
<div className="col-md-4">
|
||
<label className="form-label">What are you working on?</label>
|
||
<select className="form-select" required value={target} onChange={(e) => setTarget(e.target.value)}>
|
||
<option value="">Choose…</option>
|
||
{targets && targets.servers.length + targets.integrations.length + targets.dnsProviders.length > 1 && (
|
||
<optgroup label="Many at once">
|
||
<option value="all:everything">Everything — every server, integration and DNS provider</option>
|
||
{targets.servers.length > 1 && <option value="all:servers">All servers ({targets.servers.length})</option>}
|
||
{targets.integrations.length > 1 && <option value="all:integrations">All integrations (the enabled ones)</option>}
|
||
{targets.dnsProviders.length > 1 && <option value="all:dns_providers">All DNS providers (the enabled ones)</option>}
|
||
</optgroup>
|
||
)}
|
||
{targets && targets.servers.length > 0 && (
|
||
<optgroup label="Servers">
|
||
{targets.servers.map((s) => (
|
||
<option key={`s${s.id}`} value={`server:${s.id}`}>
|
||
{s.name}
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
{targets && targets.integrations.length > 0 && (
|
||
<optgroup label="Integrations">
|
||
{targets.integrations.map((i) => (
|
||
<option key={`i${i.id}`} value={`integration:${i.id}`}>
|
||
{i.name} ({i.type})
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
{targets && targets.dnsProviders.length > 0 && (
|
||
<optgroup label="DNS providers">
|
||
{targets.dnsProviders.map((p) => (
|
||
<option key={`d${p.id}`} value={`dns_provider:${p.id}`}>
|
||
{p.name} ({p.providerType})
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
</select>
|
||
</div>
|
||
<div className="col-md-3">
|
||
<label className="form-label">For</label>
|
||
<select className="form-select" value={minutes} onChange={(e) => setMinutes(Number(e.target.value))}>
|
||
{DURATIONS.map((d) => (
|
||
<option key={d.minutes} value={d.minutes}>
|
||
{d.label}
|
||
</option>
|
||
))}
|
||
</select>
|
||
</div>
|
||
<div className="col-md-5">
|
||
<label className="form-label">Reason (optional)</label>
|
||
<input
|
||
className="form-control"
|
||
maxLength={200}
|
||
placeholder="e.g. kernel update and reboot"
|
||
value={reason}
|
||
onChange={(e) => setReason(e.target.value)}
|
||
/>
|
||
</div>
|
||
</div>
|
||
<div className="card-footer">
|
||
<button type="submit" className="btn btn-primary" disabled={busy || !target}>
|
||
{busy ? "Starting…" : "Start maintenance"}
|
||
</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
)}
|
||
|
||
{canEdit && kumaIntegrations && kumaIntegrations.length > 0 && (
|
||
<div className="card mb-3">
|
||
<div className="card-header">
|
||
<h3 className="card-title">Import from Uptime Kuma</h3>
|
||
</div>
|
||
<form onSubmit={importFromUptimeKuma}>
|
||
<div className="card-body row g-3">
|
||
<div className="text-secondary">
|
||
<strong>Sync schedule</strong> copies Uptime Kuma's maintenance windows — the one running now and the
|
||
next one of each daily, weekly or one-off window — onto the servers their monitors belong to, so they
|
||
show up under Scheduled below and silence alerts when they start. It needs the login username and
|
||
password filled in on the integration, and runs by itself every 15 minutes when{" "}
|
||
<em>Keep maintenance windows in step</em> is ticked there.
|
||
</div>
|
||
<div className="text-secondary">
|
||
<strong>Import now</strong> only looks at what is in maintenance <em>this moment</em>: pick a duration
|
||
— it doesn't have to match Uptime Kuma's own schedule exactly, and importing again later just extends
|
||
the window instead of stacking a second one.
|
||
</div>
|
||
{kumaIntegrations.length > 1 && (
|
||
<div className="col-md-5">
|
||
<label className="form-label">Uptime Kuma integration</label>
|
||
<select
|
||
className="form-select"
|
||
value={kumaIntegrationId}
|
||
onChange={(e) => setKumaIntegrationId(e.target.value ? Number(e.target.value) : "")}
|
||
>
|
||
{kumaIntegrations.map((i) => (
|
||
<option key={i.id} value={i.id} disabled={!i.enabled}>
|
||
{i.name}
|
||
{!i.enabled ? " — disabled" : ""}
|
||
</option>
|
||
))}
|
||
</select>
|
||
</div>
|
||
)}
|
||
<div className="col-md-3">
|
||
<label className="form-label">For</label>
|
||
<select className="form-select" value={kumaMinutes} onChange={(e) => setKumaMinutes(Number(e.target.value))}>
|
||
{DURATIONS.map((d) => (
|
||
<option key={d.minutes} value={d.minutes}>
|
||
{d.label}
|
||
</option>
|
||
))}
|
||
</select>
|
||
</div>
|
||
</div>
|
||
{syncError && (
|
||
<div className="card-body pt-0">
|
||
<div className="alert alert-danger mb-0">{syncError}</div>
|
||
</div>
|
||
)}
|
||
{syncResult && (
|
||
<div className="card-body pt-0">
|
||
<div className={`alert ${syncResult.started + syncResult.updated + syncResult.removed > 0 ? "alert-success" : "alert-info"} mb-0`}>
|
||
{syncResult.maintenances.length === 0
|
||
? "Uptime Kuma has no maintenance windows."
|
||
: `Read ${syncResult.maintenances.length} maintenance window${syncResult.maintenances.length === 1 ? "" : "s"} from Uptime Kuma: ${syncResult.started} added, ${syncResult.updated} changed, ${syncResult.removed} removed here.`}
|
||
<ul className="mb-0 mt-2">
|
||
{syncResult.maintenances.map((m) => (
|
||
<li key={m.id}>
|
||
<strong>{m.title}</strong>{" "}
|
||
<span className="text-secondary">
|
||
({m.strategy}, {m.status})
|
||
</span>
|
||
{m.targets.length > 0 ? ` → ${m.targets.map((t) => `${t.name} (${t.type === "dns_provider" ? "DNS provider" : t.type})`).join(", ")}` : m.note ? ` — nothing to schedule: ${m.note}` : ""}
|
||
{m.unmatched.length > 0 && <span className="text-secondary"> · nothing here for {m.unmatched.join(", ")}</span>}
|
||
{m.unmatched.length > 0 && (
|
||
<div className="text-secondary small">
|
||
Is one of those yours? Add its address under <em>Address aliases</em> below, saying what it belongs to.
|
||
</div>
|
||
)}
|
||
<div className="text-secondary small">
|
||
Covers {m.monitorCount} monitor{m.monitorCount === 1 ? "" : "s"} in Uptime Kuma ·{" "}
|
||
{m.slots.length === 0
|
||
? "Uptime Kuma gave no time slot"
|
||
: m.slots.map((s) => `${formatDateTime(new Date(s.start))} – ${formatDateTime(new Date(s.end))}`).join("; ")}
|
||
</div>
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
)}
|
||
{kumaError && (
|
||
<div className="card-body pt-0">
|
||
<div className="alert alert-danger mb-0">{kumaError}</div>
|
||
</div>
|
||
)}
|
||
{kumaResult && (
|
||
<div className="card-body pt-0">
|
||
{kumaResult.monitorsInMaintenance === 0 ? (
|
||
<div className="alert alert-info mb-0">
|
||
{kumaResult.monitorsChecked === 0
|
||
? "Uptime Kuma answered, but reported no monitors at all."
|
||
: `Read ${kumaResult.monitorsChecked} monitor${kumaResult.monitorsChecked === 1 ? "" : "s"} from Uptime Kuma; none is in maintenance right now.`}{" "}
|
||
Only a maintenance window that is active at this moment can be imported — one scheduled for later
|
||
shows up here once it starts.
|
||
</div>
|
||
) : (
|
||
<div className="alert alert-success mb-0">
|
||
{kumaResult.imported.length > 0 ? (
|
||
<>
|
||
{kumaResult.imported.length} window{kumaResult.imported.length === 1 ? "" : "s"}{" "}
|
||
{kumaResult.imported.every((i) => i.extended)
|
||
? "extended"
|
||
: kumaResult.imported.every((i) => !i.extended)
|
||
? "started"
|
||
: "started or extended"}
|
||
: {kumaResult.imported.map((i) => `${i.serverName} (${i.extended ? "extended" : "started"})`).join(", ")}.
|
||
</>
|
||
) : (
|
||
"None of the monitors currently in maintenance matched a server."
|
||
)}
|
||
{kumaResult.unmatched.length > 0 && (
|
||
<div className="mt-1">
|
||
{kumaResult.unmatched.length} monitor{kumaResult.unmatched.length === 1 ? "" : "s"} in maintenance
|
||
{" "}couldn't be matched to a server: {kumaResult.unmatched.join(", ")}.
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
<div className="card-footer d-flex align-items-center gap-3">
|
||
<button type="button" className="btn btn-primary" onClick={syncFromUptimeKuma} disabled={syncBusy || kumaIntegrationId === ""}>
|
||
{syncBusy ? "Syncing…" : "Sync schedule"}
|
||
</button>
|
||
<button type="submit" className="btn" disabled={kumaBusy || kumaIntegrationId === ""}>
|
||
{kumaBusy ? "Importing…" : "Import now"}
|
||
</button>
|
||
{kumaIntegrationId === "" && (
|
||
<span className="text-secondary">Every Uptime Kuma integration is disabled — enable one under Integrations.</span>
|
||
)}
|
||
</div>
|
||
</form>
|
||
</div>
|
||
)}
|
||
|
||
{canEdit && kumaIntegrations && kumaIntegrations.length > 0 && (
|
||
<div className="card mb-3">
|
||
<div className="card-header">
|
||
<h3 className="card-title">Address aliases</h3>
|
||
</div>
|
||
<form onSubmit={addAlias}>
|
||
<div className="card-body row g-3">
|
||
<div className="text-secondary">
|
||
Uptime Kuma may watch something by a different address than the one you added it with here — a host
|
||
added by its LAN address but monitored over Tailscale, for instance. An alias says that an address
|
||
belongs to a server, integration or DNS provider, so the syncing above puts the maintenance window
|
||
there. Matching stays exact: only the address you list counts.
|
||
</div>
|
||
<div className="col-md-4">
|
||
<label className="form-label">Address in Uptime Kuma</label>
|
||
<input
|
||
className="form-control"
|
||
required
|
||
maxLength={253}
|
||
placeholder="e.g. 100.116.179.43 or felicia.tail1234.ts.net"
|
||
value={aliasAddress}
|
||
onChange={(e) => setAliasAddress(e.target.value)}
|
||
/>
|
||
</div>
|
||
<div className="col-md-5">
|
||
<label className="form-label">Belongs to</label>
|
||
<select className="form-select" required value={aliasTarget} onChange={(e) => setAliasTarget(e.target.value)}>
|
||
<option value="">Choose…</option>
|
||
{targets && targets.servers.length > 0 && (
|
||
<optgroup label="Servers">
|
||
{targets.servers.map((s) => (
|
||
<option key={`s${s.id}`} value={`server:${s.id}`}>
|
||
{s.name}
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
{targets && targets.integrations.length > 0 && (
|
||
<optgroup label="Integrations">
|
||
{targets.integrations.map((i) => (
|
||
<option key={`i${i.id}`} value={`integration:${i.id}`}>
|
||
{i.name} ({i.type})
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
{targets && targets.dnsProviders.length > 0 && (
|
||
<optgroup label="DNS providers">
|
||
{targets.dnsProviders.map((p) => (
|
||
<option key={`d${p.id}`} value={`dns_provider:${p.id}`}>
|
||
{p.name} ({p.providerType})
|
||
</option>
|
||
))}
|
||
</optgroup>
|
||
)}
|
||
</select>
|
||
</div>
|
||
<div className="col-md-3 d-flex align-items-end">
|
||
<button type="submit" className="btn btn-primary" disabled={aliasBusy || !aliasTarget || !aliasAddress.trim()}>
|
||
{aliasBusy ? "Adding…" : "Add alias"}
|
||
</button>
|
||
</div>
|
||
</div>
|
||
{aliasError && (
|
||
<div className="card-body pt-0">
|
||
<div className="alert alert-danger mb-0">{aliasError}</div>
|
||
</div>
|
||
)}
|
||
</form>
|
||
{aliases.length > 0 && (
|
||
<div className="table-responsive">
|
||
<table className="table table-vcenter card-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Address</th>
|
||
<th>Belongs to</th>
|
||
<th className="w-1">Actions</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{aliases.map((a) => (
|
||
<tr key={a.id}>
|
||
<td>{a.address}</td>
|
||
<td>
|
||
{a.targetName} <span className="text-secondary">· {a.targetKind}</span>
|
||
</td>
|
||
<td>
|
||
<button className="btn btn-sm btn-outline-danger" onClick={() => removeAlias(a)}>
|
||
Remove
|
||
</button>
|
||
</td>
|
||
</tr>
|
||
))}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
|
||
{upcoming.length > 0 && (
|
||
<div className="card mb-3">
|
||
<div className="card-header">
|
||
<h3 className="card-title">Scheduled</h3>
|
||
</div>
|
||
<div className="table-responsive">
|
||
<table className="table table-vcenter card-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Target</th>
|
||
<th>Reason</th>
|
||
<th>Starts</th>
|
||
<th>Ends</th>
|
||
{canEdit && <th className="w-1">Actions</th>}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{upcoming.map((w) => (
|
||
<tr key={w.id}>
|
||
<td>
|
||
{w.targetName} <span className="text-secondary">· {w.targetKind}</span>
|
||
</td>
|
||
<td className="text-secondary">{w.reason ?? "—"}</td>
|
||
<td>
|
||
<span className="badge bg-blue-lt text-blue me-2">in {formatRemaining(w.startedAt, now)}</span>
|
||
<span className="text-secondary small">{formatDateTime(new Date(w.startedAt))}</span>
|
||
</td>
|
||
<td className="text-secondary small">{formatDateTime(new Date(w.endsAt))}</td>
|
||
{canEdit && (
|
||
<td>
|
||
<button className="btn btn-sm btn-outline-secondary" onClick={() => end(w)}>
|
||
Cancel
|
||
</button>
|
||
</td>
|
||
)}
|
||
</tr>
|
||
))}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div className="card-footer text-secondary small">
|
||
Not silencing anything yet. These start by themselves; the schedule comes from Uptime Kuma and is refreshed
|
||
every 15 minutes, so a cancelled one stays cancelled but a change in Uptime Kuma is followed.
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
<div className="card mb-3">
|
||
<div className="card-header">
|
||
<h3 className="card-title">Active</h3>
|
||
{canEdit && (windows?.length ?? 0) > 1 && (
|
||
<div className="card-actions">
|
||
<button className="btn btn-sm btn-outline-secondary" onClick={() => void endAll()}>
|
||
End all ({windows?.length})
|
||
</button>
|
||
</div>
|
||
)}
|
||
</div>
|
||
<div className="table-responsive">
|
||
<table className="table table-vcenter card-table">
|
||
<thead>
|
||
<tr>
|
||
<th>Target</th>
|
||
<th>Reason</th>
|
||
<th>Ends</th>
|
||
<th>Started by</th>
|
||
{canEdit && <th className="w-1">Actions</th>}
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{windows?.map((w) => (
|
||
<tr key={w.id}>
|
||
<td>
|
||
{w.targetName} <span className="text-secondary">· {w.targetKind}</span>
|
||
{w.source?.startsWith("kuma:") && <span className="badge bg-cyan-lt ms-2">Uptime Kuma</span>}
|
||
</td>
|
||
<td className="text-secondary">{w.reason ?? "—"}</td>
|
||
<td>
|
||
<span className="badge bg-yellow-lt text-yellow me-2">{formatRemaining(w.endsAt, now)} left</span>
|
||
<span className="text-secondary small">{formatDateTime(new Date(w.endsAt))}</span>
|
||
</td>
|
||
<td className="text-secondary">{w.createdBy ?? "—"}</td>
|
||
{canEdit && (
|
||
<td>
|
||
<button className="btn btn-sm btn-outline-secondary" onClick={() => end(w)}>
|
||
End now
|
||
</button>
|
||
</td>
|
||
)}
|
||
</tr>
|
||
))}
|
||
{windows?.length === 0 && (
|
||
<tr>
|
||
<td colSpan={canEdit ? 5 : 4} className="text-secondary text-center">
|
||
Nothing is in maintenance — all alerts are active.
|
||
</td>
|
||
</tr>
|
||
)}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
|
||
<div className="card">
|
||
<div className="card-header">
|
||
<h3 className="card-title">What gets silenced</h3>
|
||
</div>
|
||
<div className="card-body">
|
||
<div className="row">
|
||
<div className="col-md-6">
|
||
<div className="fw-bold mb-1">Silenced for the target</div>
|
||
<ul className="text-secondary">
|
||
<li>Server offline and disk-full alerts (for a server).</li>
|
||
<li>Storage, volume and disk-health alerts (for a Proxmox or Synology integration).</li>
|
||
<li>Backup-failure and uncovered-guest alerts (for a Proxmox integration).</li>
|
||
<li>Backup-verification-failure alerts (for a Proxmox Backup Server integration).</li>
|
||
<li>Failed-run alerts for the Semaphore or Gitea integration you choose.</li>
|
||
<li>
|
||
"Integration down" alerts for that <em>type</em> of service — these are tracked per type (e.g. all
|
||
Proxmox), not per instance, so with two Proxmox integrations a failure on the other one is silenced
|
||
too while a window is open.
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
<div className="col-md-6">
|
||
<div className="fw-bold mb-1">Not silenced</div>
|
||
<ul className="text-secondary">
|
||
<li>Secret and certificate expiry, Tailscale key expiry, Docker update reminders.</li>
|
||
<li>DNS record change notifications.</li>
|
||
</ul>
|
||
<div className="fw-bold mb-1">When a window ends</div>
|
||
<div className="text-secondary">
|
||
A problem that started during it and is still there alerts on the next check (within 15 minutes). One
|
||
that was already alerted before it began and has since cleared is reported as cleared; one that
|
||
started and cleared entirely inside the window is never reported.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</>
|
||
);
|
||
}
|