Disk fill forecasts, skeleton loaders, and a Silence button on alerts
A disk that is on course to be full within 14 days (setting: 0 turns it off) is flagged on the Alerts page and dashboard, from the server's own history: needs three days of steady growth, skips erratic disks and ones the ordinary disk alert covers. Skeleton placeholders replace "Fetching status…" and "Loading…". Alerts that a maintenance window can silence get a Silence button (1, 4 or 24 hours) that starts one, and the alert list is refreshed at once when a window starts or ends. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82974b98d0
commit
f7f5e1cd41
24 files changed
+566
-25
No files matched your search
@@ -133,7 +133,7 @@ export interface ServerMetricSeries {
|
||||
points: { t: string; v: number }[];
|
||||
latest: number | null;
|
||||
/** Disks only: the rate of change in points a day, and the days until full when it is rising. */
|
||||
trend: { perDay: number; daysToFull: number | null } | null;
|
||||
trend: { perDay: number; fit: number; spanDays: number; daysToFull: number | null } | null;
|
||||
}
|
||||
|
||||
export interface IpamEntry {
|
||||
@@ -282,6 +282,8 @@ export interface HealthCheckSettings {
|
||||
serverOfflineMinutes: number;
|
||||
diskUsagePercent: number;
|
||||
domainWarnDays: number;
|
||||
/** A disk on course to be full within this many days is flagged on the Alerts page; 0 is off. */
|
||||
diskForecastDays: number;
|
||||
}
|
||||
|
||||
export interface QuietHoursSettings {
|
||||
@@ -434,6 +436,8 @@ export interface AlertItem {
|
||||
link: string | null;
|
||||
/** Under a maintenance window: still a real problem, but its notifications are held back. */
|
||||
silenced: boolean;
|
||||
/** What a maintenance window would go on to silence it — what the Silence button acts on. Null when nothing can silence it. */
|
||||
target?: { type: MaintenanceTargetType; id: number; name: string } | null;
|
||||
/** The osTicket ticket opened for it, if one was. */
|
||||
ticket?: { number: string | null; url: string | null; grouped: boolean; openedAt: string | null } | null;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, type IntegrationField, type IntegrationSummary, type IntegrationType } from "../api/client";
|
||||
import { BlockSkeleton } from "./Skeleton";
|
||||
|
||||
const TYPE_LABELS: Record<IntegrationType, string> = {
|
||||
tailscale: "Tailscale",
|
||||
@@ -93,7 +94,9 @@ export default function IntegrationEditForm({
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="card mb-3">
|
||||
<div className="card-body text-secondary">Loading…</div>
|
||||
<div className="card-body">
|
||||
<BlockSkeleton lines={4} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api, type ServerMetricSeries } from "../api/client";
|
||||
import Sparkline from "./Sparkline";
|
||||
import { BlockSkeleton } from "./Skeleton";
|
||||
|
||||
const RANGES = [
|
||||
{ days: 1, label: "24 hours" },
|
||||
@@ -64,7 +65,7 @@ export default function ServerTrends({ serverId }: { serverId: number }) {
|
||||
{failed ? (
|
||||
<div className="text-secondary">Couldn't load the history.</div>
|
||||
) : series === null ? (
|
||||
<div className="text-secondary">Loading…</div>
|
||||
<BlockSkeleton lines={4} />
|
||||
) : series.length === 0 ? (
|
||||
<div className="text-secondary">
|
||||
No history yet. A sample is kept about every ten minutes once the agent has reported, so lines appear here after a short while.
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import { useState } from "react";
|
||||
import { api, type AlertItem } from "../api/client";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
const CHOICES = [
|
||||
{ minutes: 60, label: "1 h", words: "1 hour" },
|
||||
{ minutes: 240, label: "4 h", words: "4 hours" },
|
||||
{ minutes: 1440, label: "24 h", words: "24 hours" },
|
||||
];
|
||||
|
||||
/**
|
||||
* "Silence" on an alert: pick how long, and a maintenance window goes on whatever the alert is about. That silences everything
|
||||
* about that server or integration, not just this one alert — which is what a maintenance window is — so it says so, and the
|
||||
* Maintenance page is where to end it early. The choices open in place, so nothing is clipped by the table around it.
|
||||
*/
|
||||
export default function SilenceButton({ alert, onDone }: { alert: AlertItem; onDone: () => void }) {
|
||||
const [choosing, setChoosing] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const target = alert.target;
|
||||
if (!target || alert.silenced) return null;
|
||||
|
||||
async function silence(minutes: number, words: string) {
|
||||
if (!target) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.maintenance.start({
|
||||
targetType: target.type,
|
||||
targetId: target.id,
|
||||
minutes,
|
||||
reason: `Silenced from the Alerts page: ${alert.message}`.slice(0, 200),
|
||||
});
|
||||
toast.success(`${target.name} is silenced for ${words} — every alert about it. End it early under Maintenance.`);
|
||||
// The sidebar badge and the maintenance banner listen for this.
|
||||
window.dispatchEvent(new Event("maintenance-changed"));
|
||||
setChoosing(false);
|
||||
onDone();
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!choosing) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-sm btn-outline-secondary"
|
||||
title={`Silence all alerts about ${target.name} for a while`}
|
||||
onClick={() => setChoosing(true)}
|
||||
>
|
||||
Silence
|
||||
</button>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="btn-group btn-group-sm" role="group" aria-label={`Silence ${target.name} for`}>
|
||||
{CHOICES.map((c) => (
|
||||
<button key={c.minutes} type="button" className="btn" disabled={busy} onClick={() => silence(c.minutes, c.words)} title={`Silence ${target.name} for ${c.words}`}>
|
||||
{c.label}
|
||||
</button>
|
||||
))}
|
||||
<button type="button" className="btn" disabled={busy} onClick={() => setChoosing(false)} aria-label="Cancel">
|
||||
✕
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { CSSProperties } from "react";
|
||||
|
||||
/** A grey bar with a slow shimmer, standing where text or a figure will be, so the page keeps its shape while it loads. */
|
||||
export function Skeleton({ width = "100%", height = "1rem", className = "", style }: { width?: string | number; height?: string | number; className?: string; style?: CSSProperties }) {
|
||||
return <span aria-hidden="true" className={`skeleton ${className}`.trim()} style={{ width, height, ...style }} />;
|
||||
}
|
||||
|
||||
/** The inside of a dashboard widget while its figures are on the way: three figures with captions, and the bar beneath. */
|
||||
export function WidgetSkeleton() {
|
||||
return (
|
||||
<div role="status" aria-live="polite">
|
||||
<div className="row g-2 mb-3">
|
||||
{[0, 1, 2].map((i) => (
|
||||
<div className="col-4" key={i}>
|
||||
<Skeleton width="55%" height="1.5rem" className="d-block mb-1" />
|
||||
<Skeleton width="80%" height="0.7rem" className="d-block" />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Skeleton height="0.55rem" className="d-block" />
|
||||
<span className="visually-hidden">Loading…</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** A few lines of text-shaped bars, for a card or a settings page that is still loading. */
|
||||
export function BlockSkeleton({ lines = 3 }: { lines?: number }) {
|
||||
const widths = ["90%", "75%", "85%", "60%", "80%"];
|
||||
return (
|
||||
<div role="status" aria-live="polite">
|
||||
{Array.from({ length: lines }, (_, i) => (
|
||||
<Skeleton key={i} width={widths[i % widths.length]} height="0.95rem" className="d-block mb-2" />
|
||||
))}
|
||||
<span className="visually-hidden">Loading…</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** A whole page's worth, for the full-page "Loading…" states (a title bar, then a card of lines). */
|
||||
export function PageSkeleton() {
|
||||
return (
|
||||
<div role="status" aria-live="polite">
|
||||
<Skeleton width="14rem" height="1.6rem" className="d-block mb-4" />
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<BlockSkeleton lines={5} />
|
||||
</div>
|
||||
</div>
|
||||
<span className="visually-hidden">Loading…</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -17,6 +17,8 @@ let state: State = { report: null, failed: false };
|
||||
const listeners = new Set<() => void>();
|
||||
let timer: ReturnType<typeof setInterval> | null = null;
|
||||
let inFlight = false;
|
||||
/** Someone asked again while a look was under way, so that look may predate what they changed: go again once it is done. */
|
||||
let again = false;
|
||||
|
||||
function set(next: State) {
|
||||
state = next;
|
||||
@@ -24,7 +26,10 @@ function set(next: State) {
|
||||
}
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
if (inFlight) return;
|
||||
if (inFlight) {
|
||||
again = true;
|
||||
return;
|
||||
}
|
||||
inFlight = true;
|
||||
try {
|
||||
set({ report: await api.alerts.list(), failed: false });
|
||||
@@ -32,9 +37,20 @@ async function refresh(): Promise<void> {
|
||||
set({ report: state.report, failed: true });
|
||||
} finally {
|
||||
inFlight = false;
|
||||
if (again) {
|
||||
again = false;
|
||||
void refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A maintenance window starting or ending changes what is silenced, so look again at once rather than at the next minute.
|
||||
if (typeof window !== "undefined") {
|
||||
window.addEventListener("maintenance-changed", () => {
|
||||
if (listeners.size > 0) void refresh();
|
||||
});
|
||||
}
|
||||
|
||||
function subscribe(listener: () => void): () => void {
|
||||
listeners.add(listener);
|
||||
if (listeners.size === 1) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import { formatAgo } from "../utils/duration";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import TableToolbar from "../components/TableToolbar";
|
||||
import SilenceButton from "../components/SilenceButton";
|
||||
|
||||
const SEVERITY: Record<AlertSeverity, { label: string; badge: string; rank: number }> = {
|
||||
critical: { label: "Critical", badge: "bg-red-lt text-red", rank: 0 },
|
||||
@@ -32,7 +33,8 @@ const CATEGORY_LABELS: Record<AlertCategory, string> = {
|
||||
|
||||
type Row = AlertItem & { rank: number };
|
||||
|
||||
export default function Alerts(_props: { user: CurrentUser }) {
|
||||
export default function Alerts({ user }: { user: CurrentUser }) {
|
||||
const canSilence = user.role === "admin" || user.role === "operator";
|
||||
const [report, setReport] = useState<AlertsReport | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -211,6 +213,7 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
||||
<SortableTh<Row> label="Kind" sortKeyName="category" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Source" sortKeyName="source" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
<SortableTh<Row> label="Alert" sortKeyName="message" activeKey={sortKey} direction={sortDir} onSort={requestSort} />
|
||||
{canSilence && <th className="w-1"></th>}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -243,11 +246,16 @@ export default function Alerts(_props: { user: CurrentUser }) {
|
||||
);
|
||||
})()}
|
||||
</td>
|
||||
{canSilence && (
|
||||
<td className="text-nowrap">
|
||||
<SilenceButton alert={a} onDone={() => void load(true)} />
|
||||
</td>
|
||||
)}
|
||||
</tr>
|
||||
))}
|
||||
{(sorted ?? []).length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={4} className="text-secondary text-center">
|
||||
<td colSpan={canSilence ? 5 : 4} className="text-secondary text-center">
|
||||
Nothing matches these filters.
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
import { formatAgo } from "../utils/duration";
|
||||
import StatusStrip from "../components/StatusStrip";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { WidgetSkeleton } from "../components/Skeleton";
|
||||
|
||||
const DNS_TYPE_COLORS: Record<string, string> = {
|
||||
A: "#60a5fa",
|
||||
@@ -579,7 +580,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
>
|
||||
<ErrorNotice error={dnsError} className="mb-2" />
|
||||
{!dnsStats ? (
|
||||
<div className="text-secondary">Fetching status…</div>
|
||||
<WidgetSkeleton />
|
||||
) : dnsStats.totalProviders === 0 ? (
|
||||
<div className="text-secondary">
|
||||
Configure a DNS provider from the <Link to="/dns">DNS</Link> page.
|
||||
@@ -628,7 +629,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
>
|
||||
{!secrets ? (
|
||||
<div className="text-secondary">Fetching status…</div>
|
||||
<WidgetSkeleton />
|
||||
) : totalSecrets === 0 ? (
|
||||
<div className="text-secondary">
|
||||
Configure a secret from the <Link to="/secrets">Secrets</Link> page.
|
||||
@@ -672,7 +673,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
>
|
||||
<ErrorNotice error={serverError} className="mb-2" />
|
||||
{!serverSummary ? (
|
||||
!serverError && <div className="text-secondary">Fetching status…</div>
|
||||
!serverError && <WidgetSkeleton />
|
||||
) : serverSummary.total === 0 ? (
|
||||
<div className="text-secondary">
|
||||
Add a server from the <Link to="/servers">Servers</Link> page.
|
||||
@@ -765,7 +766,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
>
|
||||
<ErrorNotice error={domainError} className="mb-2" />
|
||||
{!domainList ? (
|
||||
!domainError && <div className="text-secondary">Fetching status…</div>
|
||||
!domainError && <WidgetSkeleton />
|
||||
) : domains.length === 0 ? (
|
||||
<div className="text-secondary">
|
||||
Domains for your DNS zones appear on the <Link to="/domains">Domains</Link> page after the next daily check, or add one there.
|
||||
@@ -1081,7 +1082,7 @@ export default function Dashboard({ user }: { user: CurrentUser }) {
|
||||
) : (
|
||||
<div className="text-secondary mt-2">
|
||||
{integration ? (
|
||||
"Fetching status…"
|
||||
<WidgetSkeleton />
|
||||
) : (
|
||||
<>
|
||||
Configure this integration from the <Link to="/integrations">Integrations</Link> page.
|
||||
|
||||
@@ -21,6 +21,7 @@ import { guessAdminUrl, portOptionLabel } from "../utils/adminLinkUrl";
|
||||
import { confirmDialog } from "../utils/dialogs";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { useBreadcrumbTail } from "../utils/breadcrumb";
|
||||
import { PageSkeleton } from "../components/Skeleton";
|
||||
|
||||
const SCHEDULE_TYPE_OPTIONS: { value: ScheduleType; label: string }[] = Object.entries(SCHEDULE_TYPE_LABELS).map(
|
||||
([value, label]) => ({ value: value as ScheduleType, label }),
|
||||
@@ -344,7 +345,7 @@ export default function ServerDetail({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div className="text-secondary">Loading…</div>;
|
||||
if (loading) return <PageSkeleton />;
|
||||
if (error && !detail) return <div className="alert alert-danger">{error}</div>;
|
||||
if (!detail) return null;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { api } from "../../api/client";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
|
||||
const PROVIDER_NAMES: Record<string, string> = {
|
||||
cloudflare: "Cloudflare",
|
||||
@@ -92,7 +93,7 @@ export default function BadgeSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div className="text-secondary">Loading…</div>;
|
||||
if (loading) return <PageSkeleton />;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { api, type AppSettings, type DateFormat, type TimeFormat } from "../../a
|
||||
import { setDateTimeSettings } from "../../utils/date";
|
||||
import { setPageSize } from "../../utils/pageSize";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
|
||||
const DATE_FORMAT_OPTIONS: { value: DateFormat; label: string; example: string }[] = [
|
||||
{ value: "ymd", label: "Year-Month-Day", example: "2026-09-15" },
|
||||
@@ -53,7 +54,7 @@ export default function DisplaySettings() {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div className="text-secondary">Loading…</div>;
|
||||
if (loading) return <PageSkeleton />;
|
||||
|
||||
const dateExample = DATE_FORMAT_OPTIONS.find((o) => o.value === dateFormat)?.example ?? "";
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { api, type AppSettings } from "../../api/client";
|
||||
import { confirmDialog } from "../../utils/dialogs";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
|
||||
const INTERVAL_OPTIONS: { value: number; label: string }[] = [
|
||||
{ value: 1, label: "Every hour" },
|
||||
@@ -67,7 +68,7 @@ export default function LogSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div className="text-secondary">Loading…</div>;
|
||||
if (loading) return <PageSkeleton />;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type HealthCheckSettings,
|
||||
} from "../../api/client";
|
||||
import { ErrorNotice } from "../../components/Notice";
|
||||
import { PageSkeleton } from "../../components/Skeleton";
|
||||
|
||||
const TIMEZONES = [
|
||||
"UTC",
|
||||
@@ -57,7 +58,7 @@ const DEFAULT_NOTIFICATIONS: NotificationEvents = {
|
||||
integrationFailureThreshold: 3,
|
||||
};
|
||||
const DEFAULT_QUIET_HOURS: QuietHoursSettings = { enabled: false, start: "22:00", end: "07:00" };
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30 };
|
||||
const DEFAULT_HEALTH_CHECKS: HealthCheckSettings = { serverOfflineMinutes: 60, diskUsagePercent: 90, domainWarnDays: 30, diskForecastDays: 14 };
|
||||
|
||||
type TestResult = { ok: boolean; message: string } | null;
|
||||
|
||||
@@ -198,7 +199,7 @@ export default function NotificationSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <div className="text-secondary">Loading…</div>;
|
||||
if (loading) return <PageSkeleton />;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -598,6 +599,24 @@ export default function NotificationSettings() {
|
||||
</div>
|
||||
<div className="form-hint">Servers, Proxmox storage, Synology volumes. Checked every 15 min; a recovery notice follows.</div>
|
||||
</div>
|
||||
<div className="col-6">
|
||||
<label className="form-label">Warn when a disk will fill within</label>
|
||||
<div className="input-group">
|
||||
<input
|
||||
type="number"
|
||||
className="form-control"
|
||||
min={0}
|
||||
max={90}
|
||||
value={healthChecks.diskForecastDays}
|
||||
onChange={(e) => setHealthChecks((h) => ({ ...h, diskForecastDays: Number(e.target.value) }))}
|
||||
/>
|
||||
<span className="input-group-text">days</span>
|
||||
</div>
|
||||
<div className="form-hint">
|
||||
From each agent server's own history, shown on the Alerts page and dashboard (not sent as a notification). Needs a few days of
|
||||
steady growth to say anything. 0 turns it off.
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-6">
|
||||
<label className="form-label">Domain expiry warning</label>
|
||||
<div className="input-group">
|
||||
|
||||
@@ -264,6 +264,33 @@ html[data-env] .navbar-vertical {
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Skeletons: grey stand-ins for text and figures that are still loading, so the page doesn't jump when they arrive. ── */
|
||||
.skeleton {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
background-color: color-mix(in srgb, currentColor 12%, transparent);
|
||||
background-image: linear-gradient(90deg, transparent 0%, color-mix(in srgb, currentColor 14%, transparent) 50%, transparent 100%);
|
||||
background-repeat: no-repeat;
|
||||
background-size: 40% 100%;
|
||||
border-radius: 0.25rem;
|
||||
animation: skeleton-shimmer 1.4s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes skeleton-shimmer {
|
||||
from {
|
||||
background-position: -60% 0;
|
||||
}
|
||||
to {
|
||||
background-position: 160% 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.skeleton {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sidebar submenus: a little tighter than Tabler's dropdown rows, so several open groups still fit on one screen. */
|
||||
.navbar-vertical .dropdown-menu .dropdown-item {
|
||||
padding-top: 0.3rem;
|
||||
|
||||
Reference in new issue
Block a user