Lidarr/Readarr, integration inspector, app versions, grouped alerts
Lidarr and Readarr join the shared *arr reader. Integrations get an Inspect button that runs the reader once and shows what each request returned as shapes (never values) and where the result is empty. Operations -> App versions compares each application's version with its newest GitHub release (lookup off until an admin switches it on; optional alert). The Alerts page can group by source, kind of problem or type of alert. The shared HTTP helper no longer reuses connections (stale-socket resets). Migration 0078; docs and tests included. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
551eb1597a
commit
93aaf5476d
45 files changed
+10033
-65
No files matched your search
@@ -16,6 +16,8 @@ import SilenceButton from "../components/SilenceButton";
|
||||
import RunPlaybookButton from "../components/RunPlaybookButton";
|
||||
import RunbookEntry from "../components/RunbookEntry";
|
||||
import AlertKindRunbookEntry from "../components/AlertKindRunbook";
|
||||
import AlertGroupRow from "../components/AlertGroupRow";
|
||||
import { GROUP_BY_LABELS, groupAlerts, isGroup, type GroupBy } from "../utils/alertGroups";
|
||||
import AckDrawer, { ackWords } from "../components/AckDrawer";
|
||||
import CloseDrawer, { CloseBulkDrawer } from "../components/CloseDrawer";
|
||||
import SnoozeDrawer, { SnoozeBulkDrawer, snoozeWords } from "../components/SnoozeDrawer";
|
||||
@@ -122,6 +124,25 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
}
|
||||
});
|
||||
const [open, setOpen] = useState<Set<string>>(new Set());
|
||||
// The alerts in groups — by where they come from, what kind of problem, or what type of alert — each group folding away; remembered. (Not the same as the nesting above, which is by cause.)
|
||||
const [groupBy, setGroupBy] = useState<GroupBy>(() => {
|
||||
try {
|
||||
const v = localStorage.getItem("alerts.groupBy");
|
||||
return v === "source" || v === "category" || v === "kind" ? v : "none";
|
||||
} catch {
|
||||
return "none";
|
||||
}
|
||||
});
|
||||
const [foldedGroups, setFoldedGroups] = useState<Set<string>>(new Set());
|
||||
function chooseGroupBy(by: GroupBy) {
|
||||
setGroupBy(by);
|
||||
setFoldedGroups(new Set());
|
||||
try {
|
||||
localStorage.setItem("alerts.groupBy", by);
|
||||
} catch {
|
||||
// a remembered choice is only a convenience
|
||||
}
|
||||
}
|
||||
function chooseGrouped(on: boolean) {
|
||||
setGrouped(on);
|
||||
try {
|
||||
@@ -182,6 +203,17 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
const { sorted, sortKey, sortDir, requestSort } = useSortable(rows);
|
||||
const { pageItems, page, setPage, pageCount, totalCount } = usePagination(sorted);
|
||||
|
||||
// Grouped, every alert is shown (a page is cut across groups); not grouped, a page at a time.
|
||||
const shown = useMemo(() => groupAlerts(groupBy === "none" ? (pageItems ?? []) : (sorted ?? []), groupBy, foldedGroups, (c) => CATEGORY_LABELS[c]), [groupBy, pageItems, sorted, foldedGroups]);
|
||||
function toggleGroup(id: string) {
|
||||
setFoldedGroups((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
const presentCategories = useMemo(() => [...new Set((report?.alerts ?? []).map((a) => a.category))], [report]);
|
||||
|
||||
function exportCsv() {
|
||||
@@ -225,6 +257,15 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
return next;
|
||||
});
|
||||
}
|
||||
/** Ticks everything in a group that can be ticked — or, when all of it is, unticks it. */
|
||||
function pickGroup(ids: string[]) {
|
||||
setPicked((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (ids.length > 0 && ids.every((id) => next.has(id))) for (const id of ids) next.delete(id);
|
||||
else for (const id of ids) next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
function afterBulk() {
|
||||
void load(true);
|
||||
reloadBadge();
|
||||
@@ -429,6 +470,13 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
<option value="warning">Warning</option>
|
||||
<option value="info">Info</option>
|
||||
</select>
|
||||
<select className="form-select form-select-sm w-auto" value={groupBy} aria-label="Grouping" onChange={(e) => chooseGroupBy(e.target.value as GroupBy)}>
|
||||
{(Object.keys(GROUP_BY_LABELS) as GroupBy[]).map((g) => (
|
||||
<option key={g} value={g}>
|
||||
{GROUP_BY_LABELS[g]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<select className="form-select form-select-sm w-auto" value={category} onChange={(e) => setCategory(e.target.value as "all" | AlertCategory)}>
|
||||
<option value="all">All kinds</option>
|
||||
{presentCategories.map((c) => (
|
||||
@@ -496,7 +544,10 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(pageItems ?? []).map((a) => (
|
||||
{shown.map((a) =>
|
||||
isGroup(a) ? (
|
||||
<AlertGroupRow key={a.id} group={a} colSpan={canSilence ? 5 : 4} canPick={canSilence} allPicked={a.pickable.length > 0 && a.pickable.every((id) => picked.has(id))} onToggle={() => toggleGroup(a.id)} onPick={() => pickGroup(a.pickable)} />
|
||||
) : (
|
||||
<Fragment key={a.id}>
|
||||
<tr className={`alert-row alert-row-${a.severity}${a.silenced ? " text-secondary" : ""}`} style={a.silenced ? { opacity: 0.65 } : undefined}>
|
||||
<td>
|
||||
@@ -648,7 +699,7 @@ function AlertsNow({ user, tabs }: { user: CurrentUser; tabs: React.ReactNode })
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<Pagination page={page} pageCount={pageCount} totalCount={totalCount} onPageChange={setPage} />
|
||||
{groupBy === "none" && <Pagination page={page} pageCount={pageCount} totalCount={totalCount} onPageChange={setPage} />}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
|
||||
@@ -13,7 +13,8 @@ import { ErrorNotice } from "../components/Notice";
|
||||
import { toast } from "../utils/toast";
|
||||
import UptimeRibbon from "../components/UptimeRibbon";
|
||||
import RunbookEntry from "../components/RunbookEntry";
|
||||
import { groupOfType, TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
|
||||
import IntegrationInspector from "../components/IntegrationInspector";
|
||||
import { groupOfType, INSPECTABLE, TYPE_GROUPS, TYPE_LABELS, TYPE_PAGES } from "../utils/integrationTypes";
|
||||
|
||||
/** "pve.example.lan" out of "https://pve.example.lan:8006/", or the text itself when it isn't an address. */
|
||||
function hostOf(baseUrl: string): string {
|
||||
@@ -85,6 +86,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
const [integrations, setIntegrations] = useState<IntegrationSummary[] | null>(null);
|
||||
const [adding, setAdding] = useState(false);
|
||||
const [editingIntegration, setEditingIntegration] = useState<IntegrationSummary | null>(null);
|
||||
const [inspecting, setInspecting] = useState<IntegrationSummary | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [integrationColors, setIntegrationColors] = useState<Record<string, string>>({});
|
||||
const [testingId, setTestingId] = useState<number | null>(null);
|
||||
@@ -184,6 +186,7 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
</div>
|
||||
{tabs}
|
||||
<ErrorNotice error={error} />
|
||||
{inspecting && <IntegrationInspector integration={inspecting} onClose={() => setInspecting(null)} />}
|
||||
|
||||
{editingIntegration ? (
|
||||
<IntegrationEditForm
|
||||
@@ -293,6 +296,11 @@ function IntegrationsList({ user, tabs }: { user: CurrentUser; tabs: ReactNode }
|
||||
<button className="btn btn-sm" onClick={() => testIntegration(i)} disabled={testingId === i.id}>
|
||||
{testingId === i.id ? "Testing…" : "Test"}
|
||||
</button>
|
||||
{i.enabled && INSPECTABLE.includes(i.type) && (
|
||||
<button className="btn btn-sm" onClick={() => setInspecting(i)} title="Read it once now and see what each request got back — to check that what is shown is what is there">
|
||||
Inspect
|
||||
</button>
|
||||
)}
|
||||
<button className="btn btn-sm" onClick={() => setEditingIntegration(i)}>
|
||||
Edit
|
||||
</button>
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ErrorNotice } from "../components/Notice";
|
||||
import { formatBytes } from "./settings/StorageSettings";
|
||||
import { readableError } from "../utils/errors";
|
||||
|
||||
const KIND_NAMES: Record<ArrApp["kind"], string> = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr" };
|
||||
const KIND_NAMES: Record<ArrApp["kind"], string> = { sonarr: "Sonarr", radarr: "Radarr", prowlarr: "Prowlarr", lidarr: "Lidarr", readarr: "Readarr" };
|
||||
const QUEUE_SHOWN = 25;
|
||||
|
||||
function Badge({ a }: { a: ArrApp }) {
|
||||
@@ -214,7 +214,7 @@ export default function Media() {
|
||||
<>
|
||||
<h2 className="page-title">Media managers</h2>
|
||||
<p className="text-secondary">
|
||||
Sonarr, Radarr and Prowlarr, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is searched, grabbed or changed. <strong>What an application says is wrong with itself</strong>, <strong>downloads stuck for two hours</strong> and{" "}
|
||||
Sonarr, Radarr, Prowlarr, Lidarr and Readarr, read every few minutes (see <Link to="/integrations">Integrations</Link>) — nothing is searched, grabbed or changed. <strong>What an application says is wrong with itself</strong>, <strong>downloads stuck for two hours</strong> and{" "}
|
||||
<strong>a disk nearly full</strong> are alerts — see <Link to="/alerts">Alerts</Link>.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
@@ -222,7 +222,7 @@ export default function Media() {
|
||||
{data && data.length === 0 && (
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<EmptyState title="No Sonarr, Radarr or Prowlarr connected" hint="Add one under Integrations with its address and API key (Settings → General → Security → API Key in the application)." />
|
||||
<EmptyState title="No media manager connected" hint="Add one under Integrations with its address and API key (Settings → General → Security → API Key in the application)." />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { api, type AppVersions, type CurrentUser } from "../api/client";
|
||||
import EmptyState from "../components/EmptyState";
|
||||
import TimeAgo from "../components/TimeAgo";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import { ErrorNotice } from "../components/Notice";
|
||||
import { readableError } from "../utils/errors";
|
||||
import { toast } from "../utils/toast";
|
||||
|
||||
type Row = AppVersions["rows"][number];
|
||||
|
||||
const LAG: Record<Row["lag"], { text: string; badge: string }> = {
|
||||
same: { text: "Up to date", badge: "bg-green-lt text-green" },
|
||||
patch: { text: "A patch behind", badge: "bg-blue-lt text-blue" },
|
||||
minor: { text: "A minor update behind", badge: "bg-yellow-lt text-yellow" },
|
||||
major: { text: "A major version behind", badge: "bg-red-lt text-red" },
|
||||
ahead: { text: "Ahead of the newest release", badge: "bg-secondary-lt text-secondary" },
|
||||
unknown: { text: "Not compared", badge: "bg-secondary-lt text-secondary" },
|
||||
};
|
||||
const ORDER: Record<Row["lag"], number> = { major: 0, minor: 1, patch: 2, unknown: 3, ahead: 4, same: 5 };
|
||||
|
||||
/** What each connected application runs, against the newest release of it — the lookup is switched on here, and is the only thing this app asks of an address of its own choosing. */
|
||||
export default function Versions({ user }: { user: CurrentUser }) {
|
||||
const isAdmin = user.role === "admin";
|
||||
const [data, setData] = useState<AppVersions | null>(null);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [days, setDays] = useState("0");
|
||||
|
||||
const adopt = (d: AppVersions) => {
|
||||
setData(d);
|
||||
setDays(String(d.alertAfterDays));
|
||||
setError(null);
|
||||
};
|
||||
useEffect(() => {
|
||||
api.versions
|
||||
.get()
|
||||
.then(adopt)
|
||||
.catch((err) => setError(readableError(err)));
|
||||
}, []);
|
||||
|
||||
async function save(enabled: boolean, alertAfterDays: number) {
|
||||
setBusy(true);
|
||||
try {
|
||||
adopt(await api.versions.save({ enabled, alertAfterDays }));
|
||||
toast.success(enabled ? "Saved." : "Switched off.");
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
setBusy(true);
|
||||
try {
|
||||
const r = await api.versions.refresh();
|
||||
adopt(r);
|
||||
toast[r.result.failed > 0 ? "error" : "success"](r.result.failed > 0 ? `${r.result.failed} could not be looked up — see the list.` : `Looked up ${r.result.checked}.`);
|
||||
} catch (err) {
|
||||
toast.error(readableError(err));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
const rows = [...(data?.rows ?? [])].sort((a, b) => ORDER[a.lag] - ORDER[b.lag] || a.label.localeCompare(b.label));
|
||||
const behind = rows.filter((r) => r.lag === "patch" || r.lag === "minor" || r.lag === "major").length;
|
||||
return (
|
||||
<>
|
||||
<h2 className="page-title">App versions</h2>
|
||||
<p className="text-secondary">
|
||||
The version each connected application runs — as it was last read (see <Link to="/integrations">Integrations</Link>) — against the newest release of it. It looks the newest ones up on GitHub once a day; <strong>that is the only thing this app asks of an address that is not yours</strong>, so it is switched
|
||||
off until you switch it on. Proxmox, Synology and the rest, which have no release to compare with, are not listed.
|
||||
</p>
|
||||
<ErrorNotice error={error} />
|
||||
{!data && !error && <BlockSkeleton lines={4} />}
|
||||
{data && (
|
||||
<>
|
||||
<div className="card mb-3">
|
||||
<div className="card-body">
|
||||
<label className="form-check mb-2">
|
||||
<input type="checkbox" className="form-check-input" checked={data.enabled} disabled={!isAdmin || busy} onChange={(e) => void save(e.target.checked, Number(days) || 0)} />
|
||||
<span className="form-check-label">
|
||||
Look up the newest releases
|
||||
<span className="form-hint d-block">
|
||||
Asks <code>api.github.com</code> for the newest release of each application you have connected — its name, nothing about you or your systems. An administrator can switch this.
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div className="d-flex flex-wrap align-items-center gap-2">
|
||||
<label htmlFor="alert-after">Warn when a newer release has been out for</label>
|
||||
<input
|
||||
id="alert-after"
|
||||
className="form-control form-control-sm"
|
||||
style={{ width: 80 }}
|
||||
inputMode="numeric"
|
||||
value={days}
|
||||
disabled={!isAdmin || busy || !data.enabled}
|
||||
onChange={(e) => setDays(e.target.value.replace(/[^0-9]/g, ""))}
|
||||
onBlur={() => Number(days) !== data.alertAfterDays && void save(data.enabled, Math.min(365, Number(days) || 0))}
|
||||
/>
|
||||
<span>days (0 = never)</span>
|
||||
{isAdmin && data.enabled && (
|
||||
<button className="btn btn-sm ms-auto" disabled={busy} onClick={() => void refresh()}>
|
||||
{busy ? "Looking…" : "Look up now"}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="text-secondary small mt-2">
|
||||
{data.enabled ? (data.lastCheckedAt ? <>Last looked up <TimeAgo value={data.lastCheckedAt} />.</> : "Not looked up yet — it is done a few minutes after it is switched on.") : "Switched off."} A warning is raised under <Link to="/alerts">Alerts</Link> only with a number of days above 0.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div className="card">
|
||||
<div className="card-body">
|
||||
<EmptyState title="No versions known yet" hint="An application's version is known once its integration has been read: Sonarr, Radarr, Prowlarr, Lidarr, Readarr, AdGuard Home, Grafana, Jellyfin, Immich, Paperless-ngx, Nextcloud, NetBox, Authentik and Prometheus are compared." />
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div className="card">
|
||||
<div className="card-header">
|
||||
<h3 className="card-title">
|
||||
{rows.length} {rows.length === 1 ? "application" : "applications"}
|
||||
{data.enabled ? `, ${behind === 0 ? "none behind" : `${behind} behind`}` : ""}
|
||||
</h3>
|
||||
</div>
|
||||
<div className="table-responsive">
|
||||
<table className="table table-vcenter card-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Application</th>
|
||||
<th>Running</th>
|
||||
<th>Newest release</th>
|
||||
<th>Compared</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((r) => (
|
||||
<tr key={r.integrationId}>
|
||||
<td>
|
||||
<strong>{r.label}</strong>
|
||||
<div className="text-secondary small">{r.name}</div>
|
||||
</td>
|
||||
<td>
|
||||
<code>{r.running}</code>
|
||||
</td>
|
||||
<td>
|
||||
{r.latest ? (
|
||||
<>
|
||||
{r.latest.url ? (
|
||||
<a href={r.latest.url} target="_blank" rel="noopener noreferrer">
|
||||
<code>{r.latest.tag}</code>
|
||||
</a>
|
||||
) : (
|
||||
<code>{r.latest.tag}</code>
|
||||
)}
|
||||
{r.latest.publishedAt && (
|
||||
<div className="text-secondary small">
|
||||
out <TimeAgo value={r.latest.publishedAt} />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<span className="text-secondary">{data.enabled ? "not known yet" : "—"}</span>
|
||||
)}
|
||||
{r.lookupError && <div className="text-yellow small">{r.lookupError}</div>}
|
||||
</td>
|
||||
<td>
|
||||
<span className={`badge ${LAG[r.lag].badge}`}>{LAG[r.lag].text}</span>
|
||||
{r.daysOut !== null && <div className="text-secondary small">{r.daysOut === 0 ? "a newer one came out today" : r.daysOut === 1 ? "a newer one has been out a day" : `a newer one has been out ${r.daysOut} days`}</div>}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user