Add a weekly digest and report which version of the agent each server runs
- Weekly digest through the notification channels: alerts now, a week of uptime, what happened, disks heading for full, expiring secrets and domains, updates waiting, planned maintenance. Off until switched on in Settings -> Notifications; Preview and Send it now there. Setting key 'digest'. - Agents say their version in every report (Linux and Windows scripts are version 2); the server compares it with the scripts it serves and marks agents that are behind on the Servers, server and Updates pages. servers.agent_version, migration 0026. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3da5c639b1
commit
aa94d84f6c
28 files changed
+3179
-19
No files matched your search
@@ -7,9 +7,11 @@ import {
|
||||
type SmtpSettings,
|
||||
type WebhookSettings,
|
||||
type NotificationEvents,
|
||||
type DigestSettings,
|
||||
type QuietHoursSettings,
|
||||
type HealthCheckSettings,
|
||||
} from "../../api/client";
|
||||
import { readableError } from "../../utils/errors";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
|
||||
@@ -58,6 +60,17 @@ const DEFAULT_NOTIFICATIONS: NotificationEvents = {
|
||||
integrationFailureThreshold: 3,
|
||||
};
|
||||
const DEFAULT_QUIET_HOURS: QuietHoursSettings = { enabled: false, start: "22:00", end: "07:00" };
|
||||
const DEFAULT_DIGEST: DigestSettings = { enabled: false, day: 1, time: "08:00" };
|
||||
// Monday first, as a week reads; the numbers are what the server keeps (0 = Sunday).
|
||||
const DIGEST_DAYS: { value: number; label: string }[] = [
|
||||
{ value: 1, label: "Monday" },
|
||||
{ value: 2, label: "Tuesday" },
|
||||
{ value: 3, label: "Wednesday" },
|
||||
{ value: 4, label: "Thursday" },
|
||||
{ value: 5, label: "Friday" },
|
||||
{ value: 6, label: "Saturday" },
|
||||
{ value: 0, label: "Sunday" },
|
||||
];
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14 };
|
||||
|
||||
type TestResult = { ok: boolean; message: string } | null;
|
||||
@@ -85,6 +98,10 @@ export default function NotificationSettings() {
|
||||
const [notifications, setNotifications] = useState<NotificationEvents>(DEFAULT_NOTIFICATIONS);
|
||||
const [quietHours, setQuietHours] = useState<QuietHoursSettings>(DEFAULT_QUIET_HOURS);
|
||||
const [healthChecks, setHealthChecks] = useState<HealthCheckSettings>(DEFAULT_HEALTH_CHECKS);
|
||||
const [digest, setDigest] = useState<DigestSettings>(DEFAULT_DIGEST);
|
||||
const [digestPreview, setDigestPreview] = useState<{ title: string; message: string } | null>(null);
|
||||
const [digestBusy, setDigestBusy] = useState<"preview" | "send" | null>(null);
|
||||
const [digestResult, setDigestResult] = useState<TestResult>(null);
|
||||
const [queuedCount, setQueuedCount] = useState<number | null>(null);
|
||||
const [flushing, setFlushing] = useState(false);
|
||||
const [flushResult, setFlushResult] = useState<string | null>(null);
|
||||
@@ -109,6 +126,7 @@ export default function NotificationSettings() {
|
||||
setNotifications(res.settings.notifications);
|
||||
setQuietHours(res.settings.quietHours);
|
||||
setHealthChecks(res.settings.healthChecks);
|
||||
setDigest(res.settings.digest ?? DEFAULT_DIGEST);
|
||||
})
|
||||
.catch((err) => setLoadError(err instanceof Error ? err.message : String(err)))
|
||||
.finally(() => setLoading(false));
|
||||
@@ -123,7 +141,7 @@ export default function NotificationSettings() {
|
||||
setSaveError(null);
|
||||
setSaved(false);
|
||||
try {
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, notifications, quietHours, healthChecks });
|
||||
await api.settings.update({ gotify, ntfy, smtp, webhook, notifications, quietHours, healthChecks, digest });
|
||||
setSaved(true);
|
||||
setTimeout(() => setSaved(false), 3000);
|
||||
} catch (err) {
|
||||
@@ -133,6 +151,32 @@ export default function NotificationSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDigestPreview() {
|
||||
setDigestBusy("preview");
|
||||
setDigestResult(null);
|
||||
try {
|
||||
const res = await api.settings.digestPreview();
|
||||
setDigestPreview({ title: res.title, message: res.message });
|
||||
} catch (err) {
|
||||
setDigestResult({ ok: false, message: err instanceof Error ? err.message : String(err) });
|
||||
} finally {
|
||||
setDigestBusy(null);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDigestSend() {
|
||||
setDigestBusy("send");
|
||||
setDigestResult(null);
|
||||
try {
|
||||
const res = await api.settings.digestSend();
|
||||
setDigestResult({ ok: true, message: `Sent through ${res.channels} channel${res.channels === 1 ? "" : "s"}.` });
|
||||
} catch (err) {
|
||||
setDigestResult({ ok: false, message: readableError(err) });
|
||||
} finally {
|
||||
setDigestBusy(null);
|
||||
}
|
||||
}
|
||||
|
||||
async function handleFlushNow() {
|
||||
setFlushing(true);
|
||||
setFlushResult(null);
|
||||
@@ -740,6 +784,63 @@ export default function NotificationSettings() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="col-md-6">
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">Weekly digest</h3>
|
||||
</div>
|
||||
<div className="card-body">
|
||||
<p className="text-secondary">
|
||||
One message a week through the channels above, in the time zone set above: what is wrong now, what was down and for how long, what happened,
|
||||
disks heading for full, things about to expire, updates waiting and maintenance coming up. A topic with nothing to say is left out, and a
|
||||
quiet week says so in one line. Quiet hours hold it like any other notification.
|
||||
</p>
|
||||
<label className="form-check mb-3">
|
||||
<input type="checkbox" className="form-check-input" checked={digest.enabled} onChange={(e) => setDigest((d) => ({ ...d, enabled: e.target.checked }))} />
|
||||
<span className="form-check-label">Send the weekly digest</span>
|
||||
</label>
|
||||
<div className="row g-2 mb-3">
|
||||
<div className="col-6">
|
||||
<label className="form-label" htmlFor="digest-day">
|
||||
Day
|
||||
</label>
|
||||
<select id="digest-day" className="form-select" value={digest.day} disabled={!digest.enabled} onChange={(e) => setDigest((d) => ({ ...d, day: Number(e.target.value) }))}>
|
||||
{DIGEST_DAYS.map((d) => (
|
||||
<option key={d.value} value={d.value}>
|
||||
{d.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-6">
|
||||
<label className="form-label" htmlFor="digest-time">
|
||||
Time
|
||||
</label>
|
||||
<input id="digest-time" type="time" className="form-control" value={digest.time} disabled={!digest.enabled} onChange={(e) => setDigest((d) => ({ ...d, time: e.target.value }))} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="btn-list">
|
||||
<button type="button" className="btn btn-outline-secondary" onClick={handleDigestPreview} disabled={digestBusy !== null}>
|
||||
{digestBusy === "preview" ? "Gathering…" : "Preview"}
|
||||
</button>
|
||||
<button type="button" className="btn btn-outline-secondary" onClick={handleDigestSend} disabled={digestBusy !== null}>
|
||||
{digestBusy === "send" ? "Sending…" : "Send it now"}
|
||||
</button>
|
||||
</div>
|
||||
<div className="form-hint mt-2">Settings above are saved with the Save button; the preview and "send it now" don't depend on them.</div>
|
||||
<TestBadge result={digestResult} />
|
||||
{digestPreview && (
|
||||
<div className="mt-3">
|
||||
<div className="fw-bold">{digestPreview.title}</div>
|
||||
<pre className="border rounded p-2 mt-1 mb-0" style={{ whiteSpace: "pre-wrap", fontSize: "0.8125rem" }}>
|
||||
{digestPreview.message}
|
||||
</pre>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user