@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-2-2767e21 → 0.0.0-snapshot-scatter-chart-embed-8efdfab
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/PromQL.js +9 -7
- package/dist/cjs/components/index.js +10 -8
- package/dist/cjs/index.js +33 -19
- package/dist/cjs/model/index.js +15 -13
- package/dist/cjs/model/parse-sample-values.js +6 -2
- package/dist/cjs/model/prometheus-client.js +40 -5
- package/dist/cjs/model/prometheus-selectors.js +12 -4
- package/dist/cjs/model/templating.js +7 -5
- package/dist/cjs/model/time.js +14 -8
- package/dist/cjs/plugins/MatcherEditor.js +13 -11
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +612 -0
- package/dist/cjs/plugins/prometheus-datasource.js +58 -6
- package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +88 -0
- package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +123 -0
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +48 -50
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +41 -21
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +42 -9
- package/dist/cjs/plugins/prometheus-variables.js +60 -54
- package/dist/cjs/plugins/types.js +7 -0
- package/dist/cjs/plugins/variable.js +9 -7
- package/dist/cjs/utils/index.js +10 -8
- package/dist/cjs/utils/utils.js +12 -6
- package/dist/components/PromQL.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/parse-sample-values.js.map +1 -1
- package/dist/model/prometheus-client.d.ts +4 -0
- package/dist/model/prometheus-client.d.ts.map +1 -1
- package/dist/model/prometheus-client.js +24 -0
- package/dist/model/prometheus-client.js.map +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/model/templating.js.map +1 -1
- package/dist/model/time.js +1 -1
- package/dist/model/time.js.map +1 -1
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor.d.ts +9 -0
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor.js +560 -0
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +1 -5
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +56 -6
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +80 -0
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +21 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +115 -0
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +1 -0
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +43 -47
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.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 +34 -16
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/index.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +10 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js +36 -8
- package/dist/plugins/prometheus-time-series-query/query-editor-model.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts +2 -2
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
- package/dist/plugins/prometheus-variables.js +27 -27
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/types.d.ts +9 -2
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js +1 -1
- package/dist/plugins/types.js.map +1 -1
- package/dist/plugins/variable.js +2 -2
- package/dist/plugins/variable.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +3 -3
- package/dist/utils/utils.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,612 @@
|
|
|
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: function() {
|
|
20
|
+
return PrometheusDatasourceEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
+
const _material = require("@mui/material");
|
|
26
|
+
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
27
|
+
const _immer = require("immer");
|
|
28
|
+
const _reacthookform = require("react-hook-form");
|
|
29
|
+
const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
|
|
30
|
+
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
31
|
+
const _types = require("./types");
|
|
32
|
+
function _interop_require_default(obj) {
|
|
33
|
+
return obj && obj.__esModule ? obj : {
|
|
34
|
+
default: obj
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
38
|
+
if (typeof WeakMap !== "function") return null;
|
|
39
|
+
var cacheBabelInterop = new WeakMap();
|
|
40
|
+
var cacheNodeInterop = new WeakMap();
|
|
41
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
42
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
43
|
+
})(nodeInterop);
|
|
44
|
+
}
|
|
45
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
46
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
47
|
+
return obj;
|
|
48
|
+
}
|
|
49
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
50
|
+
return {
|
|
51
|
+
default: obj
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
55
|
+
if (cache && cache.has(obj)) {
|
|
56
|
+
return cache.get(obj);
|
|
57
|
+
}
|
|
58
|
+
var newObj = {};
|
|
59
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
|
+
for(var key in obj){
|
|
61
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
62
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
63
|
+
if (desc && (desc.get || desc.set)) {
|
|
64
|
+
Object.defineProperty(newObj, key, desc);
|
|
65
|
+
} else {
|
|
66
|
+
newObj[key] = obj[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
newObj.default = obj;
|
|
71
|
+
if (cache) {
|
|
72
|
+
cache.set(obj, newObj);
|
|
73
|
+
}
|
|
74
|
+
return newObj;
|
|
75
|
+
}
|
|
76
|
+
function PrometheusDatasourceEditor(props) {
|
|
77
|
+
var _value_proxy, _value_proxy1, _value_proxy2;
|
|
78
|
+
const { value , onChange , isReadonly } = props;
|
|
79
|
+
const strDirect = 'Direct access';
|
|
80
|
+
const strProxy = 'Proxy';
|
|
81
|
+
// utilitary function used for headers when renaming a property
|
|
82
|
+
// -> TODO it would be cleaner to manipulate headers as an intermediary list instead, to avoid doing this.
|
|
83
|
+
const buildNewHeaders = (oldHeaders, oldName, newName)=>{
|
|
84
|
+
if (oldHeaders === undefined) return oldHeaders;
|
|
85
|
+
const keys = Object.keys(oldHeaders);
|
|
86
|
+
const newHeaders = keys.reduce((acc, val)=>{
|
|
87
|
+
if (val === oldName) {
|
|
88
|
+
acc[newName] = oldHeaders[oldName] || '';
|
|
89
|
+
} else {
|
|
90
|
+
acc[val] = oldHeaders[val] || '';
|
|
91
|
+
}
|
|
92
|
+
return acc;
|
|
93
|
+
}, {});
|
|
94
|
+
return {
|
|
95
|
+
...newHeaders
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
const tabs = [
|
|
99
|
+
{
|
|
100
|
+
label: strDirect,
|
|
101
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
102
|
+
name: "URL",
|
|
103
|
+
render: ({ field , fieldState })=>{
|
|
104
|
+
var _fieldState_error;
|
|
105
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
106
|
+
...field,
|
|
107
|
+
fullWidth: true,
|
|
108
|
+
label: "URL",
|
|
109
|
+
value: value.directUrl || '',
|
|
110
|
+
error: !!fieldState.error,
|
|
111
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
112
|
+
InputProps: {
|
|
113
|
+
readOnly: isReadonly
|
|
114
|
+
},
|
|
115
|
+
InputLabelProps: {
|
|
116
|
+
shrink: isReadonly ? true : undefined
|
|
117
|
+
},
|
|
118
|
+
onChange: (e)=>{
|
|
119
|
+
field.onChange(e);
|
|
120
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
121
|
+
draft.directUrl = e.target.value;
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
label: strProxy,
|
|
130
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
131
|
+
children: [
|
|
132
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
133
|
+
name: "URL",
|
|
134
|
+
render: ({ field , fieldState })=>{
|
|
135
|
+
var _value_proxy, _fieldState_error;
|
|
136
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
137
|
+
...field,
|
|
138
|
+
fullWidth: true,
|
|
139
|
+
label: "URL",
|
|
140
|
+
value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.url) || '',
|
|
141
|
+
error: !!fieldState.error,
|
|
142
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
143
|
+
InputProps: {
|
|
144
|
+
readOnly: isReadonly
|
|
145
|
+
},
|
|
146
|
+
InputLabelProps: {
|
|
147
|
+
shrink: isReadonly ? true : undefined
|
|
148
|
+
},
|
|
149
|
+
onChange: (e)=>{
|
|
150
|
+
field.onChange(e);
|
|
151
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
152
|
+
if (draft.proxy !== undefined) {
|
|
153
|
+
draft.proxy.spec.url = e.target.value;
|
|
154
|
+
}
|
|
155
|
+
}));
|
|
156
|
+
},
|
|
157
|
+
sx: {
|
|
158
|
+
mb: 2
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}),
|
|
163
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
164
|
+
variant: "h4",
|
|
165
|
+
mb: 2,
|
|
166
|
+
children: "Allowed endpoints"
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
169
|
+
container: true,
|
|
170
|
+
spacing: 2,
|
|
171
|
+
mb: 2,
|
|
172
|
+
children: [
|
|
173
|
+
((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.allowedEndpoints) && ((_value_proxy1 = value.proxy) === null || _value_proxy1 === void 0 ? void 0 : _value_proxy1.spec.allowedEndpoints.length) != 0 ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern , method }, i)=>{
|
|
174
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
175
|
+
children: [
|
|
176
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
177
|
+
item: true,
|
|
178
|
+
xs: 8,
|
|
179
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
180
|
+
name: `Endpoint pattern ${i}`,
|
|
181
|
+
render: ({ field , fieldState })=>{
|
|
182
|
+
var _fieldState_error;
|
|
183
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
184
|
+
...field,
|
|
185
|
+
fullWidth: true,
|
|
186
|
+
label: "Endpoint pattern",
|
|
187
|
+
value: endpointPattern,
|
|
188
|
+
error: !!fieldState.error,
|
|
189
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
190
|
+
InputProps: {
|
|
191
|
+
readOnly: isReadonly
|
|
192
|
+
},
|
|
193
|
+
InputLabelProps: {
|
|
194
|
+
shrink: isReadonly ? true : undefined
|
|
195
|
+
},
|
|
196
|
+
onChange: (e)=>{
|
|
197
|
+
field.onChange(e);
|
|
198
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
199
|
+
if (draft.proxy !== undefined) {
|
|
200
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
201
|
+
draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
|
|
202
|
+
if (i === itemIndex) {
|
|
203
|
+
return {
|
|
204
|
+
endpointPattern: e.target.value,
|
|
205
|
+
method: item.method
|
|
206
|
+
};
|
|
207
|
+
} else {
|
|
208
|
+
return item;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}),
|
|
218
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
219
|
+
item: true,
|
|
220
|
+
xs: 3,
|
|
221
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
222
|
+
name: `Method ${i}`,
|
|
223
|
+
render: ({ field , fieldState })=>{
|
|
224
|
+
var _fieldState_error;
|
|
225
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
226
|
+
...field,
|
|
227
|
+
select: true,
|
|
228
|
+
fullWidth: true,
|
|
229
|
+
label: "Method",
|
|
230
|
+
value: method,
|
|
231
|
+
error: !!fieldState.error,
|
|
232
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
233
|
+
InputProps: {
|
|
234
|
+
readOnly: isReadonly
|
|
235
|
+
},
|
|
236
|
+
InputLabelProps: {
|
|
237
|
+
shrink: isReadonly ? true : undefined
|
|
238
|
+
},
|
|
239
|
+
onChange: (e)=>{
|
|
240
|
+
field.onChange(e);
|
|
241
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
242
|
+
if (draft.proxy !== undefined) {
|
|
243
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
244
|
+
draft.proxy.spec.allowedEndpoints = (_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.map((item, itemIndex)=>{
|
|
245
|
+
if (i === itemIndex) {
|
|
246
|
+
return {
|
|
247
|
+
endpointPattern: item.endpointPattern,
|
|
248
|
+
method: e.target.value
|
|
249
|
+
};
|
|
250
|
+
} else {
|
|
251
|
+
return item;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}));
|
|
256
|
+
},
|
|
257
|
+
children: [
|
|
258
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
259
|
+
value: "GET",
|
|
260
|
+
children: "GET"
|
|
261
|
+
}),
|
|
262
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
263
|
+
value: "POST",
|
|
264
|
+
children: "POST"
|
|
265
|
+
}),
|
|
266
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
267
|
+
value: "PUT",
|
|
268
|
+
children: "PUT"
|
|
269
|
+
}),
|
|
270
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
271
|
+
value: "PATCH",
|
|
272
|
+
children: "PATCH"
|
|
273
|
+
}),
|
|
274
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
275
|
+
value: "DELETE",
|
|
276
|
+
children: "DELETE"
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
}),
|
|
283
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
284
|
+
item: true,
|
|
285
|
+
xs: 1,
|
|
286
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
287
|
+
name: `Remove Endpoint ${i}`,
|
|
288
|
+
render: ({ field })=>{
|
|
289
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
290
|
+
...field,
|
|
291
|
+
disabled: isReadonly,
|
|
292
|
+
// Remove the given allowed endpoint from the list
|
|
293
|
+
onClick: (e)=>{
|
|
294
|
+
field.onChange(e);
|
|
295
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
296
|
+
if (draft.proxy !== undefined) {
|
|
297
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
298
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
299
|
+
...((_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.filter((item, itemIndex)=>{
|
|
300
|
+
return itemIndex !== i;
|
|
301
|
+
})) || []
|
|
302
|
+
];
|
|
303
|
+
}
|
|
304
|
+
}));
|
|
305
|
+
},
|
|
306
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
]
|
|
312
|
+
}, i);
|
|
313
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
314
|
+
item: true,
|
|
315
|
+
xs: 4,
|
|
316
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
317
|
+
sx: {
|
|
318
|
+
fontStyle: 'italic'
|
|
319
|
+
},
|
|
320
|
+
children: "None"
|
|
321
|
+
})
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
324
|
+
item: true,
|
|
325
|
+
xs: 12,
|
|
326
|
+
sx: {
|
|
327
|
+
paddingTop: '0px !important',
|
|
328
|
+
paddingLeft: '5px !important'
|
|
329
|
+
},
|
|
330
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
331
|
+
disabled: isReadonly,
|
|
332
|
+
// Add a new (empty) allowed endpoint to the list
|
|
333
|
+
onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
334
|
+
if (draft.proxy !== undefined) {
|
|
335
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
336
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
337
|
+
...(_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) !== null && _draft_proxy_spec_allowedEndpoints !== void 0 ? _draft_proxy_spec_allowedEndpoints : [],
|
|
338
|
+
{
|
|
339
|
+
endpointPattern: '',
|
|
340
|
+
method: ''
|
|
341
|
+
}
|
|
342
|
+
];
|
|
343
|
+
}
|
|
344
|
+
})),
|
|
345
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
346
|
+
})
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
}),
|
|
350
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
351
|
+
variant: "h4",
|
|
352
|
+
mb: 2,
|
|
353
|
+
children: "Request Headers"
|
|
354
|
+
}),
|
|
355
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
356
|
+
container: true,
|
|
357
|
+
spacing: 2,
|
|
358
|
+
mb: 2,
|
|
359
|
+
children: [
|
|
360
|
+
((_value_proxy2 = value.proxy) === null || _value_proxy2 === void 0 ? void 0 : _value_proxy2.spec.headers) && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
|
|
361
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
362
|
+
children: [
|
|
363
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
364
|
+
item: true,
|
|
365
|
+
xs: 4,
|
|
366
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
367
|
+
name: `Header name ${i}`,
|
|
368
|
+
render: ({ field , fieldState })=>{
|
|
369
|
+
var _fieldState_error;
|
|
370
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
371
|
+
...field,
|
|
372
|
+
fullWidth: true,
|
|
373
|
+
label: "Header name",
|
|
374
|
+
value: headerName,
|
|
375
|
+
error: !!fieldState.error,
|
|
376
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
377
|
+
InputProps: {
|
|
378
|
+
readOnly: isReadonly
|
|
379
|
+
},
|
|
380
|
+
InputLabelProps: {
|
|
381
|
+
shrink: isReadonly ? true : undefined
|
|
382
|
+
},
|
|
383
|
+
onChange: (e)=>{
|
|
384
|
+
field.onChange(e);
|
|
385
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
386
|
+
if (draft.proxy !== undefined) {
|
|
387
|
+
draft.proxy.spec.headers = buildNewHeaders(draft.proxy.spec.headers, headerName, e.target.value);
|
|
388
|
+
}
|
|
389
|
+
}));
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
})
|
|
394
|
+
}),
|
|
395
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
396
|
+
item: true,
|
|
397
|
+
xs: 7,
|
|
398
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
399
|
+
name: `Header value ${i}`,
|
|
400
|
+
render: ({ field , fieldState })=>{
|
|
401
|
+
var _value_proxy_spec_headers, _value_proxy, _fieldState_error;
|
|
402
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
403
|
+
...field,
|
|
404
|
+
fullWidth: true,
|
|
405
|
+
label: "Header value",
|
|
406
|
+
value: (_value_proxy_spec_headers = (_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers) === null || _value_proxy_spec_headers === void 0 ? void 0 : _value_proxy_spec_headers[headerName],
|
|
407
|
+
error: !!fieldState.error,
|
|
408
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
409
|
+
InputProps: {
|
|
410
|
+
readOnly: isReadonly
|
|
411
|
+
},
|
|
412
|
+
InputLabelProps: {
|
|
413
|
+
shrink: isReadonly ? true : undefined
|
|
414
|
+
},
|
|
415
|
+
onChange: (e)=>{
|
|
416
|
+
field.onChange(e);
|
|
417
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
418
|
+
if (draft.proxy !== undefined) {
|
|
419
|
+
draft.proxy.spec.headers = {
|
|
420
|
+
...draft.proxy.spec.headers,
|
|
421
|
+
[headerName]: e.target.value
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
}));
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
})
|
|
429
|
+
}),
|
|
430
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
431
|
+
item: true,
|
|
432
|
+
xs: 1,
|
|
433
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
434
|
+
name: `Remove Header ${i}`,
|
|
435
|
+
render: ({ field })=>{
|
|
436
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
437
|
+
...field,
|
|
438
|
+
disabled: isReadonly,
|
|
439
|
+
// Remove the given header from the list
|
|
440
|
+
onClick: (e)=>{
|
|
441
|
+
var _value_proxy;
|
|
442
|
+
field.onChange(e);
|
|
443
|
+
const newHeaders = {
|
|
444
|
+
...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
|
|
445
|
+
};
|
|
446
|
+
delete newHeaders[headerName];
|
|
447
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
448
|
+
if (draft.proxy !== undefined) {
|
|
449
|
+
draft.proxy.spec.headers = newHeaders;
|
|
450
|
+
}
|
|
451
|
+
}));
|
|
452
|
+
},
|
|
453
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
})
|
|
457
|
+
})
|
|
458
|
+
]
|
|
459
|
+
}, i);
|
|
460
|
+
}),
|
|
461
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
462
|
+
item: true,
|
|
463
|
+
xs: 12,
|
|
464
|
+
sx: {
|
|
465
|
+
paddingTop: '0px !important',
|
|
466
|
+
paddingLeft: '5px !important'
|
|
467
|
+
},
|
|
468
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
469
|
+
disabled: isReadonly,
|
|
470
|
+
// Add a new (empty) header to the list
|
|
471
|
+
onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
472
|
+
if (draft.proxy !== undefined) {
|
|
473
|
+
draft.proxy.spec.headers = {
|
|
474
|
+
...draft.proxy.spec.headers,
|
|
475
|
+
'': ''
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
})),
|
|
479
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
480
|
+
})
|
|
481
|
+
})
|
|
482
|
+
]
|
|
483
|
+
}),
|
|
484
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
485
|
+
name: "Secret",
|
|
486
|
+
render: ({ field , fieldState })=>{
|
|
487
|
+
var _value_proxy, _fieldState_error;
|
|
488
|
+
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.TextField, {
|
|
489
|
+
...field,
|
|
490
|
+
fullWidth: true,
|
|
491
|
+
label: "Secret",
|
|
492
|
+
value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.secret) || '',
|
|
493
|
+
error: !!fieldState.error,
|
|
494
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
495
|
+
InputProps: {
|
|
496
|
+
readOnly: isReadonly
|
|
497
|
+
},
|
|
498
|
+
InputLabelProps: {
|
|
499
|
+
shrink: isReadonly ? true : undefined
|
|
500
|
+
},
|
|
501
|
+
onChange: (e)=>{
|
|
502
|
+
field.onChange(e);
|
|
503
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
504
|
+
if (draft.proxy !== undefined) {
|
|
505
|
+
draft.proxy.spec.secret = e.target.value;
|
|
506
|
+
}
|
|
507
|
+
}));
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
})
|
|
512
|
+
]
|
|
513
|
+
})
|
|
514
|
+
}
|
|
515
|
+
];
|
|
516
|
+
// Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
|
|
517
|
+
// bug in case the tabs get eventually swapped in the future.
|
|
518
|
+
const directModeId = tabs.findIndex((tab)=>tab.label == strDirect);
|
|
519
|
+
const proxyModeId = tabs.findIndex((tab)=>tab.label == strProxy);
|
|
520
|
+
// In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
|
|
521
|
+
// Otherwise (create datasource), set defaultTab to Direct access.
|
|
522
|
+
const defaultTab = value.proxy ? proxyModeId : directModeId;
|
|
523
|
+
const initialSpecDirect = {
|
|
524
|
+
directUrl: ''
|
|
525
|
+
};
|
|
526
|
+
const initialSpecProxy = {
|
|
527
|
+
proxy: {
|
|
528
|
+
kind: 'HTTPProxy',
|
|
529
|
+
spec: {
|
|
530
|
+
allowedEndpoints: [
|
|
531
|
+
// list of standard endpoints suggested by default
|
|
532
|
+
{
|
|
533
|
+
endpointPattern: '/api/v1/labels',
|
|
534
|
+
method: 'POST'
|
|
535
|
+
},
|
|
536
|
+
{
|
|
537
|
+
endpointPattern: '/api/v1/series',
|
|
538
|
+
method: 'POST'
|
|
539
|
+
},
|
|
540
|
+
{
|
|
541
|
+
endpointPattern: '/api/v1/metadata',
|
|
542
|
+
method: 'GET'
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
endpointPattern: '/api/v1/query',
|
|
546
|
+
method: 'POST'
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
endpointPattern: '/api/v1/query_range',
|
|
550
|
+
method: 'POST'
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
|
|
554
|
+
method: 'GET'
|
|
555
|
+
}
|
|
556
|
+
],
|
|
557
|
+
url: ''
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
// For better user experience, save previous states in mind for both mode.
|
|
562
|
+
// This avoids losing everything when the user changes their mind back.
|
|
563
|
+
const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
|
|
564
|
+
const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
|
|
565
|
+
// When changing mode, remove previous mode's config + append default values for the new mode.
|
|
566
|
+
const handleModeChange = (v)=>{
|
|
567
|
+
var _tabs_v, _tabs_v1;
|
|
568
|
+
if (((_tabs_v = tabs[v]) === null || _tabs_v === void 0 ? void 0 : _tabs_v.label) == strDirect) {
|
|
569
|
+
setPreviousSpecProxy(value);
|
|
570
|
+
onChange(previousSpecDirect);
|
|
571
|
+
} else if (((_tabs_v1 = tabs[v]) === null || _tabs_v1 === void 0 ? void 0 : _tabs_v1.label) == strProxy) {
|
|
572
|
+
setPreviousSpecDirect(value);
|
|
573
|
+
onChange(previousSpecProxy);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
577
|
+
children: [
|
|
578
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
579
|
+
variant: "h4",
|
|
580
|
+
mb: 2,
|
|
581
|
+
children: "General Settings"
|
|
582
|
+
}),
|
|
583
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
584
|
+
fullWidth: true,
|
|
585
|
+
label: "Scrape Interval",
|
|
586
|
+
value: value.scrapeInterval || '',
|
|
587
|
+
placeholder: `Default: ${_types.DEFAULT_SCRAPE_INTERVAL}`,
|
|
588
|
+
InputProps: {
|
|
589
|
+
readOnly: isReadonly
|
|
590
|
+
},
|
|
591
|
+
InputLabelProps: {
|
|
592
|
+
shrink: isReadonly ? true : undefined
|
|
593
|
+
},
|
|
594
|
+
onChange: (e)=>onChange({
|
|
595
|
+
...value,
|
|
596
|
+
scrapeInterval: e.target.value
|
|
597
|
+
})
|
|
598
|
+
}),
|
|
599
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
600
|
+
variant: "h4",
|
|
601
|
+
mt: 2,
|
|
602
|
+
children: "HTTP Settings"
|
|
603
|
+
}),
|
|
604
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.OptionsEditorRadios, {
|
|
605
|
+
isReadonly: isReadonly,
|
|
606
|
+
tabs: tabs,
|
|
607
|
+
defaultTab: defaultTab,
|
|
608
|
+
onModeChange: handleModeChange
|
|
609
|
+
})
|
|
610
|
+
]
|
|
611
|
+
});
|
|
612
|
+
}
|