@nivaro/react 0.3.50 → 0.3.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +13 -3
- package/dist/shared/components/ItemEditForm.js +4720 -4593
- package/dist/shared/components/QueryTable.js +337 -324
- package/dist/shared/components/ReportView.js +105 -99
- package/dist/shared/components/alerts/AlertManagerView.js +327 -301
- package/dist/shared/components/item-edit/CatalogPickerField.js +1149 -1111
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
- package/dist/shared/components/item-edit/FieldRenderer.js +227 -223
- package/dist/shared/components/item-edit/FieldRow.js +287 -265
- package/dist/shared/components/item-edit/FilePickerField.js +315 -307
- package/dist/shared/components/item-edit/InlineTableField.js +491 -466
- package/dist/shared/components/item-edit/RecordHeaderActions.js +76 -75
- package/dist/shared/components/item-edit/RecordLiveSync.js +93 -91
- package/dist/shared/components/item-edit/RelationCombobox.js +62 -60
- package/dist/shared/components/item-edit/SummaryPanel.js +287 -277
- package/dist/shared/components/item-edit/UserChip.js +233 -200
- package/dist/shared/components/item-edit/header-midair.js +51 -0
- package/dist/shared/components/item-edit/line-midair.js +76 -70
- package/dist/shared/components/panels/CommentPanel.js +290 -284
- package/dist/shared/components/panels/ItemLockBanner.js +30 -30
- package/dist/shared/components/panels/PipelinePanel.js +956 -901
- package/dist/shared/components/panels/TaskPanel.js +71 -61
- package/dist/shared/components/panels/TransitionRequirementsDialog.js +569 -439
- package/dist/shared/components/panels/requirement-side-effects.js +40 -0
- package/dist/shared/components/queue/QueueWorklist.js +141 -130
- package/dist/shared/lib/draft-store.js +48 -34
- package/dist/shared/lib/query-stats.js +60 -60
- package/package.json +1 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { jsx as t, jsxs as l, Fragment as
|
|
2
|
-
import { listNotificationSubscriptions as
|
|
3
|
-
import { useQueryClient as
|
|
4
|
-
import { LayoutGrid as
|
|
5
|
-
import { useState as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { useMyScopes as
|
|
8
|
-
import { cn as
|
|
9
|
-
import { ToggleSwitch as A, SelectInput as
|
|
10
|
-
import { OPERATOR_LABELS as
|
|
11
|
-
const
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as ct } from "react/jsx-runtime";
|
|
2
|
+
import { listNotificationSubscriptions as mt, deleteNotificationSubscription as ht } from "@nivaro/sdk";
|
|
3
|
+
import { useQueryClient as ut, useQuery as v, useMutation as de } from "@tanstack/react-query";
|
|
4
|
+
import { LayoutGrid as Se, Bell as Ee, BellRing as oe, Clock as pt, ChartColumn as xt, History as $e, FlaskConical as Re, Activity as bt, Plus as ce, Gauge as gt, Users as ft, Lock as yt, Pencil as me, Trash2 as j, Siren as Te } from "lucide-react";
|
|
5
|
+
import { useState as k, useMemo as Y } from "react";
|
|
6
|
+
import { useNivaroClient as vt } from "../../context.js";
|
|
7
|
+
import { useMyScopes as kt, matchScopeDimension as Nt, effectiveScopeSeedIds as wt, translateScopeValues as _t } from "../../lib/use-my-scopes.js";
|
|
8
|
+
import { cn as n } from "../../lib/utils.js";
|
|
9
|
+
import { ToggleSwitch as A, SelectInput as De, AlertRuleDrawer as At, AnomalyRuleDrawer as Ct, NotifSubEditDrawer as St } from "./drawers.js";
|
|
10
|
+
import { OPERATOR_LABELS as Z, fmtMetric as $, fmtDateTime as P } from "./types.js";
|
|
11
|
+
const Et = {
|
|
12
12
|
budget: "bg-orange-50 text-orange-600 dark:bg-orange-500/10 dark:text-orange-400",
|
|
13
13
|
workflows: "bg-sky-50 text-sky-600 dark:bg-sky-500/10 dark:text-sky-400",
|
|
14
14
|
inventory: "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",
|
|
15
15
|
sla: "bg-pink-50 text-pink-600 dark:bg-pink-500/10 dark:text-pink-400",
|
|
16
16
|
compliance: "bg-violet-50 text-violet-600 dark:bg-violet-500/10 dark:text-violet-400",
|
|
17
17
|
spend: "bg-amber-50 text-amber-600 dark:bg-amber-500/10 dark:text-amber-400"
|
|
18
|
-
},
|
|
18
|
+
}, $t = (s) => n(
|
|
19
19
|
"inline-flex rounded-full px-2 py-px text-[10.5px] font-semibold capitalize",
|
|
20
|
-
|
|
20
|
+
Et[s] ?? "bg-slate-100 text-slate-600 dark:bg-muted dark:text-slate-300"
|
|
21
21
|
);
|
|
22
|
-
function
|
|
22
|
+
function O({ status: s }) {
|
|
23
23
|
return /* @__PURE__ */ t(
|
|
24
24
|
"span",
|
|
25
25
|
{
|
|
26
|
-
className:
|
|
26
|
+
className: n(
|
|
27
27
|
"inline-flex rounded-full px-2 py-px text-[10.5px] font-semibold capitalize",
|
|
28
28
|
{
|
|
29
29
|
active: "bg-emerald-50 text-emerald-600 dark:bg-emerald-500/10 dark:text-emerald-400",
|
|
@@ -33,17 +33,23 @@ function F({ status: n }) {
|
|
|
33
33
|
firing: "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400",
|
|
34
34
|
new: "bg-red-50 text-red-600 dark:bg-red-500/10 dark:text-red-400",
|
|
35
35
|
archived: "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
|
|
36
|
-
}[
|
|
36
|
+
}[s] ?? "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400"
|
|
37
37
|
),
|
|
38
|
-
children:
|
|
38
|
+
children: s
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return
|
|
42
|
+
function J(s) {
|
|
43
|
+
return s.created_by ?? null;
|
|
44
|
+
}
|
|
45
|
+
function he({ on: s }) {
|
|
46
|
+
return /* @__PURE__ */ t("span", { className: "text-[11.5px] text-slate-500 dark:text-slate-400", children: s ? "On" : "Off" });
|
|
47
|
+
}
|
|
48
|
+
function q({ n: s, tone: d }) {
|
|
49
|
+
return s ? /* @__PURE__ */ t(
|
|
44
50
|
"span",
|
|
45
51
|
{
|
|
46
|
-
className:
|
|
52
|
+
className: n(
|
|
47
53
|
"ml-1.5 inline-flex min-w-[18px] items-center justify-center rounded-full px-1.5 py-px text-[10px] font-bold",
|
|
48
54
|
{
|
|
49
55
|
red: "bg-red-500 text-white",
|
|
@@ -52,13 +58,13 @@ function T({ n, tone: d }) {
|
|
|
52
58
|
teal: "bg-teal-500 text-white"
|
|
53
59
|
}[d ?? "cyan"]
|
|
54
60
|
),
|
|
55
|
-
children:
|
|
61
|
+
children: s
|
|
56
62
|
}
|
|
57
63
|
) : null;
|
|
58
64
|
}
|
|
59
|
-
const
|
|
60
|
-
function
|
|
61
|
-
const d = Date.now() - new Date(
|
|
65
|
+
const Rt = "px-3 py-2 text-left text-[10px] font-semibold uppercase tracking-wider text-slate-400 dark:text-slate-500", r = "px-3 py-2.5 align-middle text-[12px] text-slate-600 dark:text-slate-300", Tt = n(r, "font-mono tabular-nums text-slate-800 dark:text-slate-100"), w = "inline-flex h-7 w-7 items-center justify-center rounded-md border border-slate-200 text-slate-400 transition-colors hover:border-slate-300 hover:bg-slate-50 hover:text-slate-700 dark:border-border dark:hover:bg-muted/50 dark:hover:text-slate-200";
|
|
66
|
+
function X(s) {
|
|
67
|
+
const d = Date.now() - new Date(s).getTime();
|
|
62
68
|
if (!Number.isFinite(d)) return null;
|
|
63
69
|
const i = Math.floor(d / 6e4);
|
|
64
70
|
if (i < 0) return null;
|
|
@@ -69,24 +75,24 @@ function ce(n) {
|
|
|
69
75
|
const p = Math.floor(u / 24);
|
|
70
76
|
return p < 30 ? `${p}d ago` : null;
|
|
71
77
|
}
|
|
72
|
-
function
|
|
73
|
-
const i = new Date(d).getTime() - new Date(
|
|
78
|
+
function qe(s, d) {
|
|
79
|
+
const i = new Date(d).getTime() - new Date(s).getTime();
|
|
74
80
|
if (!Number.isFinite(i) || i <= 0) return null;
|
|
75
81
|
const u = Math.round(i / 6e4);
|
|
76
82
|
if (u < 60) return `${u}m`;
|
|
77
83
|
const p = Math.round(u / 60);
|
|
78
84
|
return p < 48 ? `${p}h` : `${Math.round(p / 24)}d`;
|
|
79
85
|
}
|
|
80
|
-
function
|
|
81
|
-
if (!
|
|
82
|
-
const i =
|
|
83
|
-
return /* @__PURE__ */ l("span", { className:
|
|
84
|
-
/* @__PURE__ */ t("span", { className: "block whitespace-nowrap text-[11.5px] text-slate-600 dark:text-slate-300", children:
|
|
86
|
+
function ue({ value: s, className: d }) {
|
|
87
|
+
if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
|
|
88
|
+
const i = X(s);
|
|
89
|
+
return /* @__PURE__ */ l("span", { className: n("block leading-tight", d), children: [
|
|
90
|
+
/* @__PURE__ */ t("span", { className: "block whitespace-nowrap text-[11.5px] text-slate-600 dark:text-slate-300", children: P(s) }),
|
|
85
91
|
i && /* @__PURE__ */ t("span", { className: "block text-[10.5px] text-slate-500 dark:text-slate-400", children: i })
|
|
86
92
|
] });
|
|
87
93
|
}
|
|
88
|
-
function
|
|
89
|
-
value:
|
|
94
|
+
function Dt({
|
|
95
|
+
value: s,
|
|
90
96
|
threshold: d,
|
|
91
97
|
unit: i,
|
|
92
98
|
operator: u,
|
|
@@ -96,42 +102,42 @@ function $t({
|
|
|
96
102
|
/* @__PURE__ */ t(
|
|
97
103
|
"span",
|
|
98
104
|
{
|
|
99
|
-
className:
|
|
105
|
+
className: n(
|
|
100
106
|
"text-[12.5px] font-semibold",
|
|
101
107
|
p ? "text-red-600 dark:text-red-400" : "text-slate-800 dark:text-slate-100"
|
|
102
108
|
),
|
|
103
|
-
children:
|
|
109
|
+
children: $(s, i ?? void 0)
|
|
104
110
|
}
|
|
105
111
|
),
|
|
106
112
|
/* @__PURE__ */ l("span", { className: "text-[10.5px] text-slate-400 dark:text-slate-500", children: [
|
|
107
|
-
u ? `${
|
|
108
|
-
|
|
113
|
+
u ? `${Z[u] ?? u} ` : "/ ",
|
|
114
|
+
$(d, i ?? void 0)
|
|
109
115
|
] })
|
|
110
116
|
] });
|
|
111
117
|
}
|
|
112
|
-
function
|
|
113
|
-
operator:
|
|
118
|
+
function qt({
|
|
119
|
+
operator: s,
|
|
114
120
|
threshold: d,
|
|
115
121
|
unit: i
|
|
116
122
|
}) {
|
|
117
123
|
return /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 rounded-md border border-slate-200 bg-slate-50 px-1.5 py-0.5 font-mono text-[11.5px] tabular-nums text-slate-700 dark:border-border dark:bg-muted/40 dark:text-slate-200", children: [
|
|
118
|
-
/* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children:
|
|
119
|
-
|
|
124
|
+
/* @__PURE__ */ t("span", { className: "text-slate-400 dark:text-slate-500", children: Z[s] ?? s }),
|
|
125
|
+
$(d, i ?? void 0)
|
|
120
126
|
] });
|
|
121
127
|
}
|
|
122
|
-
function
|
|
123
|
-
const [d, i] =
|
|
124
|
-
if (!
|
|
125
|
-
const u =
|
|
128
|
+
function Ft({ text: s }) {
|
|
129
|
+
const [d, i] = k(!1);
|
|
130
|
+
if (!s) return /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" });
|
|
131
|
+
const u = s.length > 120;
|
|
126
132
|
return /* @__PURE__ */ l("span", { className: "block", children: [
|
|
127
133
|
/* @__PURE__ */ t(
|
|
128
134
|
"span",
|
|
129
135
|
{
|
|
130
|
-
className:
|
|
136
|
+
className: n(
|
|
131
137
|
"block text-[11.5px] leading-relaxed text-slate-600 dark:text-slate-400",
|
|
132
138
|
!d && "line-clamp-2"
|
|
133
139
|
),
|
|
134
|
-
children:
|
|
140
|
+
children: s
|
|
135
141
|
}
|
|
136
142
|
),
|
|
137
143
|
u && /* @__PURE__ */ t(
|
|
@@ -145,8 +151,8 @@ function Dt({ text: n }) {
|
|
|
145
151
|
)
|
|
146
152
|
] });
|
|
147
153
|
}
|
|
148
|
-
function
|
|
149
|
-
title:
|
|
154
|
+
function pe({
|
|
155
|
+
title: s,
|
|
150
156
|
hint: d,
|
|
151
157
|
action: i,
|
|
152
158
|
wide: u,
|
|
@@ -159,11 +165,11 @@ function oe({
|
|
|
159
165
|
/* @__PURE__ */ l(
|
|
160
166
|
"section",
|
|
161
167
|
{
|
|
162
|
-
className:
|
|
168
|
+
className: n("flex min-h-0 flex-col gap-2", u ? "max-w-[1560px]" : "max-w-[1180px]"),
|
|
163
169
|
children: [
|
|
164
170
|
/* @__PURE__ */ l("header", { className: "flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1", children: [
|
|
165
171
|
/* @__PURE__ */ l("div", { className: "flex items-baseline gap-2.5", children: [
|
|
166
|
-
/* @__PURE__ */ t("h2", { className: "text-[13.5px] font-semibold text-slate-800 dark:text-slate-100", children:
|
|
172
|
+
/* @__PURE__ */ t("h2", { className: "text-[13.5px] font-semibold text-slate-800 dark:text-slate-100", children: s }),
|
|
167
173
|
d && /* @__PURE__ */ t("p", { className: "text-[11.5px] text-slate-400 dark:text-slate-500", children: d })
|
|
168
174
|
] }),
|
|
169
175
|
i
|
|
@@ -175,268 +181,268 @@ function oe({
|
|
|
175
181
|
);
|
|
176
182
|
}
|
|
177
183
|
function C({
|
|
178
|
-
headers:
|
|
184
|
+
headers: s,
|
|
179
185
|
children: d,
|
|
180
186
|
empty: i,
|
|
181
187
|
emptyHint: u,
|
|
182
188
|
emptyIcon: p,
|
|
183
|
-
emptyAction:
|
|
189
|
+
emptyAction: M,
|
|
184
190
|
loading: _
|
|
185
191
|
}) {
|
|
186
192
|
const g = !_ && (!d || Array.isArray(d) && d.length === 0);
|
|
187
193
|
return /* @__PURE__ */ t("div", { className: "overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ l("table", { className: "w-full border-collapse", children: [
|
|
188
|
-
/* @__PURE__ */ t("thead", { className: "border-b border-slate-200 bg-slate-50/80 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("tr", { children:
|
|
189
|
-
const
|
|
194
|
+
/* @__PURE__ */ t("thead", { className: "border-b border-slate-200 bg-slate-50/80 dark:border-border dark:bg-muted/30", children: /* @__PURE__ */ t("tr", { children: s.map((f, S) => {
|
|
195
|
+
const F = typeof f == "string" ? f : f.label, m = typeof f == "string" ? void 0 : f.width, o = typeof f == "string" ? void 0 : f.align;
|
|
190
196
|
return /* @__PURE__ */ t(
|
|
191
197
|
"th",
|
|
192
198
|
{
|
|
193
|
-
className:
|
|
199
|
+
className: n(Rt, o === "right" && "text-right"),
|
|
194
200
|
style: m ? { width: m } : void 0,
|
|
195
|
-
children:
|
|
201
|
+
children: F
|
|
196
202
|
},
|
|
197
|
-
`${
|
|
203
|
+
`${F}-${S}`
|
|
198
204
|
);
|
|
199
205
|
}) }) }),
|
|
200
|
-
/* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: _ ? Array.from({ length: 5 }, (f, S) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan:
|
|
206
|
+
/* @__PURE__ */ t("tbody", { className: "divide-y divide-slate-100 dark:divide-border/50", children: _ ? Array.from({ length: 5 }, (f, S) => /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-3", colSpan: s.length, children: /* @__PURE__ */ t(
|
|
201
207
|
"span",
|
|
202
208
|
{
|
|
203
209
|
className: "block h-3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]",
|
|
204
210
|
style: { width: `${45 + S * 19 % 45}%` }
|
|
205
211
|
}
|
|
206
|
-
) }) }, S)) : g ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-14", colSpan:
|
|
212
|
+
) }) }, S)) : g ? /* @__PURE__ */ t("tr", { children: /* @__PURE__ */ t("td", { className: "px-3 py-14", colSpan: s.length, children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
|
|
207
213
|
p && /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: p }),
|
|
208
214
|
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: i }),
|
|
209
215
|
u && /* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: u }),
|
|
210
|
-
|
|
216
|
+
M && /* @__PURE__ */ t("div", { className: "mt-1", children: M })
|
|
211
217
|
] }) }) }) : d })
|
|
212
218
|
] }) }) });
|
|
213
219
|
}
|
|
214
|
-
function
|
|
215
|
-
defaultTab:
|
|
220
|
+
function Wt({
|
|
221
|
+
defaultTab: s = "catalog",
|
|
216
222
|
hiddenTabs: d = [],
|
|
217
223
|
onOpenReport: i,
|
|
218
224
|
className: u
|
|
219
225
|
}) {
|
|
220
|
-
const p =
|
|
221
|
-
|
|
226
|
+
const p = vt(), M = ut(), { scopes: _ } = kt(), [g, f] = k(s), [S, F] = k(null), m = (e) => {
|
|
227
|
+
F(e), window.setTimeout(() => F(null), 2500);
|
|
222
228
|
}, o = (e, a, h) => p.request({ _method: e, _path: a, _body: h }), { data: R } = v({
|
|
223
229
|
queryKey: ["nvr-ma-me"],
|
|
224
230
|
queryFn: () => o("GET", "/auth/me").then((e) => e.data)
|
|
225
|
-
}),
|
|
226
|
-
for (const a of e)
|
|
227
|
-
}, { data:
|
|
231
|
+
}), Fe = String((R == null ? void 0 : R.id) ?? "").toLowerCase(), Le = !!(R != null && R.is_admin), b = (...e) => {
|
|
232
|
+
for (const a of e) M.invalidateQueries({ queryKey: [a] });
|
|
233
|
+
}, { data: T = [], isLoading: ee } = v({
|
|
228
234
|
queryKey: ["nvr-ma-definitions"],
|
|
229
235
|
queryFn: () => o("GET", "/metric-alerts/definitions").then((e) => e.data)
|
|
230
|
-
}), { data:
|
|
236
|
+
}), { data: I = [], isLoading: je } = v({
|
|
231
237
|
queryKey: ["nvr-ma-rules"],
|
|
232
238
|
queryFn: () => o("GET", "/metric-alerts/rules").then((e) => e.data)
|
|
233
|
-
}), { data:
|
|
239
|
+
}), { data: H = [], isLoading: Oe } = v({
|
|
234
240
|
queryKey: ["nvr-ma-subs"],
|
|
235
241
|
queryFn: () => o("GET", "/metric-alerts/subscriptions").then(
|
|
236
242
|
(e) => e.data
|
|
237
243
|
)
|
|
238
|
-
}), { data:
|
|
244
|
+
}), { data: G = [], isLoading: Pe } = v({
|
|
239
245
|
queryKey: ["nvr-ma-log"],
|
|
240
246
|
queryFn: () => o("GET", "/metric-alerts/log?limit=100").then(
|
|
241
247
|
(e) => e.data
|
|
242
248
|
)
|
|
243
|
-
}), { data:
|
|
249
|
+
}), { data: xe = [], isLoading: Me } = v({
|
|
244
250
|
queryKey: ["nvr-ma-notif-subs"],
|
|
245
|
-
queryFn: () => p.request(
|
|
246
|
-
}),
|
|
251
|
+
queryFn: () => p.request(mt()).then((e) => e.data)
|
|
252
|
+
}), K = de({
|
|
247
253
|
// Raw PATCH — the route accepts label/filter_field/filter_value/filters/
|
|
248
254
|
// digest_frequency/is_active; the typed SDK command covers a subset.
|
|
249
255
|
mutationFn: ({ id: e, patch: a }) => o("PATCH", `/notification-subscriptions/${e}`, a),
|
|
250
256
|
onSuccess: () => b("nvr-ma-notif-subs")
|
|
251
|
-
}),
|
|
252
|
-
mutationFn: (e) => p.request(
|
|
257
|
+
}), Ie = de({
|
|
258
|
+
mutationFn: (e) => p.request(ht(e)),
|
|
253
259
|
onSuccess: () => b("nvr-ma-notif-subs")
|
|
254
|
-
}),
|
|
260
|
+
}), He = d.includes("widget_alerts"), { data: be = [], isLoading: Ge } = v({
|
|
255
261
|
queryKey: ["nvr-ma-report-alerts"],
|
|
256
|
-
enabled: !
|
|
262
|
+
enabled: !He,
|
|
257
263
|
queryFn: () => o("GET", "/metric-alerts/report-alerts").then((e) => e.data)
|
|
258
|
-
}), { data:
|
|
264
|
+
}), { data: ge = [], isLoading: Ke } = v({
|
|
259
265
|
queryKey: ["nvr-ma-report-alerts-log"],
|
|
260
266
|
enabled: !d.includes("widget_alert_history"),
|
|
261
267
|
queryFn: () => o("GET", "/metric-alerts/report-alerts-log").then(
|
|
262
268
|
(e) => e.data
|
|
263
269
|
)
|
|
264
|
-
}), { data:
|
|
270
|
+
}), { data: Be = [] } = v({
|
|
265
271
|
queryKey: ["nvr-ma-anomaly-defs"],
|
|
266
272
|
queryFn: () => o("GET", "/metric-alerts/anomaly-definitions").then(
|
|
267
273
|
(e) => e.data
|
|
268
274
|
)
|
|
269
|
-
}), { data:
|
|
275
|
+
}), { data: fe = [], isLoading: ze } = v({
|
|
270
276
|
queryKey: ["nvr-ma-anomaly-rules"],
|
|
271
277
|
queryFn: () => o("GET", "/metric-alerts/anomaly-rules").then((e) => e.data)
|
|
272
|
-
}), { data:
|
|
278
|
+
}), { data: B = [], isLoading: We } = v({
|
|
273
279
|
queryKey: ["nvr-ma-anomaly-log"],
|
|
274
280
|
queryFn: () => o("GET", "/metric-alerts/anomaly-log").then((e) => e.data)
|
|
275
|
-
}), [
|
|
276
|
-
() => Object.fromEntries(
|
|
277
|
-
[
|
|
278
|
-
),
|
|
281
|
+
}), [Ue, z] = k(!1), [te, ye] = k(null), [Ve, ve] = k(null), [Qe, W] = k(!1), [ae, U] = k(null), [V, le] = k(null), [ke, Q] = k(!1), Ne = Y(
|
|
282
|
+
() => Object.fromEntries(H.map((e) => [e.rule_id, e])),
|
|
283
|
+
[H]
|
|
284
|
+
), Ye = Y(() => {
|
|
279
285
|
const e = {};
|
|
280
|
-
for (const a of
|
|
286
|
+
for (const a of G)
|
|
281
287
|
a.status === "firing" && !a.resolved_at && (e[a.rule_id] = a);
|
|
282
288
|
return e;
|
|
283
|
-
}, [
|
|
284
|
-
() =>
|
|
285
|
-
[
|
|
286
|
-
),
|
|
287
|
-
const a =
|
|
289
|
+
}, [G]), we = Y(
|
|
290
|
+
() => B.filter((e) => e.status !== "resolved").length,
|
|
291
|
+
[B]
|
|
292
|
+
), Je = async (e) => {
|
|
293
|
+
const a = Ne[e.id];
|
|
288
294
|
try {
|
|
289
295
|
a ? (await o("DELETE", `/metric-alerts/subscriptions/${a.id}`), m("Unsubscribed from alert")) : (await o("POST", "/metric-alerts/subscriptions", { rule_id: e.id }), m("Subscribed to alert")), b("nvr-ma-subs");
|
|
290
296
|
} catch {
|
|
291
297
|
m("Failed to update subscription");
|
|
292
298
|
}
|
|
293
|
-
},
|
|
299
|
+
}, re = async (e, a) => {
|
|
294
300
|
try {
|
|
295
301
|
await o("PATCH", `/metric-alerts/subscriptions/${e}`, a), b("nvr-ma-subs");
|
|
296
302
|
} catch {
|
|
297
303
|
m("Failed to update subscription");
|
|
298
304
|
}
|
|
299
|
-
},
|
|
305
|
+
}, Xe = async (e) => {
|
|
300
306
|
var a, h;
|
|
301
|
-
|
|
307
|
+
Q(!0);
|
|
302
308
|
try {
|
|
303
|
-
if (
|
|
304
|
-
await o("PATCH", `/metric-alerts/rules/${
|
|
309
|
+
if (te)
|
|
310
|
+
await o("PATCH", `/metric-alerts/rules/${te.id}`, e), m("Alert rule updated");
|
|
305
311
|
else {
|
|
306
|
-
const c =
|
|
312
|
+
const c = T.find((x) => x.id === e.definition_id), y = { ...e.filters ?? {} };
|
|
307
313
|
for (const x of (c == null ? void 0 : c.supported_filters) ?? []) {
|
|
308
314
|
if ((a = y[x.key]) != null && a.length) continue;
|
|
309
|
-
const
|
|
310
|
-
if (!
|
|
311
|
-
const
|
|
312
|
-
if (!(
|
|
313
|
-
const
|
|
314
|
-
y[x.key] = await
|
|
315
|
+
const N = Nt(_, { key: x.key, collection: x.collection });
|
|
316
|
+
if (!N) continue;
|
|
317
|
+
const E = (h = _ == null ? void 0 : _.restricted) == null ? void 0 : h[N.name];
|
|
318
|
+
if (!(E != null && E.length)) continue;
|
|
319
|
+
const L = wt(_, N.name), ot = L.length ? L : E;
|
|
320
|
+
y[x.key] = await _t(
|
|
315
321
|
p,
|
|
316
|
-
|
|
317
|
-
|
|
322
|
+
N,
|
|
323
|
+
ot,
|
|
318
324
|
x.value_field
|
|
319
325
|
);
|
|
320
326
|
}
|
|
321
327
|
await o("POST", "/metric-alerts/rules", { ...e, filters: y }), m("Alert rule created");
|
|
322
328
|
}
|
|
323
|
-
|
|
329
|
+
z(!1), b("nvr-ma-rules", "nvr-ma-subs");
|
|
324
330
|
} catch {
|
|
325
331
|
m("Failed to save rule");
|
|
326
332
|
} finally {
|
|
327
|
-
|
|
333
|
+
Q(!1);
|
|
328
334
|
}
|
|
329
|
-
},
|
|
335
|
+
}, Ze = async (e) => {
|
|
330
336
|
if (window.confirm(`Delete rule "${e.name}"? This removes the rule and all subscriptions.`))
|
|
331
337
|
try {
|
|
332
338
|
await o("DELETE", `/metric-alerts/rules/${e.id}`), m("Alert rule deleted"), b("nvr-ma-rules", "nvr-ma-subs", "nvr-ma-log");
|
|
333
339
|
} catch {
|
|
334
340
|
m("Failed to delete rule");
|
|
335
341
|
}
|
|
336
|
-
},
|
|
337
|
-
|
|
342
|
+
}, et = async (e) => {
|
|
343
|
+
Q(!0);
|
|
338
344
|
try {
|
|
339
|
-
|
|
345
|
+
ae ? (await o("PATCH", `/metric-alerts/anomaly-rules/${ae.id}`, e), m("Anomaly rule updated")) : (await o("POST", "/metric-alerts/anomaly-rules", e), m("Anomaly rule created")), W(!1), U(null), b("nvr-ma-anomaly-rules");
|
|
340
346
|
} catch {
|
|
341
347
|
m("Failed to save anomaly rule");
|
|
342
348
|
} finally {
|
|
343
|
-
|
|
349
|
+
Q(!1);
|
|
344
350
|
}
|
|
345
|
-
},
|
|
351
|
+
}, tt = async (e) => {
|
|
346
352
|
if (window.confirm(`Delete anomaly rule "${e.name}"? Its log entries are also removed.`))
|
|
347
353
|
try {
|
|
348
354
|
await o("DELETE", `/metric-alerts/anomaly-rules/${e.id}`), m("Anomaly rule deleted"), b("nvr-ma-anomaly-rules", "nvr-ma-anomaly-log");
|
|
349
355
|
} catch {
|
|
350
356
|
m("Failed to delete anomaly rule");
|
|
351
357
|
}
|
|
352
|
-
},
|
|
358
|
+
}, _e = async (e, a) => {
|
|
353
359
|
try {
|
|
354
360
|
await o("PATCH", `/metric-alerts/anomaly-rules/${e}`, a), b("nvr-ma-anomaly-rules");
|
|
355
361
|
} catch {
|
|
356
362
|
m("Failed to update anomaly rule");
|
|
357
363
|
}
|
|
358
|
-
},
|
|
364
|
+
}, Ae = async (e, a) => {
|
|
359
365
|
try {
|
|
360
366
|
await o("PATCH", `/metric-alerts/anomaly-log/${e}`, { status: a }), b("nvr-ma-anomaly-log");
|
|
361
367
|
} catch {
|
|
362
368
|
m("Failed to update anomaly");
|
|
363
369
|
}
|
|
364
|
-
},
|
|
370
|
+
}, se = async (e, a) => {
|
|
365
371
|
try {
|
|
366
372
|
await o("PATCH", `/report-studio/${e.report}/alerts/${e.id}`, a), b("nvr-ma-report-alerts");
|
|
367
373
|
} catch {
|
|
368
374
|
m("Failed to update widget alert");
|
|
369
375
|
}
|
|
370
|
-
},
|
|
376
|
+
}, at = async (e) => {
|
|
371
377
|
if (window.confirm(`Delete widget alert "${e.name}"?`))
|
|
372
378
|
try {
|
|
373
379
|
await o("DELETE", `/report-studio/${e.report}/alerts/${e.id}`), m("Widget alert deleted"), b("nvr-ma-report-alerts", "nvr-ma-report-alerts-log");
|
|
374
380
|
} catch {
|
|
375
381
|
m("Failed to delete widget alert");
|
|
376
382
|
}
|
|
377
|
-
},
|
|
383
|
+
}, lt = de({
|
|
378
384
|
mutationFn: (e) => o("POST", `/report-studio/${e.report_id}/alerts/${e.alert}/resolve`),
|
|
379
385
|
onSuccess: () => b("nvr-ma-report-alerts-log", "nvr-ma-report-alerts")
|
|
380
|
-
}),
|
|
386
|
+
}), rt = Y(() => {
|
|
381
387
|
const e = /* @__PURE__ */ new Map();
|
|
382
|
-
for (const a of
|
|
388
|
+
for (const a of T)
|
|
383
389
|
e.has(a.category) || e.set(a.category, []), e.get(a.category).push(a);
|
|
384
390
|
return e;
|
|
385
|
-
}, [
|
|
386
|
-
{ key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t(
|
|
387
|
-
{ key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t(
|
|
391
|
+
}, [T]), ne = G.filter((e) => e.status === "firing").length, st = ge.filter((e) => e.status === "firing").length, nt = fe.filter((e) => e.status === "active").length, it = B.filter((e) => e.status === "new").length, dt = [
|
|
392
|
+
{ key: "catalog", label: "Alert Catalog", icon: /* @__PURE__ */ t(Se, { className: "h-3.5 w-3.5" }) },
|
|
393
|
+
{ key: "rules", label: "Alert Rules", icon: /* @__PURE__ */ t(Ee, { className: "h-3.5 w-3.5" }) },
|
|
388
394
|
{
|
|
389
395
|
key: "subscriptions",
|
|
390
396
|
label: "My Subscriptions",
|
|
391
|
-
icon: /* @__PURE__ */ t(
|
|
392
|
-
badge: /* @__PURE__ */ t(
|
|
397
|
+
icon: /* @__PURE__ */ t(oe, { className: "h-3.5 w-3.5" }),
|
|
398
|
+
badge: /* @__PURE__ */ t(q, { n: H.length + xe.length, tone: "cyan" })
|
|
393
399
|
},
|
|
394
400
|
{
|
|
395
401
|
key: "history",
|
|
396
402
|
label: "Alert History",
|
|
397
|
-
icon: /* @__PURE__ */ t(
|
|
398
|
-
badge: /* @__PURE__ */ t(
|
|
403
|
+
icon: /* @__PURE__ */ t(pt, { className: "h-3.5 w-3.5" }),
|
|
404
|
+
badge: /* @__PURE__ */ t(q, { n: ne, tone: "red" })
|
|
399
405
|
},
|
|
400
406
|
{
|
|
401
407
|
key: "widget_alerts",
|
|
402
408
|
label: "Widget Alerts",
|
|
403
|
-
icon: /* @__PURE__ */ t(
|
|
404
|
-
badge: /* @__PURE__ */ t(
|
|
409
|
+
icon: /* @__PURE__ */ t(xt, { className: "h-3.5 w-3.5" }),
|
|
410
|
+
badge: /* @__PURE__ */ t(q, { n: be.length, tone: "violet" })
|
|
405
411
|
},
|
|
406
412
|
{
|
|
407
413
|
key: "widget_alert_history",
|
|
408
414
|
label: "Widget Alert History",
|
|
409
|
-
icon: /* @__PURE__ */ t(
|
|
410
|
-
badge: /* @__PURE__ */ t(
|
|
415
|
+
icon: /* @__PURE__ */ t($e, { className: "h-3.5 w-3.5" }),
|
|
416
|
+
badge: /* @__PURE__ */ t(q, { n: st, tone: "red" })
|
|
411
417
|
},
|
|
412
418
|
{
|
|
413
419
|
key: "anomaly_rules",
|
|
414
420
|
label: "Anomaly Rules",
|
|
415
|
-
icon: /* @__PURE__ */ t(
|
|
416
|
-
badge: /* @__PURE__ */ t(
|
|
421
|
+
icon: /* @__PURE__ */ t(Re, { className: "h-3.5 w-3.5" }),
|
|
422
|
+
badge: /* @__PURE__ */ t(q, { n: nt, tone: "teal" })
|
|
417
423
|
},
|
|
418
424
|
{
|
|
419
425
|
key: "anomaly_history",
|
|
420
426
|
label: "Anomaly History",
|
|
421
|
-
icon: /* @__PURE__ */ t(
|
|
422
|
-
badge: /* @__PURE__ */ t(
|
|
427
|
+
icon: /* @__PURE__ */ t(bt, { className: "h-3.5 w-3.5" }),
|
|
428
|
+
badge: /* @__PURE__ */ t(q, { n: it, tone: "red" })
|
|
423
429
|
}
|
|
424
|
-
].filter((e) => !d.includes(e.key)),
|
|
425
|
-
|
|
426
|
-
},
|
|
427
|
-
return /* @__PURE__ */ l("div", { className:
|
|
430
|
+
].filter((e) => !d.includes(e.key)), Ce = (e) => {
|
|
431
|
+
ye(null), ve(e ?? null), z(!0);
|
|
432
|
+
}, D = (e) => Le || e != null && String(e).toLowerCase() === Fe, ie = "inline-flex h-7 items-center gap-1.5 rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white hover:opacity-90";
|
|
433
|
+
return /* @__PURE__ */ l("div", { className: n("flex flex-col gap-3", u), "data-alert-manager": "", children: [
|
|
428
434
|
S && /* @__PURE__ */ t("div", { className: "fixed right-4 top-4 z-[60] rounded-md bg-[#0f172a] px-3 py-2 text-[12.5px] text-white shadow-lg dark:bg-slate-100 dark:text-slate-900", children: S }),
|
|
429
435
|
/* @__PURE__ */ t(
|
|
430
436
|
"div",
|
|
431
437
|
{
|
|
432
438
|
className: "flex flex-wrap gap-1 border-b border-slate-200 pb-px dark:border-border",
|
|
433
439
|
"data-alert-tabs": "",
|
|
434
|
-
children:
|
|
440
|
+
children: dt.map((e) => /* @__PURE__ */ l(
|
|
435
441
|
"button",
|
|
436
442
|
{
|
|
437
443
|
type: "button",
|
|
438
444
|
onClick: () => f(e.key),
|
|
439
|
-
className:
|
|
445
|
+
className: n(
|
|
440
446
|
"inline-flex items-center gap-1.5 rounded-t-md border-b-2 px-2.5 py-1.5 text-[12.5px] transition-colors",
|
|
441
447
|
g === e.key ? "border-nvr-cyan font-semibold text-nvr-navy dark:text-nvr-cyan" : "border-transparent text-slate-500 hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200"
|
|
442
448
|
),
|
|
@@ -450,7 +456,7 @@ function Bt({
|
|
|
450
456
|
))
|
|
451
457
|
}
|
|
452
458
|
),
|
|
453
|
-
g === "catalog" &&
|
|
459
|
+
g === "catalog" && ee && /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }, (e, a) => /* @__PURE__ */ l(
|
|
454
460
|
"div",
|
|
455
461
|
{
|
|
456
462
|
className: "rounded-lg border border-slate-200 bg-white p-3 dark:border-border dark:bg-card",
|
|
@@ -462,21 +468,21 @@ function Bt({
|
|
|
462
468
|
},
|
|
463
469
|
a
|
|
464
470
|
)) }),
|
|
465
|
-
g === "catalog" && !
|
|
471
|
+
g === "catalog" && !ee && T.length > 0 && // One continuous list, not a card grid: the old layout repeated an
|
|
466
472
|
// identical box (and an identical saturated button) fourteen times,
|
|
467
473
|
// and its per-category grids left orphan holes on odd counts. Rows
|
|
468
474
|
// also make room for the fact that actually matters here — whether
|
|
469
475
|
// this metric is already being watched.
|
|
470
|
-
/* @__PURE__ */ t("section", { className: "max-w-[1180px] overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [...
|
|
476
|
+
/* @__PURE__ */ t("section", { className: "max-w-[1180px] overflow-hidden rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: [...rt.entries()].map(([e, a], h) => /* @__PURE__ */ l("div", { children: [
|
|
471
477
|
/* @__PURE__ */ l(
|
|
472
478
|
"div",
|
|
473
479
|
{
|
|
474
|
-
className:
|
|
480
|
+
className: n(
|
|
475
481
|
"flex items-center gap-2 bg-slate-50/80 px-3 py-1.5 dark:bg-muted/30",
|
|
476
482
|
h > 0 && "border-t border-slate-200 dark:border-border"
|
|
477
483
|
),
|
|
478
484
|
children: [
|
|
479
|
-
/* @__PURE__ */ t("span", { className:
|
|
485
|
+
/* @__PURE__ */ t("span", { className: $t(e), children: e }),
|
|
480
486
|
/* @__PURE__ */ l("span", { className: "text-[11px] text-slate-400 dark:text-slate-500", children: [
|
|
481
487
|
a.length,
|
|
482
488
|
" metric",
|
|
@@ -486,7 +492,7 @@ function Bt({
|
|
|
486
492
|
}
|
|
487
493
|
),
|
|
488
494
|
/* @__PURE__ */ t("ul", { className: "divide-y divide-slate-100 dark:divide-border/50", children: a.map((c) => {
|
|
489
|
-
const y =
|
|
495
|
+
const y = I.filter((x) => x.definition_id === c.id).length;
|
|
490
496
|
return /* @__PURE__ */ l(
|
|
491
497
|
"li",
|
|
492
498
|
{
|
|
@@ -496,7 +502,7 @@ function Bt({
|
|
|
496
502
|
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
|
|
497
503
|
/* @__PURE__ */ t("p", { className: "truncate text-[13px] font-medium text-slate-800 dark:text-slate-100", children: c.name }),
|
|
498
504
|
y > 0 && /* @__PURE__ */ l("span", { className: "inline-flex shrink-0 items-center gap-1 rounded-full bg-nvr-cyan/10 px-1.5 py-px text-[10px] font-semibold text-nvr-navy dark:text-nvr-cyan", children: [
|
|
499
|
-
/* @__PURE__ */ t(
|
|
505
|
+
/* @__PURE__ */ t(oe, { className: "h-2.5 w-2.5" }),
|
|
500
506
|
y
|
|
501
507
|
] })
|
|
502
508
|
] }),
|
|
@@ -506,9 +512,9 @@ function Bt({
|
|
|
506
512
|
/* @__PURE__ */ t("span", { className: "text-[10px] uppercase tracking-wide text-slate-400 dark:text-slate-500", children: c.unit }),
|
|
507
513
|
/* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "·" }),
|
|
508
514
|
/* @__PURE__ */ l("span", { children: [
|
|
509
|
-
|
|
515
|
+
Z[c.default_operator] ?? c.default_operator,
|
|
510
516
|
" ",
|
|
511
|
-
c.default_threshold != null ?
|
|
517
|
+
c.default_threshold != null ? $(c.default_threshold, c.unit) : "—"
|
|
512
518
|
] })
|
|
513
519
|
] }),
|
|
514
520
|
/* @__PURE__ */ l(
|
|
@@ -517,10 +523,10 @@ function Bt({
|
|
|
517
523
|
type: "button",
|
|
518
524
|
className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-slate-200 px-2.5 text-[12px] font-medium text-slate-600 transition-colors hover:border-nvr-cyan hover:bg-nvr-cyan/[0.08] hover:text-nvr-navy dark:border-border dark:text-slate-300 dark:hover:text-nvr-cyan",
|
|
519
525
|
onClick: () => {
|
|
520
|
-
|
|
526
|
+
Ce(c.id), f("rules");
|
|
521
527
|
},
|
|
522
528
|
children: [
|
|
523
|
-
/* @__PURE__ */ t(
|
|
529
|
+
/* @__PURE__ */ t(ce, { className: "h-3 w-3" }),
|
|
524
530
|
" Rule"
|
|
525
531
|
]
|
|
526
532
|
}
|
|
@@ -531,18 +537,18 @@ function Bt({
|
|
|
531
537
|
);
|
|
532
538
|
}) })
|
|
533
539
|
] }, e)) }),
|
|
534
|
-
g === "catalog" && !
|
|
535
|
-
/* @__PURE__ */ t(
|
|
540
|
+
g === "catalog" && !ee && T.length === 0 && /* @__PURE__ */ t("div", { className: "rounded-lg border border-slate-200 bg-white py-16 dark:border-border dark:bg-card", children: /* @__PURE__ */ l("div", { className: "mx-auto flex max-w-sm flex-col items-center gap-2 text-center", children: [
|
|
541
|
+
/* @__PURE__ */ t(gt, { className: "h-5 w-5 text-slate-300 dark:text-slate-600" }),
|
|
536
542
|
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium text-slate-600 dark:text-slate-300", children: "No metrics in the catalog yet" }),
|
|
537
543
|
/* @__PURE__ */ t("p", { className: "text-[12px] leading-relaxed text-slate-400 dark:text-slate-500", children: "Metric definitions describe what can be measured — once an admin adds them, you can build alert rules on top." })
|
|
538
544
|
] }) }),
|
|
539
545
|
g === "rules" && /* @__PURE__ */ t(
|
|
540
|
-
|
|
546
|
+
pe,
|
|
541
547
|
{
|
|
542
548
|
title: "Alert rules",
|
|
543
|
-
hint: `${
|
|
544
|
-
action: /* @__PURE__ */ l("button", { type: "button", className:
|
|
545
|
-
/* @__PURE__ */ t(
|
|
549
|
+
hint: `${I.length} rule${I.length === 1 ? "" : "s"} · shared and personal`,
|
|
550
|
+
action: /* @__PURE__ */ l("button", { type: "button", className: ie, onClick: () => Ce(), children: [
|
|
551
|
+
/* @__PURE__ */ t(ce, { className: "h-3 w-3" }),
|
|
546
552
|
" New rule"
|
|
547
553
|
] }),
|
|
548
554
|
children: /* @__PURE__ */ t(
|
|
@@ -558,19 +564,19 @@ function Bt({
|
|
|
558
564
|
],
|
|
559
565
|
empty: "No alert rules yet",
|
|
560
566
|
emptyHint: "Pick a metric from the catalog and set the threshold that should page you.",
|
|
561
|
-
emptyIcon: /* @__PURE__ */ t(
|
|
562
|
-
emptyAction: /* @__PURE__ */ l("button", { type: "button", className:
|
|
563
|
-
/* @__PURE__ */ t(
|
|
567
|
+
emptyIcon: /* @__PURE__ */ t(Te, { className: "h-5 w-5" }),
|
|
568
|
+
emptyAction: /* @__PURE__ */ l("button", { type: "button", className: ie, onClick: () => f("catalog"), children: [
|
|
569
|
+
/* @__PURE__ */ t(Se, { className: "h-3 w-3" }),
|
|
564
570
|
" Browse catalog"
|
|
565
571
|
] }),
|
|
566
|
-
loading:
|
|
567
|
-
children:
|
|
568
|
-
var
|
|
569
|
-
const a = !!
|
|
572
|
+
loading: je,
|
|
573
|
+
children: I.map((e) => {
|
|
574
|
+
var E, L;
|
|
575
|
+
const a = !!Ne[e.id], h = D(e.created_by), c = Ye[e.id], y = e.status !== "active", x = e.last_checked_at, N = x ? X(x) : null;
|
|
570
576
|
return /* @__PURE__ */ l(
|
|
571
577
|
"tr",
|
|
572
578
|
{
|
|
573
|
-
className:
|
|
579
|
+
className: n(
|
|
574
580
|
"transition-colors hover:bg-slate-50/70 dark:hover:bg-muted/25",
|
|
575
581
|
y && "opacity-60"
|
|
576
582
|
),
|
|
@@ -580,14 +586,14 @@ function Bt({
|
|
|
580
586
|
e.definition && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: e.definition.name })
|
|
581
587
|
] }),
|
|
582
588
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
583
|
-
|
|
589
|
+
qt,
|
|
584
590
|
{
|
|
585
591
|
operator: e.operator,
|
|
586
592
|
threshold: e.threshold_value,
|
|
587
|
-
unit: (
|
|
593
|
+
unit: (E = e.definition) == null ? void 0 : E.unit
|
|
588
594
|
}
|
|
589
595
|
) }),
|
|
590
|
-
/* @__PURE__ */ t("td", { className: r, children: y ? /* @__PURE__ */ t(
|
|
596
|
+
/* @__PURE__ */ t("td", { className: r, children: y ? /* @__PURE__ */ t(O, { status: e.status }) : c ? /* @__PURE__ */ l("span", { className: "flex flex-col gap-0.5", children: [
|
|
591
597
|
/* @__PURE__ */ l("span", { className: "inline-flex w-fit items-center gap-1.5 rounded-full bg-red-50 px-2 py-px text-[10.5px] font-semibold text-red-600 dark:bg-red-500/10 dark:text-red-400", children: [
|
|
592
598
|
/* @__PURE__ */ t(
|
|
593
599
|
"span",
|
|
@@ -599,19 +605,39 @@ function Bt({
|
|
|
599
605
|
"Firing"
|
|
600
606
|
] }),
|
|
601
607
|
/* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-500 dark:text-slate-400", children: [
|
|
602
|
-
|
|
603
|
-
|
|
608
|
+
$(c.metric_value, (L = e.definition) == null ? void 0 : L.unit),
|
|
609
|
+
X(c.fired_at) ? ` · ${X(c.fired_at)}` : ""
|
|
604
610
|
] })
|
|
605
|
-
] }) : /* @__PURE__ */ l(
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
611
|
+
] }) : x ? /* @__PURE__ */ l(
|
|
612
|
+
"span",
|
|
613
|
+
{
|
|
614
|
+
className: "inline-flex items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-slate-400",
|
|
615
|
+
"data-tip": N ? `Checked ${N}` : void 0,
|
|
616
|
+
children: [
|
|
617
|
+
/* @__PURE__ */ t("span", { "aria-hidden": !0, className: "h-1.5 w-1.5 rounded-full bg-emerald-500/70" }),
|
|
618
|
+
"Within threshold"
|
|
619
|
+
]
|
|
620
|
+
}
|
|
621
|
+
) : (
|
|
622
|
+
// No check has run since the rule was saved: an alert
|
|
623
|
+
// that never ran must not read as healthy (army5 b11-N1).
|
|
624
|
+
/* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1.5 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
625
|
+
/* @__PURE__ */ t(
|
|
626
|
+
"span",
|
|
627
|
+
{
|
|
628
|
+
"aria-hidden": !0,
|
|
629
|
+
className: "h-1.5 w-1.5 rounded-full border border-slate-400 dark:border-slate-500"
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
"Not checked yet"
|
|
633
|
+
] })
|
|
634
|
+
) }),
|
|
635
|
+
/* @__PURE__ */ t("td", { className: n(r, "capitalize text-slate-500 dark:text-slate-400"), children: e.check_frequency }),
|
|
610
636
|
/* @__PURE__ */ t("td", { className: r, children: e.is_shared ? /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 text-[11.5px] text-slate-500 dark:text-slate-400", children: [
|
|
611
|
-
/* @__PURE__ */ t(
|
|
637
|
+
/* @__PURE__ */ t(ft, { className: "h-3 w-3" }),
|
|
612
638
|
" Team"
|
|
613
639
|
] }) : /* @__PURE__ */ l("span", { className: "inline-flex items-center gap-1 text-[11.5px] text-slate-400 dark:text-slate-500", children: [
|
|
614
|
-
/* @__PURE__ */ t(
|
|
640
|
+
/* @__PURE__ */ t(yt, { className: "h-3 w-3" }),
|
|
615
641
|
" Private"
|
|
616
642
|
] }) }),
|
|
617
643
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-1", children: [
|
|
@@ -621,15 +647,15 @@ function Bt({
|
|
|
621
647
|
type: "button",
|
|
622
648
|
title: a ? "Unsubscribe from this rule" : "Subscribe to this rule",
|
|
623
649
|
"aria-pressed": a,
|
|
624
|
-
onClick: () =>
|
|
625
|
-
className:
|
|
650
|
+
onClick: () => Je(e),
|
|
651
|
+
className: n(
|
|
626
652
|
w,
|
|
627
653
|
a && "border-nvr-cyan bg-nvr-cyan/10 text-nvr-navy hover:bg-nvr-cyan/15 dark:text-nvr-cyan"
|
|
628
654
|
),
|
|
629
|
-
children: a ? /* @__PURE__ */ t(
|
|
655
|
+
children: a ? /* @__PURE__ */ t(oe, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(Ee, { className: "h-3.5 w-3.5" })
|
|
630
656
|
}
|
|
631
657
|
),
|
|
632
|
-
h && /* @__PURE__ */ l(
|
|
658
|
+
h && /* @__PURE__ */ l(ct, { children: [
|
|
633
659
|
/* @__PURE__ */ t(
|
|
634
660
|
"button",
|
|
635
661
|
{
|
|
@@ -637,9 +663,9 @@ function Bt({
|
|
|
637
663
|
title: "Edit rule",
|
|
638
664
|
className: w,
|
|
639
665
|
onClick: () => {
|
|
640
|
-
|
|
666
|
+
ye(e), ve(null), z(!0);
|
|
641
667
|
},
|
|
642
|
-
children: /* @__PURE__ */ t(
|
|
668
|
+
children: /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" })
|
|
643
669
|
}
|
|
644
670
|
),
|
|
645
671
|
/* @__PURE__ */ t(
|
|
@@ -647,12 +673,12 @@ function Bt({
|
|
|
647
673
|
{
|
|
648
674
|
type: "button",
|
|
649
675
|
title: "Delete rule",
|
|
650
|
-
className:
|
|
676
|
+
className: n(
|
|
651
677
|
w,
|
|
652
678
|
"hover:border-red-300 hover:bg-red-50 hover:text-red-600 dark:hover:bg-red-500/10 dark:hover:text-red-400"
|
|
653
679
|
),
|
|
654
|
-
onClick: () =>
|
|
655
|
-
children: /* @__PURE__ */ t(
|
|
680
|
+
onClick: () => Ze(e),
|
|
681
|
+
children: /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" })
|
|
656
682
|
}
|
|
657
683
|
)
|
|
658
684
|
] })
|
|
@@ -681,8 +707,8 @@ function Bt({
|
|
|
681
707
|
{ label: "", width: 40 }
|
|
682
708
|
],
|
|
683
709
|
empty: "No subscriptions yet — browse the Alert Catalog or Rules tab to subscribe",
|
|
684
|
-
loading:
|
|
685
|
-
children:
|
|
710
|
+
loading: Oe,
|
|
711
|
+
children: H.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
|
|
686
712
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
687
713
|
/* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.rule_name ?? `Rule #${e.rule_id}` }),
|
|
688
714
|
e.definition_name && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400", children: e.definition_name })
|
|
@@ -691,21 +717,21 @@ function Bt({
|
|
|
691
717
|
A,
|
|
692
718
|
{
|
|
693
719
|
checked: !!e.delivery_in_app,
|
|
694
|
-
onChange: (a) =>
|
|
720
|
+
onChange: (a) => re(e.id, { delivery_in_app: a })
|
|
695
721
|
}
|
|
696
722
|
) }),
|
|
697
723
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
698
724
|
A,
|
|
699
725
|
{
|
|
700
726
|
checked: !!e.delivery_email,
|
|
701
|
-
onChange: (a) =>
|
|
727
|
+
onChange: (a) => re(e.id, { delivery_email: a })
|
|
702
728
|
}
|
|
703
729
|
) }),
|
|
704
730
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
705
|
-
|
|
731
|
+
De,
|
|
706
732
|
{
|
|
707
733
|
value: String(e.digest_frequency),
|
|
708
|
-
onChange: (a) =>
|
|
734
|
+
onChange: (a) => re(e.id, { digest_frequency: a }),
|
|
709
735
|
options: [
|
|
710
736
|
{ label: "Immediate", value: "immediate" },
|
|
711
737
|
{ label: "Daily", value: "daily" },
|
|
@@ -714,18 +740,18 @@ function Bt({
|
|
|
714
740
|
className: "h-7 w-[105px] text-[11.5px]"
|
|
715
741
|
}
|
|
716
742
|
) }),
|
|
717
|
-
/* @__PURE__ */ t("td", { className:
|
|
718
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
743
|
+
/* @__PURE__ */ t("td", { className: n(r, "text-[11.5px] text-slate-400"), children: P(e.last_notified) }),
|
|
744
|
+
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
|
|
719
745
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
720
746
|
"button",
|
|
721
747
|
{
|
|
722
748
|
type: "button",
|
|
723
749
|
title: "Unsubscribe",
|
|
724
|
-
className:
|
|
750
|
+
className: n(w, "hover:border-red-300 hover:text-red-500"),
|
|
725
751
|
onClick: async () => {
|
|
726
752
|
window.confirm("Unsubscribe from this alert?") && (await o("DELETE", `/metric-alerts/subscriptions/${e.id}`), b("nvr-ma-subs"));
|
|
727
753
|
},
|
|
728
|
-
children: /* @__PURE__ */ t(
|
|
754
|
+
children: /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" })
|
|
729
755
|
}
|
|
730
756
|
) })
|
|
731
757
|
] }, e.id))
|
|
@@ -744,8 +770,8 @@ function Bt({
|
|
|
744
770
|
{ label: "", width: 80 }
|
|
745
771
|
],
|
|
746
772
|
empty: "No record notifications yet — subscribe from a record, queue, or workflow",
|
|
747
|
-
loading:
|
|
748
|
-
children:
|
|
773
|
+
loading: Me,
|
|
774
|
+
children: xe.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
|
|
749
775
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
750
776
|
/* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.label || (e.collection ? e.collection.replace(/_/g, " ") : "Queue digest") }),
|
|
751
777
|
/* @__PURE__ */ l("div", { className: "mt-0.5 flex flex-wrap items-center gap-1", children: [
|
|
@@ -773,12 +799,12 @@ function Bt({
|
|
|
773
799
|
))
|
|
774
800
|
] })
|
|
775
801
|
] }),
|
|
776
|
-
/* @__PURE__ */ t("td", { className:
|
|
802
|
+
/* @__PURE__ */ t("td", { className: n(r, "capitalize"), children: String(e.event_type).replace(/_/g, " ") }),
|
|
777
803
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
778
|
-
|
|
804
|
+
De,
|
|
779
805
|
{
|
|
780
806
|
value: String(e.digest_frequency ?? "instant"),
|
|
781
|
-
onChange: (a) =>
|
|
807
|
+
onChange: (a) => K.mutate({ id: e.id, patch: { digest_frequency: a } }),
|
|
782
808
|
options: [
|
|
783
809
|
{ label: "Instant", value: "instant" },
|
|
784
810
|
{ label: "Daily", value: "daily" },
|
|
@@ -791,7 +817,7 @@ function Bt({
|
|
|
791
817
|
A,
|
|
792
818
|
{
|
|
793
819
|
checked: !!e.is_active,
|
|
794
|
-
onChange: (a) =>
|
|
820
|
+
onChange: (a) => K.mutate({ id: e.id, patch: { is_active: a } })
|
|
795
821
|
}
|
|
796
822
|
) }),
|
|
797
823
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
|
|
@@ -801,8 +827,8 @@ function Bt({
|
|
|
801
827
|
type: "button",
|
|
802
828
|
title: "Edit",
|
|
803
829
|
className: w,
|
|
804
|
-
onClick: () =>
|
|
805
|
-
children: /* @__PURE__ */ t(
|
|
830
|
+
onClick: () => le(e),
|
|
831
|
+
children: /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" })
|
|
806
832
|
}
|
|
807
833
|
),
|
|
808
834
|
/* @__PURE__ */ t(
|
|
@@ -810,11 +836,11 @@ function Bt({
|
|
|
810
836
|
{
|
|
811
837
|
type: "button",
|
|
812
838
|
title: "Remove subscription",
|
|
813
|
-
className:
|
|
839
|
+
className: n(w, "hover:border-red-300 hover:text-red-500"),
|
|
814
840
|
onClick: () => {
|
|
815
|
-
window.confirm("Remove this notification subscription?") &&
|
|
841
|
+
window.confirm("Remove this notification subscription?") && Ie.mutate(e.id);
|
|
816
842
|
},
|
|
817
|
-
children: /* @__PURE__ */ t(
|
|
843
|
+
children: /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" })
|
|
818
844
|
}
|
|
819
845
|
)
|
|
820
846
|
] }) })
|
|
@@ -823,10 +849,10 @@ function Bt({
|
|
|
823
849
|
)
|
|
824
850
|
] }),
|
|
825
851
|
g === "history" && /* @__PURE__ */ t(
|
|
826
|
-
|
|
852
|
+
pe,
|
|
827
853
|
{
|
|
828
854
|
title: "Alert history",
|
|
829
|
-
hint:
|
|
855
|
+
hint: ne > 0 ? `${ne} open · last 100 events` : "Last 100 events — none open",
|
|
830
856
|
children: /* @__PURE__ */ t(
|
|
831
857
|
C,
|
|
832
858
|
{
|
|
@@ -839,10 +865,10 @@ function Bt({
|
|
|
839
865
|
],
|
|
840
866
|
empty: "No alerts have fired",
|
|
841
867
|
emptyHint: "Events appear here the first time a rule crosses its threshold.",
|
|
842
|
-
emptyIcon: /* @__PURE__ */ t(
|
|
843
|
-
loading:
|
|
844
|
-
children:
|
|
845
|
-
const a = e.status === "firing" && !e.resolved_at, h = e.resolved_at ?
|
|
868
|
+
emptyIcon: /* @__PURE__ */ t($e, { className: "h-5 w-5" }),
|
|
869
|
+
loading: Pe,
|
|
870
|
+
children: G.map((e) => {
|
|
871
|
+
const a = e.status === "firing" && !e.resolved_at, h = e.resolved_at ? qe(e.fired_at, e.resolved_at) : qe(e.fired_at, (/* @__PURE__ */ new Date()).toISOString());
|
|
846
872
|
return /* @__PURE__ */ l(
|
|
847
873
|
"tr",
|
|
848
874
|
{
|
|
@@ -859,7 +885,7 @@ function Bt({
|
|
|
859
885
|
/* @__PURE__ */ t(
|
|
860
886
|
"span",
|
|
861
887
|
{
|
|
862
|
-
className:
|
|
888
|
+
className: n(
|
|
863
889
|
"font-medium",
|
|
864
890
|
a ? "text-slate-800 dark:text-slate-100" : "text-slate-600 dark:text-slate-300"
|
|
865
891
|
),
|
|
@@ -868,7 +894,7 @@ function Bt({
|
|
|
868
894
|
)
|
|
869
895
|
] }) }),
|
|
870
896
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
871
|
-
|
|
897
|
+
Dt,
|
|
872
898
|
{
|
|
873
899
|
value: e.metric_value,
|
|
874
900
|
threshold: e.threshold_value,
|
|
@@ -876,9 +902,9 @@ function Bt({
|
|
|
876
902
|
breaching: a
|
|
877
903
|
}
|
|
878
904
|
) }),
|
|
879
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
880
|
-
/* @__PURE__ */ t("td", { className: r, children: e.resolved_at ? /* @__PURE__ */ t(
|
|
881
|
-
/* @__PURE__ */ t("td", { className:
|
|
905
|
+
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(ue, { value: e.fired_at }) }),
|
|
906
|
+
/* @__PURE__ */ t("td", { className: r, children: e.resolved_at ? /* @__PURE__ */ t(ue, { value: e.resolved_at }) : /* @__PURE__ */ t("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-red-50 px-2 py-px text-[10.5px] font-semibold text-red-600 dark:bg-red-500/10 dark:text-red-400", children: "Still open" }) }),
|
|
907
|
+
/* @__PURE__ */ t("td", { className: n(Tt, "text-right"), children: /* @__PURE__ */ t("span", { className: n(a && "text-red-600 dark:text-red-400"), children: h ?? "—" }) })
|
|
882
908
|
]
|
|
883
909
|
},
|
|
884
910
|
e.id
|
|
@@ -904,8 +930,8 @@ function Bt({
|
|
|
904
930
|
{ label: "", width: 40 }
|
|
905
931
|
],
|
|
906
932
|
empty: "No widget alerts yet — open any report widget and click the bell icon",
|
|
907
|
-
loading:
|
|
908
|
-
children:
|
|
933
|
+
loading: Ge,
|
|
934
|
+
children: be.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
|
|
909
935
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
910
936
|
/* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.name }),
|
|
911
937
|
e.report_name && /* @__PURE__ */ t(
|
|
@@ -913,7 +939,7 @@ function Bt({
|
|
|
913
939
|
{
|
|
914
940
|
type: "button",
|
|
915
941
|
onClick: () => i == null ? void 0 : i(e.report),
|
|
916
|
-
className:
|
|
942
|
+
className: n(
|
|
917
943
|
"text-[11px] text-slate-400",
|
|
918
944
|
i && "underline-offset-2 hover:text-nvr-navy hover:underline dark:hover:text-nvr-cyan"
|
|
919
945
|
),
|
|
@@ -921,7 +947,7 @@ function Bt({
|
|
|
921
947
|
}
|
|
922
948
|
)
|
|
923
949
|
] }),
|
|
924
|
-
/* @__PURE__ */ t("td", { className:
|
|
950
|
+
/* @__PURE__ */ t("td", { className: n(r, "text-[11.5px] text-slate-400"), children: (e.filters ?? []).length ? (e.filters ?? []).map((a) => `${a.field}: ${(a.labels ?? a.values).join(", ")}`).join(" · ") : "All data" }),
|
|
925
951
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1", children: (e.conditions ?? []).map((a, h) => /* @__PURE__ */ l(
|
|
926
952
|
"span",
|
|
927
953
|
{
|
|
@@ -929,43 +955,43 @@ function Bt({
|
|
|
929
955
|
children: [
|
|
930
956
|
a.field,
|
|
931
957
|
" ",
|
|
932
|
-
|
|
958
|
+
Z[a.op] ?? a.op,
|
|
933
959
|
" ",
|
|
934
960
|
a.value
|
|
935
961
|
]
|
|
936
962
|
},
|
|
937
963
|
`${a.field}-${h}`
|
|
938
964
|
)) }) }),
|
|
939
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
965
|
+
/* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
|
|
940
966
|
A,
|
|
941
967
|
{
|
|
942
968
|
checked: !!e.delivery_inapp,
|
|
943
|
-
onChange: (a) =>
|
|
969
|
+
onChange: (a) => se(e, { delivery_inapp: a })
|
|
944
970
|
}
|
|
945
|
-
) }),
|
|
946
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
971
|
+
) : /* @__PURE__ */ t(he, { on: !!e.delivery_inapp }) }),
|
|
972
|
+
/* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
|
|
947
973
|
A,
|
|
948
974
|
{
|
|
949
975
|
checked: !!e.delivery_email,
|
|
950
|
-
onChange: (a) =>
|
|
976
|
+
onChange: (a) => se(e, { delivery_email: a })
|
|
951
977
|
}
|
|
952
|
-
) }),
|
|
953
|
-
/* @__PURE__ */ t("td", { className:
|
|
954
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
978
|
+
) : /* @__PURE__ */ t(he, { on: !!e.delivery_email }) }),
|
|
979
|
+
/* @__PURE__ */ t("td", { className: n(r, "text-[11.5px] text-slate-400"), children: P(e.last_fired) }),
|
|
980
|
+
/* @__PURE__ */ t("td", { className: r, children: D(J(e)) ? /* @__PURE__ */ t(
|
|
955
981
|
A,
|
|
956
982
|
{
|
|
957
983
|
checked: !!e.is_active,
|
|
958
|
-
onChange: (a) =>
|
|
984
|
+
onChange: (a) => se(e, { is_active: a })
|
|
959
985
|
}
|
|
960
|
-
) }),
|
|
961
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
986
|
+
) : /* @__PURE__ */ t(he, { on: !!e.is_active }) }),
|
|
987
|
+
/* @__PURE__ */ t("td", { className: r, children: D(J(e)) && /* @__PURE__ */ t(
|
|
962
988
|
"button",
|
|
963
989
|
{
|
|
964
990
|
type: "button",
|
|
965
991
|
title: "Delete",
|
|
966
|
-
className:
|
|
967
|
-
onClick: () =>
|
|
968
|
-
children: /* @__PURE__ */ t(
|
|
992
|
+
className: n(w, "hover:border-red-300 hover:text-red-500"),
|
|
993
|
+
onClick: () => at(e),
|
|
994
|
+
children: /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" })
|
|
969
995
|
}
|
|
970
996
|
) })
|
|
971
997
|
] }, e.id))
|
|
@@ -986,8 +1012,8 @@ function Bt({
|
|
|
986
1012
|
{ label: "", width: 90 }
|
|
987
1013
|
],
|
|
988
1014
|
empty: "No widget alert history yet",
|
|
989
|
-
loading:
|
|
990
|
-
children:
|
|
1015
|
+
loading: Ke,
|
|
1016
|
+
children: ge.map((e) => /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
|
|
991
1017
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
992
1018
|
/* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.alert_name }),
|
|
993
1019
|
e.report_name && /* @__PURE__ */ t("p", { className: "text-[11px] text-slate-400", children: e.report_name })
|
|
@@ -1004,15 +1030,15 @@ function Bt({
|
|
|
1004
1030
|
},
|
|
1005
1031
|
a
|
|
1006
1032
|
)) }) }),
|
|
1007
|
-
/* @__PURE__ */ t("td", { className:
|
|
1008
|
-
/* @__PURE__ */ t("td", { className:
|
|
1009
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
1033
|
+
/* @__PURE__ */ t("td", { className: n(r, "text-[11.5px]"), children: P(e.fired_at) }),
|
|
1034
|
+
/* @__PURE__ */ t("td", { className: n(r, "text-[11.5px] text-slate-400"), children: P(e.resolved_at) }),
|
|
1035
|
+
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
|
|
1010
1036
|
/* @__PURE__ */ t("td", { className: r, children: e.status === "firing" && /* @__PURE__ */ t(
|
|
1011
1037
|
"button",
|
|
1012
1038
|
{
|
|
1013
1039
|
type: "button",
|
|
1014
1040
|
className: "rounded border border-nvr-cyan px-2 py-0.5 text-[11.5px] font-medium text-nvr-navy hover:bg-nvr-cyan/10 dark:text-nvr-cyan",
|
|
1015
|
-
onClick: () =>
|
|
1041
|
+
onClick: () => lt.mutate(e),
|
|
1016
1042
|
children: "Resolve"
|
|
1017
1043
|
}
|
|
1018
1044
|
) })
|
|
@@ -1027,12 +1053,12 @@ function Bt({
|
|
|
1027
1053
|
"button",
|
|
1028
1054
|
{
|
|
1029
1055
|
type: "button",
|
|
1030
|
-
className:
|
|
1056
|
+
className: ie,
|
|
1031
1057
|
onClick: () => {
|
|
1032
|
-
|
|
1058
|
+
U(null), W(!0);
|
|
1033
1059
|
},
|
|
1034
1060
|
children: [
|
|
1035
|
-
/* @__PURE__ */ t(
|
|
1061
|
+
/* @__PURE__ */ t(ce, { className: "h-3 w-3" }),
|
|
1036
1062
|
" New Rule"
|
|
1037
1063
|
]
|
|
1038
1064
|
}
|
|
@@ -1051,9 +1077,9 @@ function Bt({
|
|
|
1051
1077
|
{ label: "", width: 80 }
|
|
1052
1078
|
],
|
|
1053
1079
|
empty: "No anomaly rules yet — create one to start detecting unusual patterns",
|
|
1054
|
-
loading:
|
|
1055
|
-
children:
|
|
1056
|
-
const a =
|
|
1080
|
+
loading: ze,
|
|
1081
|
+
children: fe.map((e) => {
|
|
1082
|
+
const a = D(e.created_by);
|
|
1057
1083
|
return /* @__PURE__ */ l("tr", { className: "hover:bg-slate-50/60 dark:hover:bg-muted/30", children: [
|
|
1058
1084
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
1059
1085
|
/* @__PURE__ */ t("p", { className: "font-medium text-slate-800 dark:text-slate-100", children: e.name }),
|
|
@@ -1062,20 +1088,20 @@ function Bt({
|
|
|
1062
1088
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
1063
1089
|
"span",
|
|
1064
1090
|
{
|
|
1065
|
-
className:
|
|
1091
|
+
className: n(
|
|
1066
1092
|
"inline-flex rounded-full px-2 py-px text-[10.5px] font-semibold capitalize",
|
|
1067
1093
|
e.sensitivity === "high" ? "bg-orange-50 text-orange-600 dark:bg-orange-500/10 dark:text-orange-400" : e.sensitivity === "low" ? "bg-slate-100 text-slate-500 dark:bg-muted dark:text-slate-400" : "bg-sky-50 text-sky-600 dark:bg-sky-500/10 dark:text-sky-400"
|
|
1068
1094
|
),
|
|
1069
1095
|
children: e.sensitivity ?? "medium"
|
|
1070
1096
|
}
|
|
1071
1097
|
) }),
|
|
1072
|
-
/* @__PURE__ */ t("td", { className:
|
|
1098
|
+
/* @__PURE__ */ t("td", { className: n(r, "capitalize"), children: e.check_frequency }),
|
|
1073
1099
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
1074
1100
|
A,
|
|
1075
1101
|
{
|
|
1076
1102
|
checked: !!e.delivery_in_app,
|
|
1077
1103
|
disabled: !a,
|
|
1078
|
-
onChange: (h) =>
|
|
1104
|
+
onChange: (h) => _e(e.id, { delivery_in_app: h })
|
|
1079
1105
|
}
|
|
1080
1106
|
) }),
|
|
1081
1107
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
@@ -1083,10 +1109,10 @@ function Bt({
|
|
|
1083
1109
|
{
|
|
1084
1110
|
checked: !!e.delivery_email,
|
|
1085
1111
|
disabled: !a,
|
|
1086
|
-
onChange: (h) =>
|
|
1112
|
+
onChange: (h) => _e(e.id, { delivery_email: h })
|
|
1087
1113
|
}
|
|
1088
1114
|
) }),
|
|
1089
|
-
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(
|
|
1115
|
+
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ t(O, { status: e.status }) }),
|
|
1090
1116
|
/* @__PURE__ */ t("td", { className: r, children: a && /* @__PURE__ */ l("div", { className: "flex items-center gap-1", children: [
|
|
1091
1117
|
/* @__PURE__ */ t(
|
|
1092
1118
|
"button",
|
|
@@ -1095,9 +1121,9 @@ function Bt({
|
|
|
1095
1121
|
title: "Edit",
|
|
1096
1122
|
className: w,
|
|
1097
1123
|
onClick: () => {
|
|
1098
|
-
|
|
1124
|
+
U(e), W(!0);
|
|
1099
1125
|
},
|
|
1100
|
-
children: /* @__PURE__ */ t(
|
|
1126
|
+
children: /* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" })
|
|
1101
1127
|
}
|
|
1102
1128
|
),
|
|
1103
1129
|
/* @__PURE__ */ t(
|
|
@@ -1105,9 +1131,9 @@ function Bt({
|
|
|
1105
1131
|
{
|
|
1106
1132
|
type: "button",
|
|
1107
1133
|
title: "Delete",
|
|
1108
|
-
className:
|
|
1109
|
-
onClick: () =>
|
|
1110
|
-
children: /* @__PURE__ */ t(
|
|
1134
|
+
className: n(w, "hover:border-red-300 hover:text-red-500"),
|
|
1135
|
+
onClick: () => tt(e),
|
|
1136
|
+
children: /* @__PURE__ */ t(j, { className: "h-3.5 w-3.5" })
|
|
1111
1137
|
}
|
|
1112
1138
|
)
|
|
1113
1139
|
] }) })
|
|
@@ -1117,11 +1143,11 @@ function Bt({
|
|
|
1117
1143
|
)
|
|
1118
1144
|
] }),
|
|
1119
1145
|
g === "anomaly_history" && /* @__PURE__ */ t(
|
|
1120
|
-
|
|
1146
|
+
pe,
|
|
1121
1147
|
{
|
|
1122
1148
|
wide: !0,
|
|
1123
1149
|
title: "Detected anomalies",
|
|
1124
|
-
hint: `Last 200 detections${
|
|
1150
|
+
hint: `Last 200 detections${we ? ` · ${we} needing review` : ""}`,
|
|
1125
1151
|
children: /* @__PURE__ */ t(
|
|
1126
1152
|
C,
|
|
1127
1153
|
{
|
|
@@ -1134,12 +1160,12 @@ function Bt({
|
|
|
1134
1160
|
],
|
|
1135
1161
|
empty: "No anomalies detected",
|
|
1136
1162
|
emptyHint: "Detections appear here when a subject deviates from its own recent pattern.",
|
|
1137
|
-
emptyIcon: /* @__PURE__ */ t(
|
|
1138
|
-
loading:
|
|
1139
|
-
children:
|
|
1163
|
+
emptyIcon: /* @__PURE__ */ t(Re, { className: "h-5 w-5" }),
|
|
1164
|
+
loading: We,
|
|
1165
|
+
children: B.map((e) => {
|
|
1140
1166
|
const a = e.stats_snapshot ?? {}, h = Object.values(
|
|
1141
1167
|
a.group ?? {}
|
|
1142
|
-
).filter(Boolean), c = typeof a.multiplier == "number" ? a.multiplier : null, y = typeof a.value == "number" ? a.value : null, x = typeof a.mean == "number" ? a.mean : null,
|
|
1168
|
+
).filter(Boolean), c = typeof a.multiplier == "number" ? a.multiplier : null, y = typeof a.value == "number" ? a.value : null, x = typeof a.mean == "number" ? a.mean : null, N = e.status !== "resolved";
|
|
1143
1169
|
return /* @__PURE__ */ l(
|
|
1144
1170
|
"tr",
|
|
1145
1171
|
{
|
|
@@ -1162,7 +1188,7 @@ function Bt({
|
|
|
1162
1188
|
/* @__PURE__ */ l(
|
|
1163
1189
|
"span",
|
|
1164
1190
|
{
|
|
1165
|
-
className:
|
|
1191
|
+
className: n(
|
|
1166
1192
|
"font-mono text-[13px] font-semibold tabular-nums",
|
|
1167
1193
|
c >= 3 ? "text-red-600 dark:text-red-400" : "text-amber-600 dark:text-amber-400"
|
|
1168
1194
|
),
|
|
@@ -1173,15 +1199,15 @@ function Bt({
|
|
|
1173
1199
|
}
|
|
1174
1200
|
),
|
|
1175
1201
|
y != null && x != null && /* @__PURE__ */ l("span", { className: "font-mono text-[10.5px] tabular-nums text-slate-400 dark:text-slate-500", children: [
|
|
1176
|
-
|
|
1202
|
+
$(y, "dollar"),
|
|
1177
1203
|
" vs ",
|
|
1178
|
-
|
|
1204
|
+
$(x, "dollar")
|
|
1179
1205
|
] })
|
|
1180
1206
|
] }) : /* @__PURE__ */ t("span", { className: "text-slate-300 dark:text-slate-600", children: "—" }) }),
|
|
1181
|
-
/* @__PURE__ */ t("td", { className:
|
|
1207
|
+
/* @__PURE__ */ t("td", { className: n(r, "max-w-0"), children: /* @__PURE__ */ t(Ft, { text: e.ai_explanation }) }),
|
|
1182
1208
|
/* @__PURE__ */ l("td", { className: r, children: [
|
|
1183
|
-
/* @__PURE__ */ t(
|
|
1184
|
-
e.status !== "new" && /* @__PURE__ */ t("span", { className: "mt-1 block", children: /* @__PURE__ */ t(
|
|
1209
|
+
/* @__PURE__ */ t(ue, { value: e.detected_at }),
|
|
1210
|
+
e.status !== "new" && /* @__PURE__ */ t("span", { className: "mt-1 block", children: /* @__PURE__ */ t(O, { status: e.status }) })
|
|
1185
1211
|
] }),
|
|
1186
1212
|
/* @__PURE__ */ t("td", { className: r, children: /* @__PURE__ */ l("div", { className: "flex items-center justify-end gap-1", children: [
|
|
1187
1213
|
e.status === "new" && /* @__PURE__ */ t(
|
|
@@ -1189,16 +1215,16 @@ function Bt({
|
|
|
1189
1215
|
{
|
|
1190
1216
|
type: "button",
|
|
1191
1217
|
className: "inline-flex h-7 items-center rounded-md border border-slate-200 px-2.5 text-[11.5px] font-medium text-slate-600 transition-colors hover:bg-slate-50 dark:border-border dark:text-slate-300 dark:hover:bg-muted",
|
|
1192
|
-
onClick: () =>
|
|
1218
|
+
onClick: () => Ae(e.id, "acknowledged"),
|
|
1193
1219
|
children: "Acknowledge"
|
|
1194
1220
|
}
|
|
1195
1221
|
),
|
|
1196
|
-
|
|
1222
|
+
N && /* @__PURE__ */ t(
|
|
1197
1223
|
"button",
|
|
1198
1224
|
{
|
|
1199
1225
|
type: "button",
|
|
1200
1226
|
className: "inline-flex h-7 items-center rounded-md border border-nvr-cyan px-2.5 text-[11.5px] font-medium text-nvr-navy transition-colors hover:bg-nvr-cyan/10 dark:text-nvr-cyan",
|
|
1201
|
-
onClick: () =>
|
|
1227
|
+
onClick: () => Ae(e.id, "resolved"),
|
|
1202
1228
|
children: "Resolve"
|
|
1203
1229
|
}
|
|
1204
1230
|
)
|
|
@@ -1212,43 +1238,43 @@ function Bt({
|
|
|
1212
1238
|
)
|
|
1213
1239
|
}
|
|
1214
1240
|
),
|
|
1215
|
-
/* @__PURE__ */ t("span", { className: "hidden", children: /* @__PURE__ */ t(
|
|
1241
|
+
/* @__PURE__ */ t("span", { className: "hidden", children: /* @__PURE__ */ t(Te, { className: "h-4 w-4" }) }),
|
|
1216
1242
|
/* @__PURE__ */ t(
|
|
1217
|
-
|
|
1243
|
+
At,
|
|
1218
1244
|
{
|
|
1219
|
-
open:
|
|
1220
|
-
definitions:
|
|
1221
|
-
editRule:
|
|
1222
|
-
preselectedDefinitionId:
|
|
1223
|
-
onClose: () =>
|
|
1224
|
-
onSave:
|
|
1225
|
-
saving:
|
|
1245
|
+
open: Ue,
|
|
1246
|
+
definitions: T,
|
|
1247
|
+
editRule: te,
|
|
1248
|
+
preselectedDefinitionId: Ve,
|
|
1249
|
+
onClose: () => z(!1),
|
|
1250
|
+
onSave: Xe,
|
|
1251
|
+
saving: ke
|
|
1226
1252
|
}
|
|
1227
1253
|
),
|
|
1228
1254
|
/* @__PURE__ */ t(
|
|
1229
|
-
|
|
1255
|
+
Ct,
|
|
1230
1256
|
{
|
|
1231
|
-
open:
|
|
1232
|
-
definitions:
|
|
1233
|
-
editRule:
|
|
1257
|
+
open: Qe,
|
|
1258
|
+
definitions: Be,
|
|
1259
|
+
editRule: ae,
|
|
1234
1260
|
onClose: () => {
|
|
1235
|
-
|
|
1261
|
+
W(!1), U(null);
|
|
1236
1262
|
},
|
|
1237
|
-
onSave:
|
|
1238
|
-
saving:
|
|
1263
|
+
onSave: et,
|
|
1264
|
+
saving: ke
|
|
1239
1265
|
}
|
|
1240
1266
|
),
|
|
1241
1267
|
/* @__PURE__ */ t(
|
|
1242
|
-
|
|
1268
|
+
St,
|
|
1243
1269
|
{
|
|
1244
|
-
open:
|
|
1245
|
-
sub:
|
|
1246
|
-
onClose: () =>
|
|
1247
|
-
saving:
|
|
1270
|
+
open: V != null,
|
|
1271
|
+
sub: V,
|
|
1272
|
+
onClose: () => le(null),
|
|
1273
|
+
saving: K.isPending,
|
|
1248
1274
|
onSave: (e) => {
|
|
1249
|
-
|
|
1250
|
-
{ id:
|
|
1251
|
-
{ onSuccess: () =>
|
|
1275
|
+
V && K.mutate(
|
|
1276
|
+
{ id: V.id, patch: e },
|
|
1277
|
+
{ onSuccess: () => le(null) }
|
|
1252
1278
|
);
|
|
1253
1279
|
}
|
|
1254
1280
|
}
|
|
@@ -1256,5 +1282,5 @@ function Bt({
|
|
|
1256
1282
|
] });
|
|
1257
1283
|
}
|
|
1258
1284
|
export {
|
|
1259
|
-
|
|
1285
|
+
Wt as AlertManagerView
|
|
1260
1286
|
};
|