Service-level targets with error budgets, and quarterly and annual reports
Monitoring -> Service levels: a target (99.9 %) on an endpoint check, a server or an integration, measured over calendar months. Shows the figure, downtime used, the error budget left, and how the last six months went. 80 % of the budget used is a warning and an overspent budget a critical alert. Endpoints are measured day by day, servers and integrations to the minute from the audit log. The report page gains Quarter and Year (same figures, with a Service levels section), and two settings send the quarterly and annual report after the month that ends them. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
31044b2b64
commit
3b31b16796
31 files changed
+7706
-61
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link, useSearchParams } from "react-router-dom";
|
||||
import { IconPrinter } from "@tabler/icons-react";
|
||||
import { api, type AvailabilityRow, type CurrentUser, type MonthlyReport as Report } from "../api/client";
|
||||
import { api, type AvailabilityRow, type CurrentUser, type MonthlyReport as Report, type ServiceLevelResult } from "../api/client";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { CATEGORY_NAMES, incidentPath, SEVERITY_BADGE } from "../components/IncidentHistory";
|
||||
@@ -33,6 +33,51 @@ const average = (rows: { percent: number | null }[]) => {
|
||||
|
||||
const percentBadge = (p: number | null) => (p === null ? "text-secondary" : p >= 99.9 ? "text-green" : p >= 99 ? "" : p >= 95 ? "text-yellow" : "text-red");
|
||||
|
||||
/** How each service-level target did over the stretch: its figure against the target, and the downtime against what it allowed. */
|
||||
function ServiceLevelsSection({ rows, partial }: { rows: ServiceLevelResult[]; partial: boolean }) {
|
||||
if (rows.length === 0) return null;
|
||||
const metCount = rows.filter((l) => l.met).length;
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Service levels</h3>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
<p>
|
||||
<strong>{metCount}</strong> of {rows.length} {rows.length === 1 ? "target was" : "targets were"} met{partial ? " so far" : ""}. Each is judged on the downtime it allowed over the whole stretch (the error budget).{" "}
|
||||
<Link to="/service-levels">Set targets</Link>
|
||||
</p>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Target</th>
|
||||
<th className="text-end">Target</th>
|
||||
<th className="text-end">Achieved</th>
|
||||
<th className="text-end">Down for</th>
|
||||
<th className="text-end">Allowed</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((l) => (
|
||||
<tr key={l.id}>
|
||||
<td>{l.name}</td>
|
||||
<td className="text-end">{l.target}%</td>
|
||||
<td className={`text-end ${l.met ? "text-green" : "text-red"}`}>{l.percent}%</td>
|
||||
<td className="text-end text-secondary">{l.downMinutes > 0 ? span(l.downMinutes) : "—"}</td>
|
||||
<td className="text-end text-secondary">{l.allowedMinutes >= 1 ? span(l.allowedMinutes) : "under a minute"}</td>
|
||||
<td>{l.met ? <span className="badge bg-green-lt text-green">met</span> : <span className="badge bg-red-lt text-red">missed</span>}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Availability({ title, rows, hint }: { title: string; rows: AvailabilityRow[]; hint?: string }) {
|
||||
if (rows.length === 0) return null;
|
||||
return (
|
||||
@@ -71,7 +116,7 @@ function Availability({ title, rows, hint }: { title: string; rows: Availability
|
||||
export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
const [params, setParams] = useSearchParams();
|
||||
const month = params.get("month") ?? undefined;
|
||||
const [data, setData] = useState<{ report: Report; months: { id: string; label: string }[] } | null>(null);
|
||||
const [data, setData] = useState<{ report: Report; months: { id: string; label: string }[]; quarters: { id: string; label: string }[]; years: { id: string; label: string }[] } | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -101,6 +146,12 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
|
||||
const r = data?.report;
|
||||
const kind = r?.period ?? (month ? (/Q/.test(month) ? "quarter" : /^\d{4}$/.test(month) ? "year" : "month") : "month");
|
||||
const noun = kind === "year" ? "Annual" : kind === "quarter" ? "Quarterly" : "Monthly";
|
||||
const stretch = kind === "year" ? "year" : kind === "quarter" ? "quarter" : "month";
|
||||
const options = data ? (kind === "year" ? data.years : kind === "quarter" ? data.quarters : data.months) : [];
|
||||
/** The newest finished one of a kind, which is what is shown when nothing is asked for. */
|
||||
const lastWhole = (list: { id: string }[]) => list[1]?.id ?? list[0]?.id;
|
||||
const serverAvg = r ? average(r.servers) : null;
|
||||
const endpointAvg = r ? average(r.endpoints) : null;
|
||||
const cards = r
|
||||
@@ -116,14 +167,23 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
return (
|
||||
<div className="report-page">
|
||||
<div className="d-flex flex-wrap align-items-center gap-2 mb-1">
|
||||
<h2 className="page-title mb-0">Monthly report</h2>
|
||||
<h2 className="page-title mb-0">{noun} report</h2>
|
||||
<div className="ms-auto d-flex flex-wrap gap-2 no-print">
|
||||
{data && (
|
||||
<select className="form-select w-auto" aria-label="Month" value={r?.month ?? ""} onChange={(e) => setParams(e.target.value === data.months[1]?.id ? {} : { month: e.target.value }, { replace: true })}>
|
||||
{data.months.map((m) => (
|
||||
<div className="btn-group" role="group" aria-label="What the report covers">
|
||||
{([["month", "Month", data.months], ["quarter", "Quarter", data.quarters], ["year", "Year", data.years]] as const).map(([k, label, list]) => (
|
||||
<button key={k} type="button" className={`btn ${kind === k ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={kind === k} onClick={() => setParams(k === "month" ? {} : { month: lastWhole(list) ?? "" }, { replace: true })}>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{data && (
|
||||
<select className="form-select w-auto" aria-label={noun === "Monthly" ? "Month" : noun === "Quarterly" ? "Quarter" : "Year"} value={r?.month ?? ""} onChange={(e) => setParams(e.target.value === lastWhole(options) && kind === "month" ? {} : { month: e.target.value }, { replace: true })}>
|
||||
{options.map((m) => (
|
||||
<option key={m.id} value={m.id}>
|
||||
{m.label}
|
||||
{m.id === data.months[0].id ? " (so far)" : ""}
|
||||
{m.id === options[0].id ? " (so far)" : ""}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -137,11 +197,11 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
<p className="text-secondary no-print">
|
||||
How the month went, in one page: availability, incidents and how long they took, updates applied, restore tests and backups, and what was renewed.
|
||||
How the {stretch} went, in one page: availability, how each service-level target did, incidents and how long they took, updates applied, restore tests and backups, and what was renewed.
|
||||
{user.role === "admin" ? (
|
||||
<>
|
||||
{" "}
|
||||
It can be sent on a day of the month: <Link to="/settings/notifications">Settings → Notifications</Link>.
|
||||
It can be sent on a day of the month, and a quarter's and year's report after the month that ends it: <Link to="/settings/notifications">Settings → Notifications</Link>.
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
@@ -153,7 +213,7 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
<h3 className="mb-1">{r.label}</h3>
|
||||
<div className="text-secondary mb-3">
|
||||
{formatDate(new Date(r.from))} – {formatDate(new Date(r.to))}
|
||||
{r.partial ? " · the month is not over, so this is the month so far" : ""} · time zone {r.timezone}
|
||||
{r.partial ? ` · the ${stretch} is not over, so this is the ${stretch} so far` : ""} · time zone {r.timezone}
|
||||
</div>
|
||||
|
||||
<div className="row row-cards mb-3">
|
||||
@@ -213,6 +273,8 @@ export default function MonthlyReport({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ServiceLevelsSection rows={r.serviceLevels} partial={r.partial} />
|
||||
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Incidents</h3>
|
||||
|
||||
@@ -0,0 +1,292 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type CurrentUser, type ServiceLevel, type ServiceLevelInput, type ServiceLevelSubject } from "../api/client";
|
||||
import EmptyState from "../components/EmptyState";
|
||||
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 SUBJECT_WORDS: Record<ServiceLevelSubject, string> = { endpoint: "Endpoint check", server: "Server", integration: "Integration" };
|
||||
const SUBJECT_HINTS: Record<ServiceLevelSubject, string> = {
|
||||
endpoint: "Measured from the check's answers, day by day: the share that failed.",
|
||||
server: "Measured from when it stopped reporting and reported again, to the minute.",
|
||||
integration: "Measured from when calls to that kind of service started failing and worked again.",
|
||||
};
|
||||
|
||||
/** "43 min", "4 h", "2 d 3 h"; under a minute is said so. */
|
||||
function span(minutes: number): string {
|
||||
if (minutes < 1) return "under a minute";
|
||||
const m = Math.round(minutes);
|
||||
if (m < 60) return `${m} min`;
|
||||
const h = Math.floor(m / 60);
|
||||
if (h < 24) return m % 60 && h < 10 ? `${h} h ${m % 60} min` : `${h} h`;
|
||||
const d = Math.floor(h / 24);
|
||||
return h % 24 ? `${d} d ${h % 24} h` : `${d} d`;
|
||||
}
|
||||
|
||||
const COLOR = { ok: "#2fb344", at_risk: "#f59f00", breached: "#e05252", no_data: "#9aa0a6" } as const;
|
||||
const BADGE = {
|
||||
ok: { label: "Within budget", cls: "bg-green-lt text-green" },
|
||||
at_risk: { label: "Budget nearly used", cls: "bg-yellow-lt text-yellow" },
|
||||
breached: { label: "Target missed", cls: "bg-red-lt text-red" },
|
||||
no_data: { label: "Nothing to measure yet", cls: "bg-secondary-lt text-secondary" },
|
||||
} as const;
|
||||
|
||||
interface Draft {
|
||||
id: number | null;
|
||||
name: string;
|
||||
subjectType: ServiceLevelSubject;
|
||||
subjectId: string;
|
||||
target: string;
|
||||
alert: boolean;
|
||||
}
|
||||
const EMPTY: Draft = { id: null, name: "", subjectType: "endpoint", subjectId: "", target: "99.9", alert: true };
|
||||
|
||||
function Card({ level: l, isAdmin, onEdit, onRemove }: { level: ServiceLevel; isAdmin: boolean; onEdit: () => void; onRemove: () => void }) {
|
||||
const b = l.budget;
|
||||
const used = b.usedPercent ?? 0;
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-header">
|
||||
<div>
|
||||
<h3 className="card-title mb-0">
|
||||
{l.name} <span className={`badge ${BADGE[b.state].cls}`}>{BADGE[b.state].label}</span>
|
||||
</h3>
|
||||
<div className="text-secondary small">
|
||||
{SUBJECT_WORDS[l.subjectType]}: {l.subjectName ?? <em>removed</em>} · target <strong>{l.target}%</strong> a month
|
||||
</div>
|
||||
</div>
|
||||
{isAdmin && (
|
||||
<div className="card-actions btn-list flex-nowrap">
|
||||
<button className="btn btn-sm btn-outline-secondary" onClick={onEdit}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="btn btn-sm btn-outline-danger" onClick={onRemove}>
|
||||
Remove
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="card-body">
|
||||
{b.state === "no_data" ? (
|
||||
<div className="text-secondary">{l.subjectName === null ? "What this measured has been removed." : `Nothing has been recorded for ${l.period.label} yet. ${SUBJECT_HINTS[l.subjectType]}`}</div>
|
||||
) : (
|
||||
<>
|
||||
<div className="row g-3 mb-2">
|
||||
<div className="col-6 col-md-3">
|
||||
<div className="text-secondary small">So far in {l.period.label}</div>
|
||||
<div className="h2 mb-0" style={{ color: COLOR[b.state] }}>
|
||||
{l.measure.percent}%
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-6 col-md-3">
|
||||
<div className="text-secondary small">Down</div>
|
||||
<div className="h2 mb-0">{l.measure.downMinutes > 0 ? span(l.measure.downMinutes) : "—"}</div>
|
||||
</div>
|
||||
<div className="col-6 col-md-3">
|
||||
<div className="text-secondary small">Allowed this month</div>
|
||||
<div className="h2 mb-0">{span(b.allowedMinutes)}</div>
|
||||
</div>
|
||||
<div className="col-6 col-md-3">
|
||||
<div className="text-secondary small">{b.remainingMinutes >= 0 ? "Left in the budget" : "Over the budget by"}</div>
|
||||
<div className="h2 mb-0" style={{ color: b.remainingMinutes < 0 ? COLOR.breached : undefined }}>
|
||||
{b.remainingMinutes >= 0 ? span(b.remainingMinutes) : span(-b.remainingMinutes)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="progress progress-sm mb-1" role="progressbar" aria-label="Error budget used" aria-valuenow={Math.min(100, Math.round(used))} aria-valuemin={0} aria-valuemax={100}>
|
||||
<div className="progress-bar" style={{ width: `${Math.min(100, used)}%`, background: COLOR[b.state] }} />
|
||||
</div>
|
||||
<div className="text-secondary small">
|
||||
{used >= 100 ? "The whole error budget is used" : `${Math.round(used)}% of the error budget is used`}
|
||||
{b.projectedPercent !== null && b.state !== "breached" ? ` · at this pace, about ${b.projectedPercent}% by the end of the month` : ""}
|
||||
{l.alert ? "" : " · no alert for this one"}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{l.history.some((h) => h.percent !== null) && (
|
||||
<div className="mt-3">
|
||||
<div className="text-secondary small mb-1">The months before</div>
|
||||
<div className="d-flex flex-wrap gap-2">
|
||||
{l.history.map((h) => (
|
||||
<span
|
||||
key={h.id}
|
||||
className={`badge ${h.met === null ? "bg-secondary-lt text-secondary" : h.met ? "bg-green-lt text-green" : "bg-red-lt text-red"}`}
|
||||
title={h.percent === null ? `${h.label}: nothing recorded` : `${h.label}: ${h.percent}%, down ${span(h.downMinutes)} of ${span(h.allowedMinutes)} allowed`}
|
||||
>
|
||||
{h.label.split(" ")[0].slice(0, 3)} {h.percent === null ? "—" : `${h.percent}%`}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** What each service is held to — "99.9% for Gitea" — and what is left of this month's error budget; the months before show whether it was kept. */
|
||||
export default function ServiceLevels({ user }: { user: CurrentUser }) {
|
||||
const isAdmin = user.role === "admin";
|
||||
const [data, setData] = useState<Awaited<ReturnType<typeof api.serviceLevels.list>> | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [draft, setDraft] = useState<Draft | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
function load() {
|
||||
api.serviceLevels
|
||||
.list()
|
||||
.then((res) => {
|
||||
setData(res);
|
||||
setError(null);
|
||||
})
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}
|
||||
useEffect(() => {
|
||||
load();
|
||||
const t = setInterval(load, 120_000);
|
||||
return () => clearInterval(t);
|
||||
}, []);
|
||||
|
||||
const set = <K extends keyof Draft>(key: K, value: Draft[K]) => setDraft((d) => (d ? { ...d, [key]: value } : d));
|
||||
const subjects = data && draft ? data.subjects[draft.subjectType] : [];
|
||||
|
||||
async function save(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!draft) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
const input: ServiceLevelInput = { name: draft.name.trim(), subjectType: draft.subjectType, subjectId: Number(draft.subjectId), target: Number(draft.target), alert: draft.alert };
|
||||
try {
|
||||
if (draft.id === null) await api.serviceLevels.create(input);
|
||||
else await api.serviceLevels.update(draft.id, input);
|
||||
toast.success(draft.id === null ? `Set a target for ${input.name}.` : "Saved.");
|
||||
setDraft(null);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(l: ServiceLevel) {
|
||||
if (!(await confirmDialog({ title: "Remove a target", message: `Remove the target for "${l.name}"? What was measured is kept; only the target goes.`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
await api.serviceLevels.remove(l.id);
|
||||
load();
|
||||
} catch (err) {
|
||||
setError(readableError(err));
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="d-flex align-items-center mb-1">
|
||||
<h2 className="page-title mb-0">Service levels</h2>
|
||||
{isAdmin && !draft && (
|
||||
<button className="btn btn-primary ms-auto" onClick={() => setDraft({ ...EMPTY })}>
|
||||
Set a target
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-secondary">
|
||||
What a service is held to — for example <strong>99.9%</strong> for Gitea — and what is left of this month’s <strong>error budget</strong>: the downtime the target allows. A month with 99.9% allows about 45 minutes. The months before show whether it
|
||||
was kept. When most of the budget is used it is a warning, and when it is overspent a critical alert, until the month turns over. Planned maintenance is not taken out: down is down. The same figures are in the{" "}
|
||||
<Link to="/reports">monthly, quarterly and annual reports</Link>.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
|
||||
{draft && data && (
|
||||
<form className="card mb-3" onSubmit={save}>
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">{draft.id === null ? "Set a target" : `Edit ${draft.name || "the target"}`}</h3>
|
||||
</div>
|
||||
<div className="card-body row g-3">
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="sl-name">
|
||||
Name
|
||||
</label>
|
||||
<input id="sl-name" className="form-control" required maxLength={100} placeholder="e.g. Gitea answers" value={draft.name} onChange={(e) => set("name", e.target.value)} />
|
||||
</div>
|
||||
<div className="col-md-3">
|
||||
<label className="form-label" htmlFor="sl-type">
|
||||
Measured on
|
||||
</label>
|
||||
<select
|
||||
id="sl-type"
|
||||
className="form-select"
|
||||
value={draft.subjectType}
|
||||
onChange={(e) => setDraft((d) => (d ? { ...d, subjectType: e.target.value as ServiceLevelSubject, subjectId: "" } : d))}
|
||||
>
|
||||
{(Object.keys(SUBJECT_WORDS) as ServiceLevelSubject[]).map((k) => (
|
||||
<option key={k} value={k}>
|
||||
{SUBJECT_WORDS[k]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-md-5">
|
||||
<label className="form-label" htmlFor="sl-subject">
|
||||
Which one
|
||||
</label>
|
||||
<select id="sl-subject" className="form-select" required value={draft.subjectId} onChange={(e) => set("subjectId", e.target.value)}>
|
||||
<option value="">— choose —</option>
|
||||
{subjects.map((s) => (
|
||||
<option key={s.id} value={s.id}>
|
||||
{s.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="form-hint text-secondary small mt-1">{SUBJECT_HINTS[draft.subjectType]}</div>
|
||||
</div>
|
||||
<div className="col-md-4">
|
||||
<label className="form-label" htmlFor="sl-target">
|
||||
Target, per calendar month
|
||||
</label>
|
||||
<div className="input-group">
|
||||
<input id="sl-target" type="number" className="form-control" required min={90} max={99.999} step="any" value={draft.target} onChange={(e) => set("target", e.target.value)} />
|
||||
<span className="input-group-text">%</span>
|
||||
</div>
|
||||
<div className="form-hint text-secondary small mt-1">
|
||||
99% allows about 7 h a month, 99.9% about 45 min, 99.99% about 4 min. Between 90 and 99.999.
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-md-8 d-flex align-items-end">
|
||||
<label className="form-check mb-0">
|
||||
<input type="checkbox" className="form-check-input" checked={draft.alert} onChange={(e) => set("alert", e.target.checked)} />
|
||||
<span className="form-check-label">Warn when 80% of the month’s error budget is used, and when it is overspent</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div className="card-footer d-flex gap-2">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy || draft.name.trim() === "" || draft.subjectId === ""}>
|
||||
{busy ? "Saving…" : "Save"}
|
||||
</button>
|
||||
<button type="button" className="btn" onClick={() => setDraft(null)}>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
|
||||
{!data && !error && <BlockSkeleton lines={4} />}
|
||||
{data?.levels.length === 0 && !draft && (
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<EmptyState
|
||||
title="No targets are set"
|
||||
hint="Say how available something should be — an endpoint check, a server, an integration — and see what is left of the month's error budget."
|
||||
action={isAdmin ? { label: "Set a target", onClick: () => setDraft({ ...EMPTY }) } : undefined}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{data?.levels.map((l) => (
|
||||
<Card key={l.id} level={l} isAdmin={isAdmin} onEdit={() => setDraft({ id: l.id, name: l.name, subjectType: l.subjectType, subjectId: String(l.subjectId), target: String(l.target), alert: l.alert })} onRemove={() => void remove(l)} />
|
||||
))}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ const DIGEST_DAYS: { value: number; label: string }[] = [
|
||||
{ value: 0, label: "Sunday" },
|
||||
];
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14, backupStaleHours: 48, restoreTestDays: 0, newPortAlerts: true, flapRaises: 3, deviceOfflineMinutes: 10, osSupportWarnDays: 90, baselineAlerts: true };
|
||||
const DEFAULT_MONTHLY: MonthlyReportSettings = { enabled: false, day: 1, time: "08:00" };
|
||||
const DEFAULT_MONTHLY: MonthlyReportSettings = { enabled: false, quarterly: false, annual: false, day: 1, time: "08:00" };
|
||||
|
||||
type TestResult = { ok: boolean; message: string } | null;
|
||||
type EventKey = { [K in keyof NotificationEvents]: NotificationEvents[K] extends boolean ? K : never }[keyof NotificationEvents];
|
||||
@@ -284,7 +284,7 @@ export default function NotificationSettings() {
|
||||
setHealthChecks(s.healthChecks);
|
||||
const d = s.digest ?? DEFAULT_DIGEST;
|
||||
setDigest(d);
|
||||
const mo = s.monthlyReport ?? DEFAULT_MONTHLY;
|
||||
const mo = { ...DEFAULT_MONTHLY, ...s.monthlyReport };
|
||||
setMonthly(mo);
|
||||
setBaseline(JSON.stringify({ gotify: s.gotify, ntfy: s.ntfy, smtp: s.smtp, webhook: s.webhook, webPush: wp, routing: rt, escalation: es, notifications: s.notifications, quietHours: s.quietHours, healthChecks: s.healthChecks, digest: d, monthlyReport: mo }));
|
||||
})
|
||||
@@ -1012,6 +1012,14 @@ export default function NotificationSettings() {
|
||||
<input id="monthly-time" type="time" className="form-control" value={monthly.time} disabled={!monthly.enabled} onChange={(e) => setMonthly((m) => ({ ...m, time: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<label className="form-check mb-1">
|
||||
<input type="checkbox" className="form-check-input" checked={monthly.quarterly} disabled={!monthly.enabled} onChange={(e) => setMonthly((m) => ({ ...m, quarterly: e.target.checked }))} />
|
||||
<span className="form-check-label">Also send a quarterly report, after the month that ends a quarter (March, June, September, December)</span>
|
||||
</label>
|
||||
<label className="form-check mb-3">
|
||||
<input type="checkbox" className="form-check-input" checked={monthly.annual} disabled={!monthly.enabled} onChange={(e) => setMonthly((m) => ({ ...m, annual: e.target.checked }))} />
|
||||
<span className="form-check-label">Also send an annual report, after December</span>
|
||||
</label>
|
||||
<div className="btn-list">
|
||||
<button type="button" className="btn btn-outline-secondary" onClick={handleMonthlyPreview} disabled={monthlyBusy !== null}>
|
||||
{monthlyBusy === "preview" ? "Gathering…" : "Preview last month"}
|
||||
|
||||
Reference in new issue
Block a user