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