@perses-dev/dashboards 0.8.1 → 0.9.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/cjs/components/Dashboard.js +29 -14
- package/dist/cjs/components/DashboardToolbar.js +148 -20
- package/dist/cjs/components/GridLayout/GridItemContent.js +24 -18
- package/dist/cjs/components/GridLayout/GridLayout.js +88 -26
- package/dist/cjs/components/GridLayout/GridTitle.js +69 -31
- package/dist/cjs/components/GridLayout/index.js +18 -19
- package/dist/cjs/components/Panel/Panel.js +145 -55
- package/dist/cjs/components/Panel/Panel.test.js +50 -41
- package/dist/cjs/components/Panel/PanelContent.js +40 -12
- package/dist/cjs/components/Panel/index.js +16 -17
- package/dist/cjs/components/PanelDrawer/PanelDrawer.js +82 -107
- package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +91 -92
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +152 -0
- package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +40 -0
- package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +38 -0
- package/dist/cjs/components/PanelDrawer/index.js +28 -0
- package/dist/cjs/components/PanelDrawer/panel-editor-model.js +140 -0
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +120 -31
- package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +90 -83
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
- package/dist/cjs/components/TimeRangeControls/index.js +16 -17
- package/dist/cjs/components/Variables/Variable.js +186 -35
- package/dist/cjs/components/Variables/VariableList.js +100 -13
- package/dist/cjs/components/Variables/index.js +17 -18
- package/dist/cjs/components/index.js +21 -21
- package/dist/cjs/context/DashboardAppSlice.js +43 -31
- package/dist/cjs/context/DashboardProvider.js +88 -58
- package/dist/cjs/context/DatasourceStoreProvider.js +68 -0
- package/dist/cjs/context/LayoutsSlice.js +40 -27
- package/dist/cjs/context/QueryStringProvider.js +69 -15
- package/dist/cjs/context/TemplateVariableProvider.js +128 -136
- package/dist/cjs/context/TimeRangeProvider.js +79 -30
- package/dist/cjs/context/index.js +22 -22
- package/dist/cjs/css/styles.js +43 -39
- package/dist/cjs/index.js +19 -20
- package/dist/cjs/test/dashboard-provider.js +51 -0
- package/dist/cjs/test/index.js +18 -18
- package/dist/cjs/test/plugin-registry.js +52 -25
- package/dist/cjs/test/render.js +25 -22
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/test/testDashboard.js +193 -109
- package/dist/cjs/utils/functions.js +9 -5
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +50 -23
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +62 -31
- package/dist/cjs/views/ViewDashboard/index.js +16 -17
- package/dist/cjs/views/index.js +16 -17
- package/dist/components/Dashboard.js +38 -1
- package/dist/components/Dashboard.js.map +1 -0
- package/dist/components/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar.js +154 -1
- package/dist/components/DashboardToolbar.js.map +1 -0
- package/dist/components/GridLayout/GridItemContent.js +35 -1
- package/dist/components/GridLayout/GridItemContent.js.map +1 -0
- package/dist/components/GridLayout/GridLayout.js +99 -1
- package/dist/components/GridLayout/GridLayout.js.map +1 -0
- package/dist/components/GridLayout/GridTitle.js +77 -1
- package/dist/components/GridLayout/GridTitle.js.map +1 -0
- package/dist/components/GridLayout/index.js +16 -1
- package/dist/components/GridLayout/index.js.map +1 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +170 -1
- package/dist/components/Panel/Panel.js.map +1 -0
- package/dist/components/Panel/Panel.test.js +71 -1
- package/dist/components/Panel/Panel.test.js.map +1 -0
- package/dist/components/Panel/PanelContent.d.ts +2 -4
- package/dist/components/Panel/PanelContent.d.ts.map +1 -1
- package/dist/components/Panel/PanelContent.js +40 -1
- package/dist/components/Panel/PanelContent.js.map +1 -0
- package/dist/components/Panel/index.js +15 -1
- package/dist/components/Panel/index.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
- package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelDrawer.js +95 -1
- package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
- package/dist/components/PanelDrawer/PanelDrawer.test.js +103 -1
- package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js +142 -0
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +7 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js +34 -0
- package/dist/components/PanelDrawer/PanelSpecEditor.js.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +8 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +1 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.js +34 -0
- package/dist/components/PanelDrawer/PanelTypeSelect.js.map +1 -0
- package/dist/components/PanelDrawer/index.d.ts +2 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -0
- package/dist/components/PanelDrawer/index.js +15 -0
- package/dist/components/PanelDrawer/index.js.map +1 -0
- package/dist/components/PanelDrawer/panel-editor-model.d.ts +27 -0
- package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +1 -0
- package/dist/components/PanelDrawer/panel-editor-model.js +133 -0
- package/dist/components/PanelDrawer/panel-editor-model.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js +138 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +95 -1
- package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -1
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/Variables/Variable.d.ts.map +1 -1
- package/dist/components/Variables/Variable.js +202 -1
- package/dist/components/Variables/Variable.js.map +1 -0
- package/dist/components/Variables/VariableList.js +108 -1
- package/dist/components/Variables/VariableList.js.map +1 -0
- package/dist/components/Variables/index.js +16 -1
- package/dist/components/Variables/index.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +20 -1
- package/dist/components/index.js.map +1 -0
- package/dist/context/DashboardAppSlice.js +45 -1
- package/dist/context/DashboardAppSlice.js.map +1 -0
- package/dist/context/DashboardProvider.d.ts +4 -2
- package/dist/context/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider.js +107 -1
- package/dist/context/DashboardProvider.js.map +1 -0
- package/dist/context/DatasourceStoreProvider.d.ts +16 -0
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
- package/dist/context/DatasourceStoreProvider.js +64 -0
- package/dist/context/DatasourceStoreProvider.js.map +1 -0
- package/dist/context/LayoutsSlice.js +43 -1
- package/dist/context/LayoutsSlice.js.map +1 -0
- package/dist/context/QueryStringProvider.js +40 -1
- package/dist/context/QueryStringProvider.js.map +1 -0
- package/dist/context/TemplateVariableProvider.d.ts +6 -3
- package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider.js +192 -1
- package/dist/context/TemplateVariableProvider.js.map +1 -0
- package/dist/context/TimeRangeProvider.js +72 -1
- package/dist/context/TimeRangeProvider.js.map +1 -0
- package/dist/context/index.d.ts +3 -2
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +21 -1
- package/dist/context/index.js.map +1 -0
- package/dist/css/styles.js +186 -1
- package/dist/css/styles.js.map +1 -0
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -0
- package/dist/test/dashboard-provider.d.ts +19 -0
- package/dist/test/dashboard-provider.d.ts.map +1 -0
- package/dist/test/dashboard-provider.js +40 -0
- package/dist/test/dashboard-provider.js.map +1 -0
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +17 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/plugin-registry.d.ts +2 -3
- package/dist/test/plugin-registry.d.ts.map +1 -1
- package/dist/test/plugin-registry.js +74 -1
- package/dist/test/plugin-registry.js.map +1 -0
- package/dist/test/render.d.ts +1 -2
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +34 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/test/testDashboard.d.ts.map +1 -1
- package/dist/test/testDashboard.js +274 -1
- package/dist/test/testDashboard.js.map +1 -0
- package/dist/utils/functions.js +17 -1
- package/dist/utils/functions.js.map +1 -0
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +56 -1
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts +2 -0
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +79 -1
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
- package/dist/views/ViewDashboard/index.js +15 -1
- package/dist/views/ViewDashboard/index.js.map +1 -0
- package/dist/views/index.js +15 -1
- package/dist/views/index.js.map +1 -0
- package/package.json +13 -7
- package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
- package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
- package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TemplateVariableList = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
1
|
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,14 +10,105 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "TemplateVariableList", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TemplateVariableList
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _context = require("../../context");
|
|
25
|
+
const _variable = require("./Variable");
|
|
21
26
|
function TemplateVariableList() {
|
|
22
|
-
const [isEditing, setIsEditing] = (0,
|
|
23
|
-
const variableDefinitions = (0,
|
|
24
|
-
const { isEditMode
|
|
25
|
-
return
|
|
27
|
+
const [isEditing, setIsEditing] = (0, _react.useState)(false);
|
|
28
|
+
const variableDefinitions = (0, _context.useTemplateVariableDefinitions)();
|
|
29
|
+
const { isEditMode } = (0, _context.useEditMode)();
|
|
30
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Drawer, {
|
|
33
|
+
anchor: 'right',
|
|
34
|
+
open: isEditing,
|
|
35
|
+
onClose: ()=>setIsEditing(false),
|
|
36
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
37
|
+
width: 900,
|
|
38
|
+
p: 4,
|
|
39
|
+
children: [
|
|
40
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableContainer, {
|
|
41
|
+
component: _material.Paper,
|
|
42
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Table, {
|
|
43
|
+
sx: {
|
|
44
|
+
minWidth: 650
|
|
45
|
+
},
|
|
46
|
+
"aria-label": "simple table",
|
|
47
|
+
children: [
|
|
48
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableHead, {
|
|
49
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
52
|
+
children: "Variable Name"
|
|
53
|
+
}),
|
|
54
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
55
|
+
align: "right",
|
|
56
|
+
children: "Type"
|
|
57
|
+
})
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableBody, {
|
|
62
|
+
children: variableDefinitions.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.TableRow, {
|
|
63
|
+
sx: {
|
|
64
|
+
'&:last-child td, &:last-child th': {
|
|
65
|
+
border: 0
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
70
|
+
component: "th",
|
|
71
|
+
scope: "row",
|
|
72
|
+
sx: {
|
|
73
|
+
fontWeight: 'bold'
|
|
74
|
+
},
|
|
75
|
+
children: v.spec.name
|
|
76
|
+
}),
|
|
77
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TableCell, {
|
|
78
|
+
align: "right",
|
|
79
|
+
children: v.kind
|
|
80
|
+
})
|
|
81
|
+
]
|
|
82
|
+
}, v.spec.name))
|
|
83
|
+
})
|
|
84
|
+
]
|
|
85
|
+
})
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("pre", {
|
|
88
|
+
children: JSON.stringify(variableDefinitions, null, 2)
|
|
89
|
+
})
|
|
90
|
+
]
|
|
91
|
+
})
|
|
92
|
+
}),
|
|
93
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
94
|
+
display: 'flex',
|
|
95
|
+
justifyContent: "space-between",
|
|
96
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
97
|
+
direction: 'row',
|
|
98
|
+
spacing: 2,
|
|
99
|
+
children: [
|
|
100
|
+
variableDefinitions.map((v)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
101
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_variable.TemplateVariable, {
|
|
102
|
+
name: v.spec.name
|
|
103
|
+
}, v.spec.name)
|
|
104
|
+
}, v.spec.name)),
|
|
105
|
+
isEditMode && /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Button, {
|
|
106
|
+
onClick: ()=>setIsEditing(true),
|
|
107
|
+
children: "Modify Variables"
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
});
|
|
26
114
|
}
|
|
27
|
-
exports.TemplateVariableList = TemplateVariableList;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,20 +10,20 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./Variable"), exports);
|
|
18
|
+
_exportStar(require("./VariableList"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,23 +10,24 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./Dashboard"), exports);
|
|
18
|
+
_exportStar(require("./GridLayout"), exports);
|
|
19
|
+
_exportStar(require("./Panel"), exports);
|
|
20
|
+
_exportStar(require("./PanelDrawer"), exports);
|
|
21
|
+
_exportStar(require("./TimeRangeControls"), exports);
|
|
22
|
+
_exportStar(require("./Variables"), exports);
|
|
23
|
+
function _exportStar(from, to) {
|
|
24
|
+
Object.keys(from).forEach(function(k) {
|
|
25
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return from[k];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
return from;
|
|
33
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,35 +10,48 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
createDashboardAppSlice: ()=>createDashboardAppSlice,
|
|
25
|
+
useDashboardApp: ()=>useDashboardApp
|
|
26
|
+
});
|
|
27
|
+
const _immer = require("zustand/middleware/immer");
|
|
28
|
+
const _dashboardProvider = require("./DashboardProvider");
|
|
29
|
+
const createDashboardAppSlice = (0, _immer.immer)((set)=>({
|
|
30
|
+
openPanelDrawer: ({ groupIndex , panelKey })=>set((state)=>{
|
|
31
|
+
state.panelDrawer = {
|
|
32
|
+
groupIndex,
|
|
33
|
+
panelKey
|
|
34
|
+
};
|
|
35
|
+
}),
|
|
36
|
+
closePanelDrawer: ()=>set((state)=>{
|
|
37
|
+
state.panelDrawer = undefined;
|
|
38
|
+
}),
|
|
39
|
+
openPanelGroupDialog: (groupIndex)=>set((state)=>{
|
|
40
|
+
state.panelGroupDialog = {
|
|
41
|
+
groupIndex
|
|
42
|
+
};
|
|
43
|
+
}),
|
|
44
|
+
closePanelGroupDialog: ()=>set((state)=>{
|
|
45
|
+
state.panelGroupDialog = undefined;
|
|
46
|
+
})
|
|
43
47
|
}));
|
|
48
|
+
function useDashboardApp() {
|
|
49
|
+
return (0, _dashboardProvider.useDashboardStore)(({ panelDrawer , openPanelDrawer , closePanelDrawer , panelGroupDialog , openPanelGroupDialog , closePanelGroupDialog , })=>({
|
|
50
|
+
panelDrawer,
|
|
51
|
+
openPanelDrawer,
|
|
52
|
+
closePanelDrawer,
|
|
53
|
+
panelGroupDialog,
|
|
54
|
+
openPanelGroupDialog,
|
|
55
|
+
closePanelGroupDialog
|
|
56
|
+
}));
|
|
44
57
|
}
|
|
45
|
-
exports.useDashboardApp = useDashboardApp;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DashboardProvider = exports.useDashboardStore = exports.useDashboard = exports.useEditMode = exports.usePanels = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
1
|
// Copyright 2022 The Perses Authors
|
|
9
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -17,82 +10,119 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
17
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
11
|
// See the License for the specific language governing permissions and
|
|
19
12
|
// limitations under the License.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
usePanels: ()=>usePanels,
|
|
25
|
+
useEditMode: ()=>useEditMode,
|
|
26
|
+
useDashboard: ()=>useDashboard,
|
|
27
|
+
DashboardContext: ()=>DashboardContext,
|
|
28
|
+
useDashboardStore: ()=>useDashboardStore,
|
|
29
|
+
DashboardProvider: ()=>DashboardProvider
|
|
30
|
+
});
|
|
31
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
32
|
+
const _zustand = require("zustand");
|
|
33
|
+
const _immer = require("zustand/middleware/immer");
|
|
34
|
+
const _shallow = /*#__PURE__*/ _interopRequireDefault(require("zustand/shallow"));
|
|
35
|
+
const _react = require("react");
|
|
36
|
+
const _immer1 = /*#__PURE__*/ _interopRequireDefault(require("immer"));
|
|
37
|
+
const _dashboardAppSlice = require("./DashboardAppSlice");
|
|
38
|
+
const _layoutsSlice = require("./LayoutsSlice");
|
|
39
|
+
function _interopRequireDefault(obj) {
|
|
40
|
+
return obj && obj.__esModule ? obj : {
|
|
41
|
+
default: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
27
44
|
function usePanels() {
|
|
28
|
-
return useDashboardStore(({ panels, updatePanel
|
|
45
|
+
return useDashboardStore(({ panels , updatePanel })=>({
|
|
46
|
+
panels,
|
|
47
|
+
updatePanel
|
|
48
|
+
}));
|
|
29
49
|
}
|
|
30
|
-
exports.usePanels = usePanels;
|
|
31
50
|
function useEditMode() {
|
|
32
|
-
return useDashboardStore(({ isEditMode, setEditMode
|
|
51
|
+
return useDashboardStore(({ isEditMode , setEditMode })=>({
|
|
52
|
+
isEditMode,
|
|
53
|
+
setEditMode
|
|
54
|
+
}));
|
|
33
55
|
}
|
|
34
|
-
exports.useEditMode = useEditMode;
|
|
35
56
|
function useDashboard() {
|
|
36
|
-
const selectDashboardSpec = (state)
|
|
37
|
-
return (0,
|
|
57
|
+
const selectDashboardSpec = (state)=>{
|
|
58
|
+
return (0, _immer1.default)(state.dashboard, (draftState)=>{
|
|
38
59
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
60
|
draftState.panels = state.panels;
|
|
40
61
|
draftState.layouts = state.layouts;
|
|
41
62
|
});
|
|
42
63
|
};
|
|
43
64
|
const dashboard = useDashboardStore(selectDashboardSpec);
|
|
44
|
-
return {
|
|
65
|
+
return {
|
|
66
|
+
dashboard
|
|
67
|
+
};
|
|
45
68
|
}
|
|
46
|
-
|
|
47
|
-
const DashboardContext = (0, react_1.createContext)(undefined);
|
|
69
|
+
const DashboardContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
48
70
|
function useDashboardStore(selector) {
|
|
49
|
-
const store = (0,
|
|
71
|
+
const store = (0, _react.useContext)(DashboardContext);
|
|
50
72
|
if (store === undefined) {
|
|
51
73
|
throw new Error('No DashboardContext found. Did you forget a Provider?');
|
|
52
74
|
}
|
|
53
|
-
return (0,
|
|
75
|
+
return (0, _zustand.useStore)(store, selector, _shallow.default);
|
|
54
76
|
}
|
|
55
|
-
exports.useDashboardStore = useDashboardStore;
|
|
56
77
|
function DashboardProvider(props) {
|
|
57
|
-
const { children, initialState: { dashboardSpec, isEditMode
|
|
58
|
-
const { layouts, panels
|
|
59
|
-
const dashboardStore = (0,
|
|
78
|
+
const { children , initialState: { dashboardSpec , isEditMode } , } = props;
|
|
79
|
+
const { layouts , panels } = dashboardSpec;
|
|
80
|
+
const dashboardStore = (0, _zustand.createStore)()((0, _immer.immer)((set, get, api)=>{
|
|
60
81
|
return {
|
|
61
|
-
...(0,
|
|
62
|
-
...(0,
|
|
82
|
+
...(0, _dashboardAppSlice.createDashboardAppSlice)(set, get, api, []),
|
|
83
|
+
...(0, _layoutsSlice.createLayoutsSlice)(set, get, api, []),
|
|
63
84
|
layouts,
|
|
64
85
|
panels,
|
|
65
86
|
dashboard: dashboardSpec,
|
|
66
|
-
updatePanel: (name, panel, groupIndex = 0)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
87
|
+
updatePanel: (name, panel, groupIndex = 0)=>{
|
|
88
|
+
return set((state)=>{
|
|
89
|
+
// add new panel to layouts if panels[name] is undefined
|
|
90
|
+
if (state.panels[name] === undefined) {
|
|
91
|
+
var ref;
|
|
92
|
+
// find maximum y so new panel is added to the end of the grid
|
|
93
|
+
let maxY = 0;
|
|
94
|
+
(ref = state.layouts[groupIndex]) === null || ref === void 0 ? void 0 : ref.spec.items.forEach((layout)=>{
|
|
95
|
+
if (layout.y > maxY) {
|
|
96
|
+
maxY = layout.y;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
const panelLayout = {
|
|
100
|
+
x: 0,
|
|
101
|
+
y: maxY + 1,
|
|
102
|
+
width: 12,
|
|
103
|
+
height: 6,
|
|
104
|
+
content: {
|
|
105
|
+
$ref: `#/spec/panels/${name}`
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const layouts = state.layouts;
|
|
109
|
+
if (layouts && layouts[groupIndex]) {
|
|
110
|
+
var ref1;
|
|
111
|
+
(ref1 = layouts[groupIndex]) === null || ref1 === void 0 ? void 0 : ref1.spec.items.push(panelLayout);
|
|
75
112
|
}
|
|
76
|
-
});
|
|
77
|
-
const panelLayout = {
|
|
78
|
-
x: 0,
|
|
79
|
-
y: maxY + 1,
|
|
80
|
-
width: 12,
|
|
81
|
-
height: 6,
|
|
82
|
-
content: { $ref: `#/spec/panels/${name}` },
|
|
83
|
-
};
|
|
84
|
-
const layouts = state.layouts;
|
|
85
|
-
if (layouts && layouts[groupIndex]) {
|
|
86
|
-
(_b = layouts[groupIndex]) === null || _b === void 0 ? void 0 : _b.spec.items.push(panelLayout);
|
|
87
113
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
114
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
115
|
+
state.panels[name] = panel;
|
|
116
|
+
});
|
|
117
|
+
},
|
|
92
118
|
isEditMode: !!isEditMode,
|
|
93
|
-
setEditMode: (isEditMode)
|
|
119
|
+
setEditMode: (isEditMode)=>set({
|
|
120
|
+
isEditMode
|
|
121
|
+
})
|
|
94
122
|
};
|
|
95
123
|
}));
|
|
96
|
-
return (
|
|
124
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(DashboardContext.Provider, {
|
|
125
|
+
value: dashboardStore,
|
|
126
|
+
children: children
|
|
127
|
+
});
|
|
97
128
|
}
|
|
98
|
-
exports.DashboardProvider = DashboardProvider;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "DatasourceStoreProvider", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>DatasourceStoreProvider
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _core = require("@perses-dev/core");
|
|
24
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
25
|
+
function DatasourceStoreProvider(props) {
|
|
26
|
+
const { dashboardResource , datasourceApi , children } = props;
|
|
27
|
+
const getDatasource = (0, _core.useEvent)(async (selector)=>{
|
|
28
|
+
// Try to find it in dashboard spec
|
|
29
|
+
const { datasources } = dashboardResource.spec;
|
|
30
|
+
const dashboardDatasource = findDashboardDatasource(datasources, selector);
|
|
31
|
+
if (dashboardDatasource !== undefined) {
|
|
32
|
+
return dashboardDatasource;
|
|
33
|
+
}
|
|
34
|
+
// Try to find it at the project level as a Datasource resource
|
|
35
|
+
const { project } = dashboardResource.metadata;
|
|
36
|
+
const datasource = await datasourceApi.getDatasource(project, selector);
|
|
37
|
+
if (datasource !== undefined) {
|
|
38
|
+
return datasource.spec;
|
|
39
|
+
}
|
|
40
|
+
// Try to find it at the global level as a GlobalDatasource resource
|
|
41
|
+
const globalDatasource = await datasourceApi.getGlobalDatasource(selector);
|
|
42
|
+
if (globalDatasource !== undefined) {
|
|
43
|
+
return globalDatasource.spec;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(`No datasource found for kind '${selector.kind}' and name '${selector.name}'`);
|
|
46
|
+
});
|
|
47
|
+
const ctxValue = (0, _react.useMemo)(()=>({
|
|
48
|
+
getDatasource
|
|
49
|
+
}), [
|
|
50
|
+
getDatasource
|
|
51
|
+
]);
|
|
52
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.DatasourceStoreContext.Provider, {
|
|
53
|
+
value: ctxValue,
|
|
54
|
+
children: children
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Helper to find a datasource in the list embedded in a dashboard spec
|
|
58
|
+
function findDashboardDatasource(dashboardDatasources, selector) {
|
|
59
|
+
if (dashboardDatasources === undefined) return undefined;
|
|
60
|
+
// If using a name in the selector...
|
|
61
|
+
if (selector.name !== undefined) {
|
|
62
|
+
const named = dashboardDatasources[selector.name];
|
|
63
|
+
if (named === undefined) return undefined;
|
|
64
|
+
return named.plugin.kind === selector.kind ? named : undefined;
|
|
65
|
+
}
|
|
66
|
+
// If only using a kind, try to find one with that kind that is the default
|
|
67
|
+
return Object.values(dashboardDatasources).find((ds)=>ds.plugin.kind === selector.kind && ds.default === true);
|
|
68
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,32 +10,46 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
createLayoutsSlice: ()=>createLayoutsSlice,
|
|
25
|
+
useLayouts: ()=>useLayouts
|
|
26
|
+
});
|
|
27
|
+
const _immer = require("zustand/middleware/immer");
|
|
28
|
+
const _dashboardProvider = require("./DashboardProvider");
|
|
29
|
+
const createLayoutsSlice = (0, _immer.immer)((set)=>{
|
|
30
|
+
return {
|
|
31
|
+
updateLayout: (layout, index)=>set((state)=>{
|
|
32
|
+
if (index === undefined) {
|
|
33
|
+
state.layouts.unshift(layout);
|
|
34
|
+
} else {
|
|
35
|
+
state.layouts[index] = layout;
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
addItemToLayout: (index, item)=>{
|
|
39
|
+
return set((state)=>{
|
|
40
|
+
const layouts = state.layouts;
|
|
41
|
+
if (layouts && layouts[index]) {
|
|
42
|
+
var ref;
|
|
43
|
+
(ref = layouts[index]) === null || ref === void 0 ? void 0 : ref.spec.items.push(item);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
32
46
|
}
|
|
33
|
-
}
|
|
34
|
-
})
|
|
47
|
+
};
|
|
48
|
+
});
|
|
35
49
|
function useLayouts() {
|
|
36
|
-
return (0,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
return (0, _dashboardProvider.useDashboardStore)(({ layouts , updateLayout , addItemToLayout })=>({
|
|
51
|
+
layouts,
|
|
52
|
+
updateLayout,
|
|
53
|
+
addItemToLayout
|
|
54
|
+
}));
|
|
41
55
|
}
|
|
42
|
-
exports.useLayouts = useLayouts;
|