@devtable/dashboard 1.17.0 → 1.20.0
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/api-caller/index.d.ts +3 -3
- package/dist/contexts/definition-context.d.ts +2 -2
- package/dist/contexts/panel-context.d.ts +2 -2
- package/dist/dashboard.es.js +323 -225
- package/dist/dashboard.umd.js +8 -8
- package/dist/definition-editor/{data-source-editor → query-editor}/context-and-snippets.d.ts +0 -0
- package/dist/definition-editor/{data-source-editor → query-editor}/data-preview.d.ts +0 -0
- package/dist/definition-editor/query-editor/editor.d.ts +7 -0
- package/dist/definition-editor/query-editor/form.d.ts +8 -0
- package/dist/definition-editor/query-editor/index.d.ts +5 -0
- package/dist/definition-editor/{data-source-editor → query-editor}/preview-sql.d.ts +0 -0
- package/dist/definition-editor/query-editor/select-or-add-query.d.ts +7 -0
- package/dist/panel/index.d.ts +1 -1
- package/dist/panel/settings/common/data-field-selector.d.ts +12 -0
- package/dist/panel/settings/pick-query/index.d.ts +5 -0
- package/dist/panel/viz/bar-3d/panel.d.ts +2 -2
- package/dist/panel/viz/cartesian/panel/index.d.ts +1 -1
- package/dist/panel/viz/cartesian/panel/series/fields.bar.d.ts +9 -0
- package/dist/panel/viz/cartesian/panel/series/fields.line.d.ts +9 -0
- package/dist/panel/viz/cartesian/panel/{series.d.ts → series/index.d.ts} +3 -2
- package/dist/panel/viz/cartesian/panel/series/series-item.d.ts +16 -0
- package/dist/panel/viz/cartesian/type.d.ts +4 -1
- package/dist/panel/viz/pie/panel.d.ts +1 -1
- package/dist/panel/viz/stats/panel.d.ts +1 -1
- package/dist/panel/viz/sunburst/panel.d.ts +1 -1
- package/dist/panel/viz/table/panel.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/types/dashboard.d.ts +3 -3
- package/dist/types/viz-panel.d.ts +1 -0
- package/package.json +1 -1
- package/dist/definition-editor/data-source-editor/editor.d.ts +0 -7
- package/dist/definition-editor/data-source-editor/form.d.ts +0 -8
- package/dist/definition-editor/data-source-editor/index.d.ts +0 -5
- package/dist/definition-editor/data-source-editor/select-or-add-data-source.d.ts +0 -7
- package/dist/panel/settings/pick-data-source/index.d.ts +0 -5
- package/dist/panel/viz/bar-3d/type.d.ts +0 -4
package/dist/dashboard.es.js
CHANGED
|
@@ -36,7 +36,7 @@ var __publicField = (obj, key, value) => {
|
|
|
36
36
|
import React from "react";
|
|
37
37
|
import _ from "lodash";
|
|
38
38
|
import RGL, { WidthProvider } from "react-grid-layout";
|
|
39
|
-
import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, SegmentedControl, NumberInput,
|
|
39
|
+
import { Popover, Tooltip, Group, Text, ActionIcon, Box, Button, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, Switch, SegmentedControl, NumberInput, Slider, ColorInput, Accordion, JsonInput, Modal, AppShell, Tabs, Menu, Divider, Container, Textarea } from "@mantine/core";
|
|
40
40
|
import { useRequest } from "ahooks";
|
|
41
41
|
import axios from "axios";
|
|
42
42
|
import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, Database, Recycle, Share } from "tabler-icons-react";
|
|
@@ -132,11 +132,11 @@ const APIClient = {
|
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
const queryBySQL = ({ context, definitions, title,
|
|
136
|
-
if (!
|
|
135
|
+
const queryBySQL = ({ context, definitions, title, query }) => async () => {
|
|
136
|
+
if (!query || !query.sql) {
|
|
137
137
|
return [];
|
|
138
138
|
}
|
|
139
|
-
const { type, key, sql } =
|
|
139
|
+
const { type, key, sql } = query;
|
|
140
140
|
const needParams = sql.includes("$");
|
|
141
141
|
try {
|
|
142
142
|
const params = getSQLParams(context, definitions);
|
|
@@ -174,8 +174,8 @@ const initialContext$1 = {
|
|
|
174
174
|
description: "",
|
|
175
175
|
setDescription: () => {
|
|
176
176
|
},
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
queryID: "",
|
|
178
|
+
setQueryID: () => {
|
|
179
179
|
},
|
|
180
180
|
viz: {
|
|
181
181
|
type: "",
|
|
@@ -191,8 +191,8 @@ const initialContext = {
|
|
|
191
191
|
sqlSnippets: [],
|
|
192
192
|
setSQLSnippets: () => {
|
|
193
193
|
},
|
|
194
|
-
|
|
195
|
-
|
|
194
|
+
queries: [],
|
|
195
|
+
setQueries: () => {
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
198
|
const DefinitionContext = React.createContext(initialContext);
|
|
@@ -230,8 +230,8 @@ const jsx = jsxRuntime.exports.jsx;
|
|
|
230
230
|
const jsxs = jsxRuntime.exports.jsxs;
|
|
231
231
|
const Fragment = jsxRuntime.exports.Fragment;
|
|
232
232
|
function DescriptionPopover({
|
|
233
|
-
position,
|
|
234
|
-
trigger = "
|
|
233
|
+
position = "bottom",
|
|
234
|
+
trigger = "hover"
|
|
235
235
|
}) {
|
|
236
236
|
const {
|
|
237
237
|
freezeLayout
|
|
@@ -269,13 +269,14 @@ function DescriptionPopover({
|
|
|
269
269
|
return /* @__PURE__ */ jsx(Popover, {
|
|
270
270
|
opened,
|
|
271
271
|
onClose: () => setOpened(false),
|
|
272
|
-
withCloseButton:
|
|
272
|
+
withCloseButton: trigger === "click",
|
|
273
273
|
withArrow: true,
|
|
274
274
|
trapFocus: true,
|
|
275
275
|
closeOnEscape: false,
|
|
276
276
|
placement: "center",
|
|
277
277
|
position,
|
|
278
278
|
target,
|
|
279
|
+
width: "40vw",
|
|
279
280
|
children: /* @__PURE__ */ jsx(RichTextEditor, {
|
|
280
281
|
readOnly: true,
|
|
281
282
|
value: description,
|
|
@@ -380,7 +381,7 @@ function PreviewPanel() {
|
|
|
380
381
|
mx: "auto",
|
|
381
382
|
mt: "xl",
|
|
382
383
|
p: "5px",
|
|
383
|
-
spacing:
|
|
384
|
+
spacing: 5,
|
|
384
385
|
sx: {
|
|
385
386
|
width: "600px",
|
|
386
387
|
height: "450px",
|
|
@@ -392,8 +393,6 @@ function PreviewPanel() {
|
|
|
392
393
|
position: "apart",
|
|
393
394
|
noWrap: true,
|
|
394
395
|
sx: {
|
|
395
|
-
borderBottom: "1px solid #eee",
|
|
396
|
-
paddingBottom: "5px",
|
|
397
396
|
flexGrow: 0,
|
|
398
397
|
flexShrink: 0
|
|
399
398
|
},
|
|
@@ -492,9 +491,9 @@ function DataPreview({
|
|
|
492
491
|
}) {
|
|
493
492
|
const definitions = React.useContext(DefinitionContext);
|
|
494
493
|
const contextInfo = React.useContext(ContextInfoContext);
|
|
495
|
-
const
|
|
496
|
-
return definitions.
|
|
497
|
-
}, [definitions.
|
|
494
|
+
const query = React.useMemo(() => {
|
|
495
|
+
return definitions.queries.find((d) => d.id === id);
|
|
496
|
+
}, [definitions.queries, id]);
|
|
498
497
|
const {
|
|
499
498
|
data = [],
|
|
500
499
|
loading,
|
|
@@ -503,9 +502,9 @@ function DataPreview({
|
|
|
503
502
|
context: contextInfo,
|
|
504
503
|
definitions,
|
|
505
504
|
title: id,
|
|
506
|
-
|
|
505
|
+
query
|
|
507
506
|
}), {
|
|
508
|
-
refreshDeps: [contextInfo, definitions,
|
|
507
|
+
refreshDeps: [contextInfo, definitions, query]
|
|
509
508
|
});
|
|
510
509
|
if (loading) {
|
|
511
510
|
return /* @__PURE__ */ jsx(LoadingOverlay, {
|
|
@@ -581,22 +580,22 @@ function DataPreview({
|
|
|
581
580
|
})]
|
|
582
581
|
});
|
|
583
582
|
}
|
|
584
|
-
function
|
|
583
|
+
function PickQuery({}) {
|
|
585
584
|
const {
|
|
586
|
-
|
|
585
|
+
queries
|
|
587
586
|
} = React.useContext(DefinitionContext);
|
|
588
587
|
const {
|
|
589
|
-
|
|
590
|
-
|
|
588
|
+
queryID,
|
|
589
|
+
setQueryID,
|
|
591
590
|
data,
|
|
592
591
|
loading
|
|
593
592
|
} = React.useContext(PanelContext);
|
|
594
593
|
const options = React.useMemo(() => {
|
|
595
|
-
return
|
|
594
|
+
return queries.map((d) => ({
|
|
596
595
|
value: d.id,
|
|
597
596
|
label: d.id
|
|
598
597
|
}));
|
|
599
|
-
}, [
|
|
598
|
+
}, [queries]);
|
|
600
599
|
return /* @__PURE__ */ jsxs(Group, {
|
|
601
600
|
direction: "column",
|
|
602
601
|
grow: true,
|
|
@@ -608,11 +607,11 @@ function PickDataSource({}) {
|
|
|
608
607
|
alignItems: "baseline"
|
|
609
608
|
},
|
|
610
609
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
611
|
-
children: "Select a
|
|
610
|
+
children: "Select a Query"
|
|
612
611
|
}), /* @__PURE__ */ jsx(Select, {
|
|
613
612
|
data: options,
|
|
614
|
-
value:
|
|
615
|
-
onChange:
|
|
613
|
+
value: queryID,
|
|
614
|
+
onChange: setQueryID,
|
|
616
615
|
allowDeselect: false,
|
|
617
616
|
clearable: false,
|
|
618
617
|
sx: {
|
|
@@ -620,7 +619,7 @@ function PickDataSource({}) {
|
|
|
620
619
|
}
|
|
621
620
|
})]
|
|
622
621
|
}), /* @__PURE__ */ jsx(DataPreview, {
|
|
623
|
-
id:
|
|
622
|
+
id: queryID
|
|
624
623
|
})]
|
|
625
624
|
});
|
|
626
625
|
}
|
|
@@ -1673,9 +1672,39 @@ function PreviewViz({}) {
|
|
|
1673
1672
|
loading
|
|
1674
1673
|
});
|
|
1675
1674
|
}
|
|
1675
|
+
function _DataFieldSelector({
|
|
1676
|
+
label,
|
|
1677
|
+
required,
|
|
1678
|
+
value,
|
|
1679
|
+
onChange,
|
|
1680
|
+
data,
|
|
1681
|
+
sx
|
|
1682
|
+
}, ref) {
|
|
1683
|
+
const options = React.useMemo(() => {
|
|
1684
|
+
if (!Array.isArray(data) || data.length === 0) {
|
|
1685
|
+
return [];
|
|
1686
|
+
}
|
|
1687
|
+
const keys = Object.keys(data[0]);
|
|
1688
|
+
return keys.map((k2) => ({
|
|
1689
|
+
label: k2,
|
|
1690
|
+
value: k2
|
|
1691
|
+
}));
|
|
1692
|
+
}, [data]);
|
|
1693
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
1694
|
+
ref,
|
|
1695
|
+
label,
|
|
1696
|
+
data: options,
|
|
1697
|
+
value,
|
|
1698
|
+
onChange,
|
|
1699
|
+
required,
|
|
1700
|
+
sx
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
const DataFieldSelector = React.forwardRef(_DataFieldSelector);
|
|
1676
1704
|
function VizBar3DPanel({
|
|
1677
1705
|
conf,
|
|
1678
|
-
setConf
|
|
1706
|
+
setConf,
|
|
1707
|
+
data
|
|
1679
1708
|
}) {
|
|
1680
1709
|
const defaultValues = _.assign({}, {
|
|
1681
1710
|
"x_axis_data_key": "x",
|
|
@@ -1723,12 +1752,10 @@ function VizBar3DPanel({
|
|
|
1723
1752
|
control,
|
|
1724
1753
|
render: ({
|
|
1725
1754
|
field
|
|
1726
|
-
}) => /* @__PURE__ */ jsx(
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
size: "md",
|
|
1731
|
-
label: "Data Key"
|
|
1755
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1756
|
+
label: "Data Field",
|
|
1757
|
+
required: true,
|
|
1758
|
+
data
|
|
1732
1759
|
}, field))
|
|
1733
1760
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1734
1761
|
name: "xAxis3D.name",
|
|
@@ -1759,12 +1786,10 @@ function VizBar3DPanel({
|
|
|
1759
1786
|
control,
|
|
1760
1787
|
render: ({
|
|
1761
1788
|
field
|
|
1762
|
-
}) => /* @__PURE__ */ jsx(
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
size: "md",
|
|
1767
|
-
label: "Data Key"
|
|
1789
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1790
|
+
label: "Data Field",
|
|
1791
|
+
required: true,
|
|
1792
|
+
data
|
|
1768
1793
|
}, field))
|
|
1769
1794
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1770
1795
|
name: "yAxis3D.name",
|
|
@@ -1795,12 +1820,10 @@ function VizBar3DPanel({
|
|
|
1795
1820
|
control,
|
|
1796
1821
|
render: ({
|
|
1797
1822
|
field
|
|
1798
|
-
}) => /* @__PURE__ */ jsx(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
size: "md",
|
|
1803
|
-
label: "Data Key"
|
|
1823
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
1824
|
+
label: "Data Field",
|
|
1825
|
+
required: true,
|
|
1826
|
+
data
|
|
1804
1827
|
}, field))
|
|
1805
1828
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
1806
1829
|
name: "zAxis3D.name",
|
|
@@ -1890,6 +1913,98 @@ function _MantineColorSelector({
|
|
|
1890
1913
|
});
|
|
1891
1914
|
}
|
|
1892
1915
|
const MantineColorSelector = React.forwardRef(_MantineColorSelector);
|
|
1916
|
+
function BarFields({
|
|
1917
|
+
control,
|
|
1918
|
+
index: index2
|
|
1919
|
+
}) {
|
|
1920
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1921
|
+
direction: "row",
|
|
1922
|
+
grow: true,
|
|
1923
|
+
align: "top",
|
|
1924
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
1925
|
+
name: `series.${index2}.stack`,
|
|
1926
|
+
control,
|
|
1927
|
+
render: ({
|
|
1928
|
+
field
|
|
1929
|
+
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
1930
|
+
label: "Stack",
|
|
1931
|
+
placeholder: "Stack bars by this ID",
|
|
1932
|
+
sx: {
|
|
1933
|
+
flexGrow: 1
|
|
1934
|
+
}
|
|
1935
|
+
}, field))
|
|
1936
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
1937
|
+
name: `series.${index2}.barWidth`,
|
|
1938
|
+
control,
|
|
1939
|
+
render: ({
|
|
1940
|
+
field
|
|
1941
|
+
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
1942
|
+
label: "Bar Width",
|
|
1943
|
+
sx: {
|
|
1944
|
+
flexGrow: 1
|
|
1945
|
+
}
|
|
1946
|
+
}, field))
|
|
1947
|
+
})]
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
const stepOptions = [{
|
|
1951
|
+
label: "off",
|
|
1952
|
+
value: "false"
|
|
1953
|
+
}, {
|
|
1954
|
+
label: "start",
|
|
1955
|
+
value: "start"
|
|
1956
|
+
}, {
|
|
1957
|
+
label: "middle",
|
|
1958
|
+
value: "middle"
|
|
1959
|
+
}, {
|
|
1960
|
+
label: "end",
|
|
1961
|
+
value: "end"
|
|
1962
|
+
}];
|
|
1963
|
+
function LineFields({
|
|
1964
|
+
control,
|
|
1965
|
+
index: index2
|
|
1966
|
+
}) {
|
|
1967
|
+
return /* @__PURE__ */ jsxs(Group, {
|
|
1968
|
+
direction: "row",
|
|
1969
|
+
grow: true,
|
|
1970
|
+
align: "center",
|
|
1971
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
1972
|
+
name: `series.${index2}.step`,
|
|
1973
|
+
control,
|
|
1974
|
+
render: ({
|
|
1975
|
+
field
|
|
1976
|
+
}) => /* @__PURE__ */ jsx(Select, __spreadProps(__spreadValues({
|
|
1977
|
+
label: "Step",
|
|
1978
|
+
data: stepOptions,
|
|
1979
|
+
sx: {
|
|
1980
|
+
flexGrow: 1,
|
|
1981
|
+
maxWidth: "48%"
|
|
1982
|
+
}
|
|
1983
|
+
}, field), {
|
|
1984
|
+
value: String(field.value),
|
|
1985
|
+
onChange: (v) => {
|
|
1986
|
+
const step = v === "false" ? false : v;
|
|
1987
|
+
field.onChange(step);
|
|
1988
|
+
}
|
|
1989
|
+
}))
|
|
1990
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
1991
|
+
name: `series.${index2}.smooth`,
|
|
1992
|
+
control,
|
|
1993
|
+
render: ({
|
|
1994
|
+
field
|
|
1995
|
+
}) => /* @__PURE__ */ jsx(Box, {
|
|
1996
|
+
sx: {
|
|
1997
|
+
flexGrow: 1
|
|
1998
|
+
},
|
|
1999
|
+
children: /* @__PURE__ */ jsx(Switch, {
|
|
2000
|
+
label: "Smooth Line",
|
|
2001
|
+
checked: field.value,
|
|
2002
|
+
onChange: (event) => field.onChange(event.currentTarget.checked)
|
|
2003
|
+
})
|
|
2004
|
+
})
|
|
2005
|
+
})]
|
|
2006
|
+
});
|
|
2007
|
+
}
|
|
1893
2008
|
const labelPositions = [{
|
|
1894
2009
|
label: "off",
|
|
1895
2010
|
value: ""
|
|
@@ -1938,7 +2053,8 @@ function SeriesItemField({
|
|
|
1938
2053
|
index: index2,
|
|
1939
2054
|
remove,
|
|
1940
2055
|
seriesItem,
|
|
1941
|
-
yAxisOptions
|
|
2056
|
+
yAxisOptions,
|
|
2057
|
+
data
|
|
1942
2058
|
}) {
|
|
1943
2059
|
const type = seriesItem.type;
|
|
1944
2060
|
return /* @__PURE__ */ jsxs(Group, {
|
|
@@ -1999,9 +2115,10 @@ function SeriesItemField({
|
|
|
1999
2115
|
control,
|
|
2000
2116
|
render: ({
|
|
2001
2117
|
field
|
|
2002
|
-
}) => /* @__PURE__ */ jsx(
|
|
2003
|
-
label: "Value
|
|
2118
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2119
|
+
label: "Value Field",
|
|
2004
2120
|
required: true,
|
|
2121
|
+
data,
|
|
2005
2122
|
sx: {
|
|
2006
2123
|
flex: 1
|
|
2007
2124
|
}
|
|
@@ -2039,34 +2156,12 @@ function SeriesItemField({
|
|
|
2039
2156
|
}));
|
|
2040
2157
|
}
|
|
2041
2158
|
})]
|
|
2042
|
-
}), type === "
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
control,
|
|
2049
|
-
render: ({
|
|
2050
|
-
field
|
|
2051
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2052
|
-
label: "Stack",
|
|
2053
|
-
placeholder: "Stack bars by this ID",
|
|
2054
|
-
sx: {
|
|
2055
|
-
flexGrow: 1
|
|
2056
|
-
}
|
|
2057
|
-
}, field))
|
|
2058
|
-
}), /* @__PURE__ */ jsx(Controller, {
|
|
2059
|
-
name: `series.${index2}.barWidth`,
|
|
2060
|
-
control,
|
|
2061
|
-
render: ({
|
|
2062
|
-
field
|
|
2063
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2064
|
-
label: "Bar Width",
|
|
2065
|
-
sx: {
|
|
2066
|
-
flexGrow: 1
|
|
2067
|
-
}
|
|
2068
|
-
}, field))
|
|
2069
|
-
})]
|
|
2159
|
+
}), type === "line" && /* @__PURE__ */ jsx(LineFields, {
|
|
2160
|
+
index: index2,
|
|
2161
|
+
control
|
|
2162
|
+
}), type === "bar" && /* @__PURE__ */ jsx(BarFields, {
|
|
2163
|
+
index: index2,
|
|
2164
|
+
control
|
|
2070
2165
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
2071
2166
|
name: `series.${index2}.label_position`,
|
|
2072
2167
|
control,
|
|
@@ -2108,7 +2203,8 @@ function SeriesItemField({
|
|
|
2108
2203
|
function SeriesField({
|
|
2109
2204
|
control,
|
|
2110
2205
|
watch,
|
|
2111
|
-
getValues
|
|
2206
|
+
getValues,
|
|
2207
|
+
data
|
|
2112
2208
|
}) {
|
|
2113
2209
|
const {
|
|
2114
2210
|
fields,
|
|
@@ -2118,7 +2214,7 @@ function SeriesField({
|
|
|
2118
2214
|
control,
|
|
2119
2215
|
name: "series"
|
|
2120
2216
|
});
|
|
2121
|
-
const watchFieldArray = watch("
|
|
2217
|
+
const watchFieldArray = watch("series");
|
|
2122
2218
|
const controlledFields = fields.map((field, index2) => {
|
|
2123
2219
|
return __spreadValues(__spreadValues({}, field), watchFieldArray[index2]);
|
|
2124
2220
|
});
|
|
@@ -2130,7 +2226,9 @@ function SeriesField({
|
|
|
2130
2226
|
yAxisIndex: 0,
|
|
2131
2227
|
label_position: "top",
|
|
2132
2228
|
stack: "",
|
|
2133
|
-
color: "#000"
|
|
2229
|
+
color: "#000",
|
|
2230
|
+
step: false,
|
|
2231
|
+
smooth: false
|
|
2134
2232
|
});
|
|
2135
2233
|
const yAxisOptions = React.useMemo(() => {
|
|
2136
2234
|
return getValues().y_axes.map(({
|
|
@@ -2152,7 +2250,8 @@ function SeriesField({
|
|
|
2152
2250
|
index: index2,
|
|
2153
2251
|
remove,
|
|
2154
2252
|
seriesItem,
|
|
2155
|
-
yAxisOptions
|
|
2253
|
+
yAxisOptions,
|
|
2254
|
+
data
|
|
2156
2255
|
})), /* @__PURE__ */ jsx(Group, {
|
|
2157
2256
|
position: "center",
|
|
2158
2257
|
mt: "xs",
|
|
@@ -2335,7 +2434,9 @@ function withDefaults(series) {
|
|
|
2335
2434
|
label_position = "top",
|
|
2336
2435
|
stack = "1",
|
|
2337
2436
|
color: color2 = "black",
|
|
2338
|
-
barWidth = "30"
|
|
2437
|
+
barWidth = "30",
|
|
2438
|
+
smooth = false,
|
|
2439
|
+
step = false
|
|
2339
2440
|
}) {
|
|
2340
2441
|
return {
|
|
2341
2442
|
type,
|
|
@@ -2346,14 +2447,17 @@ function withDefaults(series) {
|
|
|
2346
2447
|
label_position,
|
|
2347
2448
|
stack,
|
|
2348
2449
|
color: color2,
|
|
2349
|
-
barWidth
|
|
2450
|
+
barWidth,
|
|
2451
|
+
smooth,
|
|
2452
|
+
step
|
|
2350
2453
|
};
|
|
2351
2454
|
}
|
|
2352
2455
|
return series.map(setDefaults);
|
|
2353
2456
|
}
|
|
2354
2457
|
function VizCartesianChartPanel({
|
|
2355
2458
|
conf,
|
|
2356
|
-
setConf
|
|
2459
|
+
setConf,
|
|
2460
|
+
data
|
|
2357
2461
|
}) {
|
|
2358
2462
|
const _a = conf, {
|
|
2359
2463
|
series,
|
|
@@ -2387,13 +2491,14 @@ function VizCartesianChartPanel({
|
|
|
2387
2491
|
control,
|
|
2388
2492
|
handleSubmit,
|
|
2389
2493
|
watch,
|
|
2390
|
-
formState: {
|
|
2391
|
-
isDirty
|
|
2392
|
-
},
|
|
2393
2494
|
getValues
|
|
2394
2495
|
} = useForm({
|
|
2395
2496
|
defaultValues
|
|
2396
2497
|
});
|
|
2498
|
+
const values = getValues();
|
|
2499
|
+
const changed = React.useMemo(() => {
|
|
2500
|
+
return !_.isEqual(values, conf);
|
|
2501
|
+
}, [values, conf]);
|
|
2397
2502
|
return /* @__PURE__ */ jsx(Group, {
|
|
2398
2503
|
direction: "column",
|
|
2399
2504
|
mt: "md",
|
|
@@ -2414,43 +2519,46 @@ function VizCartesianChartPanel({
|
|
|
2414
2519
|
mr: 5,
|
|
2415
2520
|
variant: "filled",
|
|
2416
2521
|
color: "blue",
|
|
2417
|
-
disabled: !
|
|
2522
|
+
disabled: !changed,
|
|
2418
2523
|
children: /* @__PURE__ */ jsx(DeviceFloppy, {
|
|
2419
2524
|
size: 20
|
|
2420
2525
|
})
|
|
2421
2526
|
})]
|
|
2422
|
-
}), /* @__PURE__ */
|
|
2423
|
-
name: "x_axis_data_key",
|
|
2424
|
-
control,
|
|
2425
|
-
render: ({
|
|
2426
|
-
field
|
|
2427
|
-
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2428
|
-
size: "md",
|
|
2429
|
-
mb: "lg",
|
|
2430
|
-
label: "X Axis Data Key"
|
|
2431
|
-
}, field))
|
|
2432
|
-
}), /* @__PURE__ */ jsx(Group, {
|
|
2527
|
+
}), /* @__PURE__ */ jsxs(Group, {
|
|
2433
2528
|
direction: "column",
|
|
2434
2529
|
grow: true,
|
|
2435
2530
|
noWrap: true,
|
|
2436
2531
|
mb: "lg",
|
|
2437
|
-
children: /* @__PURE__ */ jsx(Controller, {
|
|
2532
|
+
children: [/* @__PURE__ */ jsx(Controller, {
|
|
2533
|
+
name: "x_axis_data_key",
|
|
2534
|
+
control,
|
|
2535
|
+
render: ({
|
|
2536
|
+
field
|
|
2537
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2538
|
+
label: "X Axis Data Field",
|
|
2539
|
+
required: true,
|
|
2540
|
+
data,
|
|
2541
|
+
sx: {
|
|
2542
|
+
flex: 1
|
|
2543
|
+
}
|
|
2544
|
+
}, field))
|
|
2545
|
+
}), /* @__PURE__ */ jsx(Controller, {
|
|
2438
2546
|
name: "x_axis_name",
|
|
2439
2547
|
control,
|
|
2440
2548
|
render: ({
|
|
2441
2549
|
field
|
|
2442
2550
|
}) => /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2443
|
-
size: "md",
|
|
2444
2551
|
label: "X Axis Name"
|
|
2445
2552
|
}, field))
|
|
2446
|
-
})
|
|
2553
|
+
})]
|
|
2447
2554
|
}), /* @__PURE__ */ jsx(YAxesField, {
|
|
2448
2555
|
control,
|
|
2449
2556
|
watch
|
|
2450
2557
|
}), /* @__PURE__ */ jsx(SeriesField, {
|
|
2451
2558
|
control,
|
|
2452
2559
|
watch,
|
|
2453
|
-
getValues
|
|
2560
|
+
getValues,
|
|
2561
|
+
data
|
|
2454
2562
|
})]
|
|
2455
2563
|
})
|
|
2456
2564
|
});
|
|
@@ -2460,7 +2568,8 @@ function VizPiePanel({
|
|
|
2460
2568
|
label_field,
|
|
2461
2569
|
value_field
|
|
2462
2570
|
},
|
|
2463
|
-
setConf
|
|
2571
|
+
setConf,
|
|
2572
|
+
data
|
|
2464
2573
|
}) {
|
|
2465
2574
|
const form = useForm$1({
|
|
2466
2575
|
initialValues: {
|
|
@@ -2503,19 +2612,14 @@ function VizPiePanel({
|
|
|
2503
2612
|
border: "1px solid #eee",
|
|
2504
2613
|
borderRadius: "5px"
|
|
2505
2614
|
},
|
|
2506
|
-
children: [/* @__PURE__ */ jsx(
|
|
2615
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2507
2616
|
label: "Label Field",
|
|
2508
2617
|
required: true,
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
}
|
|
2512
|
-
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
2618
|
+
data
|
|
2619
|
+
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2513
2620
|
label: "Value Field",
|
|
2514
|
-
placeholder: "get column value by this field",
|
|
2515
2621
|
required: true,
|
|
2516
|
-
|
|
2517
|
-
flex: 1
|
|
2518
|
-
}
|
|
2622
|
+
data
|
|
2519
2623
|
}, form.getInputProps("value_field")))]
|
|
2520
2624
|
})]
|
|
2521
2625
|
})
|
|
@@ -2713,7 +2817,8 @@ function _ColorArrayInput({
|
|
|
2713
2817
|
const ColorArrayInput = React.forwardRef(_ColorArrayInput);
|
|
2714
2818
|
function VizStatsPanel({
|
|
2715
2819
|
conf,
|
|
2716
|
-
setConf
|
|
2820
|
+
setConf,
|
|
2821
|
+
data
|
|
2717
2822
|
}) {
|
|
2718
2823
|
const defaultValues = _.merge({}, {
|
|
2719
2824
|
align: "center",
|
|
@@ -2789,6 +2894,7 @@ function VizStatsPanel({
|
|
|
2789
2894
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
2790
2895
|
direction: "row",
|
|
2791
2896
|
grow: true,
|
|
2897
|
+
noWrap: true,
|
|
2792
2898
|
children: [/* @__PURE__ */ jsx(Controller, {
|
|
2793
2899
|
name: "content.prefix",
|
|
2794
2900
|
control,
|
|
@@ -2805,12 +2911,10 @@ function VizStatsPanel({
|
|
|
2805
2911
|
control,
|
|
2806
2912
|
render: ({
|
|
2807
2913
|
field
|
|
2808
|
-
}) => /* @__PURE__ */ jsx(
|
|
2914
|
+
}) => /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2809
2915
|
label: "Data Field",
|
|
2810
2916
|
required: true,
|
|
2811
|
-
|
|
2812
|
-
flexGrow: 1
|
|
2813
|
-
}
|
|
2917
|
+
data
|
|
2814
2918
|
}, field))
|
|
2815
2919
|
}), /* @__PURE__ */ jsx(Controller, {
|
|
2816
2920
|
name: "content.postfix",
|
|
@@ -2939,7 +3043,8 @@ function SunburstPanel({
|
|
|
2939
3043
|
label_field,
|
|
2940
3044
|
value_field
|
|
2941
3045
|
},
|
|
2942
|
-
setConf
|
|
3046
|
+
setConf,
|
|
3047
|
+
data
|
|
2943
3048
|
}) {
|
|
2944
3049
|
const form = useForm$1({
|
|
2945
3050
|
initialValues: {
|
|
@@ -2982,19 +3087,14 @@ function SunburstPanel({
|
|
|
2982
3087
|
border: "1px solid #eee",
|
|
2983
3088
|
borderRadius: "5px"
|
|
2984
3089
|
},
|
|
2985
|
-
children: [/* @__PURE__ */ jsx(
|
|
3090
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2986
3091
|
label: "Label Field",
|
|
2987
3092
|
required: true,
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
}
|
|
2991
|
-
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
3093
|
+
data
|
|
3094
|
+
}, form.getInputProps("label_field"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
2992
3095
|
label: "Value Field",
|
|
2993
|
-
placeholder: "get column value by this field",
|
|
2994
3096
|
required: true,
|
|
2995
|
-
|
|
2996
|
-
flex: 1
|
|
2997
|
-
}
|
|
3097
|
+
data
|
|
2998
3098
|
}, form.getInputProps("value_field")))]
|
|
2999
3099
|
})]
|
|
3000
3100
|
})
|
|
@@ -3026,7 +3126,8 @@ function VizTablePanel(_e) {
|
|
|
3026
3126
|
} = _h, restConf = __objRest(_h, [
|
|
3027
3127
|
"columns"
|
|
3028
3128
|
]), {
|
|
3029
|
-
setConf
|
|
3129
|
+
setConf,
|
|
3130
|
+
data
|
|
3030
3131
|
} = _f;
|
|
3031
3132
|
const form = useForm$1({
|
|
3032
3133
|
initialValues: __spreadValues({
|
|
@@ -3080,10 +3181,10 @@ function VizTablePanel(_e) {
|
|
|
3080
3181
|
border: "1px solid #eee",
|
|
3081
3182
|
borderRadius: "5px"
|
|
3082
3183
|
},
|
|
3083
|
-
children: [/* @__PURE__ */ jsx(
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3184
|
+
children: [/* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
3185
|
+
label: "ID Field",
|
|
3186
|
+
required: true,
|
|
3187
|
+
data
|
|
3087
3188
|
}, form.getInputProps("id_field"))), /* @__PURE__ */ jsxs(Group, {
|
|
3088
3189
|
position: "apart",
|
|
3089
3190
|
mb: "lg",
|
|
@@ -3179,25 +3280,16 @@ function VizTablePanel(_e) {
|
|
|
3179
3280
|
children: [/* @__PURE__ */ jsxs(Group, {
|
|
3180
3281
|
position: "apart",
|
|
3181
3282
|
grow: true,
|
|
3182
|
-
sx: {
|
|
3183
|
-
"> *": {
|
|
3184
|
-
flexGrow: 1,
|
|
3185
|
-
maxWidth: "100%"
|
|
3186
|
-
}
|
|
3187
|
-
},
|
|
3188
3283
|
children: [/* @__PURE__ */ jsx(TextInput, __spreadValues({
|
|
3189
3284
|
label: "Label",
|
|
3190
3285
|
required: true,
|
|
3191
3286
|
sx: {
|
|
3192
3287
|
flex: 1
|
|
3193
3288
|
}
|
|
3194
|
-
}, form.getListInputProps("columns", index2, "label"))), /* @__PURE__ */ jsx(
|
|
3289
|
+
}, form.getListInputProps("columns", index2, "label"))), /* @__PURE__ */ jsx(DataFieldSelector, __spreadValues({
|
|
3195
3290
|
label: "Value Field",
|
|
3196
|
-
placeholder: "get column value by this field",
|
|
3197
3291
|
required: true,
|
|
3198
|
-
|
|
3199
|
-
flex: 1
|
|
3200
|
-
}
|
|
3292
|
+
data
|
|
3201
3293
|
}, form.getListInputProps("columns", index2, "value_field"))), /* @__PURE__ */ jsx(ValueTypeSelector, __spreadValues({
|
|
3202
3294
|
label: "Value Type",
|
|
3203
3295
|
sx: {
|
|
@@ -3405,6 +3497,7 @@ const types = [{
|
|
|
3405
3497
|
}];
|
|
3406
3498
|
function EditVizConf() {
|
|
3407
3499
|
const {
|
|
3500
|
+
data,
|
|
3408
3501
|
viz,
|
|
3409
3502
|
setViz
|
|
3410
3503
|
} = React.useContext(PanelContext);
|
|
@@ -3449,7 +3542,8 @@ function EditVizConf() {
|
|
|
3449
3542
|
})
|
|
3450
3543
|
}), Panel2 && /* @__PURE__ */ jsx(Panel2, {
|
|
3451
3544
|
conf: viz.conf,
|
|
3452
|
-
setConf: setVizConf
|
|
3545
|
+
setConf: setVizConf,
|
|
3546
|
+
data
|
|
3453
3547
|
}), !Panel2 && /* @__PURE__ */ jsx(JsonInput, {
|
|
3454
3548
|
minRows: 20,
|
|
3455
3549
|
label: "Config",
|
|
@@ -3529,11 +3623,11 @@ function PanelSettingsModal({
|
|
|
3529
3623
|
children: /* @__PURE__ */ jsxs(Tabs, {
|
|
3530
3624
|
initialTab: 2,
|
|
3531
3625
|
children: [/* @__PURE__ */ jsxs(Tabs.Tab, {
|
|
3532
|
-
label: "Data
|
|
3626
|
+
label: "Data",
|
|
3533
3627
|
children: [/* @__PURE__ */ jsx(LoadingOverlay, {
|
|
3534
3628
|
visible: loading,
|
|
3535
3629
|
exitTransitionDuration: 0
|
|
3536
|
-
}), /* @__PURE__ */ jsx(
|
|
3630
|
+
}), /* @__PURE__ */ jsx(PickQuery, {})]
|
|
3537
3631
|
}), /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
3538
3632
|
label: "Panel",
|
|
3539
3633
|
children: /* @__PURE__ */ jsx(PanelConfig, {})
|
|
@@ -3545,6 +3639,7 @@ function PanelSettingsModal({
|
|
|
3545
3639
|
})
|
|
3546
3640
|
});
|
|
3547
3641
|
}
|
|
3642
|
+
var titleBar = "";
|
|
3548
3643
|
function PanelTitleBar({}) {
|
|
3549
3644
|
const [opened, setOpened] = React.useState(false);
|
|
3550
3645
|
const open = () => setOpened(true);
|
|
@@ -3556,30 +3651,33 @@ function PanelTitleBar({}) {
|
|
|
3556
3651
|
const {
|
|
3557
3652
|
inEditMode
|
|
3558
3653
|
} = React.useContext(LayoutStateContext);
|
|
3559
|
-
return /* @__PURE__ */ jsxs(
|
|
3560
|
-
position: "apart",
|
|
3561
|
-
noWrap: true,
|
|
3654
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
3562
3655
|
sx: {
|
|
3563
|
-
|
|
3564
|
-
paddingBottom: "5px"
|
|
3656
|
+
position: "relative"
|
|
3565
3657
|
},
|
|
3566
|
-
children: [/* @__PURE__ */ jsx(
|
|
3658
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
3659
|
+
sx: {
|
|
3660
|
+
position: "absolute",
|
|
3661
|
+
left: 0,
|
|
3662
|
+
top: 0,
|
|
3663
|
+
height: 28
|
|
3664
|
+
},
|
|
3567
3665
|
children: /* @__PURE__ */ jsx(DescriptionPopover, {})
|
|
3568
3666
|
}), /* @__PURE__ */ jsx(Group, {
|
|
3569
3667
|
grow: true,
|
|
3570
3668
|
position: "center",
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
weight: "bold",
|
|
3574
|
-
children: title
|
|
3575
|
-
})
|
|
3576
|
-
}), /* @__PURE__ */ jsx(Group, {
|
|
3577
|
-
position: "right",
|
|
3578
|
-
spacing: 0,
|
|
3669
|
+
px: 20,
|
|
3670
|
+
className: "panel-title-wrapper",
|
|
3579
3671
|
sx: {
|
|
3580
|
-
|
|
3672
|
+
flexGrow: 1
|
|
3581
3673
|
},
|
|
3582
3674
|
children: /* @__PURE__ */ jsxs(Menu, {
|
|
3675
|
+
control: /* @__PURE__ */ jsx(Text, {
|
|
3676
|
+
lineClamp: 1,
|
|
3677
|
+
weight: "bold",
|
|
3678
|
+
children: title
|
|
3679
|
+
}),
|
|
3680
|
+
placement: "center",
|
|
3583
3681
|
children: [/* @__PURE__ */ jsx(Menu.Item, {
|
|
3584
3682
|
onClick: refreshData,
|
|
3585
3683
|
icon: /* @__PURE__ */ jsx(Refresh, {
|
|
@@ -3610,7 +3708,7 @@ function PanelTitleBar({}) {
|
|
|
3610
3708
|
var index$1 = "";
|
|
3611
3709
|
function Panel({
|
|
3612
3710
|
viz: initialViz,
|
|
3613
|
-
|
|
3711
|
+
queryID: initialQueryID,
|
|
3614
3712
|
title: initialTitle,
|
|
3615
3713
|
description: initialDesc,
|
|
3616
3714
|
update,
|
|
@@ -3621,24 +3719,24 @@ function Panel({
|
|
|
3621
3719
|
const definitions = React.useContext(DefinitionContext);
|
|
3622
3720
|
const [title, setTitle] = React.useState(initialTitle);
|
|
3623
3721
|
const [description, setDescription] = React.useState(initialDesc);
|
|
3624
|
-
const [
|
|
3722
|
+
const [queryID, setQueryID] = React.useState(initialQueryID);
|
|
3625
3723
|
const [viz, setViz] = React.useState(initialViz);
|
|
3626
|
-
const
|
|
3627
|
-
if (!
|
|
3724
|
+
const query = React.useMemo(() => {
|
|
3725
|
+
if (!queryID) {
|
|
3628
3726
|
return void 0;
|
|
3629
3727
|
}
|
|
3630
|
-
return definitions.
|
|
3631
|
-
}, [
|
|
3728
|
+
return definitions.queries.find((d) => d.id === queryID);
|
|
3729
|
+
}, [queryID, definitions.queries]);
|
|
3632
3730
|
React.useEffect(() => {
|
|
3633
3731
|
update == null ? void 0 : update({
|
|
3634
3732
|
id,
|
|
3635
3733
|
layout,
|
|
3636
3734
|
title,
|
|
3637
3735
|
description,
|
|
3638
|
-
|
|
3736
|
+
queryID,
|
|
3639
3737
|
viz
|
|
3640
3738
|
});
|
|
3641
|
-
}, [title, description,
|
|
3739
|
+
}, [title, description, query, viz, id, layout, queryID]);
|
|
3642
3740
|
const {
|
|
3643
3741
|
data = [],
|
|
3644
3742
|
loading,
|
|
@@ -3647,9 +3745,9 @@ function Panel({
|
|
|
3647
3745
|
context: contextInfo,
|
|
3648
3746
|
definitions,
|
|
3649
3747
|
title,
|
|
3650
|
-
|
|
3748
|
+
query
|
|
3651
3749
|
}), {
|
|
3652
|
-
refreshDeps: [contextInfo, definitions,
|
|
3750
|
+
refreshDeps: [contextInfo, definitions, query]
|
|
3653
3751
|
});
|
|
3654
3752
|
const refreshData = refresh;
|
|
3655
3753
|
return /* @__PURE__ */ jsx(PanelContext.Provider, {
|
|
@@ -3660,8 +3758,8 @@ function Panel({
|
|
|
3660
3758
|
setTitle,
|
|
3661
3759
|
description,
|
|
3662
3760
|
setDescription,
|
|
3663
|
-
|
|
3664
|
-
|
|
3761
|
+
queryID,
|
|
3762
|
+
setQueryID,
|
|
3665
3763
|
viz,
|
|
3666
3764
|
setViz,
|
|
3667
3765
|
refreshData
|
|
@@ -3875,7 +3973,7 @@ function PreviewSQL({
|
|
|
3875
3973
|
children: explained
|
|
3876
3974
|
});
|
|
3877
3975
|
}
|
|
3878
|
-
function
|
|
3976
|
+
function QueryForm({
|
|
3879
3977
|
value,
|
|
3880
3978
|
onChange
|
|
3881
3979
|
}) {
|
|
@@ -3932,7 +4030,7 @@ function DataSourceForm({
|
|
|
3932
4030
|
},
|
|
3933
4031
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
3934
4032
|
weight: 500,
|
|
3935
|
-
children: "
|
|
4033
|
+
children: "Edit Query"
|
|
3936
4034
|
}), /* @__PURE__ */ jsx(ActionIcon, {
|
|
3937
4035
|
type: "submit",
|
|
3938
4036
|
mr: 5,
|
|
@@ -3995,81 +4093,81 @@ function DataSourceForm({
|
|
|
3995
4093
|
})
|
|
3996
4094
|
});
|
|
3997
4095
|
}
|
|
3998
|
-
function
|
|
4096
|
+
function QueryEditor({
|
|
3999
4097
|
id,
|
|
4000
4098
|
setID
|
|
4001
4099
|
}) {
|
|
4002
4100
|
const {
|
|
4003
|
-
|
|
4004
|
-
|
|
4101
|
+
queries,
|
|
4102
|
+
setQueries
|
|
4005
4103
|
} = React.useContext(DefinitionContext);
|
|
4006
|
-
const
|
|
4007
|
-
return
|
|
4008
|
-
}, [
|
|
4104
|
+
const query = React.useMemo(() => {
|
|
4105
|
+
return queries.find((d) => d.id === id);
|
|
4106
|
+
}, [queries, id]);
|
|
4009
4107
|
const update = React.useCallback((value) => {
|
|
4010
|
-
const index2 =
|
|
4108
|
+
const index2 = queries.findIndex((d) => d.id === id);
|
|
4011
4109
|
if (index2 === -1) {
|
|
4012
4110
|
console.error(new Error("Invalid data source id when updating by id"));
|
|
4013
4111
|
return;
|
|
4014
4112
|
}
|
|
4015
|
-
|
|
4113
|
+
setQueries((prevs) => {
|
|
4016
4114
|
const index22 = prevs.findIndex((p2) => p2.id === id);
|
|
4017
4115
|
prevs.splice(index22, 1, value);
|
|
4018
4116
|
return [...prevs];
|
|
4019
4117
|
});
|
|
4020
4118
|
setID(value.id);
|
|
4021
|
-
}, [id,
|
|
4119
|
+
}, [id, queries, setQueries, setID]);
|
|
4022
4120
|
if (!id) {
|
|
4023
4121
|
return null;
|
|
4024
4122
|
}
|
|
4025
|
-
if (!
|
|
4123
|
+
if (!query) {
|
|
4026
4124
|
return /* @__PURE__ */ jsx("span", {
|
|
4027
4125
|
children: "Invalid Data Source ID"
|
|
4028
4126
|
});
|
|
4029
4127
|
}
|
|
4030
|
-
return /* @__PURE__ */ jsx(
|
|
4031
|
-
value:
|
|
4128
|
+
return /* @__PURE__ */ jsx(QueryForm, {
|
|
4129
|
+
value: query,
|
|
4032
4130
|
onChange: update
|
|
4033
4131
|
});
|
|
4034
4132
|
}
|
|
4035
|
-
function
|
|
4133
|
+
function SelectOrAddQuery({
|
|
4036
4134
|
id,
|
|
4037
4135
|
setID
|
|
4038
4136
|
}) {
|
|
4039
4137
|
const {
|
|
4040
|
-
|
|
4041
|
-
|
|
4138
|
+
queries,
|
|
4139
|
+
setQueries
|
|
4042
4140
|
} = React.useContext(DefinitionContext);
|
|
4043
4141
|
const chooseDefault = React.useCallback(() => {
|
|
4044
4142
|
var _a, _b;
|
|
4045
|
-
setID((_b = (_a =
|
|
4046
|
-
}, [setID,
|
|
4143
|
+
setID((_b = (_a = queries[0]) == null ? void 0 : _a.id) != null ? _b : "");
|
|
4144
|
+
}, [setID, queries]);
|
|
4047
4145
|
React.useEffect(() => {
|
|
4048
4146
|
if (!id) {
|
|
4049
4147
|
chooseDefault();
|
|
4050
4148
|
return;
|
|
4051
4149
|
}
|
|
4052
|
-
const index2 =
|
|
4150
|
+
const index2 = queries.findIndex((d) => d.id === id);
|
|
4053
4151
|
if (index2 === -1) {
|
|
4054
4152
|
chooseDefault();
|
|
4055
4153
|
}
|
|
4056
|
-
}, [id,
|
|
4154
|
+
}, [id, queries, chooseDefault]);
|
|
4057
4155
|
const options = React.useMemo(() => {
|
|
4058
|
-
return
|
|
4156
|
+
return queries.map((d) => ({
|
|
4059
4157
|
value: d.id,
|
|
4060
4158
|
label: d.id
|
|
4061
4159
|
}));
|
|
4062
|
-
}, [
|
|
4160
|
+
}, [queries]);
|
|
4063
4161
|
const add = React.useCallback(() => {
|
|
4064
|
-
const
|
|
4162
|
+
const newQuery = {
|
|
4065
4163
|
id: randomId(),
|
|
4066
4164
|
type: "postgresql",
|
|
4067
4165
|
key: "",
|
|
4068
4166
|
sql: ""
|
|
4069
4167
|
};
|
|
4070
|
-
|
|
4071
|
-
setID(
|
|
4072
|
-
}, [
|
|
4168
|
+
setQueries((prevs) => [...prevs, newQuery]);
|
|
4169
|
+
setID(newQuery.id);
|
|
4170
|
+
}, [setQueries, setID]);
|
|
4073
4171
|
return /* @__PURE__ */ jsx(Group, {
|
|
4074
4172
|
pb: "xl",
|
|
4075
4173
|
children: /* @__PURE__ */ jsxs(Group, {
|
|
@@ -4079,7 +4177,7 @@ function SelectOrAddDataSource({
|
|
|
4079
4177
|
alignItems: "baseline"
|
|
4080
4178
|
},
|
|
4081
4179
|
children: [/* @__PURE__ */ jsx(Text, {
|
|
4082
|
-
children: "Select a
|
|
4180
|
+
children: "Select a Query"
|
|
4083
4181
|
}), /* @__PURE__ */ jsx(Select, {
|
|
4084
4182
|
data: options,
|
|
4085
4183
|
value: id,
|
|
@@ -4096,13 +4194,13 @@ function SelectOrAddDataSource({
|
|
|
4096
4194
|
mt: "md",
|
|
4097
4195
|
children: /* @__PURE__ */ jsx(Button, {
|
|
4098
4196
|
onClick: add,
|
|
4099
|
-
children: "Add a
|
|
4197
|
+
children: "Add a Query"
|
|
4100
4198
|
})
|
|
4101
4199
|
})]
|
|
4102
4200
|
})
|
|
4103
4201
|
});
|
|
4104
4202
|
}
|
|
4105
|
-
function
|
|
4203
|
+
function EditQueries({}) {
|
|
4106
4204
|
const [id, setID] = React.useState("");
|
|
4107
4205
|
return /* @__PURE__ */ jsxs(AppShell, {
|
|
4108
4206
|
sx: {
|
|
@@ -4132,10 +4230,10 @@ function EditDataSources({}) {
|
|
|
4132
4230
|
flexGrow: 1,
|
|
4133
4231
|
maxWidth: "calc(60% - 16px)"
|
|
4134
4232
|
},
|
|
4135
|
-
children: [/* @__PURE__ */ jsx(
|
|
4233
|
+
children: [/* @__PURE__ */ jsx(SelectOrAddQuery, {
|
|
4136
4234
|
id,
|
|
4137
4235
|
setID
|
|
4138
|
-
}), /* @__PURE__ */ jsx(
|
|
4236
|
+
}), /* @__PURE__ */ jsx(QueryEditor, {
|
|
4139
4237
|
id,
|
|
4140
4238
|
setID
|
|
4141
4239
|
})]
|
|
@@ -4453,8 +4551,8 @@ function DataEditorModal({
|
|
|
4453
4551
|
label: "SQL Snippet",
|
|
4454
4552
|
children: /* @__PURE__ */ jsx(EditSQLSnippets, {})
|
|
4455
4553
|
}), /* @__PURE__ */ jsx(Tabs.Tab, {
|
|
4456
|
-
label: "
|
|
4457
|
-
children: /* @__PURE__ */ jsx(
|
|
4554
|
+
label: "Queries",
|
|
4555
|
+
children: /* @__PURE__ */ jsx(EditQueries, {})
|
|
4458
4556
|
})]
|
|
4459
4557
|
})
|
|
4460
4558
|
});
|
|
@@ -4472,8 +4570,8 @@ function DashboardActions({
|
|
|
4472
4570
|
inUseMode
|
|
4473
4571
|
} = React.useContext(LayoutStateContext);
|
|
4474
4572
|
const [dataEditorOpened, setDataEditorOpened] = React.useState(false);
|
|
4475
|
-
const
|
|
4476
|
-
const
|
|
4573
|
+
const openQueries = () => setDataEditorOpened(true);
|
|
4574
|
+
const closeQueries = () => setDataEditorOpened(false);
|
|
4477
4575
|
return /* @__PURE__ */ jsxs(Group, {
|
|
4478
4576
|
position: "apart",
|
|
4479
4577
|
pt: "sm",
|
|
@@ -4497,7 +4595,7 @@ function DashboardActions({
|
|
|
4497
4595
|
}), inEditMode && /* @__PURE__ */ jsx(Button, {
|
|
4498
4596
|
variant: "default",
|
|
4499
4597
|
size: "sm",
|
|
4500
|
-
onClick:
|
|
4598
|
+
onClick: openQueries,
|
|
4501
4599
|
leftIcon: /* @__PURE__ */ jsx(Database, {
|
|
4502
4600
|
size: 20
|
|
4503
4601
|
}),
|
|
@@ -4522,7 +4620,7 @@ function DashboardActions({
|
|
|
4522
4620
|
})]
|
|
4523
4621
|
}), /* @__PURE__ */ jsx(DataEditorModal, {
|
|
4524
4622
|
opened: dataEditorOpened,
|
|
4525
|
-
close:
|
|
4623
|
+
close: closeQueries
|
|
4526
4624
|
}), inUseMode && /* @__PURE__ */ jsx(Button, {
|
|
4527
4625
|
variant: "default",
|
|
4528
4626
|
size: "sm",
|
|
@@ -4547,7 +4645,7 @@ function Dashboard({
|
|
|
4547
4645
|
const [layoutFrozen, freezeLayout] = React.useState(false);
|
|
4548
4646
|
const [panels, setPanels] = React.useState(dashboard.panels);
|
|
4549
4647
|
const [sqlSnippets, setSQLSnippets] = React.useState(dashboard.definition.sqlSnippets);
|
|
4550
|
-
const [
|
|
4648
|
+
const [queries, setQueries] = React.useState(dashboard.definition.queries);
|
|
4551
4649
|
const [mode, setMode] = React.useState(DashboardMode.Edit);
|
|
4552
4650
|
const hasChanges = React.useMemo(() => {
|
|
4553
4651
|
const cleanJSON = (v) => JSON.parse(JSON.stringify(v));
|
|
@@ -4558,14 +4656,14 @@ function Dashboard({
|
|
|
4558
4656
|
if (!_.isEqual(sqlSnippets, dashboard.definition.sqlSnippets)) {
|
|
4559
4657
|
return true;
|
|
4560
4658
|
}
|
|
4561
|
-
return !_.isEqual(
|
|
4562
|
-
}, [dashboard, panels, sqlSnippets,
|
|
4659
|
+
return !_.isEqual(queries, dashboard.definition.queries);
|
|
4660
|
+
}, [dashboard, panels, sqlSnippets, queries]);
|
|
4563
4661
|
const saveDashboardChanges = async () => {
|
|
4564
4662
|
const d = __spreadProps(__spreadValues({}, dashboard), {
|
|
4565
4663
|
panels,
|
|
4566
4664
|
definition: {
|
|
4567
4665
|
sqlSnippets,
|
|
4568
|
-
|
|
4666
|
+
queries
|
|
4569
4667
|
}
|
|
4570
4668
|
});
|
|
4571
4669
|
await update(d);
|
|
@@ -4580,9 +4678,9 @@ function Dashboard({
|
|
|
4580
4678
|
w: 3,
|
|
4581
4679
|
h: 15
|
|
4582
4680
|
},
|
|
4583
|
-
title: `
|
|
4584
|
-
description: "",
|
|
4585
|
-
|
|
4681
|
+
title: `Panel - ${id}`,
|
|
4682
|
+
description: "<p><br></p>",
|
|
4683
|
+
queryID: "",
|
|
4586
4684
|
viz: {
|
|
4587
4685
|
type: "text",
|
|
4588
4686
|
conf: {}
|
|
@@ -4603,9 +4701,9 @@ function Dashboard({
|
|
|
4603
4701
|
const definitions = React.useMemo(() => ({
|
|
4604
4702
|
sqlSnippets,
|
|
4605
4703
|
setSQLSnippets,
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
}), [sqlSnippets, setSQLSnippets,
|
|
4704
|
+
queries,
|
|
4705
|
+
setQueries
|
|
4706
|
+
}), [sqlSnippets, setSQLSnippets, queries, setQueries]);
|
|
4609
4707
|
return /* @__PURE__ */ jsx(ContextInfoContext.Provider, {
|
|
4610
4708
|
value: context,
|
|
4611
4709
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -4677,7 +4775,7 @@ function ReadOnlyDashboard({
|
|
|
4677
4775
|
const definition = React.useMemo(() => __spreadProps(__spreadValues({}, dashboard.definition), {
|
|
4678
4776
|
setSQLSnippets: () => {
|
|
4679
4777
|
},
|
|
4680
|
-
|
|
4778
|
+
setQueries: () => {
|
|
4681
4779
|
}
|
|
4682
4780
|
}), [dashboard]);
|
|
4683
4781
|
return /* @__PURE__ */ jsx(ContextInfoContext.Provider, {
|