@perses-dev/prometheus-plugin 0.37.2 → 0.39.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/plugins/MatcherEditor.js +6 -1
- package/dist/cjs/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +392 -0
- package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +29 -0
- package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +16 -0
- package/dist/cjs/plugins/prometheus-datasource.js +2 -1
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +2 -1
- package/dist/cjs/plugins/prometheus-variables.js +14 -2
- package/dist/cjs/plugins/variable.js +1 -0
- package/dist/plugins/MatcherEditor.d.ts +2 -1
- package/dist/plugins/MatcherEditor.d.ts.map +1 -1
- package/dist/plugins/MatcherEditor.js +6 -1
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts +9 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +342 -0
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts +3 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.js +16 -0
- package/dist/plugins/PrometheusDatasourceEditor/index.js.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts +20 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.js +15 -0
- package/dist/plugins/PrometheusDatasourceEditor/types.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +2 -1
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +2 -1
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +2 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/prometheus-variables.d.ts.map +1 -1
- package/dist/plugins/prometheus-variables.js +14 -2
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/variable.d.ts.map +1 -1
- package/dist/plugins/variable.js +1 -0
- package/dist/plugins/variable.js.map +1 -1
- package/package.json +4 -4
|
@@ -27,7 +27,7 @@ function _interopRequireDefault(obj) {
|
|
|
27
27
|
default: obj
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
function MatcherEditor({ matchers , onChange }) {
|
|
30
|
+
function MatcherEditor({ matchers , onChange , isReadonly }) {
|
|
31
31
|
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
32
32
|
spacing: 1,
|
|
33
33
|
mb: 2,
|
|
@@ -39,6 +39,9 @@ function MatcherEditor({ matchers , onChange }) {
|
|
|
39
39
|
fullWidth: true,
|
|
40
40
|
label: "Series Selector",
|
|
41
41
|
value: matcher,
|
|
42
|
+
InputProps: {
|
|
43
|
+
readOnly: isReadonly
|
|
44
|
+
},
|
|
42
45
|
onChange: (e)=>{
|
|
43
46
|
const newMatchers = (0, _immer.produce)(matchers, (draft)=>{
|
|
44
47
|
draft[index] = e.target.value;
|
|
@@ -53,6 +56,7 @@ function MatcherEditor({ matchers , onChange }) {
|
|
|
53
56
|
});
|
|
54
57
|
onChange(newMatchers);
|
|
55
58
|
},
|
|
59
|
+
disabled: isReadonly,
|
|
56
60
|
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_trashCan.default, {})
|
|
57
61
|
})
|
|
58
62
|
]
|
|
@@ -68,6 +72,7 @@ function MatcherEditor({ matchers , onChange }) {
|
|
|
68
72
|
});
|
|
69
73
|
onChange(newMatchers);
|
|
70
74
|
},
|
|
75
|
+
disabled: isReadonly,
|
|
71
76
|
children: "Add Series Selector"
|
|
72
77
|
})
|
|
73
78
|
})
|
|
@@ -0,0 +1,392 @@
|
|
|
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, "PrometheusDatasourceEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>PrometheusDatasourceEditor
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _pluginSystem = require("@perses-dev/plugin-system");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
25
|
+
const _minus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Minus"));
|
|
26
|
+
const _plus = /*#__PURE__*/ _interopRequireDefault(require("mdi-material-ui/Plus"));
|
|
27
|
+
function _interopRequireDefault(obj) {
|
|
28
|
+
return obj && obj.__esModule ? obj : {
|
|
29
|
+
default: obj
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
33
|
+
if (typeof WeakMap !== "function") return null;
|
|
34
|
+
var cacheBabelInterop = new WeakMap();
|
|
35
|
+
var cacheNodeInterop = new WeakMap();
|
|
36
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
37
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
38
|
+
})(nodeInterop);
|
|
39
|
+
}
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
41
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
45
|
+
return {
|
|
46
|
+
default: obj
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
50
|
+
if (cache && cache.has(obj)) {
|
|
51
|
+
return cache.get(obj);
|
|
52
|
+
}
|
|
53
|
+
var newObj = {};
|
|
54
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
55
|
+
for(var key in obj){
|
|
56
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
57
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
58
|
+
if (desc && (desc.get || desc.set)) {
|
|
59
|
+
Object.defineProperty(newObj, key, desc);
|
|
60
|
+
} else {
|
|
61
|
+
newObj[key] = obj[key];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
newObj.default = obj;
|
|
66
|
+
if (cache) {
|
|
67
|
+
cache.set(obj, newObj);
|
|
68
|
+
}
|
|
69
|
+
return newObj;
|
|
70
|
+
}
|
|
71
|
+
function PrometheusDatasourceEditor(props) {
|
|
72
|
+
var ref, ref1, ref2, ref3;
|
|
73
|
+
const { value , onChange , isReadonly } = props;
|
|
74
|
+
const strDirect = 'Direct access';
|
|
75
|
+
const strProxy = 'Proxy';
|
|
76
|
+
// TODO refactor with useImmer to avoid doing so much destructuring? feasibility & performances to be checked
|
|
77
|
+
// utilitary function used for headers when renaming a property
|
|
78
|
+
// -> TODO it would be cleaner to manipulate headers as a list instead, to avoid doing this.
|
|
79
|
+
// This could be a pure frontend trick, but change in the backend datamodel should also be considered
|
|
80
|
+
const buildNewHeaders = (oldHeaders, oldName, newName)=>{
|
|
81
|
+
if (oldHeaders === undefined) return oldHeaders;
|
|
82
|
+
const keys = Object.keys(oldHeaders);
|
|
83
|
+
const newHeaders = keys.reduce((acc, val)=>{
|
|
84
|
+
if (val === oldName) {
|
|
85
|
+
acc[newName] = oldHeaders[oldName] || '';
|
|
86
|
+
} else {
|
|
87
|
+
acc[val] = oldHeaders[val] || '';
|
|
88
|
+
}
|
|
89
|
+
return acc;
|
|
90
|
+
}, {});
|
|
91
|
+
return {
|
|
92
|
+
...newHeaders
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
const tabs = [
|
|
96
|
+
{
|
|
97
|
+
label: strDirect,
|
|
98
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
99
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
100
|
+
fullWidth: true,
|
|
101
|
+
label: "URL",
|
|
102
|
+
value: value.direct_url || '',
|
|
103
|
+
InputProps: {
|
|
104
|
+
readOnly: isReadonly
|
|
105
|
+
},
|
|
106
|
+
onChange: (e)=>onChange({
|
|
107
|
+
...value,
|
|
108
|
+
direct_url: e.target.value
|
|
109
|
+
})
|
|
110
|
+
})
|
|
111
|
+
})
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
label: strProxy,
|
|
115
|
+
content: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
116
|
+
children: [
|
|
117
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
118
|
+
fullWidth: true,
|
|
119
|
+
label: "URL",
|
|
120
|
+
value: ((ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.url) || '',
|
|
121
|
+
InputProps: {
|
|
122
|
+
readOnly: isReadonly
|
|
123
|
+
},
|
|
124
|
+
onChange: (e)=>onChange({
|
|
125
|
+
...value,
|
|
126
|
+
...value.proxy && {
|
|
127
|
+
proxy: {
|
|
128
|
+
...value.proxy,
|
|
129
|
+
spec: {
|
|
130
|
+
...value.proxy.spec,
|
|
131
|
+
url: e.target.value
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
}),
|
|
137
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
138
|
+
py: 2,
|
|
139
|
+
variant: "h4",
|
|
140
|
+
children: "Allowed endpoints"
|
|
141
|
+
}),
|
|
142
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
143
|
+
container: true,
|
|
144
|
+
spacing: 2,
|
|
145
|
+
mb: 2,
|
|
146
|
+
children: ((ref1 = value.proxy) === null || ref1 === void 0 ? void 0 : ref1.spec.allowed_endpoints) && value.proxy.spec.allowed_endpoints.map(({ endpoint_pattern , method }, i)=>{
|
|
147
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
148
|
+
children: [
|
|
149
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
150
|
+
item: true,
|
|
151
|
+
xs: 8,
|
|
152
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
153
|
+
disabled: true,
|
|
154
|
+
fullWidth: true,
|
|
155
|
+
label: "Endpoint pattern",
|
|
156
|
+
value: endpoint_pattern,
|
|
157
|
+
InputProps: {
|
|
158
|
+
readOnly: isReadonly
|
|
159
|
+
}
|
|
160
|
+
})
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
163
|
+
item: true,
|
|
164
|
+
xs: 4,
|
|
165
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
166
|
+
disabled: true,
|
|
167
|
+
fullWidth: true,
|
|
168
|
+
label: "URL",
|
|
169
|
+
value: method,
|
|
170
|
+
InputProps: {
|
|
171
|
+
readOnly: isReadonly
|
|
172
|
+
}
|
|
173
|
+
})
|
|
174
|
+
})
|
|
175
|
+
]
|
|
176
|
+
}, i);
|
|
177
|
+
})
|
|
178
|
+
}),
|
|
179
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
|
|
180
|
+
pb: 2,
|
|
181
|
+
variant: "h4",
|
|
182
|
+
children: "Request Headers"
|
|
183
|
+
}),
|
|
184
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Grid, {
|
|
185
|
+
container: true,
|
|
186
|
+
spacing: 2,
|
|
187
|
+
mb: 2,
|
|
188
|
+
children: [
|
|
189
|
+
((ref2 = value.proxy) === null || ref2 === void 0 ? void 0 : ref2.spec.headers) !== undefined && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
|
|
190
|
+
var ref, ref1;
|
|
191
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_react.default.Fragment, {
|
|
192
|
+
children: [
|
|
193
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
194
|
+
item: true,
|
|
195
|
+
xs: 4,
|
|
196
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
197
|
+
fullWidth: true,
|
|
198
|
+
label: "Header name",
|
|
199
|
+
value: headerName,
|
|
200
|
+
InputProps: {
|
|
201
|
+
readOnly: isReadonly
|
|
202
|
+
},
|
|
203
|
+
onChange: (e)=>onChange({
|
|
204
|
+
...value,
|
|
205
|
+
...value.proxy && {
|
|
206
|
+
proxy: {
|
|
207
|
+
...value.proxy,
|
|
208
|
+
spec: {
|
|
209
|
+
...value.proxy.spec,
|
|
210
|
+
headers: buildNewHeaders(value.proxy.spec.headers, headerName, e.target.value)
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
}),
|
|
217
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
218
|
+
item: true,
|
|
219
|
+
xs: 7,
|
|
220
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
221
|
+
fullWidth: true,
|
|
222
|
+
label: "Header value",
|
|
223
|
+
value: (ref1 = (ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.headers) === null || ref1 === void 0 ? void 0 : ref1[headerName],
|
|
224
|
+
InputProps: {
|
|
225
|
+
readOnly: isReadonly
|
|
226
|
+
},
|
|
227
|
+
onChange: (e)=>onChange({
|
|
228
|
+
...value,
|
|
229
|
+
...value.proxy && {
|
|
230
|
+
proxy: {
|
|
231
|
+
...value.proxy,
|
|
232
|
+
spec: {
|
|
233
|
+
...value.proxy.spec,
|
|
234
|
+
headers: {
|
|
235
|
+
...value.proxy.spec.headers,
|
|
236
|
+
[headerName]: e.target.value
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
}),
|
|
244
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
245
|
+
item: true,
|
|
246
|
+
xs: 1,
|
|
247
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
248
|
+
disabled: isReadonly,
|
|
249
|
+
onClick: ()=>{
|
|
250
|
+
var ref;
|
|
251
|
+
const newHeaders = {
|
|
252
|
+
...(ref = value.proxy) === null || ref === void 0 ? void 0 : ref.spec.headers
|
|
253
|
+
};
|
|
254
|
+
delete newHeaders[headerName];
|
|
255
|
+
onChange({
|
|
256
|
+
...value,
|
|
257
|
+
...value.proxy && {
|
|
258
|
+
proxy: {
|
|
259
|
+
...value.proxy,
|
|
260
|
+
spec: {
|
|
261
|
+
...value.proxy.spec,
|
|
262
|
+
headers: newHeaders
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_minus.default, {})
|
|
269
|
+
})
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
}, i);
|
|
273
|
+
}),
|
|
274
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
|
|
275
|
+
item: true,
|
|
276
|
+
xs: 12,
|
|
277
|
+
sx: {
|
|
278
|
+
paddingTop: '5px !important'
|
|
279
|
+
},
|
|
280
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
281
|
+
disabled: isReadonly,
|
|
282
|
+
onClick: ()=>onChange({
|
|
283
|
+
...value,
|
|
284
|
+
...value.proxy && {
|
|
285
|
+
proxy: {
|
|
286
|
+
...value.proxy,
|
|
287
|
+
spec: {
|
|
288
|
+
...value.proxy.spec,
|
|
289
|
+
headers: {
|
|
290
|
+
...value.proxy.spec.headers,
|
|
291
|
+
'': ''
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}),
|
|
297
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_plus.default, {})
|
|
298
|
+
})
|
|
299
|
+
})
|
|
300
|
+
]
|
|
301
|
+
}),
|
|
302
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
303
|
+
fullWidth: true,
|
|
304
|
+
label: "Secret",
|
|
305
|
+
value: ((ref3 = value.proxy) === null || ref3 === void 0 ? void 0 : ref3.spec.secret) || '',
|
|
306
|
+
InputProps: {
|
|
307
|
+
readOnly: isReadonly
|
|
308
|
+
},
|
|
309
|
+
onChange: (e)=>onChange({
|
|
310
|
+
...value,
|
|
311
|
+
...value.proxy && {
|
|
312
|
+
proxy: {
|
|
313
|
+
...value.proxy,
|
|
314
|
+
spec: {
|
|
315
|
+
...value.proxy.spec,
|
|
316
|
+
secret: e.target.value
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
];
|
|
326
|
+
// Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
|
|
327
|
+
// bug in case the tabs get eventually swapped in the future.
|
|
328
|
+
const directModeId = tabs.findIndex((tab)=>tab.label == strDirect);
|
|
329
|
+
const proxyModeId = tabs.findIndex((tab)=>tab.label == strProxy);
|
|
330
|
+
// In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
|
|
331
|
+
// Otherwise (create datasource), set defaultTab to Direct access.
|
|
332
|
+
const defaultTab = value.proxy ? proxyModeId : directModeId;
|
|
333
|
+
const initialSpecDirect = {
|
|
334
|
+
direct_url: ''
|
|
335
|
+
};
|
|
336
|
+
const initialSpecProxy = {
|
|
337
|
+
proxy: {
|
|
338
|
+
kind: 'HTTPProxy',
|
|
339
|
+
spec: {
|
|
340
|
+
allowed_endpoints: [
|
|
341
|
+
// hardcoded list of allowed endpoints for now since those are enforced by the backend
|
|
342
|
+
{
|
|
343
|
+
endpoint_pattern: '/api/v1/labels',
|
|
344
|
+
method: 'POST'
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
endpoint_pattern: '/api/v1/series',
|
|
348
|
+
method: 'POST'
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
endpoint_pattern: '/api/v1/metadata',
|
|
352
|
+
method: 'GET'
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
endpoint_pattern: '/api/v1/query',
|
|
356
|
+
method: 'POST'
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
endpoint_pattern: '/api/v1/query_range',
|
|
360
|
+
method: 'POST'
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
endpoint_pattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
|
|
364
|
+
method: 'GET'
|
|
365
|
+
}
|
|
366
|
+
],
|
|
367
|
+
url: ''
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
// For better user experience, save previous states in mind for both mode.
|
|
372
|
+
// This avoids losing everything when the user changes their mind back.
|
|
373
|
+
const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
|
|
374
|
+
const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
|
|
375
|
+
// When changing mode, remove previous mode's config + append default values for the new mode.
|
|
376
|
+
const handleModeChange = (v)=>{
|
|
377
|
+
var ref, ref1;
|
|
378
|
+
if (((ref = tabs[v]) === null || ref === void 0 ? void 0 : ref.label) == strDirect) {
|
|
379
|
+
setPreviousSpecProxy(value);
|
|
380
|
+
onChange(previousSpecDirect);
|
|
381
|
+
} else if (((ref1 = tabs[v]) === null || ref1 === void 0 ? void 0 : ref1.label) == strProxy) {
|
|
382
|
+
setPreviousSpecDirect(value);
|
|
383
|
+
onChange(previousSpecProxy);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_pluginSystem.OptionsEditorRadios, {
|
|
387
|
+
isReadonly: isReadonly,
|
|
388
|
+
tabs: tabs,
|
|
389
|
+
defaultTab: defaultTab,
|
|
390
|
+
onModeChange: handleModeChange
|
|
391
|
+
});
|
|
392
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
_exportStar(require("./PrometheusDatasourceEditor"), exports);
|
|
18
|
+
_exportStar(require("./types"), 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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
});
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "PrometheusDatasource", {
|
|
|
19
19
|
get: ()=>PrometheusDatasource
|
|
20
20
|
});
|
|
21
21
|
const _model = require("../model");
|
|
22
|
+
const _prometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
|
|
22
23
|
/**
|
|
23
24
|
* Creates a PrometheusClient for a specific datasource spec.
|
|
24
25
|
*/ const createClient = (spec, options)=>{
|
|
@@ -54,7 +55,7 @@ const _model = require("../model");
|
|
|
54
55
|
};
|
|
55
56
|
const PrometheusDatasource = {
|
|
56
57
|
createClient,
|
|
57
|
-
OptionsEditorComponent:
|
|
58
|
+
OptionsEditorComponent: _prometheusDatasourceEditor.PrometheusDatasourceEditor,
|
|
58
59
|
createInitialOptions: ()=>({
|
|
59
60
|
direct_url: ''
|
|
60
61
|
})
|
|
@@ -61,6 +61,7 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
61
61
|
datasourcePluginKind: "PrometheusDatasource",
|
|
62
62
|
value: selectedDatasource,
|
|
63
63
|
onChange: handleDatasourceChange,
|
|
64
|
+
readOnly: props.isReadonly,
|
|
64
65
|
labelId: "prom-datasource-label",
|
|
65
66
|
label: "Prometheus Datasource"
|
|
66
67
|
})
|
|
@@ -75,6 +76,9 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
75
76
|
...props.value,
|
|
76
77
|
label_name: e.target.value
|
|
77
78
|
});
|
|
79
|
+
},
|
|
80
|
+
InputProps: {
|
|
81
|
+
readOnly: props.isReadonly
|
|
78
82
|
}
|
|
79
83
|
}),
|
|
80
84
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
|
|
@@ -84,7 +88,8 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
84
88
|
...props.value,
|
|
85
89
|
matchers: e
|
|
86
90
|
});
|
|
87
|
-
}
|
|
91
|
+
},
|
|
92
|
+
isReadonly: props.isReadonly
|
|
88
93
|
})
|
|
89
94
|
]
|
|
90
95
|
});
|
|
@@ -118,6 +123,7 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
118
123
|
datasourcePluginKind: "PrometheusDatasource",
|
|
119
124
|
value: selectedDatasource,
|
|
120
125
|
onChange: handleDatasourceChange,
|
|
126
|
+
disabled: props.isReadonly,
|
|
121
127
|
labelId: "prom-datasource-label",
|
|
122
128
|
label: "Prometheus Datasource"
|
|
123
129
|
})
|
|
@@ -125,6 +131,7 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
125
131
|
}),
|
|
126
132
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_matcherEditor.MatcherEditor, {
|
|
127
133
|
matchers: (_matchers = props.value.matchers) !== null && _matchers !== void 0 ? _matchers : [],
|
|
134
|
+
isReadonly: props.isReadonly,
|
|
128
135
|
onChange: (e)=>{
|
|
129
136
|
props.onChange({
|
|
130
137
|
...props.value,
|
|
@@ -166,7 +173,8 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
166
173
|
value: selectedDatasource,
|
|
167
174
|
onChange: handleDatasourceChange,
|
|
168
175
|
labelId: "prom-datasource-label",
|
|
169
|
-
label: "Prometheus Datasource"
|
|
176
|
+
label: "Prometheus Datasource",
|
|
177
|
+
disabled: props.isReadonly
|
|
170
178
|
})
|
|
171
179
|
]
|
|
172
180
|
}),
|
|
@@ -183,11 +191,15 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
183
191
|
expr: query
|
|
184
192
|
});
|
|
185
193
|
},
|
|
194
|
+
readOnly: props.isReadonly,
|
|
186
195
|
width: "100%"
|
|
187
196
|
}),
|
|
188
197
|
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
189
198
|
label: "Label Name",
|
|
190
199
|
value: props.value.label_name,
|
|
200
|
+
InputProps: {
|
|
201
|
+
readOnly: props.isReadonly
|
|
202
|
+
},
|
|
191
203
|
onChange: (e)=>{
|
|
192
204
|
props.onChange({
|
|
193
205
|
...props.value,
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
declare type MatcherEditorProps = {
|
|
3
3
|
matchers: string[];
|
|
4
4
|
onChange: (matchers: string[]) => void;
|
|
5
|
+
isReadonly?: boolean;
|
|
5
6
|
};
|
|
6
|
-
export declare function MatcherEditor({ matchers, onChange }: MatcherEditorProps): JSX.Element;
|
|
7
|
+
export declare function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps): JSX.Element;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=MatcherEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MatcherEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/MatcherEditor.tsx"],"names":[],"mappings":";AAiBA,aAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"MatcherEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/MatcherEditor.tsx"],"names":[],"mappings":";AAiBA,aAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,kBAAkB,eAkDnF"}
|
|
@@ -14,7 +14,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
import { Stack, TextField, Button, Box, IconButton } from '@mui/material';
|
|
15
15
|
import { produce } from 'immer';
|
|
16
16
|
import TrashIcon from 'mdi-material-ui/TrashCan';
|
|
17
|
-
export function MatcherEditor({ matchers , onChange }) {
|
|
17
|
+
export function MatcherEditor({ matchers , onChange , isReadonly }) {
|
|
18
18
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
19
19
|
spacing: 1,
|
|
20
20
|
mb: 2,
|
|
@@ -26,6 +26,9 @@ export function MatcherEditor({ matchers , onChange }) {
|
|
|
26
26
|
fullWidth: true,
|
|
27
27
|
label: "Series Selector",
|
|
28
28
|
value: matcher,
|
|
29
|
+
InputProps: {
|
|
30
|
+
readOnly: isReadonly
|
|
31
|
+
},
|
|
29
32
|
onChange: (e)=>{
|
|
30
33
|
const newMatchers = produce(matchers, (draft)=>{
|
|
31
34
|
draft[index] = e.target.value;
|
|
@@ -40,6 +43,7 @@ export function MatcherEditor({ matchers , onChange }) {
|
|
|
40
43
|
});
|
|
41
44
|
onChange(newMatchers);
|
|
42
45
|
},
|
|
46
|
+
disabled: isReadonly,
|
|
43
47
|
children: /*#__PURE__*/ _jsx(TrashIcon, {})
|
|
44
48
|
})
|
|
45
49
|
]
|
|
@@ -55,6 +59,7 @@ export function MatcherEditor({ matchers , onChange }) {
|
|
|
55
59
|
});
|
|
56
60
|
onChange(newMatchers);
|
|
57
61
|
},
|
|
62
|
+
disabled: isReadonly,
|
|
58
63
|
children: "Add Series Selector"
|
|
59
64
|
})
|
|
60
65
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n};\n\nexport function MatcherEditor({ matchers, onChange }: MatcherEditorProps) {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","spacing","mb","map","matcher","index","display","fullWidth","label","value","e","newMatchers","draft","target","onClick","splice","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,OAAOC,SAAS,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../src/plugins/MatcherEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Stack, TextField, Button, Box, IconButton } from '@mui/material';\nimport { produce } from 'immer';\nimport TrashIcon from 'mdi-material-ui/TrashCan';\n\ntype MatcherEditorProps = {\n matchers: string[];\n onChange: (matchers: string[]) => void;\n isReadonly?: boolean;\n};\n\nexport function MatcherEditor({ matchers, onChange, isReadonly }: MatcherEditorProps) {\n return (\n <Stack spacing={1} mb={2}>\n {matchers.map((matcher, index) => (\n <Box key={index} display=\"flex\">\n <TextField\n fullWidth\n label=\"Series Selector\"\n value={matcher}\n InputProps={{\n readOnly: isReadonly,\n }}\n onChange={(e) => {\n const newMatchers = produce(matchers, (draft) => {\n draft[index] = e.target.value;\n });\n onChange(newMatchers);\n }}\n />\n <IconButton\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.splice(index, 1);\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n <TrashIcon />\n </IconButton>\n </Box>\n ))}\n <Box>\n <Button\n fullWidth={false}\n color=\"secondary\"\n variant=\"outlined\"\n onClick={() => {\n const newMatchers = produce(matchers, (draft) => {\n draft.push('');\n });\n onChange(newMatchers);\n }}\n disabled={isReadonly}\n >\n Add Series Selector\n </Button>\n </Box>\n </Stack>\n );\n}\n"],"names":["Stack","TextField","Button","Box","IconButton","produce","TrashIcon","MatcherEditor","matchers","onChange","isReadonly","spacing","mb","map","matcher","index","display","fullWidth","label","value","InputProps","readOnly","e","newMatchers","draft","target","onClick","splice","disabled","color","variant","push"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,KAAK,EAAEC,SAAS,EAAEC,MAAM,EAAEC,GAAG,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAC1E,SAASC,OAAO,QAAQ,OAAO,CAAC;AAChC,OAAOC,SAAS,MAAM,0BAA0B,CAAC;AAQjD,OAAO,SAASC,aAAa,CAAC,EAAEC,QAAQ,CAAA,EAAEC,QAAQ,CAAA,EAAEC,UAAU,CAAA,EAAsB,EAAE;IACpF,qBACE,MAACV,KAAK;QAACW,OAAO,EAAE,CAAC;QAAEC,EAAE,EAAE,CAAC;;YACrBJ,QAAQ,CAACK,GAAG,CAAC,CAACC,OAAO,EAAEC,KAAK,iBAC3B,MAACZ,GAAG;oBAAaa,OAAO,EAAC,MAAM;;sCAC7B,KAACf,SAAS;4BACRgB,SAAS;4BACTC,KAAK,EAAC,iBAAiB;4BACvBC,KAAK,EAAEL,OAAO;4BACdM,UAAU,EAAE;gCACVC,QAAQ,EAAEX,UAAU;6BACrB;4BACDD,QAAQ,EAAE,CAACa,CAAC,GAAK;gCACf,MAAMC,WAAW,GAAGlB,OAAO,CAACG,QAAQ,EAAE,CAACgB,KAAK,GAAK;oCAC/CA,KAAK,CAACT,KAAK,CAAC,GAAGO,CAAC,CAACG,MAAM,CAACN,KAAK,CAAC;gCAChC,CAAC,CAAC,AAAC;gCACHV,QAAQ,CAACc,WAAW,CAAC,CAAC;4BACxB,CAAC;0BACD;sCACF,KAACnB,UAAU;4BACTsB,OAAO,EAAE,IAAM;gCACb,MAAMH,WAAW,GAAGlB,OAAO,CAACG,QAAQ,EAAE,CAACgB,KAAK,GAAK;oCAC/CA,KAAK,CAACG,MAAM,CAACZ,KAAK,EAAE,CAAC,CAAC,CAAC;gCACzB,CAAC,CAAC,AAAC;gCACHN,QAAQ,CAACc,WAAW,CAAC,CAAC;4BACxB,CAAC;4BACDK,QAAQ,EAAElB,UAAU;sCAEpB,cAAA,KAACJ,SAAS,KAAG;0BACF;;mBAzBLS,KAAK,CA0BT,AACP,CAAC;0BACF,KAACZ,GAAG;0BACF,cAAA,KAACD,MAAM;oBACLe,SAAS,EAAE,KAAK;oBAChBY,KAAK,EAAC,WAAW;oBACjBC,OAAO,EAAC,UAAU;oBAClBJ,OAAO,EAAE,IAAM;wBACb,MAAMH,WAAW,GAAGlB,OAAO,CAACG,QAAQ,EAAE,CAACgB,KAAK,GAAK;4BAC/CA,KAAK,CAACO,IAAI,CAAC,EAAE,CAAC,CAAC;wBACjB,CAAC,CAAC,AAAC;wBACHtB,QAAQ,CAACc,WAAW,CAAC,CAAC;oBACxB,CAAC;oBACDK,QAAQ,EAAElB,UAAU;8BACrB,qBAED;kBAAS;cACL;;MACA,CACR;AACJ,CAAC"}
|