@sentio/ui-dashboard 0.3.6 → 0.3.8
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/index.css +204 -2
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +153 -74
- package/dist/index.d.ts +153 -74
- package/dist/index.js +622 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +620 -0
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ __export(index_exports, {
|
|
|
42
42
|
ChartTooltip: () => ChartTooltip,
|
|
43
43
|
ChartTypeButtonGroup: () => ChartTypeButtonGroup,
|
|
44
44
|
DEFAULT_HIGHLIGHT_KEY: () => DEFAULT_HIGHLIGHT_KEY,
|
|
45
|
+
DashboardRefresh: () => DashboardRefresh,
|
|
45
46
|
DataControls: () => DataControls,
|
|
46
47
|
EditDashboardDialog: () => EditDashboardDialog,
|
|
47
48
|
EditGroupDialog: () => EditGroupDialog,
|
|
@@ -62,6 +63,7 @@ __export(index_exports, {
|
|
|
62
63
|
PieChartControls: () => PieChartControls,
|
|
63
64
|
PieIcon: () => PieIcon_default,
|
|
64
65
|
QueryValueChart: () => QueryValueChart,
|
|
66
|
+
QueryValueControls: () => QueryValueControls,
|
|
65
67
|
QueryValueIcon: () => QueryValueIcon_default,
|
|
66
68
|
ReactEChartsBase: () => ReactEChartsBase,
|
|
67
69
|
RefreshButton: () => RefreshButton,
|
|
@@ -69,9 +71,12 @@ __export(index_exports, {
|
|
|
69
71
|
ScatterChartTooltip: () => ScatterChartTooltip,
|
|
70
72
|
ScatterControls: () => ScatterControls,
|
|
71
73
|
ScatterIcon: () => ScatterIcon_default,
|
|
74
|
+
SeriesControls: () => SeriesControls,
|
|
75
|
+
ShareDashboardDialog: () => ShareDashboardDialog,
|
|
72
76
|
SystemLabels: () => SystemLabels,
|
|
73
77
|
TableControls: () => TableControls,
|
|
74
78
|
TableIcon: () => TableIcon_default,
|
|
79
|
+
TimeRangeOverride: () => TimeRangeOverride,
|
|
75
80
|
TimeSeriesChart: () => TimeSeriesChart,
|
|
76
81
|
ValueControls: () => ValueControls,
|
|
77
82
|
ValueFormatters: () => ValueFormatters,
|
|
@@ -82,8 +87,10 @@ __export(index_exports, {
|
|
|
82
87
|
defaultBarGaugeConfig: () => defaultConfig2,
|
|
83
88
|
defaultDataConfig: () => defaultConfig5,
|
|
84
89
|
defaultPieConfig: () => defaultConfig,
|
|
90
|
+
defaultQueryValueConfig: () => defaultConfig9,
|
|
85
91
|
defaultScatterConfig: () => defaultConfig6,
|
|
86
92
|
defaultTableConfig: () => defaultConfig7,
|
|
93
|
+
defaultTimeRangeOverrideConfig: () => defaultConfig8,
|
|
87
94
|
defaultValueConfig: () => defaultConfig3,
|
|
88
95
|
defaultValueControlsConfig: () => defaultConfig4,
|
|
89
96
|
getDefaultValueConfig: () => getDefaultValueConfig,
|
|
@@ -4125,6 +4132,29 @@ function timeBefore(time, duration2, asStart = true) {
|
|
|
4125
4132
|
return t.subtract(durationValue, import_ui_core11.TimeUnitShortNames[duration2.unit]);
|
|
4126
4133
|
}
|
|
4127
4134
|
}
|
|
4135
|
+
function fromTimeLike(tl) {
|
|
4136
|
+
if (!tl) {
|
|
4137
|
+
return void 0;
|
|
4138
|
+
}
|
|
4139
|
+
if (tl.relativeTime) {
|
|
4140
|
+
const value = tl.relativeTime.value || 0;
|
|
4141
|
+
return {
|
|
4142
|
+
value: Math.abs(value),
|
|
4143
|
+
unit: tl.relativeTime.unit,
|
|
4144
|
+
sign: value < 0 ? -1 : 1
|
|
4145
|
+
};
|
|
4146
|
+
}
|
|
4147
|
+
return import_dayjs4.default.unix(parseInt(tl.absoluteTime || ""));
|
|
4148
|
+
}
|
|
4149
|
+
function toTimeLike(t) {
|
|
4150
|
+
if (import_dayjs4.default.isDayjs(t)) {
|
|
4151
|
+
return { absoluteTime: `${t.unix()}` };
|
|
4152
|
+
}
|
|
4153
|
+
const rt = t;
|
|
4154
|
+
return {
|
|
4155
|
+
relativeTime: { unit: rt.unit, value: rt.sign * rt.value, align: rt.align }
|
|
4156
|
+
};
|
|
4157
|
+
}
|
|
4128
4158
|
|
|
4129
4159
|
// src/charts/TimeSeriesChart.tsx
|
|
4130
4160
|
var import_ui_core15 = require("@sentio/ui-core");
|
|
@@ -7160,6 +7190,591 @@ function EditGroupDialog({
|
|
|
7160
7190
|
}
|
|
7161
7191
|
);
|
|
7162
7192
|
}
|
|
7193
|
+
|
|
7194
|
+
// src/dashboard/DashboardRefresh.tsx
|
|
7195
|
+
var import_dayjs6 = __toESM(require("dayjs"));
|
|
7196
|
+
var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime"));
|
|
7197
|
+
var import_updateLocale = __toESM(require("dayjs/plugin/updateLocale"));
|
|
7198
|
+
var import_ui_core30 = require("@sentio/ui-core");
|
|
7199
|
+
var import_react27 = require("react");
|
|
7200
|
+
var import_io2 = require("react-icons/io");
|
|
7201
|
+
var import_en = __toESM(require("dayjs/locale/en"));
|
|
7202
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
7203
|
+
import_dayjs6.default.extend(import_relativeTime.default);
|
|
7204
|
+
import_dayjs6.default.extend(import_updateLocale.default);
|
|
7205
|
+
import_dayjs6.default.locale("en.short", {
|
|
7206
|
+
...import_en.default,
|
|
7207
|
+
relativeTime: {
|
|
7208
|
+
// relative time format strings, keep %s %d as the same
|
|
7209
|
+
future: "in %s",
|
|
7210
|
+
past: "%s ago",
|
|
7211
|
+
s: "<1s",
|
|
7212
|
+
m: "1min",
|
|
7213
|
+
mm: "%dmin",
|
|
7214
|
+
h: "1h",
|
|
7215
|
+
hh: "%dh",
|
|
7216
|
+
d: "1d",
|
|
7217
|
+
dd: "%dd",
|
|
7218
|
+
M: "1m",
|
|
7219
|
+
MM: "%dm",
|
|
7220
|
+
y: "1y",
|
|
7221
|
+
yy: "%dy"
|
|
7222
|
+
}
|
|
7223
|
+
});
|
|
7224
|
+
import_dayjs6.default.locale("en");
|
|
7225
|
+
var DashboardRefresh = ({ stats, onRefresh }) => {
|
|
7226
|
+
const timeRef = (0, import_react27.useRef)(null);
|
|
7227
|
+
const [fetching, setFetching] = (0, import_react27.useState)(false);
|
|
7228
|
+
const [currentColor, setCurrentColor] = (0, import_react27.useState)("text-[#4CAF1D] border-[#4CAF1D] border" /* NORMAL */);
|
|
7229
|
+
(0, import_react27.useEffect)(() => {
|
|
7230
|
+
const updateFn = () => {
|
|
7231
|
+
if (!stats || !stats.computedAt) return;
|
|
7232
|
+
const computedAt = (0, import_dayjs6.default)(stats.computedAt).locale("en.short");
|
|
7233
|
+
timeRef.current.textContent = computedAt.fromNow(true);
|
|
7234
|
+
if (computedAt.isBefore((0, import_dayjs6.default)().subtract(1, "hour"))) {
|
|
7235
|
+
setCurrentColor("text-[#D98200] border-[#D98200] border" /* WARNNING */);
|
|
7236
|
+
} else {
|
|
7237
|
+
setCurrentColor("text-[#4CAF1D] border-[#4CAF1D] border" /* NORMAL */);
|
|
7238
|
+
}
|
|
7239
|
+
};
|
|
7240
|
+
updateFn();
|
|
7241
|
+
const interval = setInterval(() => {
|
|
7242
|
+
updateFn();
|
|
7243
|
+
}, 1e3);
|
|
7244
|
+
return () => {
|
|
7245
|
+
clearInterval(interval);
|
|
7246
|
+
};
|
|
7247
|
+
}, [stats]);
|
|
7248
|
+
const onClick = (0, import_react27.useCallback)(() => {
|
|
7249
|
+
setFetching((prevState) => {
|
|
7250
|
+
if (prevState) return prevState;
|
|
7251
|
+
onRefresh().finally(() => {
|
|
7252
|
+
setFetching(false);
|
|
7253
|
+
});
|
|
7254
|
+
return true;
|
|
7255
|
+
});
|
|
7256
|
+
}, [onRefresh]);
|
|
7257
|
+
(0, import_react27.useEffect)(() => {
|
|
7258
|
+
if (typeof window == "object") {
|
|
7259
|
+
window.addEventListener("refresh_all", onClick);
|
|
7260
|
+
return () => {
|
|
7261
|
+
window.removeEventListener("refresh_all", onClick);
|
|
7262
|
+
};
|
|
7263
|
+
}
|
|
7264
|
+
}, []);
|
|
7265
|
+
const showReload = fetching || stats?.isRefreshing;
|
|
7266
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
|
|
7267
|
+
"div",
|
|
7268
|
+
{
|
|
7269
|
+
className: (0, import_ui_core30.classNames)(
|
|
7270
|
+
"group/refresh relative ml-1 flex items-center gap-1 rounded-sm py-px pl-1 text-xs transition-all",
|
|
7271
|
+
currentColor,
|
|
7272
|
+
showReload ? "pr-5" : "pr-1.5 hover:pr-5"
|
|
7273
|
+
),
|
|
7274
|
+
children: [
|
|
7275
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("span", { className: "cursor-default text-[10px]", ref: timeRef }),
|
|
7276
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
7277
|
+
"button",
|
|
7278
|
+
{
|
|
7279
|
+
onClick,
|
|
7280
|
+
className: (0, import_ui_core30.classNames)(
|
|
7281
|
+
"absolute right-1",
|
|
7282
|
+
showReload ? "block" : "hidden group-hover/refresh:block"
|
|
7283
|
+
),
|
|
7284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
|
|
7285
|
+
import_io2.IoMdRefresh,
|
|
7286
|
+
{
|
|
7287
|
+
className: (0, import_ui_core30.classNames)(
|
|
7288
|
+
"h-3.5 w-3.5",
|
|
7289
|
+
showReload ? "animate-spin" : ""
|
|
7290
|
+
)
|
|
7291
|
+
}
|
|
7292
|
+
)
|
|
7293
|
+
}
|
|
7294
|
+
)
|
|
7295
|
+
]
|
|
7296
|
+
}
|
|
7297
|
+
);
|
|
7298
|
+
};
|
|
7299
|
+
|
|
7300
|
+
// src/dashboard/ShareDashboardDialog.tsx
|
|
7301
|
+
var import_react28 = require("react");
|
|
7302
|
+
var import_ui_core31 = require("@sentio/ui-core");
|
|
7303
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
7304
|
+
var ShareDashboardDialog = ({
|
|
7305
|
+
open,
|
|
7306
|
+
initData,
|
|
7307
|
+
onUnshare,
|
|
7308
|
+
onClose,
|
|
7309
|
+
onConfigChange,
|
|
7310
|
+
startTime,
|
|
7311
|
+
endTime,
|
|
7312
|
+
tz
|
|
7313
|
+
}) => {
|
|
7314
|
+
const [isReadonly, setIsReadonly] = (0, import_react28.useState)(
|
|
7315
|
+
initData?.config?.isReadonly ?? false
|
|
7316
|
+
);
|
|
7317
|
+
const [hideModifiers, setHideModifiers] = (0, import_react28.useState)(
|
|
7318
|
+
initData?.config?.hideModifiers ?? false
|
|
7319
|
+
);
|
|
7320
|
+
const linkText = (0, import_react28.useMemo)(() => {
|
|
7321
|
+
if (initData?.id) {
|
|
7322
|
+
let timeSuffix = startTime && endTime ? `?from=${encodeURIComponent((0, import_ui_core31.dateTimeToString)(startTime))}&to=${encodeURIComponent((0, import_ui_core31.dateTimeToString)(endTime))}&tz=${tz}` : "";
|
|
7323
|
+
if (tz) {
|
|
7324
|
+
timeSuffix += `&tz=${tz}`;
|
|
7325
|
+
}
|
|
7326
|
+
return `${location.origin}/share/${initData?.id}${timeSuffix}`;
|
|
7327
|
+
}
|
|
7328
|
+
return "";
|
|
7329
|
+
}, [initData?.id, startTime, endTime]);
|
|
7330
|
+
const handleConfigChange = (newIsReadonly, newHideModifiers) => {
|
|
7331
|
+
const config = {
|
|
7332
|
+
isReadonly: newIsReadonly,
|
|
7333
|
+
hideModifiers: newHideModifiers
|
|
7334
|
+
};
|
|
7335
|
+
onConfigChange?.(config);
|
|
7336
|
+
};
|
|
7337
|
+
const handleReadonlyChange = (checked) => {
|
|
7338
|
+
setIsReadonly(checked);
|
|
7339
|
+
handleConfigChange(checked, hideModifiers);
|
|
7340
|
+
};
|
|
7341
|
+
const handleHideModifiersChange = (checked) => {
|
|
7342
|
+
setHideModifiers(checked);
|
|
7343
|
+
handleConfigChange(isReadonly, checked);
|
|
7344
|
+
};
|
|
7345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
7346
|
+
import_ui_core31.BaseDialog,
|
|
7347
|
+
{
|
|
7348
|
+
title: "Sharing: ON",
|
|
7349
|
+
open,
|
|
7350
|
+
onCancel: () => {
|
|
7351
|
+
onUnshare?.();
|
|
7352
|
+
onClose();
|
|
7353
|
+
},
|
|
7354
|
+
cancelText: "Revoke URL",
|
|
7355
|
+
cancelProps: {
|
|
7356
|
+
status: "danger"
|
|
7357
|
+
},
|
|
7358
|
+
okText: "Done",
|
|
7359
|
+
onOk: () => {
|
|
7360
|
+
onClose();
|
|
7361
|
+
},
|
|
7362
|
+
onClose,
|
|
7363
|
+
buttonsClassName: "justify-between",
|
|
7364
|
+
footerBorder: false,
|
|
7365
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "mx-4 my-4", children: [
|
|
7366
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex overflow-hidden rounded-md border pl-3", children: [
|
|
7367
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("span", { className: "text-ilabel font-ilabel text-text-foreground flex-1 grow truncate leading-8", children: linkText }),
|
|
7368
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "group cursor-pointer border-l bg-gray-200 px-2 py-1 hover:bg-gray-100", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
7369
|
+
import_ui_core31.CopyButton,
|
|
7370
|
+
{
|
|
7371
|
+
text: linkText,
|
|
7372
|
+
size: 18,
|
|
7373
|
+
className: "text-text-foreground group-hover:text-primary h-4 w-4 align-middle"
|
|
7374
|
+
}
|
|
7375
|
+
) })
|
|
7376
|
+
] }),
|
|
7377
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-text-foreground-secondary mt-2 text-[11px]", children: "Anyone with the link can access this dashboard. You can revoke the link at any time." }),
|
|
7378
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "mt-4 space-y-3 border-t pt-4", children: [
|
|
7379
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-text-foreground text-sm font-medium", children: "Access Settings" }),
|
|
7380
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "space-y-4", children: [
|
|
7381
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
7382
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
7383
|
+
import_ui_core31.Checkbox,
|
|
7384
|
+
{
|
|
7385
|
+
checked: isReadonly,
|
|
7386
|
+
onChange: handleReadonlyChange,
|
|
7387
|
+
label: "Panel read-only access"
|
|
7388
|
+
}
|
|
7389
|
+
),
|
|
7390
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-text-foreground-secondary ml-6 text-xs", children: "Viewers can only view the dashboard without entering panel edit mode or copy configuration." })
|
|
7391
|
+
] }),
|
|
7392
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
7393
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
7394
|
+
import_ui_core31.Checkbox,
|
|
7395
|
+
{
|
|
7396
|
+
checked: hideModifiers,
|
|
7397
|
+
onChange: handleHideModifiersChange,
|
|
7398
|
+
label: "Hide controls"
|
|
7399
|
+
}
|
|
7400
|
+
),
|
|
7401
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-text-foreground-secondary ml-6 text-xs", children: "Hide panel creator and modifier for viewers" })
|
|
7402
|
+
] })
|
|
7403
|
+
] })
|
|
7404
|
+
] })
|
|
7405
|
+
] })
|
|
7406
|
+
}
|
|
7407
|
+
);
|
|
7408
|
+
};
|
|
7409
|
+
|
|
7410
|
+
// src/dashboard/TimeRangeOverride.tsx
|
|
7411
|
+
var import_lodash14 = require("lodash");
|
|
7412
|
+
var import_immer15 = require("immer");
|
|
7413
|
+
var import_ui_core32 = require("@sentio/ui-core");
|
|
7414
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
7415
|
+
var defaultConfig8 = {
|
|
7416
|
+
enabled: false
|
|
7417
|
+
};
|
|
7418
|
+
function TimeRangeOverride({
|
|
7419
|
+
config,
|
|
7420
|
+
onChange,
|
|
7421
|
+
globalStartTime,
|
|
7422
|
+
globalEndTime,
|
|
7423
|
+
globalTz,
|
|
7424
|
+
onSetGlobalTimeRange
|
|
7425
|
+
}) {
|
|
7426
|
+
config = (0, import_lodash14.defaults)(config || {}, defaultConfig8);
|
|
7427
|
+
const setEnabled = (enabled) => {
|
|
7428
|
+
config && onChange(
|
|
7429
|
+
(0, import_immer15.produce)(config, (draft) => {
|
|
7430
|
+
draft.enabled = enabled;
|
|
7431
|
+
if (enabled) {
|
|
7432
|
+
draft.timeRange = {
|
|
7433
|
+
start: toTimeLike(globalStartTime),
|
|
7434
|
+
end: toTimeLike(globalEndTime),
|
|
7435
|
+
step: draft.timeRange?.step,
|
|
7436
|
+
interval: draft.timeRange?.interval,
|
|
7437
|
+
timezone: draft.timeRange?.timezone
|
|
7438
|
+
};
|
|
7439
|
+
}
|
|
7440
|
+
})
|
|
7441
|
+
);
|
|
7442
|
+
};
|
|
7443
|
+
function onTimeRangeChange(start, end, tz) {
|
|
7444
|
+
if (config?.enabled) {
|
|
7445
|
+
onChange(
|
|
7446
|
+
(0, import_immer15.produce)(config, (draft) => {
|
|
7447
|
+
draft.timeRange = {
|
|
7448
|
+
start: toTimeLike(start),
|
|
7449
|
+
end: toTimeLike(end),
|
|
7450
|
+
timezone: tz,
|
|
7451
|
+
step: draft.timeRange?.step,
|
|
7452
|
+
interval: draft.timeRange?.interval
|
|
7453
|
+
};
|
|
7454
|
+
})
|
|
7455
|
+
);
|
|
7456
|
+
} else {
|
|
7457
|
+
onSetGlobalTimeRange(start, end, tz);
|
|
7458
|
+
}
|
|
7459
|
+
}
|
|
7460
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex flex-wrap items-center gap-4 p-2", children: [
|
|
7461
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
7462
|
+
import_ui_core32.Switch,
|
|
7463
|
+
{
|
|
7464
|
+
checked: config.enabled || false,
|
|
7465
|
+
onChange: setEnabled,
|
|
7466
|
+
label: "Override Global Time"
|
|
7467
|
+
}
|
|
7468
|
+
) }),
|
|
7469
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
7470
|
+
import_ui_core32.TimeRangePicker,
|
|
7471
|
+
{
|
|
7472
|
+
startTime: config.enabled ? fromTimeLike(config.timeRange?.start) : globalStartTime,
|
|
7473
|
+
endTime: config.enabled ? fromTimeLike(config.timeRange?.end) : globalEndTime,
|
|
7474
|
+
tz: config.enabled ? config.timeRange?.timezone || globalTz : globalTz,
|
|
7475
|
+
onChange: onTimeRangeChange
|
|
7476
|
+
}
|
|
7477
|
+
)
|
|
7478
|
+
] });
|
|
7479
|
+
}
|
|
7480
|
+
|
|
7481
|
+
// src/dashboard/SeriesControls.tsx
|
|
7482
|
+
var import_react29 = require("react");
|
|
7483
|
+
var import_ui_core33 = require("@sentio/ui-core");
|
|
7484
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
7485
|
+
var import_lu10 = require("react-icons/lu");
|
|
7486
|
+
var import_lodash15 = require("lodash");
|
|
7487
|
+
var import_react30 = require("@headlessui/react");
|
|
7488
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
7489
|
+
var seriesChartTypes = [
|
|
7490
|
+
{
|
|
7491
|
+
value: "default",
|
|
7492
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center", children: [
|
|
7493
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_lu10.LuMountainSnow, { className: "mr-2 h-4 w-4" }),
|
|
7494
|
+
"Default"
|
|
7495
|
+
] })
|
|
7496
|
+
},
|
|
7497
|
+
{
|
|
7498
|
+
value: "LINE",
|
|
7499
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center", children: [
|
|
7500
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(LineIcon_default, { className: "mr-2 h-4 w-4" }),
|
|
7501
|
+
"Line"
|
|
7502
|
+
] })
|
|
7503
|
+
},
|
|
7504
|
+
{
|
|
7505
|
+
value: "BAR",
|
|
7506
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center", children: [
|
|
7507
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(BarIcon_default, { className: "mr-2 h-4 w-4" }),
|
|
7508
|
+
"Bar"
|
|
7509
|
+
] })
|
|
7510
|
+
},
|
|
7511
|
+
{
|
|
7512
|
+
value: "AREA",
|
|
7513
|
+
label: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex items-center", children: [
|
|
7514
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(AreaIcon_default, { className: "mr-2 h-4 w-4" }),
|
|
7515
|
+
"Area"
|
|
7516
|
+
] })
|
|
7517
|
+
}
|
|
7518
|
+
];
|
|
7519
|
+
var SeriesControls = ({
|
|
7520
|
+
config,
|
|
7521
|
+
setSeriesConfig,
|
|
7522
|
+
series,
|
|
7523
|
+
enabled
|
|
7524
|
+
}) => {
|
|
7525
|
+
const parentRef = (0, import_react29.useRef)(null);
|
|
7526
|
+
const [isDisclosureOpen, setIsDisclosureOpen] = (0, import_react29.useState)(true);
|
|
7527
|
+
const shouldVirtualize = series.length > 10;
|
|
7528
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
7529
|
+
count: shouldVirtualize && isDisclosureOpen ? series.length : 0,
|
|
7530
|
+
getScrollElement: () => parentRef.current,
|
|
7531
|
+
estimateSize: () => 40,
|
|
7532
|
+
overscan: 5
|
|
7533
|
+
// Render 5 extra items outside viewport for smooth scrolling
|
|
7534
|
+
});
|
|
7535
|
+
(0, import_react29.useLayoutEffect)(() => {
|
|
7536
|
+
if (isDisclosureOpen && shouldVirtualize && parentRef.current) {
|
|
7537
|
+
const timeoutId = setTimeout(() => {
|
|
7538
|
+
virtualizer.measure();
|
|
7539
|
+
}, 10);
|
|
7540
|
+
return () => clearTimeout(timeoutId);
|
|
7541
|
+
}
|
|
7542
|
+
}, [isDisclosureOpen, shouldVirtualize, virtualizer]);
|
|
7543
|
+
const handleSeriesTypeChange = (seriesName, selectedType) => {
|
|
7544
|
+
const currentSeriesConfig = config?.seriesConfig || { series: {} };
|
|
7545
|
+
if (selectedType === "default") {
|
|
7546
|
+
const newSeriesConfig2 = (0, import_lodash15.cloneDeep)(currentSeriesConfig);
|
|
7547
|
+
if (newSeriesConfig2.series && newSeriesConfig2.series[seriesName]) {
|
|
7548
|
+
delete newSeriesConfig2.series[seriesName];
|
|
7549
|
+
}
|
|
7550
|
+
setSeriesConfig(newSeriesConfig2);
|
|
7551
|
+
return;
|
|
7552
|
+
}
|
|
7553
|
+
const newSeriesConfig = {
|
|
7554
|
+
...currentSeriesConfig,
|
|
7555
|
+
series: {
|
|
7556
|
+
...currentSeriesConfig.series,
|
|
7557
|
+
[seriesName]: { type: selectedType }
|
|
7558
|
+
}
|
|
7559
|
+
};
|
|
7560
|
+
setSeriesConfig(newSeriesConfig);
|
|
7561
|
+
};
|
|
7562
|
+
const handleReset = () => {
|
|
7563
|
+
setSeriesConfig({ series: {} });
|
|
7564
|
+
};
|
|
7565
|
+
const renderSeriesItem = (seriesName) => {
|
|
7566
|
+
const currentType = config?.seriesConfig?.series?.[seriesName]?.type || "default";
|
|
7567
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
7568
|
+
"div",
|
|
7569
|
+
{
|
|
7570
|
+
className: "text-icontent inline-flex h-8 w-full basis-0 px-2",
|
|
7571
|
+
children: [
|
|
7572
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "sm:text-icontent bg-sentio-gray-100 dark:bg-sentio-gray-200 border-main inline-flex shrink items-center rounded-l-md border border-r-0 px-2 font-medium sm:min-w-[160px]", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "truncate", title: seriesName, children: seriesName }) }),
|
|
7573
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { className: "sm:text-icontent bg-sentio-gray-100 dark:bg-sentio-gray-200 border-main inline-flex items-center whitespace-nowrap border border-r-0 px-2", children: "Show as" }),
|
|
7574
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "w-40", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7575
|
+
import_ui_core33.Select,
|
|
7576
|
+
{
|
|
7577
|
+
options: seriesChartTypes,
|
|
7578
|
+
value: currentType,
|
|
7579
|
+
onChange: (selectedType) => handleSeriesTypeChange(seriesName, selectedType),
|
|
7580
|
+
className: "focus:border-primary-500 sm:text-icontent border-main h-full rounded-r-md border",
|
|
7581
|
+
buttonClassName: "border-none! h-full!",
|
|
7582
|
+
placeholder: "Select chart type",
|
|
7583
|
+
asLayer: true
|
|
7584
|
+
}
|
|
7585
|
+
) })
|
|
7586
|
+
]
|
|
7587
|
+
},
|
|
7588
|
+
seriesName
|
|
7589
|
+
);
|
|
7590
|
+
};
|
|
7591
|
+
if (!enabled) {
|
|
7592
|
+
return null;
|
|
7593
|
+
}
|
|
7594
|
+
const titleWithReset = /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full items-center justify-between pr-2", children: [
|
|
7595
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: `Series (${series.length})` }),
|
|
7596
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7597
|
+
"button",
|
|
7598
|
+
{
|
|
7599
|
+
type: "button",
|
|
7600
|
+
onClick: (e) => {
|
|
7601
|
+
e.stopPropagation();
|
|
7602
|
+
handleReset();
|
|
7603
|
+
},
|
|
7604
|
+
className: "rounded-sm bg-gray-200 px-2 py-1 text-xs transition-colors hover:bg-gray-300",
|
|
7605
|
+
title: "Reset all series to default",
|
|
7606
|
+
children: "Reset"
|
|
7607
|
+
}
|
|
7608
|
+
)
|
|
7609
|
+
] });
|
|
7610
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react30.Disclosure, { defaultOpen: true, children: ({ open }) => {
|
|
7611
|
+
(0, import_react29.useEffect)(() => {
|
|
7612
|
+
setIsDisclosureOpen(open);
|
|
7613
|
+
}, [open]);
|
|
7614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "bg-default-bg w-full rounded-sm", children: [
|
|
7615
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
7616
|
+
import_react30.Disclosure.Button,
|
|
7617
|
+
{
|
|
7618
|
+
className: (0, import_ui_core33.classNames)(
|
|
7619
|
+
open ? "rounded-t" : "rounded-sm",
|
|
7620
|
+
"focus-visible:ring-primary-500/75 text-ilabel font-ilabel text-text-foreground hover:bg-sentio-gray-100 dark:hover:bg-sentio-gray-400 focus:outline-hidden focus-visible:ring-3 flex w-full px-2 py-1.5 text-left"
|
|
7621
|
+
),
|
|
7622
|
+
children: [
|
|
7623
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7624
|
+
import_lu10.LuChevronRight,
|
|
7625
|
+
{
|
|
7626
|
+
className: (0, import_ui_core33.classNames)(
|
|
7627
|
+
open ? "rotate-90 transform" : "",
|
|
7628
|
+
"mr-1 h-5 w-5 self-center transition-all"
|
|
7629
|
+
)
|
|
7630
|
+
}
|
|
7631
|
+
),
|
|
7632
|
+
titleWithReset
|
|
7633
|
+
]
|
|
7634
|
+
}
|
|
7635
|
+
),
|
|
7636
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(import_react30.Disclosure.Panel, { className: "p-2", children: shouldVirtualize && open ? (
|
|
7637
|
+
// Virtualized rendering for large lists - only render when open
|
|
7638
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7639
|
+
"div",
|
|
7640
|
+
{
|
|
7641
|
+
ref: parentRef,
|
|
7642
|
+
className: "text-icontent h-[200px] overflow-auto",
|
|
7643
|
+
style: {
|
|
7644
|
+
contain: "strict"
|
|
7645
|
+
},
|
|
7646
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7647
|
+
"div",
|
|
7648
|
+
{
|
|
7649
|
+
style: {
|
|
7650
|
+
height: `${virtualizer?.getTotalSize() ?? 0}px`,
|
|
7651
|
+
width: "100%",
|
|
7652
|
+
position: "relative"
|
|
7653
|
+
},
|
|
7654
|
+
children: virtualizer?.getVirtualItems().map((virtualItem) => {
|
|
7655
|
+
const seriesName = series[virtualItem.index];
|
|
7656
|
+
if (!seriesName) return null;
|
|
7657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
7658
|
+
"div",
|
|
7659
|
+
{
|
|
7660
|
+
style: {
|
|
7661
|
+
position: "absolute",
|
|
7662
|
+
top: 0,
|
|
7663
|
+
left: 0,
|
|
7664
|
+
width: "100%",
|
|
7665
|
+
height: `${virtualItem.size}px`,
|
|
7666
|
+
transform: `translateY(${virtualItem.start}px)`
|
|
7667
|
+
},
|
|
7668
|
+
children: renderSeriesItem(seriesName)
|
|
7669
|
+
},
|
|
7670
|
+
virtualItem.key
|
|
7671
|
+
);
|
|
7672
|
+
})
|
|
7673
|
+
}
|
|
7674
|
+
)
|
|
7675
|
+
}
|
|
7676
|
+
)
|
|
7677
|
+
) : (
|
|
7678
|
+
// Normal rendering for small lists
|
|
7679
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "text-icontent flex max-h-[200px] flex-col gap-2 overflow-y-auto", children: series.map((seriesName) => renderSeriesItem(seriesName)) })
|
|
7680
|
+
) })
|
|
7681
|
+
] });
|
|
7682
|
+
} });
|
|
7683
|
+
};
|
|
7684
|
+
|
|
7685
|
+
// src/dashboard/QueryValueControls.tsx
|
|
7686
|
+
var import_immer16 = require("immer");
|
|
7687
|
+
var import_lodash16 = require("lodash");
|
|
7688
|
+
var import_ui_core34 = require("@sentio/ui-core");
|
|
7689
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
7690
|
+
var defaultConfig9 = {
|
|
7691
|
+
calculation: "LAST",
|
|
7692
|
+
colorTheme: {
|
|
7693
|
+
themeType: "Gray"
|
|
7694
|
+
},
|
|
7695
|
+
showBackgroundChart: false
|
|
7696
|
+
};
|
|
7697
|
+
var CalculationItems4 = [
|
|
7698
|
+
{ label: "Last", value: "LAST" },
|
|
7699
|
+
{ label: "First", value: "FIRST" },
|
|
7700
|
+
{ label: "Total", value: "TOTAL" },
|
|
7701
|
+
{ label: "Mean", value: "MEAN" },
|
|
7702
|
+
{ label: "Max", value: "MAX" },
|
|
7703
|
+
{ label: "Min", value: "MIN" }
|
|
7704
|
+
];
|
|
7705
|
+
function QueryValueControls({
|
|
7706
|
+
config,
|
|
7707
|
+
defaultOpen,
|
|
7708
|
+
onChange,
|
|
7709
|
+
renderColorSelect
|
|
7710
|
+
}) {
|
|
7711
|
+
config = (0, import_lodash16.defaults)(config, defaultConfig9);
|
|
7712
|
+
function onCalculationChange(cal) {
|
|
7713
|
+
config && onChange((0, import_immer16.produce)(config, (draft) => void (draft.calculation = cal)));
|
|
7714
|
+
}
|
|
7715
|
+
function onSeriesCalculationChange(cal) {
|
|
7716
|
+
config && onChange((0, import_immer16.produce)(config, (draft) => void (draft.seriesCalculation = cal)));
|
|
7717
|
+
}
|
|
7718
|
+
function onSelectColor(c) {
|
|
7719
|
+
config && onChange(
|
|
7720
|
+
(0, import_immer16.produce)(config, (draft) => {
|
|
7721
|
+
draft.colorTheme = c.value;
|
|
7722
|
+
})
|
|
7723
|
+
);
|
|
7724
|
+
}
|
|
7725
|
+
function toggleShowBackgroundChart() {
|
|
7726
|
+
config && onChange(
|
|
7727
|
+
(0, import_immer16.produce)(config, (draft) => {
|
|
7728
|
+
draft.showBackgroundChart = !draft.showBackgroundChart;
|
|
7729
|
+
})
|
|
7730
|
+
);
|
|
7731
|
+
}
|
|
7732
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
7733
|
+
import_ui_core34.DisclosurePanel,
|
|
7734
|
+
{
|
|
7735
|
+
title: "Query Value Options",
|
|
7736
|
+
defaultOpen,
|
|
7737
|
+
containerClassName: "w-full bg-default-bg",
|
|
7738
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-wrap items-center gap-4", children: [
|
|
7739
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "shadow-xs flex h-8 rounded-md", children: [
|
|
7740
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center whitespace-nowrap rounded-l-md border bg-gray-50 px-3", children: "For each series, calculate the" }),
|
|
7741
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
7742
|
+
"select",
|
|
7743
|
+
{
|
|
7744
|
+
value: config?.calculation,
|
|
7745
|
+
className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center border border-x-0 py-0.5 pl-4 pr-7",
|
|
7746
|
+
onChange: (e) => onCalculationChange(e.target.value),
|
|
7747
|
+
children: CalculationItems4.map((d) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: d.value, children: d.label }, d.value))
|
|
7748
|
+
}
|
|
7749
|
+
),
|
|
7750
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center whitespace-nowrap border bg-gray-50 px-3", children: "value, then show the" }),
|
|
7751
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
7752
|
+
"select",
|
|
7753
|
+
{
|
|
7754
|
+
value: config?.seriesCalculation,
|
|
7755
|
+
className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center border border-x-0 py-0.5 pl-4 pr-7",
|
|
7756
|
+
onChange: (e) => onSeriesCalculationChange(e.target.value),
|
|
7757
|
+
children: CalculationItems4.map((d) => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("option", { value: d.value, children: d.label }, d.value))
|
|
7758
|
+
}
|
|
7759
|
+
),
|
|
7760
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sm:text-ilabel border-main text-text-foreground inline-flex items-center whitespace-nowrap rounded-r-md border bg-gray-50 px-3", children: "value of multiple series" })
|
|
7761
|
+
] }),
|
|
7762
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "focus-within:ring-primary-500 shadow-xs border-main flex h-8 divide-x divide-gray-300 rounded-md border focus-within:border-transparent focus-within:ring-2", children: [
|
|
7763
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("span", { className: "sm:text-ilabel text-text-foreground inline-flex items-center whitespace-nowrap rounded-l-md bg-gray-50 px-3", children: "Color Theme" }),
|
|
7764
|
+
renderColorSelect(config?.colorTheme, onSelectColor)
|
|
7765
|
+
] }),
|
|
7766
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
7767
|
+
import_ui_core34.Checkbox,
|
|
7768
|
+
{
|
|
7769
|
+
checked: config?.showBackgroundChart,
|
|
7770
|
+
onChange: toggleShowBackgroundChart,
|
|
7771
|
+
label: "Show Background Chart"
|
|
7772
|
+
}
|
|
7773
|
+
)
|
|
7774
|
+
] })
|
|
7775
|
+
}
|
|
7776
|
+
);
|
|
7777
|
+
}
|
|
7163
7778
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7164
7779
|
0 && (module.exports = {
|
|
7165
7780
|
AggregateInput,
|
|
@@ -7174,6 +7789,7 @@ function EditGroupDialog({
|
|
|
7174
7789
|
ChartTooltip,
|
|
7175
7790
|
ChartTypeButtonGroup,
|
|
7176
7791
|
DEFAULT_HIGHLIGHT_KEY,
|
|
7792
|
+
DashboardRefresh,
|
|
7177
7793
|
DataControls,
|
|
7178
7794
|
EditDashboardDialog,
|
|
7179
7795
|
EditGroupDialog,
|
|
@@ -7194,6 +7810,7 @@ function EditGroupDialog({
|
|
|
7194
7810
|
PieChartControls,
|
|
7195
7811
|
PieIcon,
|
|
7196
7812
|
QueryValueChart,
|
|
7813
|
+
QueryValueControls,
|
|
7197
7814
|
QueryValueIcon,
|
|
7198
7815
|
ReactEChartsBase,
|
|
7199
7816
|
RefreshButton,
|
|
@@ -7201,9 +7818,12 @@ function EditGroupDialog({
|
|
|
7201
7818
|
ScatterChartTooltip,
|
|
7202
7819
|
ScatterControls,
|
|
7203
7820
|
ScatterIcon,
|
|
7821
|
+
SeriesControls,
|
|
7822
|
+
ShareDashboardDialog,
|
|
7204
7823
|
SystemLabels,
|
|
7205
7824
|
TableControls,
|
|
7206
7825
|
TableIcon,
|
|
7826
|
+
TimeRangeOverride,
|
|
7207
7827
|
TimeSeriesChart,
|
|
7208
7828
|
ValueControls,
|
|
7209
7829
|
ValueFormatters,
|
|
@@ -7214,8 +7834,10 @@ function EditGroupDialog({
|
|
|
7214
7834
|
defaultBarGaugeConfig,
|
|
7215
7835
|
defaultDataConfig,
|
|
7216
7836
|
defaultPieConfig,
|
|
7837
|
+
defaultQueryValueConfig,
|
|
7217
7838
|
defaultScatterConfig,
|
|
7218
7839
|
defaultTableConfig,
|
|
7840
|
+
defaultTimeRangeOverrideConfig,
|
|
7219
7841
|
defaultValueConfig,
|
|
7220
7842
|
defaultValueControlsConfig,
|
|
7221
7843
|
getDefaultValueConfig,
|