@perses-dev/dashboards 0.41.1 → 0.42.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/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +11 -9
- package/dist/cjs/components/Datasources/DatasourceEditor.js +236 -0
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +109 -0
- package/dist/cjs/components/Datasources/index.js +31 -0
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +12 -1
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +3 -41
- package/dist/cjs/components/PanelDrawer/index.js +1 -0
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
- package/dist/cjs/components/Variables/TemplateVariable.js +139 -51
- package/dist/cjs/components/Variables/VariableList.js +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +4 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +58 -6
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +16 -0
- package/dist/cjs/context/useDashboard.js +5 -3
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +4 -0
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -3
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +11 -9
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts +8 -0
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
- package/dist/components/Datasources/DatasourceEditor.js +223 -0
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts +3 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.js +96 -0
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -0
- package/dist/components/Datasources/index.d.ts +3 -0
- package/dist/components/Datasources/index.d.ts.map +1 -0
- package/dist/components/Datasources/index.js +16 -0
- package/dist/components/Datasources/index.js.map +1 -0
- package/dist/components/EditJsonDialog/EditJsonDialog.js +13 -2
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +3 -2
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/index.d.ts +1 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -1
- package/dist/components/PanelDrawer/index.js +1 -0
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +141 -53
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +1 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +1 -0
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +4 -2
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -2
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +2 -1
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +59 -7
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +13 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +5 -3
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +4 -0
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +4 -5
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -6
|
@@ -59,7 +59,7 @@ function DashboardStickyToolbar(props) {
|
|
|
59
59
|
display: "flex",
|
|
60
60
|
flexWrap: "wrap",
|
|
61
61
|
alignItems: "start",
|
|
62
|
-
|
|
62
|
+
mt: isSticky ? 1.5 : 0,
|
|
63
63
|
ml: isSticky ? 2 : 0,
|
|
64
64
|
children: [
|
|
65
65
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.TemplateVariableList, {}),
|
|
@@ -70,7 +70,7 @@ function DashboardStickyToolbar(props) {
|
|
|
70
70
|
]
|
|
71
71
|
}),
|
|
72
72
|
isSticky && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
73
|
-
|
|
73
|
+
mt: 1.5,
|
|
74
74
|
mr: 2,
|
|
75
75
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {})
|
|
76
76
|
})
|
|
@@ -29,6 +29,7 @@ const _AddGroupButton = require("../AddGroupButton");
|
|
|
29
29
|
const _DownloadButton = require("../DownloadButton");
|
|
30
30
|
const _TimeRangeControls = require("../TimeRangeControls");
|
|
31
31
|
const _Variables = require("../Variables");
|
|
32
|
+
const _Datasources = require("../Datasources");
|
|
32
33
|
const _EditButton = require("../EditButton");
|
|
33
34
|
const _EditJsonButton = require("../EditJsonButton");
|
|
34
35
|
const _SaveDashboardButton = require("../SaveDashboardButton");
|
|
@@ -49,7 +50,8 @@ const DashboardToolbar = (props)=>{
|
|
|
49
50
|
"data-testid": testId,
|
|
50
51
|
children: [
|
|
51
52
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
52
|
-
|
|
53
|
+
px: 2,
|
|
54
|
+
py: 1.5,
|
|
53
55
|
display: "flex",
|
|
54
56
|
sx: {
|
|
55
57
|
backgroundColor: (theme)=>theme.palette.primary.main + '30'
|
|
@@ -58,8 +60,8 @@ const DashboardToolbar = (props)=>{
|
|
|
58
60
|
dashboardTitle,
|
|
59
61
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
60
62
|
direction: "row",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
gap: 1,
|
|
64
|
+
ml: "auto",
|
|
63
65
|
children: [
|
|
64
66
|
isReadonly && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Alert, {
|
|
65
67
|
severity: 'warning',
|
|
@@ -87,7 +89,7 @@ const DashboardToolbar = (props)=>{
|
|
|
87
89
|
display: 'flex',
|
|
88
90
|
width: '100%',
|
|
89
91
|
alignItems: 'start',
|
|
90
|
-
padding: (theme)=>theme.spacing(1, 2)
|
|
92
|
+
padding: (theme)=>theme.spacing(1, 2, 0, 2)
|
|
91
93
|
},
|
|
92
94
|
children: [
|
|
93
95
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
@@ -109,10 +111,10 @@ const DashboardToolbar = (props)=>{
|
|
|
109
111
|
direction: "row",
|
|
110
112
|
spacing: 1,
|
|
111
113
|
ml: 1,
|
|
112
|
-
mb: 1,
|
|
113
114
|
whiteSpace: "nowrap",
|
|
114
115
|
children: [
|
|
115
116
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Variables.EditVariablesButton, {}),
|
|
117
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_Datasources.EditDatasourcesButton, {}),
|
|
116
118
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_AddPanelButton.AddPanelButton, {}),
|
|
117
119
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_AddGroupButton.AddGroupButton, {})
|
|
118
120
|
]
|
|
@@ -121,7 +123,6 @@ const DashboardToolbar = (props)=>{
|
|
|
121
123
|
direction: "row",
|
|
122
124
|
spacing: 1,
|
|
123
125
|
ml: 1,
|
|
124
|
-
mb: 1,
|
|
125
126
|
children: [
|
|
126
127
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeRangeControls.TimeRangeControls, {}),
|
|
127
128
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_DownloadButton.DownloadButton, {}),
|
|
@@ -134,8 +135,9 @@ const DashboardToolbar = (props)=>{
|
|
|
134
135
|
})
|
|
135
136
|
]
|
|
136
137
|
}) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
gap: 1,
|
|
139
|
+
mx: 2,
|
|
140
|
+
mt: 1.5,
|
|
139
141
|
"data-testid": testId,
|
|
140
142
|
children: [
|
|
141
143
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
@@ -160,7 +162,7 @@ const DashboardToolbar = (props)=>{
|
|
|
160
162
|
]
|
|
161
163
|
}),
|
|
162
164
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
163
|
-
|
|
165
|
+
mt: 1,
|
|
164
166
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ErrorBoundary, {
|
|
165
167
|
FallbackComponent: _components.ErrorAlert,
|
|
166
168
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DashboardStickyToolbar.DashboardStickyToolbar, {
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// Copyright 2023 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, "DatasourceEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return DatasourceEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
26
|
+
const _Pencil = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Pencil"));
|
|
27
|
+
const _TrashCan = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/TrashCan"));
|
|
28
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
29
|
+
const _react = require("react");
|
|
30
|
+
const _useimmer = require("use-immer");
|
|
31
|
+
const _context = require("../../context");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function DatasourceEditor(props) {
|
|
38
|
+
const [datasources, setDatasources] = (0, _useimmer.useImmer)(props.datasources);
|
|
39
|
+
const [datasourceFormAction, setDatasourceFormAction] = (0, _react.useState)('update');
|
|
40
|
+
const [datasourceEdit, setDatasourceEdit] = (0, _react.useState)(null);
|
|
41
|
+
const defaultSpec = {
|
|
42
|
+
default: false,
|
|
43
|
+
plugin: {
|
|
44
|
+
// TODO: find a way to avoid assuming that the PrometheusDatasource plugin is installed
|
|
45
|
+
kind: 'PrometheusDatasource',
|
|
46
|
+
spec: {}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const { openDiscardChangesConfirmationDialog , closeDiscardChangesConfirmationDialog } = (0, _context.useDiscardChangesConfirmationDialog)();
|
|
50
|
+
const handleCancel = ()=>{
|
|
51
|
+
if (JSON.stringify(props.datasources) !== JSON.stringify(datasources)) {
|
|
52
|
+
openDiscardChangesConfirmationDialog({
|
|
53
|
+
onDiscardChanges: ()=>{
|
|
54
|
+
closeDiscardChangesConfirmationDialog();
|
|
55
|
+
props.onCancel();
|
|
56
|
+
},
|
|
57
|
+
onCancel: ()=>{
|
|
58
|
+
closeDiscardChangesConfirmationDialog();
|
|
59
|
+
},
|
|
60
|
+
description: 'You have unapplied changes. Are you sure you want to discard these changes? Changes cannot be recovered.'
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
props.onCancel();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const removeDatasource = (name)=>{
|
|
67
|
+
setDatasources((draft)=>{
|
|
68
|
+
delete draft[name];
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
const addDatasource = ()=>{
|
|
72
|
+
setDatasourceFormAction('create');
|
|
73
|
+
setDatasourceEdit({
|
|
74
|
+
name: 'NewDatasource',
|
|
75
|
+
spec: defaultSpec
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const editDatasource = (name)=>{
|
|
79
|
+
setDatasourceFormAction('update');
|
|
80
|
+
var _datasources_name;
|
|
81
|
+
setDatasourceEdit({
|
|
82
|
+
name: name,
|
|
83
|
+
spec: (_datasources_name = datasources[name]) !== null && _datasources_name !== void 0 ? _datasources_name : defaultSpec
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
|
|
87
|
+
children: datasourceEdit ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.DatasourceEditorForm, {
|
|
88
|
+
initialName: datasourceEdit.name,
|
|
89
|
+
initialSpec: datasourceEdit.spec,
|
|
90
|
+
initialAction: datasourceFormAction,
|
|
91
|
+
isDraft: true,
|
|
92
|
+
onSave: (name, spec)=>{
|
|
93
|
+
setDatasources((draft)=>{
|
|
94
|
+
draft[name] = spec;
|
|
95
|
+
setDatasourceEdit(null);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
onClose: ()=>{
|
|
99
|
+
setDatasourceEdit(null);
|
|
100
|
+
}
|
|
101
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
102
|
+
children: [
|
|
103
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
|
|
104
|
+
sx: {
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
padding: (theme)=>theme.spacing(1, 2),
|
|
108
|
+
borderBottom: (theme)=>`1px solid ${theme.palette.divider}`
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
112
|
+
variant: "h2",
|
|
113
|
+
children: "Edit Dashboard Datasources"
|
|
114
|
+
}),
|
|
115
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
116
|
+
direction: "row",
|
|
117
|
+
spacing: 1,
|
|
118
|
+
marginLeft: "auto",
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
121
|
+
disabled: props.datasources === datasources,
|
|
122
|
+
variant: "contained",
|
|
123
|
+
onClick: ()=>{
|
|
124
|
+
props.onChange(datasources);
|
|
125
|
+
},
|
|
126
|
+
children: "Apply"
|
|
127
|
+
}),
|
|
128
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
129
|
+
color: "secondary",
|
|
130
|
+
variant: "outlined",
|
|
131
|
+
onClick: handleCancel,
|
|
132
|
+
children: "Cancel"
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}),
|
|
138
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
139
|
+
padding: 2,
|
|
140
|
+
sx: {
|
|
141
|
+
overflowY: 'scroll'
|
|
142
|
+
},
|
|
143
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
|
|
144
|
+
spacing: 2,
|
|
145
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
146
|
+
spacing: 2,
|
|
147
|
+
children: [
|
|
148
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableContainer, {
|
|
149
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Table, {
|
|
150
|
+
sx: {
|
|
151
|
+
minWidth: 650
|
|
152
|
+
},
|
|
153
|
+
"aria-label": "table of datasources",
|
|
154
|
+
children: [
|
|
155
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableHead, {
|
|
156
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
157
|
+
children: [
|
|
158
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
159
|
+
children: "Name"
|
|
160
|
+
}),
|
|
161
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
162
|
+
children: "Type"
|
|
163
|
+
}),
|
|
164
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
165
|
+
children: "Description"
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
168
|
+
align: "right",
|
|
169
|
+
children: "Actions"
|
|
170
|
+
})
|
|
171
|
+
]
|
|
172
|
+
})
|
|
173
|
+
}),
|
|
174
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableBody, {
|
|
175
|
+
children: Object.entries(datasources).map(([name, spec])=>{
|
|
176
|
+
var _spec_display;
|
|
177
|
+
var _spec_display_description;
|
|
178
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableRow, {
|
|
179
|
+
children: [
|
|
180
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
181
|
+
component: "th",
|
|
182
|
+
scope: "row",
|
|
183
|
+
sx: {
|
|
184
|
+
fontWeight: 'bold'
|
|
185
|
+
},
|
|
186
|
+
children: name
|
|
187
|
+
}),
|
|
188
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
189
|
+
children: spec.plugin.kind
|
|
190
|
+
}),
|
|
191
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableCell, {
|
|
192
|
+
children: (_spec_display_description = (_spec_display = spec.display) === null || _spec_display === void 0 ? void 0 : _spec_display.description) !== null && _spec_display_description !== void 0 ? _spec_display_description : ''
|
|
193
|
+
}),
|
|
194
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TableCell, {
|
|
195
|
+
align: "right",
|
|
196
|
+
sx: {
|
|
197
|
+
whiteSpace: 'nowrap'
|
|
198
|
+
},
|
|
199
|
+
children: [
|
|
200
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
201
|
+
onClick: ()=>editDatasource(name),
|
|
202
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Pencil.default, {})
|
|
203
|
+
}),
|
|
204
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
205
|
+
onClick: ()=>removeDatasource(name),
|
|
206
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_TrashCan.default, {})
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
}, name);
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
]
|
|
215
|
+
})
|
|
216
|
+
}),
|
|
217
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
|
|
218
|
+
display: "flex",
|
|
219
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
220
|
+
variant: "contained",
|
|
221
|
+
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
|
|
222
|
+
sx: {
|
|
223
|
+
marginLeft: 'auto'
|
|
224
|
+
},
|
|
225
|
+
onClick: addDatasource,
|
|
226
|
+
children: "Add Datasource"
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
]
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
})
|
|
233
|
+
]
|
|
234
|
+
})
|
|
235
|
+
});
|
|
236
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright 2023 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, "EditDatasourcesButton", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return EditDatasourcesButton;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _react = require("react");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _PencilOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/PencilOutline"));
|
|
27
|
+
const _components = require("@perses-dev/components");
|
|
28
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
29
|
+
const _constants = require("../../constants");
|
|
30
|
+
const _context = require("../../context");
|
|
31
|
+
const _DatasourceEditor = require("./DatasourceEditor");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function EditDatasourcesButton() {
|
|
38
|
+
const [isDatasourceEditorOpen, setIsDatasourceEditorOpen] = (0, _react.useState)(false);
|
|
39
|
+
const { getLocalDatasources , setLocalDatasources , getSavedDatasources , setSavedDatasources } = (0, _pluginsystem.useDatasourceStore)();
|
|
40
|
+
const localDatasources = getLocalDatasources();
|
|
41
|
+
const savedDatasources = getSavedDatasources();
|
|
42
|
+
const { dashboard , setDashboard } = (0, _context.useDashboard)();
|
|
43
|
+
const openDatasourceEditor = ()=>{
|
|
44
|
+
setIsDatasourceEditorOpen(true);
|
|
45
|
+
};
|
|
46
|
+
const closeDatasourceEditor = ()=>{
|
|
47
|
+
setIsDatasourceEditorOpen(false);
|
|
48
|
+
};
|
|
49
|
+
const handleChangeDatasources = (datasources)=>{
|
|
50
|
+
// Calculates the new list of datasources that are allowed to be used.
|
|
51
|
+
const newSavedDatasources = Object.keys(datasources).filter((key)=>{
|
|
52
|
+
var _datasources_key, _datasources_key_plugin, _savedDatasources_key, _savedDatasources_key_plugin, _datasources_key1, _datasources_key_plugin1, _datasources_key_plugin_spec, _savedDatasources_key1, _savedDatasources_key_plugin1, _savedDatasources_key_plugin_spec;
|
|
53
|
+
var _datasources_key_plugin_spec1;
|
|
54
|
+
// Datasources are allowed to be used if a) they are direct, or b) they are proxied, and their
|
|
55
|
+
// proxy is the same as what we have saved.
|
|
56
|
+
const isDirect = 'directUrl' in ((_datasources_key_plugin_spec1 = (_datasources_key = datasources[key]) === null || _datasources_key === void 0 ? void 0 : (_datasources_key_plugin = _datasources_key.plugin) === null || _datasources_key_plugin === void 0 ? void 0 : _datasources_key_plugin.spec) !== null && _datasources_key_plugin_spec1 !== void 0 ? _datasources_key_plugin_spec1 : {});
|
|
57
|
+
var _savedDatasources_key_plugin_spec1;
|
|
58
|
+
const isSavedProxy = !isDirect && !('directUrl' in ((_savedDatasources_key_plugin_spec1 = (_savedDatasources_key = savedDatasources[key]) === null || _savedDatasources_key === void 0 ? void 0 : (_savedDatasources_key_plugin = _savedDatasources_key.plugin) === null || _savedDatasources_key_plugin === void 0 ? void 0 : _savedDatasources_key_plugin.spec) !== null && _savedDatasources_key_plugin_spec1 !== void 0 ? _savedDatasources_key_plugin_spec1 : {})) && ((_datasources_key1 = datasources[key]) === null || _datasources_key1 === void 0 ? void 0 : (_datasources_key_plugin1 = _datasources_key1.plugin) === null || _datasources_key_plugin1 === void 0 ? void 0 : (_datasources_key_plugin_spec = _datasources_key_plugin1.spec) === null || _datasources_key_plugin_spec === void 0 ? void 0 : _datasources_key_plugin_spec.proxy) === ((_savedDatasources_key1 = savedDatasources[key]) === null || _savedDatasources_key1 === void 0 ? void 0 : (_savedDatasources_key_plugin1 = _savedDatasources_key1.plugin) === null || _savedDatasources_key_plugin1 === void 0 ? void 0 : (_savedDatasources_key_plugin_spec = _savedDatasources_key_plugin1.spec) === null || _savedDatasources_key_plugin_spec === void 0 ? void 0 : _savedDatasources_key_plugin_spec.proxy);
|
|
59
|
+
return isDirect || isSavedProxy;
|
|
60
|
+
}).reduce((obj, key)=>{
|
|
61
|
+
obj[key] = datasources[key];
|
|
62
|
+
return obj;
|
|
63
|
+
}, {});
|
|
64
|
+
setDashboard({
|
|
65
|
+
...dashboard,
|
|
66
|
+
spec: {
|
|
67
|
+
...dashboard.spec,
|
|
68
|
+
datasources: datasources
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
setSavedDatasources(newSavedDatasources);
|
|
72
|
+
setLocalDatasources(datasources);
|
|
73
|
+
setIsDatasourceEditorOpen(false);
|
|
74
|
+
};
|
|
75
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
76
|
+
children: [
|
|
77
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.InfoTooltip, {
|
|
78
|
+
description: _constants.TOOLTIP_TEXT.editDatasources,
|
|
79
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
80
|
+
startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_PencilOutline.default, {}),
|
|
81
|
+
onClick: openDatasourceEditor,
|
|
82
|
+
"aria-label": _constants.TOOLTIP_TEXT.editDatasources,
|
|
83
|
+
variant: "text",
|
|
84
|
+
color: "primary",
|
|
85
|
+
sx: {
|
|
86
|
+
whiteSpace: 'nowrap',
|
|
87
|
+
minWidth: 'auto'
|
|
88
|
+
},
|
|
89
|
+
children: "Datasources"
|
|
90
|
+
})
|
|
91
|
+
}),
|
|
92
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Drawer, {
|
|
93
|
+
isOpen: isDatasourceEditorOpen,
|
|
94
|
+
onClose: closeDatasourceEditor,
|
|
95
|
+
PaperProps: {
|
|
96
|
+
sx: {
|
|
97
|
+
width: '50%'
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"data-testid": "datasource-editor",
|
|
101
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DatasourceEditor.DatasourceEditor, {
|
|
102
|
+
datasources: localDatasources,
|
|
103
|
+
onCancel: closeDatasourceEditor,
|
|
104
|
+
onChange: handleChangeDatasources
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
});
|
|
109
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
_export_star(require("./EditDatasourcesButton"), exports);
|
|
18
|
+
_export_star(require("./DatasourceEditor"), exports);
|
|
19
|
+
function _export_star(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
22
|
+
Object.defineProperty(to, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function() {
|
|
25
|
+
return from[k];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|
|
@@ -51,6 +51,7 @@ const EditJsonDialogForm = (props)=>{
|
|
|
51
51
|
const { closeEditJsonDialog } = (0, _DashboardProvider.useEditJsonDialog)();
|
|
52
52
|
const { setTimeRange , setRefreshInterval } = (0, _pluginsystem.useTimeRange)();
|
|
53
53
|
const { dashboard , setDashboard } = (0, _useDashboard.useDashboard)();
|
|
54
|
+
const { setLocalDatasources } = (0, _pluginsystem.useDatasourceStore)();
|
|
54
55
|
const [draftDashboard, setDraftDashboard] = (0, _react.useState)(dashboard);
|
|
55
56
|
const handleApply = (e)=>{
|
|
56
57
|
e.preventDefault();
|
|
@@ -60,8 +61,18 @@ const EditJsonDialogForm = (props)=>{
|
|
|
60
61
|
});
|
|
61
62
|
var _draftDashboard_spec_refreshInterval;
|
|
62
63
|
setRefreshInterval((_draftDashboard_spec_refreshInterval = draftDashboard.spec.refreshInterval) !== null && _draftDashboard_spec_refreshInterval !== void 0 ? _draftDashboard_spec_refreshInterval : '0s');
|
|
64
|
+
var _draftDashboard_spec_datasources;
|
|
65
|
+
setLocalDatasources((_draftDashboard_spec_datasources = draftDashboard.spec.datasources) !== null && _draftDashboard_spec_datasources !== void 0 ? _draftDashboard_spec_datasources : {});
|
|
63
66
|
closeEditJsonDialog();
|
|
64
67
|
};
|
|
68
|
+
const completeDraftDashboard = (dashboard)=>{
|
|
69
|
+
try {
|
|
70
|
+
const json = JSON.parse(dashboard !== null && dashboard !== void 0 ? dashboard : '{}');
|
|
71
|
+
setDraftDashboard(json);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
// do nothing
|
|
74
|
+
}
|
|
75
|
+
};
|
|
65
76
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.Dialog.Form, {
|
|
66
77
|
onSubmit: handleApply,
|
|
67
78
|
children: [
|
|
@@ -83,7 +94,7 @@ const EditJsonDialogForm = (props)=>{
|
|
|
83
94
|
minHeight: "300px",
|
|
84
95
|
maxHeight: "70vh",
|
|
85
96
|
value: draftDashboard,
|
|
86
|
-
onChange: (value)=>
|
|
97
|
+
onChange: (value)=>completeDraftDashboard(value)
|
|
87
98
|
})
|
|
88
99
|
})
|
|
89
100
|
]
|
|
@@ -29,7 +29,7 @@ _export(exports, {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const _jsxruntime = require("react/jsx-runtime");
|
|
32
|
-
const _react =
|
|
32
|
+
const _react = require("react");
|
|
33
33
|
const _material = require("@mui/material");
|
|
34
34
|
const _components = require("@perses-dev/components");
|
|
35
35
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
@@ -39,45 +39,6 @@ const _context = require("../../context");
|
|
|
39
39
|
const _validation = require("../../validation");
|
|
40
40
|
const _PanelPreview = require("./PanelPreview");
|
|
41
41
|
const _usePanelEditor = require("./usePanelEditor");
|
|
42
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
43
|
-
if (typeof WeakMap !== "function") return null;
|
|
44
|
-
var cacheBabelInterop = new WeakMap();
|
|
45
|
-
var cacheNodeInterop = new WeakMap();
|
|
46
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
47
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
48
|
-
})(nodeInterop);
|
|
49
|
-
}
|
|
50
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
51
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
52
|
-
return obj;
|
|
53
|
-
}
|
|
54
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
55
|
-
return {
|
|
56
|
-
default: obj
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
60
|
-
if (cache && cache.has(obj)) {
|
|
61
|
-
return cache.get(obj);
|
|
62
|
-
}
|
|
63
|
-
var newObj = {};
|
|
64
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
65
|
-
for(var key in obj){
|
|
66
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
67
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
68
|
-
if (desc && (desc.get || desc.set)) {
|
|
69
|
-
Object.defineProperty(newObj, key, desc);
|
|
70
|
-
} else {
|
|
71
|
-
newObj[key] = obj[key];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
newObj.default = obj;
|
|
76
|
-
if (cache) {
|
|
77
|
-
cache.set(obj, newObj);
|
|
78
|
-
}
|
|
79
|
-
return newObj;
|
|
80
|
-
}
|
|
81
42
|
function PanelEditorForm(props) {
|
|
82
43
|
const { initialValues: { panelDefinition: initialPanelDef , groupId: initialGroupId } , initialAction , onSave , onClose } = props;
|
|
83
44
|
const panelGroups = (0, _context.useListPanelGroups)();
|
|
@@ -135,7 +96,8 @@ function PanelEditorForm(props) {
|
|
|
135
96
|
onClose();
|
|
136
97
|
}
|
|
137
98
|
}
|
|
138
|
-
const handlePanelDefinitionChange = (
|
|
99
|
+
const handlePanelDefinitionChange = (nextPanelDefStr)=>{
|
|
100
|
+
const nextPanelDef = JSON.parse(nextPanelDefStr);
|
|
139
101
|
const { kind: pluginKind , spec: pluginSpec } = nextPanelDef.spec.plugin;
|
|
140
102
|
// if panel plugin kind and spec are modified, then need to save current spec
|
|
141
103
|
if (panelDefinition.spec.plugin.kind !== pluginKind && JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)) {
|
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
17
|
_export_star(require("./PanelDrawer"), exports);
|
|
18
|
+
_export_star(require("./PanelPreview"), exports);
|
|
18
19
|
function _export_star(from, to) {
|
|
19
20
|
Object.keys(from).forEach(function(k) {
|
|
20
21
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -27,7 +27,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
27
27
|
const TABLE_MAX_WIDTH = 1000;
|
|
28
28
|
function QuerySummaryTable(props) {
|
|
29
29
|
const { showTotalQueries =true } = props;
|
|
30
|
-
const
|
|
30
|
+
const datasourceClient = (0, _pluginsystem.useDatasourceClient)({
|
|
31
31
|
kind: 'PrometheusDatasource'
|
|
32
32
|
});
|
|
33
33
|
const { absoluteTimeRange } = (0, _pluginsystem.useTimeRange)();
|
|
@@ -37,7 +37,7 @@ function QuerySummaryTable(props) {
|
|
|
37
37
|
const activeQueries = queries.filter((query)=>query.state.status === 'loading');
|
|
38
38
|
const completedQueries = queries.filter((query)=>query.state.status === 'success');
|
|
39
39
|
const querySummary = (0, _pluginsystem.useActiveTimeSeriesQueries)();
|
|
40
|
-
if (
|
|
40
|
+
if (datasourceClient.isLoading === true) {
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
43
|
const warnings = [];
|