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
@@ -16,6 +16,9 @@ import { readableError } from "../utils/errors";
|
||||
import { KIND_HINTS, KIND_LABELS, money, warrantyDays, warrantyState, yearlyCost, yearlyKwh } from "../utils/inventory";
|
||||
import { toast } from "../utils/toast";
|
||||
import { EmptyRow } from "../components/EmptyState";
|
||||
import BulkBar from "../components/BulkBar";
|
||||
import { HardwareBulkDrawer } from "../components/BulkDrawers";
|
||||
import { doBulk, plural } from "../utils/bulk";
|
||||
|
||||
const KINDS = Object.keys(KIND_LABELS) as AssetKind[];
|
||||
|
||||
@@ -114,6 +117,9 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [priceText, setPriceText] = useState("");
|
||||
const [currencyText, setCurrencyText] = useState("");
|
||||
// Hardware ticked for a change in one go, and whether that form is open.
|
||||
const [picked, setPicked] = useState<Set<number>>(new Set());
|
||||
const [bulkOpen, setBulkOpen] = useState(false);
|
||||
|
||||
const [params, setParams] = useSearchParams();
|
||||
const kind = (KINDS as string[]).includes(params.get("kind") ?? "") ? (params.get("kind") as AssetKind) : "";
|
||||
@@ -166,6 +172,25 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
}
|
||||
}
|
||||
|
||||
const pickedIds = (assets ?? []).filter((a) => picked.has(a.id)).map((a) => a.id);
|
||||
const shownIds = (sorted ?? []).map((a) => a.id);
|
||||
const allShownPicked = shownIds.length > 0 && shownIds.every((id) => picked.has(id));
|
||||
function togglePicked(id: number) {
|
||||
setPicked((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (next.has(id)) next.delete(id);
|
||||
else next.add(id);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
async function bulkChange(change: { location?: string | null; warrantyUntil?: string | null; endOfSupport?: string | null }) {
|
||||
const r = await doBulk({ call: api.bulk.inventory, body: { action: "change", ids: pickedIds, ...change }, done: (res) => `${plural(res.changed, "piece")} of hardware changed.`, reload: load });
|
||||
if (r) {
|
||||
setBulkOpen(false);
|
||||
setPicked(new Set());
|
||||
}
|
||||
}
|
||||
|
||||
async function remove(a: Asset) {
|
||||
if (!(await confirmDialog({ title: "Remove from the inventory", message: `Remove "${a.name}"?`, confirmLabel: "Remove", danger: true }))) return;
|
||||
try {
|
||||
@@ -459,6 +484,27 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
onSearch={tableSearch.setQuery}
|
||||
placeholder="Search hardware…"
|
||||
filters={
|
||||
<>
|
||||
{canEdit && shownIds.length > 0 && (
|
||||
<label className="form-check mb-0">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="form-check-input"
|
||||
checked={allShownPicked}
|
||||
onChange={(e) =>
|
||||
setPicked((prev) => {
|
||||
const next = new Set(prev);
|
||||
for (const id of shownIds) {
|
||||
if (e.target.checked) next.add(id);
|
||||
else next.delete(id);
|
||||
}
|
||||
return next;
|
||||
})
|
||||
}
|
||||
/>
|
||||
<span className="form-check-label">Pick all {shownIds.length} shown</span>
|
||||
</label>
|
||||
)}
|
||||
<select
|
||||
className="form-select form-select-sm w-auto"
|
||||
aria-label="Show hardware of kind"
|
||||
@@ -482,6 +528,7 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
}
|
||||
shown={sorted?.length}
|
||||
total={all.length}
|
||||
@@ -512,6 +559,7 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
{page.pageItems?.map((a) => (
|
||||
<tr key={a.id}>
|
||||
<td className="stack-wide">
|
||||
{canEdit && <input type="checkbox" className="form-check-input me-2 align-middle" aria-label={`Pick ${a.name}`} checked={picked.has(a.id)} onChange={() => togglePicked(a.id)} />}
|
||||
{a.name}
|
||||
{(a.manufacturer || a.model) && <div className="text-secondary small">{[a.manufacturer, a.model].filter(Boolean).join(" ")}</div>}
|
||||
{a.server && (
|
||||
@@ -565,6 +613,21 @@ export default function Inventory({ user }: { user: CurrentUser }) {
|
||||
<Pagination page={page.page} pageCount={page.pageCount} totalCount={page.totalCount} onPageChange={page.setPage} />
|
||||
</div>
|
||||
|
||||
{canEdit && pickedIds.length > 0 && (
|
||||
<>
|
||||
<div className="has-bulk-bar" />
|
||||
<BulkBar count={pickedIds.length} noun={pickedIds.length === 1 ? "piece" : "pieces"} onClear={() => setPicked(new Set())}>
|
||||
<button type="button" className="btn btn-sm btn-primary" onClick={() => setBulkOpen(true)}>
|
||||
Change where / dates…
|
||||
</button>
|
||||
<Link to={`/inventory/labels?only=${pickedIds.join(",")}`} className="btn btn-sm">
|
||||
Print labels
|
||||
</Link>
|
||||
</BulkBar>
|
||||
</>
|
||||
)}
|
||||
{bulkOpen && <HardwareBulkDrawer count={pickedIds.length} onSubmit={bulkChange} onClose={() => setBulkOpen(false)} />}
|
||||
|
||||
{isAdmin && (
|
||||
<form className="card" onSubmit={saveConfig}>
|
||||
<div className="card-header">
|
||||
|
||||
Reference in new issue
Block a user