@burdenoff/microfe-bigconsole 2026.1012.1 → 2026.1012.3
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/bigconsole/components/dashboard/CreateDashboardDialog.js +328 -308
- package/dist/bigconsole/components/dashboard/ExportDashboardDialog.js +123 -121
- package/dist/bigconsole/components/dashboard/ImportDashboardDialog.js +241 -267
- package/dist/bigconsole/components/dashboard/TemplateLayoutPreview.js +3 -3
- package/dist/bigconsole/components/widgets/chart/ChartWidget.js +125 -129
- package/dist/bigconsole/components/widgets/chart/charts/AreaChart.js +50 -45
- package/dist/bigconsole/components/widgets/chart/charts/BarChart.js +40 -35
- package/dist/bigconsole/components/widgets/chart/charts/ComboChart.js +41 -48
- package/dist/bigconsole/components/widgets/chart/charts/LineChart.js +41 -36
- package/dist/bigconsole/components/widgets/chart/charts/numericSeries.d.ts +6 -0
- package/dist/bigconsole/components/widgets/chart/charts/numericSeries.js +26 -0
- package/dist/bigconsole/components/widgets/chart/charts/types.d.ts +2 -0
- package/dist/bigconsole/hooks/useExportDashboard.js +62 -38
- package/dist/bigconsole/hooks/useImportDashboard.d.ts +2 -12
- package/dist/bigconsole/hooks/useImportDashboard.js +95 -126
- package/package.json +1 -1
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { configuredNumericSeries as e } from "./numericSeries.js";
|
|
2
|
+
import t from "../ChartTooltip.js";
|
|
3
|
+
import { buildReferenceElements as n } from "./referenceElements.js";
|
|
4
|
+
import { memo as r, useMemo as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { Bar as s, CartesianGrid as c, ComposedChart as l, Legend as u, Line as d, ResponsiveContainer as f, Tooltip as p, XAxis as m, YAxis as h } from "recharts";
|
|
6
7
|
//#region src/bigconsole/components/widgets/chart/charts/ComboChart.tsx
|
|
7
|
-
var
|
|
8
|
+
var g = [
|
|
8
9
|
"var(--color-chart-1)",
|
|
9
10
|
"var(--color-chart-2)",
|
|
10
11
|
"var(--color-chart-3)",
|
|
11
12
|
"var(--color-chart-4)",
|
|
12
13
|
"var(--color-chart-5)"
|
|
13
|
-
],
|
|
14
|
-
let
|
|
15
|
-
field: e,
|
|
16
|
-
type: t === 0 ? "bar" : "line",
|
|
17
|
-
axis: t === 0 ? "left" : "right"
|
|
18
|
-
})) : [], [
|
|
19
|
-
g.series,
|
|
20
|
-
n,
|
|
21
|
-
g.xAxisKey
|
|
22
|
-
]), b = r(() => y.some((e) => e.axis === "right"), [y]), x = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
14
|
+
], _ = r(function({ data: r = [], config: _, hiddenSeries: v = [], onDataClick: y }) {
|
|
15
|
+
let b = i(() => e(r, _), [_, r]), x = i(() => b.some((e) => e.axis === "right"), [b]), S = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
23
16
|
notation: e >= 1e4 ? "compact" : "standard",
|
|
24
17
|
maximumFractionDigits: 2
|
|
25
18
|
}).format(e) : String(e);
|
|
26
|
-
return
|
|
19
|
+
return r?.length ? /* @__PURE__ */ a(f, {
|
|
27
20
|
width: "100%",
|
|
28
21
|
height: "100%",
|
|
29
|
-
children: /* @__PURE__ */
|
|
30
|
-
data:
|
|
22
|
+
children: /* @__PURE__ */ o(l, {
|
|
23
|
+
data: r,
|
|
31
24
|
margin: {
|
|
32
25
|
top: 10,
|
|
33
26
|
right: 10,
|
|
@@ -35,17 +28,17 @@ var h = [
|
|
|
35
28
|
bottom: 0
|
|
36
29
|
},
|
|
37
30
|
onClick: (e) => {
|
|
38
|
-
e?.activePayload?.[0] &&
|
|
31
|
+
e?.activePayload?.[0] && y && y(e.activePayload[0].payload, e.activeTooltipIndex || 0);
|
|
39
32
|
},
|
|
40
33
|
children: [
|
|
41
|
-
|
|
34
|
+
_.showGrid !== !1 && /* @__PURE__ */ a(c, {
|
|
42
35
|
strokeDasharray: "3 3",
|
|
43
36
|
stroke: "var(--color-border-default)",
|
|
44
37
|
opacity: .5,
|
|
45
38
|
vertical: !1
|
|
46
39
|
}),
|
|
47
|
-
/* @__PURE__ */
|
|
48
|
-
dataKey:
|
|
40
|
+
/* @__PURE__ */ a(m, {
|
|
41
|
+
dataKey: _.xAxisKey || "name",
|
|
49
42
|
tick: {
|
|
50
43
|
fill: "var(--color-text-secondary)",
|
|
51
44
|
fontSize: 12
|
|
@@ -53,7 +46,7 @@ var h = [
|
|
|
53
46
|
tickLine: { stroke: "var(--color-border-default)" },
|
|
54
47
|
axisLine: { stroke: "var(--color-border-default)" }
|
|
55
48
|
}),
|
|
56
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ a(h, {
|
|
57
50
|
yAxisId: "left",
|
|
58
51
|
tick: {
|
|
59
52
|
fill: "var(--color-text-secondary)",
|
|
@@ -61,15 +54,15 @@ var h = [
|
|
|
61
54
|
},
|
|
62
55
|
tickLine: { stroke: "var(--color-border-default)" },
|
|
63
56
|
axisLine: { stroke: "var(--color-border-default)" },
|
|
64
|
-
tickFormatter:
|
|
65
|
-
label:
|
|
66
|
-
value:
|
|
57
|
+
tickFormatter: S,
|
|
58
|
+
label: _.yAxisLabel ? {
|
|
59
|
+
value: _.yAxisLabel,
|
|
67
60
|
angle: -90,
|
|
68
61
|
position: "insideLeft",
|
|
69
62
|
fill: "var(--color-text-secondary)"
|
|
70
63
|
} : void 0
|
|
71
64
|
}),
|
|
72
|
-
|
|
65
|
+
x && /* @__PURE__ */ a(h, {
|
|
73
66
|
yAxisId: "right",
|
|
74
67
|
orientation: "right",
|
|
75
68
|
tick: {
|
|
@@ -78,45 +71,45 @@ var h = [
|
|
|
78
71
|
},
|
|
79
72
|
tickLine: { stroke: "var(--color-border-default)" },
|
|
80
73
|
axisLine: { stroke: "var(--color-border-default)" },
|
|
81
|
-
tickFormatter:
|
|
82
|
-
label:
|
|
83
|
-
value:
|
|
74
|
+
tickFormatter: S,
|
|
75
|
+
label: _.yAxisRightLabel ? {
|
|
76
|
+
value: _.yAxisRightLabel,
|
|
84
77
|
angle: 90,
|
|
85
78
|
position: "insideRight",
|
|
86
79
|
fill: "var(--color-text-secondary)"
|
|
87
80
|
} : void 0
|
|
88
81
|
}),
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
content: /* @__PURE__ */
|
|
82
|
+
/* @__PURE__ */ a(p, {
|
|
83
|
+
content: /* @__PURE__ */ a(t, { valueFormatter: S }),
|
|
91
84
|
cursor: {
|
|
92
85
|
fill: "var(--color-bg-muted)",
|
|
93
86
|
opacity: .5
|
|
94
87
|
}
|
|
95
88
|
}),
|
|
96
|
-
|
|
89
|
+
_.showLegend !== !1 && /* @__PURE__ */ a(u, {
|
|
97
90
|
wrapperStyle: { paddingTop: 20 },
|
|
98
|
-
formatter: (e) => /* @__PURE__ */
|
|
91
|
+
formatter: (e) => /* @__PURE__ */ a("span", {
|
|
99
92
|
style: { color: "var(--color-text-primary)" },
|
|
100
93
|
children: e
|
|
101
94
|
})
|
|
102
95
|
}),
|
|
103
|
-
|
|
104
|
-
let n = e.color ||
|
|
105
|
-
return e.type === "line" ? /* @__PURE__ */
|
|
96
|
+
b.map((e, t) => {
|
|
97
|
+
let n = e.color || _.colors?.[t] || g[t % g.length], r = e.axis === "right" && x ? "right" : "left", i = e.label || _.seriesNames?.[e.field] || e.field, o = v.includes(e.field);
|
|
98
|
+
return e.type === "line" ? /* @__PURE__ */ a(d, {
|
|
106
99
|
yAxisId: r,
|
|
107
|
-
type:
|
|
100
|
+
type: _.curveType || "monotone",
|
|
108
101
|
dataKey: e.field,
|
|
109
|
-
name:
|
|
102
|
+
name: i,
|
|
110
103
|
stroke: n,
|
|
111
104
|
strokeWidth: 2,
|
|
112
|
-
dot:
|
|
105
|
+
dot: _.showDots !== !1,
|
|
113
106
|
activeDot: { r: 6 },
|
|
114
|
-
hide:
|
|
107
|
+
hide: o,
|
|
115
108
|
connectNulls: !0
|
|
116
|
-
}, e.field) : /* @__PURE__ */
|
|
109
|
+
}, e.field) : /* @__PURE__ */ a(s, {
|
|
117
110
|
yAxisId: r,
|
|
118
111
|
dataKey: e.field,
|
|
119
|
-
name:
|
|
112
|
+
name: i,
|
|
120
113
|
fill: n,
|
|
121
114
|
radius: [
|
|
122
115
|
4,
|
|
@@ -124,14 +117,14 @@ var h = [
|
|
|
124
117
|
0,
|
|
125
118
|
0
|
|
126
119
|
],
|
|
127
|
-
hide:
|
|
128
|
-
stackId:
|
|
120
|
+
hide: o,
|
|
121
|
+
stackId: _.stacked ? "stack" : void 0
|
|
129
122
|
}, e.field);
|
|
130
123
|
}),
|
|
131
|
-
|
|
124
|
+
n(_.referenceLines, { yAxisId: "left" })
|
|
132
125
|
]
|
|
133
126
|
})
|
|
134
127
|
}) : null;
|
|
135
128
|
});
|
|
136
129
|
//#endregion
|
|
137
|
-
export {
|
|
130
|
+
export { _ as default };
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { numericSeriesKeys as e } from "./numericSeries.js";
|
|
2
|
+
import t from "../ChartTooltip.js";
|
|
3
|
+
import { buildReferenceElements as n } from "./referenceElements.js";
|
|
4
|
+
import { memo as r, useMemo as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
import { CartesianGrid as s, Legend as c, Line as l, LineChart as u, ResponsiveContainer as d, Tooltip as f, XAxis as p, YAxis as m } from "recharts";
|
|
6
7
|
//#region src/bigconsole/components/widgets/chart/charts/LineChart.tsx
|
|
7
|
-
var
|
|
8
|
+
var h = [
|
|
8
9
|
"var(--color-chart-1)",
|
|
9
10
|
"var(--color-chart-2)",
|
|
10
11
|
"var(--color-chart-3)",
|
|
11
12
|
"var(--color-chart-4)",
|
|
12
13
|
"var(--color-chart-5)"
|
|
13
|
-
],
|
|
14
|
-
let
|
|
14
|
+
], g = r(function({ data: r = [], config: g, hiddenSeries: _ = [], onDataClick: v }) {
|
|
15
|
+
let y = i(() => e(r, g.xAxisKey, g.selectedFields), [
|
|
16
|
+
r,
|
|
17
|
+
g.xAxisKey,
|
|
18
|
+
g.selectedFields
|
|
19
|
+
]), b = (e) => typeof e == "number" ? new Intl.NumberFormat("en-US", {
|
|
15
20
|
notation: e >= 1e4 ? "compact" : "standard",
|
|
16
21
|
maximumFractionDigits: 2
|
|
17
22
|
}).format(e) : String(e);
|
|
18
|
-
return
|
|
23
|
+
return r?.length ? /* @__PURE__ */ a(d, {
|
|
19
24
|
width: "100%",
|
|
20
25
|
height: "100%",
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
-
data:
|
|
26
|
+
children: /* @__PURE__ */ o(u, {
|
|
27
|
+
data: r,
|
|
23
28
|
margin: {
|
|
24
29
|
top: 10,
|
|
25
30
|
right: 10,
|
|
@@ -27,68 +32,68 @@ var m = [
|
|
|
27
32
|
bottom: 0
|
|
28
33
|
},
|
|
29
34
|
onClick: (e) => {
|
|
30
|
-
e?.activePayload?.[0] &&
|
|
35
|
+
e?.activePayload?.[0] && v && v(e.activePayload[0].payload, e.activeTooltipIndex || 0);
|
|
31
36
|
},
|
|
32
37
|
children: [
|
|
33
|
-
|
|
38
|
+
g.showGrid !== !1 && /* @__PURE__ */ a(s, {
|
|
34
39
|
strokeDasharray: "3 3",
|
|
35
40
|
stroke: "var(--color-border-default)",
|
|
36
41
|
opacity: .5
|
|
37
42
|
}),
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
dataKey:
|
|
43
|
+
/* @__PURE__ */ a(p, {
|
|
44
|
+
dataKey: g.xAxisKey || "name",
|
|
40
45
|
tick: {
|
|
41
46
|
fill: "var(--color-text-secondary)",
|
|
42
47
|
fontSize: 12
|
|
43
48
|
},
|
|
44
49
|
tickLine: { stroke: "var(--color-border-default)" },
|
|
45
50
|
axisLine: { stroke: "var(--color-border-default)" },
|
|
46
|
-
label:
|
|
47
|
-
value:
|
|
51
|
+
label: g.xAxisLabel ? {
|
|
52
|
+
value: g.xAxisLabel,
|
|
48
53
|
position: "insideBottom",
|
|
49
54
|
offset: -5,
|
|
50
55
|
fill: "var(--color-text-secondary)"
|
|
51
56
|
} : void 0
|
|
52
57
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
58
|
+
/* @__PURE__ */ a(m, {
|
|
54
59
|
tick: {
|
|
55
60
|
fill: "var(--color-text-secondary)",
|
|
56
61
|
fontSize: 12
|
|
57
62
|
},
|
|
58
63
|
tickLine: { stroke: "var(--color-border-default)" },
|
|
59
64
|
axisLine: { stroke: "var(--color-border-default)" },
|
|
60
|
-
tickFormatter:
|
|
61
|
-
scale:
|
|
62
|
-
domain:
|
|
63
|
-
allowDataOverflow:
|
|
64
|
-
label:
|
|
65
|
-
value:
|
|
65
|
+
tickFormatter: b,
|
|
66
|
+
scale: g.logScale ? "log" : "auto",
|
|
67
|
+
domain: g.logScale ? ["auto", "auto"] : void 0,
|
|
68
|
+
allowDataOverflow: g.logScale || void 0,
|
|
69
|
+
label: g.yAxisLabel ? {
|
|
70
|
+
value: g.yAxisLabel,
|
|
66
71
|
angle: -90,
|
|
67
72
|
position: "insideLeft",
|
|
68
73
|
fill: "var(--color-text-secondary)"
|
|
69
74
|
} : void 0
|
|
70
75
|
}),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
content: /* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ a(f, {
|
|
77
|
+
content: /* @__PURE__ */ a(t, { valueFormatter: b }),
|
|
73
78
|
cursor: { stroke: "var(--color-border-default)" }
|
|
74
79
|
}),
|
|
75
|
-
|
|
80
|
+
g.showLegend !== !1 && /* @__PURE__ */ a(c, {
|
|
76
81
|
wrapperStyle: { paddingTop: 20 },
|
|
77
|
-
formatter: (e) => /* @__PURE__ */
|
|
82
|
+
formatter: (e) => /* @__PURE__ */ a("span", {
|
|
78
83
|
style: { color: "var(--color-text-primary)" },
|
|
79
84
|
children: e
|
|
80
85
|
})
|
|
81
86
|
}),
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
type:
|
|
87
|
+
n(g.referenceLines),
|
|
88
|
+
y.map((e, t) => /* @__PURE__ */ a(l, {
|
|
89
|
+
type: g.curveType || "monotone",
|
|
85
90
|
dataKey: e,
|
|
86
|
-
name:
|
|
87
|
-
stroke:
|
|
91
|
+
name: g.seriesNames?.[e] || e,
|
|
92
|
+
stroke: g.colors?.[t] || h[t % h.length],
|
|
88
93
|
strokeWidth: 2,
|
|
89
|
-
dot:
|
|
94
|
+
dot: g.showDots !== !1,
|
|
90
95
|
activeDot: { r: 6 },
|
|
91
|
-
hide:
|
|
96
|
+
hide: _.includes(e),
|
|
92
97
|
connectNulls: !0
|
|
93
98
|
}, e))
|
|
94
99
|
]
|
|
@@ -96,4 +101,4 @@ var m = [
|
|
|
96
101
|
}) : null;
|
|
97
102
|
});
|
|
98
103
|
//#endregion
|
|
99
|
-
export {
|
|
104
|
+
export { g as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChartConfig, ChartData, SeriesConfig } from './types';
|
|
2
|
+
|
|
3
|
+
/** Use the saved field order and never turn an explicit empty selection into all metrics. */
|
|
4
|
+
export declare function numericSeriesKeys(data: readonly ChartData[], xAxisKey?: string, selectedFields?: readonly string[]): string[];
|
|
5
|
+
/** Keep explicit combo descriptors, but apply a saved numeric selection in its persisted order. */
|
|
6
|
+
export declare function configuredNumericSeries(data: readonly ChartData[], config: ChartConfig): SeriesConfig[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/bigconsole/components/widgets/chart/charts/numericSeries.ts
|
|
2
|
+
function e(e, t, n) {
|
|
3
|
+
let r = e[0];
|
|
4
|
+
return r ? [...new Set((n ?? Object.keys(r)).filter((e) => {
|
|
5
|
+
if (typeof e != "string" || e === t) return !1;
|
|
6
|
+
let n = r[e];
|
|
7
|
+
return typeof n == "number" && Number.isFinite(n);
|
|
8
|
+
}))] : [];
|
|
9
|
+
}
|
|
10
|
+
function t(t, n) {
|
|
11
|
+
if (n.series?.length) {
|
|
12
|
+
if (n.selectedFields === void 0) return n.series;
|
|
13
|
+
let r = new Map(n.series.map((e) => [e.field, e]));
|
|
14
|
+
return e(t, n.xAxisKey, n.selectedFields).flatMap((e) => {
|
|
15
|
+
let t = r.get(e);
|
|
16
|
+
return t ? [t] : [];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return e(t, n.xAxisKey, n.selectedFields).map((e, t) => ({
|
|
20
|
+
field: e,
|
|
21
|
+
type: t === 0 ? "bar" : "line",
|
|
22
|
+
axis: t === 0 ? "left" : "right"
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { t as configuredNumericSeries, e as numericSeriesKeys };
|
|
@@ -31,6 +31,8 @@ export interface ChartConfig {
|
|
|
31
31
|
type?: ChartType;
|
|
32
32
|
/** X-axis data key */
|
|
33
33
|
xAxisKey?: string;
|
|
34
|
+
/** Ordered numeric series selection; undefined auto-detects, an empty list displays no series. */
|
|
35
|
+
selectedFields?: string[];
|
|
34
36
|
/** X-axis label */
|
|
35
37
|
xAxisLabel?: string;
|
|
36
38
|
/** Y-axis label */
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import { ExportDashboardDocument as e } from "../../generated/wspace-operations.js";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
2
|
+
import { useBigConsole as t } from "../context/BigConsoleContext.js";
|
|
3
|
+
import "../context/index.js";
|
|
4
|
+
import { useCallback as n, useLayoutEffect as r, useRef as i, useState as a } from "react";
|
|
5
|
+
import { useApolloClient as o } from "@apollo/client/react";
|
|
4
6
|
//#region src/bigconsole/hooks/useExportDashboard.ts
|
|
5
|
-
function
|
|
7
|
+
function s(e, t) {
|
|
6
8
|
let n = new Blob([e], { type: "application/json" }), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
7
9
|
i.href = r, i.download = t, document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(r);
|
|
8
10
|
}
|
|
9
|
-
function
|
|
11
|
+
function c(e) {
|
|
10
12
|
return e.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").substring(0, 50);
|
|
11
13
|
}
|
|
12
|
-
function
|
|
13
|
-
let [
|
|
14
|
+
function l() {
|
|
15
|
+
let [l, u] = a(!1), [d, f] = a(null), p = o(), { currentUser: m, workspaceId: h } = t(), g = `${m?.id ?? ""}|${h ?? ""}`, _ = i(g), v = i(0);
|
|
16
|
+
r(() => (_.current = g, v.current++, u(!1), f(null), () => {
|
|
17
|
+
_.current = "";
|
|
18
|
+
}), [g]);
|
|
19
|
+
let y = n(() => {
|
|
20
|
+
if (!h || !m?.id || _.current !== g) throw Error("Select a workspace before exporting a dashboard.");
|
|
21
|
+
return {
|
|
22
|
+
requiredWorkspaceAuth: !0,
|
|
23
|
+
requiredWorkspaceId: h,
|
|
24
|
+
queryDeduplication: !1
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
h,
|
|
28
|
+
m?.id,
|
|
29
|
+
g
|
|
30
|
+
]), b = n(async (t, n = {}) => {
|
|
31
|
+
let r = ++v.current, i = () => _.current === g && v.current === r;
|
|
14
32
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
33
|
+
let r = y();
|
|
34
|
+
u(!0), f(null);
|
|
35
|
+
let a = await p.query({
|
|
17
36
|
query: e,
|
|
18
37
|
variables: {
|
|
19
38
|
id: t,
|
|
@@ -23,51 +42,56 @@ function o() {
|
|
|
23
42
|
prettyPrint: n.prettyPrint ?? !0
|
|
24
43
|
}
|
|
25
44
|
},
|
|
26
|
-
fetchPolicy: "
|
|
45
|
+
fetchPolicy: "no-cache",
|
|
46
|
+
errorPolicy: "none",
|
|
47
|
+
context: r
|
|
27
48
|
});
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
49
|
+
if (!i()) return null;
|
|
50
|
+
if (a.error) throw a.error;
|
|
51
|
+
let o = a.data?.exportDashboard;
|
|
52
|
+
if (o) {
|
|
53
|
+
let e = JSON.parse(o);
|
|
32
54
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Export returned invalid JSON");
|
|
33
|
-
|
|
34
|
-
return Object.assign(r, { exportedFrom: {
|
|
35
|
-
...a,
|
|
36
|
-
dashboardId: t
|
|
37
|
-
} }), "dashboard" in r && r.dashboard && typeof r.dashboard == "object" && (r.dashboard = {
|
|
38
|
-
...r.dashboard,
|
|
39
|
-
id: t
|
|
40
|
-
}), JSON.stringify(r, null, n.prettyPrint === !1 ? void 0 : 2);
|
|
55
|
+
return JSON.stringify(e, null, n.prettyPrint === !1 ? void 0 : 2);
|
|
41
56
|
}
|
|
42
57
|
throw Error("Export returned empty content");
|
|
43
58
|
} catch (e) {
|
|
44
|
-
return
|
|
59
|
+
return i() && f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to export dashboard")), null;
|
|
45
60
|
} finally {
|
|
46
|
-
|
|
61
|
+
i() && u(!1);
|
|
47
62
|
}
|
|
48
|
-
}, [
|
|
63
|
+
}, [
|
|
64
|
+
p,
|
|
65
|
+
g,
|
|
66
|
+
y
|
|
67
|
+
]);
|
|
49
68
|
return {
|
|
50
|
-
loading:
|
|
51
|
-
error:
|
|
52
|
-
exportDashboard:
|
|
53
|
-
downloadDashboard:
|
|
69
|
+
loading: l,
|
|
70
|
+
error: d,
|
|
71
|
+
exportDashboard: b,
|
|
72
|
+
downloadDashboard: n(async (e, t, n = {}) => {
|
|
54
73
|
try {
|
|
55
|
-
|
|
74
|
+
y();
|
|
75
|
+
let r = n.preparedContent ?? await b(e, n);
|
|
56
76
|
if (!r) return !1;
|
|
57
|
-
let
|
|
58
|
-
if (!
|
|
77
|
+
let i = t;
|
|
78
|
+
if (!i) {
|
|
59
79
|
let e = JSON.parse(r);
|
|
60
|
-
e && typeof e == "object" && "dashboard" in e && e.dashboard && typeof e.dashboard == "object" && "name" in e.dashboard && typeof e.dashboard.name == "string" && (
|
|
80
|
+
e && typeof e == "object" && "dashboard" in e && e.dashboard && typeof e.dashboard == "object" && "name" in e.dashboard && typeof e.dashboard.name == "string" && (i = e.dashboard.name);
|
|
61
81
|
}
|
|
62
|
-
return
|
|
82
|
+
return s(r, `${c(i || "dashboard")}-export-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.json`), !0;
|
|
63
83
|
} catch (e) {
|
|
64
|
-
return
|
|
84
|
+
return _.current === g && f(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to download dashboard")), !1;
|
|
65
85
|
}
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
}, [
|
|
87
|
+
b,
|
|
88
|
+
g,
|
|
89
|
+
y
|
|
90
|
+
]),
|
|
91
|
+
clearError: n(() => {
|
|
92
|
+
v.current++, u(!1), f(null);
|
|
69
93
|
}, [])
|
|
70
94
|
};
|
|
71
95
|
}
|
|
72
96
|
//#endregion
|
|
73
|
-
export {
|
|
97
|
+
export { l as default };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* useImportDashboard Hook
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* Supports both creating new dashboards and updating existing ones on re-import.
|
|
4
|
+
* Imports a validated new dashboard copy. Export provenance never authorizes updates to an existing dashboard.
|
|
6
5
|
*/
|
|
7
6
|
export interface ImportDashboardInfo {
|
|
8
7
|
name: string;
|
|
@@ -47,21 +46,12 @@ export interface ImportDashboardResult {
|
|
|
47
46
|
};
|
|
48
47
|
errorMessage?: string;
|
|
49
48
|
stats?: ImportStats;
|
|
50
|
-
/** Whether the original dashboard was also updated */
|
|
51
|
-
originalUpdated?: boolean;
|
|
52
|
-
/** The original dashboard that was updated (if any) */
|
|
53
|
-
originalDashboard?: {
|
|
54
|
-
id: string;
|
|
55
|
-
name: string;
|
|
56
|
-
};
|
|
57
|
-
/** Whether the entity already exists with no changes (show "already exists" popup) */
|
|
58
|
-
alreadyExists?: boolean;
|
|
59
49
|
}
|
|
60
50
|
export interface ImportDashboardOptions {
|
|
61
51
|
/** Override dashboard name (optional) */
|
|
62
52
|
name?: string;
|
|
63
53
|
/** Target visibility (optional, defaults to PRIVATE) */
|
|
64
|
-
visibility?: 'PRIVATE' | '
|
|
54
|
+
visibility?: 'PRIVATE' | 'WORKSPACE' | 'PUBLIC';
|
|
65
55
|
/** Skip validation warnings (default: false) */
|
|
66
56
|
skipWarnings?: boolean;
|
|
67
57
|
}
|