Flapping alerts, a noise report and bulk actions with undo
Flapping: an alert raised three times within an hour is announced once as flapping, its further raise/clear messages are held until it has been calm for an hour, and one message then says whether it is still active. Event webhooks still hear everything. The state survives restarts. Alerts > Noise lists the alerts that keep coming back (7-180 days): how often, how long, most in an hour, and a hint on what helps. Bulk actions on Alerts (acknowledge, remove acknowledgement, silence), Servers (tag, silence, runs on) and Inventory (location and dates, print labels). Each reports what it left alone and why, and has an Undo on the toast. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
be6c5552bd
commit
73a06ebe63
35 files changed
+2546
-17
No files matched your search
+126
-1
@@ -23,6 +23,9 @@ import SaveViewButton from "../components/SaveViewButton";
|
||||
import { agentState } from "../utils/agent";
|
||||
import { BlockSkeleton } from "../components/Skeleton";
|
||||
import EmptyState, { EmptyRow, LoadingRow } from "../components/EmptyState";
|
||||
import BulkBar from "../components/BulkBar";
|
||||
import { RunsOnBulkDrawer, SilenceBulkDrawer, TagBulkDrawer } from "../components/BulkDrawers";
|
||||
import { doBulk, plural } from "../utils/bulk";
|
||||
|
||||
function typeBadgeStyle(colors: Record<string, string>, type: string): CSSProperties {
|
||||
const color = colors[type];
|
||||
@@ -53,6 +56,10 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
// Picking servers to compare their trends side by side.
|
||||
const [comparing, setComparing] = useState(false);
|
||||
const [picked, setPicked] = useState<number[]>([]);
|
||||
// Picking servers to change several at once (tags, maintenance, what they run on), and which form is open.
|
||||
const [selecting, setSelecting] = useState(false);
|
||||
const [chosen, setChosen] = useState<Set<number>>(new Set());
|
||||
const [bulkForm, setBulkForm] = useState<"tag" | "silence" | "runson" | null>(null);
|
||||
const tagColors = useTagColors();
|
||||
|
||||
useEffect(() => {
|
||||
@@ -188,6 +195,8 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
changeParams((next) => (value ? next.set("status", value) : next.delete("status")));
|
||||
}
|
||||
|
||||
// Operators and administrators can change several servers at once; a viewer only looks.
|
||||
const canChange = user.role === "admin" || user.role === "operator";
|
||||
const MAX_COMPARE = 4;
|
||||
function togglePicked(id: number) {
|
||||
setPicked((prev) => (prev.includes(id) ? prev.filter((x) => x !== id) : prev.length >= MAX_COMPARE ? prev : [...prev, id]));
|
||||
@@ -196,6 +205,27 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
setComparing(false);
|
||||
setPicked([]);
|
||||
}
|
||||
function stopSelecting() {
|
||||
setSelecting(false);
|
||||
setChosen(new Set());
|
||||
setBulkForm(null);
|
||||
}
|
||||
function toggleChosen(id: number) {
|
||||
setChosen((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
const chosenIds = servers.filter((s) => chosen.has(s.id)).map((s) => s.id);
|
||||
async function runBulk(body: Record<string, unknown>, done: (changed: number) => string): Promise<void> {
|
||||
const r = await doBulk({ call: api.bulk.servers, body, done: (res) => done(res.changed), reload: () => void loadServers() });
|
||||
if (r) {
|
||||
setBulkForm(null);
|
||||
setChosen(new Set());
|
||||
}
|
||||
}
|
||||
|
||||
const cardBody = (s: ServerRecord) => (
|
||||
<div className="card-body">
|
||||
@@ -505,10 +535,37 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
<div className="ms-auto d-flex flex-wrap gap-2">
|
||||
<SaveViewButton />
|
||||
{servers.length > 1 && (
|
||||
<button type="button" className={`btn btn-sm ${comparing ? "btn-primary" : "btn-outline-secondary"}`} aria-pressed={comparing} onClick={() => (comparing ? stopComparing() : setComparing(true))}>
|
||||
<button
|
||||
type="button"
|
||||
className={`btn btn-sm ${comparing ? "btn-primary" : "btn-outline-secondary"}`}
|
||||
aria-pressed={comparing}
|
||||
onClick={() => {
|
||||
if (comparing) stopComparing();
|
||||
else {
|
||||
stopSelecting();
|
||||
setComparing(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Compare
|
||||
</button>
|
||||
)}
|
||||
{canChange && (
|
||||
<button
|
||||
type="button"
|
||||
className={`btn btn-sm ${selecting ? "btn-primary" : "btn-outline-secondary"}`}
|
||||
aria-pressed={selecting}
|
||||
onClick={() => {
|
||||
if (selecting) stopSelecting();
|
||||
else {
|
||||
stopComparing();
|
||||
setSelecting(true);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Select
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{comparing && (
|
||||
@@ -532,6 +589,19 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{selecting && (
|
||||
<div className="alert alert-info d-flex flex-wrap align-items-center gap-2" role="status">
|
||||
<span>Pick the servers to change together, then choose what to do from the bar at the foot of the page. {chosenIds.length} picked.</span>
|
||||
<div className="ms-auto d-flex gap-2">
|
||||
<button type="button" className="btn btn-sm" onClick={() => setChosen(new Set(visibleServers.map((s) => s.id)))} disabled={visibleServers.length === 0}>
|
||||
Pick all {visibleServers.length} shown
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm" onClick={stopSelecting}>
|
||||
Done
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{allTags.length > 0 && (
|
||||
<div className="d-flex flex-wrap align-items-center gap-1 mb-3">
|
||||
<span className="text-secondary small me-1">Tags</span>
|
||||
@@ -579,6 +649,15 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
>
|
||||
{cardBody(s)}
|
||||
</button>
|
||||
) : selecting ? (
|
||||
<button
|
||||
type="button"
|
||||
className={`card card-sm text-reset text-start w-100 compare-card ${chosen.has(s.id) ? "compare-card-on" : ""}`}
|
||||
aria-pressed={chosen.has(s.id)}
|
||||
onClick={() => toggleChosen(s.id)}
|
||||
>
|
||||
{cardBody(s)}
|
||||
</button>
|
||||
) : (
|
||||
<Link to={`/servers/${s.id}`} className="card card-sm text-reset text-decoration-none">
|
||||
{cardBody(s)}
|
||||
@@ -589,6 +668,52 @@ export default function Servers({ user }: { user: CurrentUser }) {
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{selecting && chosenIds.length > 0 && (
|
||||
<>
|
||||
<div className="has-bulk-bar" />
|
||||
<BulkBar count={chosenIds.length} noun={chosenIds.length === 1 ? "server" : "servers"} onClear={() => setChosen(new Set())}>
|
||||
<button type="button" className="btn btn-sm btn-primary" onClick={() => setBulkForm("tag")}>
|
||||
Tag…
|
||||
</button>
|
||||
<button type="button" className="btn btn-sm" onClick={() => setBulkForm("silence")}>
|
||||
Silence…
|
||||
</button>
|
||||
{isAdmin && (
|
||||
<button type="button" className="btn btn-sm" onClick={() => setBulkForm("runson")}>
|
||||
Runs on…
|
||||
</button>
|
||||
)}
|
||||
</BulkBar>
|
||||
</>
|
||||
)}
|
||||
{bulkForm === "tag" && (
|
||||
<TagBulkDrawer
|
||||
count={chosenIds.length}
|
||||
tags={allTags}
|
||||
onClose={() => setBulkForm(null)}
|
||||
onSubmit={(v) =>
|
||||
runBulk({ action: v.mode === "add" ? "add_tag" : "remove_tag", ids: chosenIds, tag: v.tag }, (n) => (v.mode === "add" ? `Tagged ${plural(n, "server")} ${v.tag}.` : `Took ${v.tag} off ${plural(n, "server")}.`))
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{bulkForm === "silence" && (
|
||||
<SilenceBulkDrawer
|
||||
noun={chosenIds.length === 1 ? "server" : "servers"}
|
||||
count={chosenIds.length}
|
||||
canSilenceDependents
|
||||
onClose={() => setBulkForm(null)}
|
||||
onSubmit={(v) => runBulk({ action: "silence", ids: chosenIds, ...v }, (n) => `${plural(n, "server")} put under maintenance.`)}
|
||||
/>
|
||||
)}
|
||||
{bulkForm === "runson" && (
|
||||
<RunsOnBulkDrawer
|
||||
count={chosenIds.length}
|
||||
servers={servers.filter((s) => !chosen.has(s.id)).map((s) => ({ id: s.id, name: s.name }))}
|
||||
onClose={() => setBulkForm(null)}
|
||||
onSubmit={(parentServerId) => runBulk({ action: "set_parent", ids: chosenIds, parentServerId }, (n) => `${plural(n, "server")} changed.`)}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user