@nivaro/react 0.3.45 → 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 +42 -7
- package/dist/shared/components/BaseMap.js +149 -103
- package/dist/shared/components/command-center/CommandCenterView.js +313 -69
- package/dist/shared/components/command-center/Customize.js +353 -0
- package/dist/shared/components/command-center/Header.js +279 -53
- package/dist/shared/components/command-center/KioskLinks.js +198 -0
- package/dist/shared/components/command-center/PeekPanel.js +143 -3
- package/dist/shared/components/command-center/announce.js +13 -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 +132 -3
- 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 +145 -29
- package/dist/shared/components/command-center/panels/FlowPanel.js +154 -56
- package/dist/shared/components/command-center/panels/ForecastPanel.js +244 -3
- package/dist/shared/components/command-center/panels/MapLegend.js +266 -0
- package/dist/shared/components/command-center/panels/MapPanel.js +216 -66
- package/dist/shared/components/command-center/panels/PartnersPanel.js +49 -3
- package/dist/shared/components/command-center/panels/PeoplePanel.js +257 -40
- package/dist/shared/components/command-center/panels/RegionPicker.js +88 -3
- package/dist/shared/components/command-center/panels/SystemPanel.js +158 -38
- package/dist/shared/components/command-center/panels/ThroughputPanel.js +307 -3
- package/dist/shared/components/command-center/panels/TimeBar.js +227 -6
- package/dist/shared/components/command-center/panels/TrafficPanel.js +12 -8
- package/dist/shared/components/command-center/panels/WorkloadPanel.js +82 -3
- 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 +87 -19
- 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/theme.js +39 -21
- 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/monitoring/TrafficMiniMap.js +111 -70
- package/package.json +1 -1
|
@@ -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
|
};
|