@nivaro/react 0.3.44 → 0.3.46
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 +75 -7
- package/dist/shared/components/BaseMap.js +149 -103
- package/dist/shared/components/CollectionBrowserView.js +1390 -1358
- package/dist/shared/components/DataTable.js +356 -334
- package/dist/shared/components/ProfileView.js +16 -21
- package/dist/shared/components/command-center/CommandCenterView.js +331 -352
- package/dist/shared/components/command-center/Customize.js +353 -0
- package/dist/shared/components/command-center/Header.js +296 -0
- package/dist/shared/components/command-center/KioskLinks.js +198 -0
- package/dist/shared/components/command-center/PeekPanel.js +146 -0
- package/dist/shared/components/command-center/announce.js +13 -0
- package/dist/shared/components/command-center/api.js +26 -0
- package/dist/shared/components/command-center/board-prefs.js +99 -0
- package/dist/shared/components/command-center/freshness.js +29 -0
- package/dist/shared/components/command-center/layout.js +56 -0
- package/dist/shared/components/command-center/panels/AttentionPanel.js +135 -0
- package/dist/shared/components/command-center/panels/Banner.js +75 -0
- package/dist/shared/components/command-center/panels/BoardSettings.js +223 -0
- package/dist/shared/components/command-center/panels/FeedPanel.js +149 -0
- package/dist/shared/components/command-center/panels/FlowPanel.js +159 -0
- package/dist/shared/components/command-center/panels/ForecastPanel.js +247 -0
- package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
- package/dist/shared/components/command-center/panels/MapPanel.js +224 -0
- package/dist/shared/components/command-center/panels/PartnersPanel.js +52 -0
- package/dist/shared/components/command-center/panels/PeoplePanel.js +264 -0
- package/dist/shared/components/command-center/panels/RegionPicker.js +91 -0
- package/dist/shared/components/command-center/panels/SystemPanel.js +173 -0
- package/dist/shared/components/command-center/panels/ThroughputPanel.js +310 -0
- package/dist/shared/components/command-center/panels/TimeBar.js +231 -0
- package/dist/shared/components/command-center/panels/TrafficPanel.js +15 -0
- package/dist/shared/components/command-center/panels/WorkloadPanel.js +85 -0
- package/dist/shared/components/command-center/panels/attention-actions.js +267 -0
- package/dist/shared/components/command-center/panels/map-shared.js +95 -0
- package/dist/shared/components/command-center/panels/registry.js +96 -0
- package/dist/shared/components/command-center/shell-hooks.js +118 -0
- package/dist/shared/components/command-center/shortcuts.js +37 -0
- package/dist/shared/components/command-center/state.js +12 -0
- package/dist/shared/components/command-center/theme.js +84 -0
- package/dist/shared/components/command-center/time.js +52 -0
- package/dist/shared/components/command-center/url-state.js +54 -0
- package/dist/shared/components/command-center/work-links.js +32 -0
- package/dist/shared/components/imports/ImportConsole.js +48 -47
- package/dist/shared/components/monitoring/TrafficMiniMap.js +111 -70
- package/dist/shared/components/notifications/TestMyRules.js +39 -38
- package/dist/shared/components/profile/TeamsConnect.js +2 -2
- package/dist/shared/components/queue/QueueQuickFilters.js +81 -63
- package/dist/shared/components/queue/QueueWorklist.js +598 -586
- package/dist/shared/lib/quick-filter-cascade.js +29 -0
- package/package.json +1 -1
|
@@ -6,9 +6,9 @@ import { useNivaroClient as $e, useItemEditAuth as je, useNavigation as He, useI
|
|
|
6
6
|
import { useDebounced as We } from "../../hooks/useDebounced.js";
|
|
7
7
|
import { get as M, post as xe } from "../../lib/commands.js";
|
|
8
8
|
import { useLiveEvent as Ge } from "../../lib/live.js";
|
|
9
|
-
import { formatNumber as
|
|
9
|
+
import { formatNumber as N, cn as D, formatRelative as Ye, formatDateTime as Ze } from "../../lib/utils.js";
|
|
10
10
|
import { DataTable as Xe } from "../DataTable.js";
|
|
11
|
-
import { Button as
|
|
11
|
+
import { Button as k } from "../ui/button.js";
|
|
12
12
|
import { DropdownMenu as Je, DropdownMenuTrigger as et, DropdownMenuContent as tt, DropdownMenuItem as O } from "../ui/dropdown-menu.js";
|
|
13
13
|
import { CollectionImportPanel as rt } from "./CollectionImportPanel.js";
|
|
14
14
|
import { DefinitionHealthPanel as at } from "./DefinitionHealthPanel.js";
|
|
@@ -44,13 +44,13 @@ function ve({
|
|
|
44
44
|
count: i,
|
|
45
45
|
status: l,
|
|
46
46
|
active: m,
|
|
47
|
-
onClick:
|
|
47
|
+
onClick: w
|
|
48
48
|
}) {
|
|
49
49
|
return /* @__PURE__ */ a(
|
|
50
50
|
"button",
|
|
51
51
|
{
|
|
52
52
|
type: "button",
|
|
53
|
-
onClick:
|
|
53
|
+
onClick: w,
|
|
54
54
|
"aria-pressed": m,
|
|
55
55
|
className: D(
|
|
56
56
|
"flex items-center gap-1.5 px-3 py-2 text-left transition-colors hover:bg-slate-50 dark:hover:bg-muted/40",
|
|
@@ -59,7 +59,7 @@ function ve({
|
|
|
59
59
|
),
|
|
60
60
|
children: [
|
|
61
61
|
l && /* @__PURE__ */ t("span", { className: D("h-1.5 w-1.5 shrink-0 rounded-full", ke[l].dot) }),
|
|
62
|
-
/* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i == null ? "—" :
|
|
62
|
+
/* @__PURE__ */ t("span", { className: "text-[14px] font-semibold leading-none tabular-nums text-slate-900 dark:text-foreground", children: i == null ? "—" : N(i) }),
|
|
63
63
|
/* @__PURE__ */ t("span", { className: "text-[11px] font-medium leading-none text-slate-400 dark:text-muted-foreground", children: o })
|
|
64
64
|
]
|
|
65
65
|
}
|
|
@@ -70,8 +70,8 @@ function xt({
|
|
|
70
70
|
queuedCount: i,
|
|
71
71
|
stage: l,
|
|
72
72
|
standing: m,
|
|
73
|
-
canManage:
|
|
74
|
-
onOpen:
|
|
73
|
+
canManage: w,
|
|
74
|
+
onOpen: _,
|
|
75
75
|
onCancel: I
|
|
76
76
|
}) {
|
|
77
77
|
const d = o.status === "running", p = lt(o.started_at ?? o.created_at, d);
|
|
@@ -81,7 +81,7 @@ function xt({
|
|
|
81
81
|
"button",
|
|
82
82
|
{
|
|
83
83
|
type: "button",
|
|
84
|
-
onClick:
|
|
84
|
+
onClick: _,
|
|
85
85
|
className: "font-mono text-[12px] font-medium text-slate-900 underline-offset-2 hover:underline dark:text-foreground",
|
|
86
86
|
children: o.import_key
|
|
87
87
|
}
|
|
@@ -93,7 +93,7 @@ function xt({
|
|
|
93
93
|
l && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: l }),
|
|
94
94
|
!d && m && /* @__PURE__ */ t("span", { className: "text-[12px] text-slate-600 dark:text-muted-foreground", children: m }),
|
|
95
95
|
o.row_count != null && /* @__PURE__ */ a("span", { className: "text-[12px] tabular-nums text-slate-500 dark:text-muted-foreground", children: [
|
|
96
|
-
|
|
96
|
+
N(o.row_count),
|
|
97
97
|
" rows"
|
|
98
98
|
] }),
|
|
99
99
|
i > 0 && /* @__PURE__ */ a("span", { className: "text-[12px] text-slate-500 dark:text-muted-foreground", children: [
|
|
@@ -101,7 +101,7 @@ function xt({
|
|
|
101
101
|
i,
|
|
102
102
|
" more queued"
|
|
103
103
|
] }),
|
|
104
|
-
|
|
104
|
+
w && /* @__PURE__ */ a(k, { variant: "ghost", size: "sm", className: "ml-auto h-7 px-2", onClick: I, children: [
|
|
105
105
|
/* @__PURE__ */ t(ye, { className: "h-3.5 w-3.5" }),
|
|
106
106
|
"Stop"
|
|
107
107
|
] })
|
|
@@ -112,15 +112,15 @@ function Qt({
|
|
|
112
112
|
defaultTab: i = "runs",
|
|
113
113
|
initialJobId: l,
|
|
114
114
|
onJobOpen: m,
|
|
115
|
-
initialRunId:
|
|
116
|
-
onRunOpen:
|
|
115
|
+
initialRunId: w = null,
|
|
116
|
+
onRunOpen: _,
|
|
117
117
|
initialDefinitionKey: I = null
|
|
118
118
|
}) {
|
|
119
119
|
var ie, le, de, ce;
|
|
120
|
-
const d = $e(), p = Pe(), { isAdmin: s } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [b, H] = c(() => l ? "collection" : I && s ? "definitions" : i !== "runs" && !s ? "runs" : i), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [
|
|
121
|
-
Ce(e),
|
|
122
|
-
}, [Se, Q] = c(!1), [Z, A] = c(null), [X, qe] = c({}),
|
|
123
|
-
pe(() => G(1), [h, x,
|
|
120
|
+
const d = $e(), p = Pe(), { isAdmin: s } = je(), j = He(), { open: we } = Ve(), _e = !!j.itemUrl || !!j.openItem, [b, H] = c(() => l ? "collection" : I && s ? "definitions" : i !== "runs" && !s ? "runs" : i), [h, R] = c("all"), [x, K] = c(""), [V, W] = c(""), [P, G] = c(1), [g, Y] = c("30"), [C, Ce] = c(w), S = (e) => {
|
|
121
|
+
Ce(e), _ == null || _(e);
|
|
122
|
+
}, [Se, Q] = c(!1), [Z, A] = c(null), [X, qe] = c({}), q = We(V, 300);
|
|
123
|
+
pe(() => G(1), [h, x, q, g]);
|
|
124
124
|
const T = L({
|
|
125
125
|
queryKey: ["staged-import-definitions"],
|
|
126
126
|
queryFn: () => d.request(
|
|
@@ -135,8 +135,8 @@ function Qt({
|
|
|
135
135
|
), J = L({
|
|
136
136
|
queryKey: ["staged-import-stats", g],
|
|
137
137
|
queryFn: () => d.request(M("/staged-imports/stats", { days: g }))
|
|
138
|
-
}), r = (le = J.data) == null ? void 0 : le.data, De = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : mt,
|
|
139
|
-
queryKey: ["staged-import-runs", h, x,
|
|
138
|
+
}), r = (le = J.data) == null ? void 0 : le.data, De = ((r == null ? void 0 : r.active.length) ?? 0) > 0 ? ge : mt, v = L({
|
|
139
|
+
queryKey: ["staged-import-runs", h, x, q, P, g],
|
|
140
140
|
queryFn: () => d.request(
|
|
141
141
|
M("/staged-imports", {
|
|
142
142
|
page: P,
|
|
@@ -144,23 +144,23 @@ function Qt({
|
|
|
144
144
|
days: g,
|
|
145
145
|
...h === "all" ? {} : { status: h },
|
|
146
146
|
...x ? { key: x } : {},
|
|
147
|
-
...
|
|
147
|
+
...q.trim() ? { search: q.trim() } : {}
|
|
148
148
|
})
|
|
149
149
|
),
|
|
150
150
|
refetchInterval: De,
|
|
151
151
|
// Refetching must not blank the table out from under someone reading it.
|
|
152
152
|
placeholderData: (e) => e
|
|
153
|
-
}), ee = ((de =
|
|
154
|
-
function
|
|
153
|
+
}), ee = ((de = v.data) == null ? void 0 : de.data) ?? [];
|
|
154
|
+
function y() {
|
|
155
155
|
p.invalidateQueries({ queryKey: ["staged-import-runs"] }), p.invalidateQueries({ queryKey: ["staged-import-stats"] }), p.invalidateQueries({ queryKey: ["collection-import-jobs"] });
|
|
156
156
|
}
|
|
157
|
-
const te = Ue(
|
|
158
|
-
te.current =
|
|
157
|
+
const te = Ue(y);
|
|
158
|
+
te.current = y, pe(() => {
|
|
159
159
|
if (o)
|
|
160
160
|
return o.subscribe((e) => {
|
|
161
161
|
qe((n) => ({
|
|
162
162
|
...n,
|
|
163
|
-
[e.id]: e.stage === "row_count" ? `${
|
|
163
|
+
[e.id]: e.stage === "row_count" ? `${N(e.row_count ?? 0)} rows read` : e.stage === "preparing" ? "Preparing the staging table" : e.stage === "importing" ? "Importing the rows" : e.stage === "completed" ? "Completed" : typeof e.error == "string" && e.error ? e.error : "Failed"
|
|
164
164
|
})), te.current();
|
|
165
165
|
});
|
|
166
166
|
}, [o]);
|
|
@@ -184,13 +184,13 @@ function Qt({
|
|
|
184
184
|
const oe = ue({
|
|
185
185
|
mutationFn: (e) => d.request(xe(`/staged-imports/${e}/requeue`)),
|
|
186
186
|
onSuccess: () => {
|
|
187
|
-
A(null),
|
|
187
|
+
A(null), y();
|
|
188
188
|
},
|
|
189
189
|
onError: (e) => A(e.message)
|
|
190
190
|
}), B = ue({
|
|
191
191
|
mutationFn: (e) => d.request(xe(`/staged-imports/${e}/cancel`)),
|
|
192
192
|
onSuccess: () => {
|
|
193
|
-
A(null),
|
|
193
|
+
A(null), y();
|
|
194
194
|
},
|
|
195
195
|
onError: (e) => A(e.message)
|
|
196
196
|
}), Ee = [
|
|
@@ -232,7 +232,7 @@ function Qt({
|
|
|
232
232
|
header: "Rows",
|
|
233
233
|
className: "w-[90px] text-right",
|
|
234
234
|
headerClassName: "text-right",
|
|
235
|
-
render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" :
|
|
235
|
+
render: (e) => /* @__PURE__ */ t("span", { className: "font-mono text-[11.5px] tabular-nums text-slate-700 dark:text-foreground", children: e.row_count == null ? "—" : N(e.row_count) })
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
238
|
key: "duration",
|
|
@@ -288,7 +288,7 @@ function Qt({
|
|
|
288
288
|
}
|
|
289
289
|
) }),
|
|
290
290
|
/* @__PURE__ */ a(tt, { align: "end", className: "text-[12.5px]", children: [
|
|
291
|
-
/* @__PURE__ */ a(O, { onSelect: () =>
|
|
291
|
+
/* @__PURE__ */ a(O, { onSelect: () => S(e.id), children: [
|
|
292
292
|
/* @__PURE__ */ t(ze, { className: "h-3.5 w-3.5" }),
|
|
293
293
|
" View details"
|
|
294
294
|
] }),
|
|
@@ -317,7 +317,7 @@ function Qt({
|
|
|
317
317
|
] })
|
|
318
318
|
] }) })
|
|
319
319
|
}
|
|
320
|
-
], z = h !== "all" || !!x || !!
|
|
320
|
+
], z = h !== "all" || !!x || !!q.trim(), se = ((r == null ? void 0 : r.all_time_total) ?? 0) === 0 && !J.isLoading, Le = !z && !se && ((r == null ? void 0 : r.total) ?? 0) === 0 && g !== "0", Me = C != null ? ee.find((e) => e.id === C) : void 0;
|
|
321
321
|
return /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-3", children: [
|
|
322
322
|
/* @__PURE__ */ a("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
323
323
|
/* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: ["runs", "collection", "definitions"].filter((e) => e === "runs" || s).map((e) => /* @__PURE__ */ t(
|
|
@@ -335,26 +335,26 @@ function Qt({
|
|
|
335
335
|
)) }),
|
|
336
336
|
/* @__PURE__ */ a("div", { className: "ml-auto flex items-center gap-2", children: [
|
|
337
337
|
/* @__PURE__ */ t(
|
|
338
|
-
|
|
338
|
+
k,
|
|
339
339
|
{
|
|
340
340
|
variant: "ghost",
|
|
341
341
|
size: "sm",
|
|
342
342
|
className: "h-7 px-2",
|
|
343
|
-
onClick:
|
|
343
|
+
onClick: y,
|
|
344
344
|
"aria-label": "Refresh",
|
|
345
345
|
children: /* @__PURE__ */ t(
|
|
346
346
|
Qe,
|
|
347
347
|
{
|
|
348
348
|
className: D(
|
|
349
349
|
"h-3.5 w-3.5",
|
|
350
|
-
b === "runs" &&
|
|
350
|
+
b === "runs" && v.isFetching && "motion-safe:animate-spin"
|
|
351
351
|
)
|
|
352
352
|
}
|
|
353
353
|
)
|
|
354
354
|
}
|
|
355
355
|
),
|
|
356
356
|
s && b === "runs" && /* @__PURE__ */ t(ot, { definitions: f.filter((e) => e.is_active) }),
|
|
357
|
-
s && b === "runs" && /* @__PURE__ */ a(
|
|
357
|
+
s && b === "runs" && /* @__PURE__ */ a(k, { size: "sm", className: "h-7", onClick: () => Q(!0), children: [
|
|
358
358
|
/* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
|
|
359
359
|
"New import"
|
|
360
360
|
] })
|
|
@@ -381,7 +381,7 @@ function Qt({
|
|
|
381
381
|
stage: X[u.id] ?? null,
|
|
382
382
|
standing: fe(F.get(u.id)),
|
|
383
383
|
canManage: s,
|
|
384
|
-
onOpen: () =>
|
|
384
|
+
onOpen: () => S(u.id),
|
|
385
385
|
onCancel: () => B.mutate(u.id)
|
|
386
386
|
}
|
|
387
387
|
),
|
|
@@ -427,7 +427,7 @@ function Qt({
|
|
|
427
427
|
U,
|
|
428
428
|
{
|
|
429
429
|
label: "Rows imported",
|
|
430
|
-
value: r ?
|
|
430
|
+
value: r ? N(r.rows_imported) : "—"
|
|
431
431
|
}
|
|
432
432
|
),
|
|
433
433
|
/* @__PURE__ */ t(
|
|
@@ -458,16 +458,16 @@ function Qt({
|
|
|
458
458
|
/* @__PURE__ */ t("h3", { className: "mt-3 text-[15px] font-semibold text-slate-900 dark:text-foreground", children: "No imports have run yet" }),
|
|
459
459
|
/* @__PURE__ */ t("p", { className: "mt-1.5 text-[12.5px] leading-relaxed text-slate-500 dark:text-muted-foreground", children: "An import reads a file and brings its rows into the records it is defined for. Runs are queued here and picked up by the worker within a few seconds. Runs that share a staging table go one at a time; others run side by side." }),
|
|
460
460
|
s && /* @__PURE__ */ a("div", { className: "mt-4 flex items-center gap-2", children: [
|
|
461
|
-
/* @__PURE__ */ a(
|
|
461
|
+
/* @__PURE__ */ a(k, { size: "sm", onClick: () => Q(!0), children: [
|
|
462
462
|
/* @__PURE__ */ t(me, { className: "h-3.5 w-3.5" }),
|
|
463
463
|
" Queue an import"
|
|
464
464
|
] }),
|
|
465
|
-
f.length === 0 && /* @__PURE__ */ t(
|
|
465
|
+
f.length === 0 && /* @__PURE__ */ t(k, { variant: "ghost", size: "sm", onClick: () => H("definitions"), children: "Define one first" })
|
|
466
466
|
] })
|
|
467
467
|
] }) }) : /* @__PURE__ */ a("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
468
468
|
Le && /* @__PURE__ */ a("p", { className: "flex flex-wrap items-center gap-2 rounded-md border border-slate-200 bg-white px-3 py-2 text-[12px] text-slate-600 dark:border-border dark:bg-card dark:text-muted-foreground", children: [
|
|
469
469
|
"Nothing ran in this window. All ",
|
|
470
|
-
|
|
470
|
+
N((r == null ? void 0 : r.all_time_total) ?? 0),
|
|
471
471
|
" runs on record are older than it.",
|
|
472
472
|
/* @__PURE__ */ t(
|
|
473
473
|
"button",
|
|
@@ -485,13 +485,14 @@ function Qt({
|
|
|
485
485
|
columns: Ee,
|
|
486
486
|
rows: ee,
|
|
487
487
|
rowKey: (e) => String(e.id),
|
|
488
|
-
total: ((ce =
|
|
488
|
+
total: ((ce = v.data) == null ? void 0 : ce.total) ?? 0,
|
|
489
489
|
page: P,
|
|
490
490
|
limit: be,
|
|
491
491
|
onPageChange: G,
|
|
492
|
-
isLoading:
|
|
493
|
-
isError:
|
|
492
|
+
isLoading: v.isLoading,
|
|
493
|
+
isError: v.isError,
|
|
494
494
|
errorMessage: "Those runs could not be loaded.",
|
|
495
|
+
onRetry: () => void v.refetch(),
|
|
495
496
|
searchValue: V,
|
|
496
497
|
onSearchChange: W,
|
|
497
498
|
searchPlaceholder: "Search imports, files, run ids…",
|
|
@@ -507,13 +508,13 @@ function Qt({
|
|
|
507
508
|
],
|
|
508
509
|
filterValues: { key: x },
|
|
509
510
|
onFilterChange: (e, n) => K(Array.isArray(n) ? n[0] ?? "" : n),
|
|
510
|
-
onRowClick: (e) =>
|
|
511
|
+
onRowClick: (e) => S(e.id),
|
|
511
512
|
nowrapCells: !0,
|
|
512
513
|
minBodyHeight: 280,
|
|
513
514
|
emptyMessage: z ? "No runs match these filters." : "No runs in this window — widen it above.",
|
|
514
515
|
rowClassName: (e) => e.status === "running" ? "bg-nvr-cyan/5 dark:bg-nvr-cyan/10" : void 0,
|
|
515
516
|
toolbarRight: z ? /* @__PURE__ */ t(
|
|
516
|
-
|
|
517
|
+
k,
|
|
517
518
|
{
|
|
518
519
|
variant: "ghost",
|
|
519
520
|
size: "sm",
|
|
@@ -532,10 +533,10 @@ function Qt({
|
|
|
532
533
|
it,
|
|
533
534
|
{
|
|
534
535
|
run: Me,
|
|
535
|
-
runId:
|
|
536
|
-
stage:
|
|
536
|
+
runId: C,
|
|
537
|
+
stage: C != null ? X[C] ?? null : null,
|
|
537
538
|
isAdmin: s,
|
|
538
|
-
onClose: () =>
|
|
539
|
+
onClose: () => S(null),
|
|
539
540
|
onRequeue: (e) => oe.mutate(e),
|
|
540
541
|
onCancel: (e) => B.mutate(e)
|
|
541
542
|
}
|
|
@@ -548,7 +549,7 @@ function Qt({
|
|
|
548
549
|
definitions: f.filter((e) => e.is_active),
|
|
549
550
|
runCounts: re,
|
|
550
551
|
onQueued: (e) => {
|
|
551
|
-
|
|
552
|
+
y(), S(e);
|
|
552
553
|
}
|
|
553
554
|
}
|
|
554
555
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useQuery as
|
|
3
|
-
import { useNivaroClient as
|
|
4
|
-
import { get as
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as l, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as M } from "@tanstack/react-query";
|
|
3
|
+
import { useNivaroClient as _, useNavigation as L } from "../../context.js";
|
|
4
|
+
import { get as A } from "../../lib/commands.js";
|
|
5
|
+
const C = {
|
|
6
6
|
items: "Collections",
|
|
7
7
|
widgets: "Widgets",
|
|
8
8
|
pages: "Pages",
|
|
@@ -14,44 +14,44 @@ const N = {
|
|
|
14
14
|
system: "System",
|
|
15
15
|
other: "Other"
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
const
|
|
17
|
+
function F(e, o = 4, s = 3) {
|
|
18
|
+
const m = /* @__PURE__ */ new Map();
|
|
19
19
|
for (const t of e.entities) {
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
let i = m.get(t.lane);
|
|
21
|
+
i || (i = { req: 0, series: new Array(t.series.length).fill(0) }, m.set(t.lane, i)), i.req += t.req, t.series.forEach((p, a) => {
|
|
22
|
+
i.series[a] = (i.series[a] ?? 0) + p;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
const
|
|
25
|
+
const d = e.totals.req;
|
|
26
26
|
return {
|
|
27
|
-
rpm: e.window_s ?
|
|
28
|
-
req:
|
|
27
|
+
rpm: e.window_s ? d * 60 / e.window_s : 0,
|
|
28
|
+
req: d,
|
|
29
29
|
errors: e.totals.error,
|
|
30
|
-
errPct:
|
|
30
|
+
errPct: d ? 100 * e.totals.error / d : 0,
|
|
31
31
|
p95: e.totals.p95,
|
|
32
|
-
lanes: [...
|
|
32
|
+
lanes: [...m].filter(([, t]) => t.req > 0).sort((t, i) => i[1].req - t[1].req).slice(0, o).map(([t, i]) => ({
|
|
33
33
|
lane: t,
|
|
34
|
-
label:
|
|
35
|
-
req:
|
|
36
|
-
series:
|
|
34
|
+
label: C[t] ?? t,
|
|
35
|
+
req: i.req,
|
|
36
|
+
series: i.series
|
|
37
37
|
})),
|
|
38
|
-
top: e.entities.filter((t) => t.req > 0 && !t.key.endsWith("/__other__")).sort((t,
|
|
38
|
+
top: e.entities.filter((t) => t.req > 0 && !t.key.endsWith("/__other__")).sort((t, i) => i.req - t.req).slice(0, s).map((t) => ({ key: t.key, label: t.label, req: t.req }))
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
(
|
|
41
|
+
function k({ data: e, className: o }) {
|
|
42
|
+
const d = Math.max(1, ...e), t = e.map(
|
|
43
|
+
(i, p) => `${(p / Math.max(1, e.length - 1) * 96).toFixed(1)},${(20 - i / d * 18 - 1).toFixed(1)}`
|
|
44
44
|
).join(" ");
|
|
45
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ n(
|
|
46
46
|
"svg",
|
|
47
47
|
{
|
|
48
48
|
viewBox: "0 0 96 20",
|
|
49
49
|
width: 96,
|
|
50
50
|
height: 20,
|
|
51
|
-
className:
|
|
51
|
+
className: o,
|
|
52
52
|
"aria-hidden": "true",
|
|
53
53
|
preserveAspectRatio: "none",
|
|
54
|
-
children: /* @__PURE__ */
|
|
54
|
+
children: /* @__PURE__ */ n(
|
|
55
55
|
"polyline",
|
|
56
56
|
{
|
|
57
57
|
points: t,
|
|
@@ -64,7 +64,16 @@ function w({ data: e, className: d }) {
|
|
|
64
64
|
}
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
function N(e, o, s, m) {
|
|
68
|
+
const d = s * 1e3 / Math.max(1, o), t = m - s * 1e3 + (e + 0.5) * d;
|
|
69
|
+
return Math.floor(t / 6e4) * 6e4;
|
|
70
|
+
}
|
|
71
|
+
function q(e) {
|
|
72
|
+
let o = 0;
|
|
73
|
+
for (let s = 0; s < e.length; s++) e[s] >= e[o] && (o = s);
|
|
74
|
+
return o;
|
|
75
|
+
}
|
|
76
|
+
const f = (e) => Math.round(e).toLocaleString(), T = (e) => e < 10 ? e.toFixed(1) : f(e), j = (e) => e ? e >= 1e3 ? `${(e / 1e3).toFixed(1)} s` : `${Math.round(e)} ms` : "—", S = {
|
|
68
77
|
// always dark (Command Center)
|
|
69
78
|
dark: {
|
|
70
79
|
card: "rounded-lg border border-white/10 bg-[#101828] text-[#e2e8f0]",
|
|
@@ -84,83 +93,115 @@ const h = (e) => Math.round(e).toLocaleString(), $ = (e) => e < 10 ? e.toFixed(1
|
|
|
84
93
|
link: "text-[#0e7490] hover:underline dark:text-[#67e8f9] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#0891b2]"
|
|
85
94
|
}
|
|
86
95
|
};
|
|
87
|
-
function
|
|
96
|
+
function P({
|
|
88
97
|
window: e = 300,
|
|
89
|
-
tone:
|
|
90
|
-
href:
|
|
91
|
-
refreshMs:
|
|
92
|
-
className:
|
|
98
|
+
tone: o = "auto",
|
|
99
|
+
href: s,
|
|
100
|
+
refreshMs: m = 15e3,
|
|
101
|
+
className: d,
|
|
102
|
+
onPickTime: t
|
|
93
103
|
}) {
|
|
94
|
-
const
|
|
104
|
+
const i = _(), { navigate: p } = L(), a = S[o], h = M({
|
|
95
105
|
queryKey: ["traffic-mini-map", e],
|
|
96
|
-
queryFn: () =>
|
|
106
|
+
queryFn: () => i.request(A("/traffic-map/snapshot", { window: e })).then((r) => r.data).catch(() => null),
|
|
97
107
|
// not an administrator, or no map here: render nothing
|
|
98
|
-
refetchInterval:
|
|
99
|
-
staleTime:
|
|
108
|
+
refetchInterval: m,
|
|
109
|
+
staleTime: m / 2
|
|
100
110
|
});
|
|
101
|
-
if (!
|
|
102
|
-
const
|
|
103
|
-
return /* @__PURE__ */
|
|
111
|
+
if (!h.data) return null;
|
|
112
|
+
const c = F(h.data), w = h.data.window_s, u = s ?? "/traffic-map", x = /^https?:\/\//.test(u), $ = e === 60 ? "last minute" : `last ${e / 60} min`;
|
|
113
|
+
return /* @__PURE__ */ l(
|
|
104
114
|
"section",
|
|
105
115
|
{
|
|
106
|
-
className: `${
|
|
116
|
+
className: `${a.card} ${d ?? ""}`,
|
|
107
117
|
"aria-label": "Traffic",
|
|
108
118
|
"data-traffic-mini-map": "",
|
|
109
119
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */
|
|
120
|
+
/* @__PURE__ */ l("div", { className: `flex items-center justify-between gap-2 px-3 py-2 ${a.head}`, children: [
|
|
121
|
+
/* @__PURE__ */ l("h3", { className: "text-[12.5px] font-semibold", children: [
|
|
112
122
|
"Traffic ",
|
|
113
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ l("span", { className: `font-normal ${a.muted}`, children: [
|
|
114
124
|
"· ",
|
|
115
|
-
|
|
125
|
+
$
|
|
116
126
|
] })
|
|
117
127
|
] }),
|
|
118
|
-
|
|
128
|
+
u ? /* @__PURE__ */ n(
|
|
119
129
|
"a",
|
|
120
130
|
{
|
|
121
|
-
href:
|
|
122
|
-
target:
|
|
123
|
-
rel:
|
|
124
|
-
className: `rounded text-[12px] font-medium ${
|
|
125
|
-
onClick: (
|
|
126
|
-
|
|
131
|
+
href: u,
|
|
132
|
+
target: x ? "_blank" : void 0,
|
|
133
|
+
rel: x ? "noreferrer" : void 0,
|
|
134
|
+
className: `rounded text-[12px] font-medium ${a.link}`,
|
|
135
|
+
onClick: (r) => {
|
|
136
|
+
x || r.metaKey || r.ctrlKey || (r.preventDefault(), p(u));
|
|
127
137
|
},
|
|
128
138
|
"data-traffic-mini-open": "",
|
|
129
139
|
children: "Open map"
|
|
130
140
|
}
|
|
131
141
|
) : null
|
|
132
142
|
] }),
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ l("div", { className: "grid grid-cols-3 gap-2 px-3 pt-2.5 text-[12px] tabular-nums", children: [
|
|
144
|
+
/* @__PURE__ */ l("div", { children: [
|
|
145
|
+
/* @__PURE__ */ n("p", { className: "text-[18px] font-semibold leading-tight", "data-traffic-mini-rpm": "", children: T(c.rpm) }),
|
|
146
|
+
/* @__PURE__ */ n("p", { className: a.muted, children: "requests/min" })
|
|
137
147
|
] }),
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
/* @__PURE__ */
|
|
148
|
+
/* @__PURE__ */ l("div", { children: [
|
|
149
|
+
/* @__PURE__ */ n("p", { className: `text-[18px] font-semibold leading-tight ${c.errors ? a.error : ""}`, children: f(c.errors) }),
|
|
150
|
+
/* @__PURE__ */ l("p", { className: a.muted, children: [
|
|
141
151
|
"errors",
|
|
142
|
-
|
|
152
|
+
c.req ? ` · ${c.errPct.toFixed(1)}%` : ""
|
|
143
153
|
] })
|
|
144
154
|
] }),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
147
|
-
/* @__PURE__ */
|
|
155
|
+
/* @__PURE__ */ l("div", { children: [
|
|
156
|
+
/* @__PURE__ */ n("p", { className: "text-[18px] font-semibold leading-tight", children: j(c.p95) }),
|
|
157
|
+
/* @__PURE__ */ n("p", { className: a.muted, children: "p95" })
|
|
148
158
|
] })
|
|
149
159
|
] }),
|
|
150
|
-
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
c.lanes.length === 0 ? /* @__PURE__ */ n("p", { className: `px-3 py-2.5 text-[12px] ${a.muted}`, children: "No API traffic in the window." }) : /* @__PURE__ */ n("ul", { className: "space-y-1 px-3 pb-1 pt-2.5 text-[12px]", children: c.lanes.map((r) => /* @__PURE__ */ l("li", { className: "flex items-center gap-2", "data-traffic-mini-lane": r.lane, children: [
|
|
161
|
+
/* @__PURE__ */ n("span", { className: "w-[84px] shrink-0 truncate", children: r.label }),
|
|
162
|
+
t ? /* @__PURE__ */ n(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "button",
|
|
166
|
+
className: `min-w-0 flex-1 rounded ${a.link}`,
|
|
167
|
+
"aria-label": `Rewind to the busiest minute for ${r.label} (${new Date(
|
|
168
|
+
N(
|
|
169
|
+
q(r.series),
|
|
170
|
+
r.series.length,
|
|
171
|
+
w,
|
|
172
|
+
h.dataUpdatedAt || Date.now()
|
|
173
|
+
)
|
|
174
|
+
).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" })})`,
|
|
175
|
+
"data-tip": "Click a point to rewind the board to that minute",
|
|
176
|
+
"data-traffic-mini-pick": r.lane,
|
|
177
|
+
onClick: (b) => {
|
|
178
|
+
const v = h.dataUpdatedAt || Date.now(), g = b.currentTarget.getBoundingClientRect(), y = b.detail === 0 || g.width === 0 ? q(r.series) : Math.max(
|
|
179
|
+
0,
|
|
180
|
+
Math.min(
|
|
181
|
+
r.series.length - 1,
|
|
182
|
+
Math.round(
|
|
183
|
+
(b.clientX - g.left) / g.width * (r.series.length - 1)
|
|
184
|
+
)
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
t(N(y, r.series.length, w, v));
|
|
188
|
+
},
|
|
189
|
+
children: /* @__PURE__ */ n(k, { data: r.series, className: `w-full ${a.spark}` })
|
|
190
|
+
}
|
|
191
|
+
) : /* @__PURE__ */ n(k, { data: r.series, className: `min-w-0 flex-1 ${a.spark}` }),
|
|
192
|
+
/* @__PURE__ */ n("span", { className: `w-[52px] shrink-0 text-right tabular-nums ${a.muted}`, children: f(r.req) })
|
|
193
|
+
] }, r.lane)) }),
|
|
194
|
+
c.top.length > 0 && /* @__PURE__ */ l("p", { className: `truncate px-3 pb-2.5 pt-1 text-[11.5px] ${a.muted}`, children: [
|
|
156
195
|
"Busiest: ",
|
|
157
|
-
|
|
196
|
+
c.top.map((r) => `${r.label} (${f(r.req)})`).join(", ")
|
|
158
197
|
] })
|
|
159
198
|
]
|
|
160
199
|
}
|
|
161
200
|
);
|
|
162
201
|
}
|
|
163
202
|
export {
|
|
164
|
-
|
|
165
|
-
|
|
203
|
+
P as TrafficMiniMap,
|
|
204
|
+
F as miniMapSummary,
|
|
205
|
+
N as sparkPointTime,
|
|
206
|
+
q as spikeIndex
|
|
166
207
|
};
|