@perses-dev/prometheus-plugin 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59
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 +10 -8
- package/dist/cjs/components/index.js +10 -8
- package/dist/cjs/index.js +33 -19
- package/dist/cjs/model/index.js +14 -13
- package/dist/cjs/model/parse-sample-values.js +6 -2
- package/dist/cjs/model/prometheus-client.js +43 -8
- package/dist/cjs/model/prometheus-selectors.js +12 -4
- package/dist/cjs/model/time.js +15 -9
- package/dist/cjs/plugins/MatcherEditor.js +14 -12
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +610 -0
- package/dist/cjs/plugins/prometheus-datasource.js +59 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQuery.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +49 -24
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +44 -24
- package/dist/cjs/plugins/prometheus-time-series-query/index.js +10 -8
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +44 -11
- package/dist/cjs/plugins/prometheus-variables.js +69 -63
- 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 +13 -7
- package/dist/components/PromQL.d.ts +2 -3
- package/dist/components/PromQL.d.ts.map +1 -1
- package/dist/components/PromQL.js +1 -1
- 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/api-types.d.ts +11 -11
- package/dist/model/api-types.d.ts.map +1 -1
- package/dist/model/api-types.js.map +1 -1
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +0 -1
- package/dist/model/index.js.map +1 -1
- package/dist/model/parse-sample-values.d.ts +1 -1
- package/dist/model/parse-sample-values.d.ts.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 +27 -3
- package/dist/model/prometheus-client.js.map +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/model/time.js +2 -2
- package/dist/model/time.js.map +1 -1
- package/dist/plugins/MatcherEditor.d.ts +2 -3
- package/dist/plugins/MatcherEditor.d.ts.map +1 -1
- package/dist/plugins/MatcherEditor.js +1 -1
- package/dist/plugins/MatcherEditor.js.map +1 -1
- package/dist/plugins/{PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts → PrometheusDatasourceEditor.d.ts} +1 -2
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/PrometheusDatasourceEditor.js +556 -0
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +2 -7
- package/dist/plugins/prometheus-datasource.d.ts.map +1 -1
- package/dist/plugins/prometheus-datasource.js +55 -6
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- 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 +1 -2
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +41 -18
- 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 +37 -19
- 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 +11 -2
- 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 +38 -10
- 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 +4 -4
- 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 +3 -1
- package/dist/plugins/prometheus-time-series-query/time-series-query-model.js.map +1 -1
- package/dist/plugins/prometheus-variables.d.ts.map +1 -1
- package/dist/plugins/prometheus-variables.js +37 -37
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/types.d.ts +12 -5
- 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.d.ts +2 -2
- package/dist/plugins/variable.d.ts.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 +2 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +4 -4
- package/dist/utils/utils.js.map +1 -1
- package/package.json +6 -6
- package/dist/cjs/model/templating.js +0 -26
- package/dist/cjs/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +0 -392
- package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +0 -29
- package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +0 -16
- package/dist/model/templating.d.ts +0 -6
- package/dist/model/templating.d.ts.map +0 -1
- package/dist/model/templating.js +0 -20
- package/dist/model/templating.js.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js +0 -342
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.js.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts +0 -3
- package/dist/plugins/PrometheusDatasourceEditor/index.d.ts.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/index.js +0 -16
- package/dist/plugins/PrometheusDatasourceEditor/index.js.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts +0 -20
- package/dist/plugins/PrometheusDatasourceEditor/types.d.ts.map +0 -1
- package/dist/plugins/PrometheusDatasourceEditor/types.js +0 -15
- package/dist/plugins/PrometheusDatasourceEditor/types.js.map +0 -1
|
@@ -0,0 +1,610 @@
|
|
|
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
|
+
__proto__: null
|
|
60
|
+
};
|
|
61
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
62
|
+
for(var key in obj){
|
|
63
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
64
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
65
|
+
if (desc && (desc.get || desc.set)) {
|
|
66
|
+
Object.defineProperty(newObj, key, desc);
|
|
67
|
+
} else {
|
|
68
|
+
newObj[key] = obj[key];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
newObj.default = obj;
|
|
73
|
+
if (cache) {
|
|
74
|
+
cache.set(obj, newObj);
|
|
75
|
+
}
|
|
76
|
+
return newObj;
|
|
77
|
+
}
|
|
78
|
+
function PrometheusDatasourceEditor(props) {
|
|
79
|
+
var _value_proxy, _value_proxy1, _value_proxy2;
|
|
80
|
+
const { value, onChange, isReadonly } = props;
|
|
81
|
+
const strDirect = 'Direct access';
|
|
82
|
+
const strProxy = 'Proxy';
|
|
83
|
+
// utilitary function used for headers when renaming a property
|
|
84
|
+
// -> TODO it would be cleaner to manipulate headers as an intermediary list instead, to avoid doing this.
|
|
85
|
+
const buildNewHeaders = (oldHeaders, oldName, newName)=>{
|
|
86
|
+
if (oldHeaders === undefined) return oldHeaders;
|
|
87
|
+
const keys = Object.keys(oldHeaders);
|
|
88
|
+
const newHeaders = keys.reduce((acc, val)=>{
|
|
89
|
+
if (val === oldName) {
|
|
90
|
+
acc[newName] = oldHeaders[oldName] || '';
|
|
91
|
+
} else {
|
|
92
|
+
acc[val] = oldHeaders[val] || '';
|
|
93
|
+
}
|
|
94
|
+
return acc;
|
|
95
|
+
}, {});
|
|
96
|
+
return {
|
|
97
|
+
...newHeaders
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
const tabs = [
|
|
101
|
+
{
|
|
102
|
+
label: strDirect,
|
|
103
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
104
|
+
name: "URL",
|
|
105
|
+
render: ({ field, fieldState })=>{
|
|
106
|
+
var _fieldState_error;
|
|
107
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
108
|
+
...field,
|
|
109
|
+
fullWidth: true,
|
|
110
|
+
label: "URL",
|
|
111
|
+
value: value.directUrl || '',
|
|
112
|
+
error: !!fieldState.error,
|
|
113
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
114
|
+
InputProps: {
|
|
115
|
+
readOnly: isReadonly
|
|
116
|
+
},
|
|
117
|
+
InputLabelProps: {
|
|
118
|
+
shrink: isReadonly ? true : undefined
|
|
119
|
+
},
|
|
120
|
+
onChange: (e)=>{
|
|
121
|
+
field.onChange(e);
|
|
122
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
123
|
+
draft.directUrl = e.target.value;
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: strProxy,
|
|
132
|
+
content: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
133
|
+
children: [
|
|
134
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
135
|
+
name: "URL",
|
|
136
|
+
render: ({ field, fieldState })=>{
|
|
137
|
+
var _value_proxy, _fieldState_error;
|
|
138
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
139
|
+
...field,
|
|
140
|
+
fullWidth: true,
|
|
141
|
+
label: "URL",
|
|
142
|
+
value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.url) || '',
|
|
143
|
+
error: !!fieldState.error,
|
|
144
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
145
|
+
InputProps: {
|
|
146
|
+
readOnly: isReadonly
|
|
147
|
+
},
|
|
148
|
+
InputLabelProps: {
|
|
149
|
+
shrink: isReadonly ? true : undefined
|
|
150
|
+
},
|
|
151
|
+
onChange: (e)=>{
|
|
152
|
+
field.onChange(e);
|
|
153
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
154
|
+
if (draft.proxy !== undefined) {
|
|
155
|
+
draft.proxy.spec.url = e.target.value;
|
|
156
|
+
}
|
|
157
|
+
}));
|
|
158
|
+
},
|
|
159
|
+
sx: {
|
|
160
|
+
mb: 2
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
166
|
+
variant: "h4",
|
|
167
|
+
mb: 2,
|
|
168
|
+
children: "Allowed endpoints"
|
|
169
|
+
}),
|
|
170
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
171
|
+
container: true,
|
|
172
|
+
spacing: 2,
|
|
173
|
+
mb: 2,
|
|
174
|
+
children: [
|
|
175
|
+
((_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)=>{
|
|
176
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
177
|
+
children: [
|
|
178
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
179
|
+
item: true,
|
|
180
|
+
xs: 8,
|
|
181
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
182
|
+
name: `Endpoint pattern ${i}`,
|
|
183
|
+
render: ({ field, fieldState })=>{
|
|
184
|
+
var _fieldState_error;
|
|
185
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
186
|
+
...field,
|
|
187
|
+
fullWidth: true,
|
|
188
|
+
label: "Endpoint pattern",
|
|
189
|
+
value: endpointPattern,
|
|
190
|
+
error: !!fieldState.error,
|
|
191
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
192
|
+
InputProps: {
|
|
193
|
+
readOnly: isReadonly
|
|
194
|
+
},
|
|
195
|
+
InputLabelProps: {
|
|
196
|
+
shrink: isReadonly ? true : undefined
|
|
197
|
+
},
|
|
198
|
+
onChange: (e)=>{
|
|
199
|
+
field.onChange(e);
|
|
200
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
201
|
+
if (draft.proxy !== undefined) {
|
|
202
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
203
|
+
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)=>{
|
|
204
|
+
if (i === itemIndex) {
|
|
205
|
+
return {
|
|
206
|
+
endpointPattern: e.target.value,
|
|
207
|
+
method: item.method
|
|
208
|
+
};
|
|
209
|
+
} else {
|
|
210
|
+
return item;
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
})
|
|
219
|
+
}),
|
|
220
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
221
|
+
item: true,
|
|
222
|
+
xs: 3,
|
|
223
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
224
|
+
name: `Method ${i}`,
|
|
225
|
+
render: ({ field, fieldState })=>{
|
|
226
|
+
var _fieldState_error;
|
|
227
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
228
|
+
...field,
|
|
229
|
+
select: true,
|
|
230
|
+
fullWidth: true,
|
|
231
|
+
label: "Method",
|
|
232
|
+
value: method,
|
|
233
|
+
error: !!fieldState.error,
|
|
234
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
235
|
+
InputProps: {
|
|
236
|
+
readOnly: isReadonly
|
|
237
|
+
},
|
|
238
|
+
InputLabelProps: {
|
|
239
|
+
shrink: isReadonly ? true : undefined
|
|
240
|
+
},
|
|
241
|
+
onChange: (e)=>{
|
|
242
|
+
field.onChange(e);
|
|
243
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
244
|
+
if (draft.proxy !== undefined) {
|
|
245
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
246
|
+
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)=>{
|
|
247
|
+
if (i === itemIndex) {
|
|
248
|
+
return {
|
|
249
|
+
endpointPattern: item.endpointPattern,
|
|
250
|
+
method: e.target.value
|
|
251
|
+
};
|
|
252
|
+
} else {
|
|
253
|
+
return item;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}));
|
|
258
|
+
},
|
|
259
|
+
children: [
|
|
260
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
261
|
+
value: "GET",
|
|
262
|
+
children: "GET"
|
|
263
|
+
}),
|
|
264
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
265
|
+
value: "POST",
|
|
266
|
+
children: "POST"
|
|
267
|
+
}),
|
|
268
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
269
|
+
value: "PUT",
|
|
270
|
+
children: "PUT"
|
|
271
|
+
}),
|
|
272
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
273
|
+
value: "PATCH",
|
|
274
|
+
children: "PATCH"
|
|
275
|
+
}),
|
|
276
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
277
|
+
value: "DELETE",
|
|
278
|
+
children: "DELETE"
|
|
279
|
+
})
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
})
|
|
284
|
+
}),
|
|
285
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
286
|
+
item: true,
|
|
287
|
+
xs: 1,
|
|
288
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
289
|
+
name: `Remove Endpoint ${i}`,
|
|
290
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
291
|
+
...field,
|
|
292
|
+
disabled: isReadonly,
|
|
293
|
+
// Remove the given allowed endpoint from the list
|
|
294
|
+
onClick: (e)=>{
|
|
295
|
+
field.onChange(e);
|
|
296
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
297
|
+
if (draft.proxy !== undefined) {
|
|
298
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
299
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
300
|
+
...((_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.filter((item, itemIndex)=>{
|
|
301
|
+
return itemIndex !== i;
|
|
302
|
+
})) || []
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
}));
|
|
306
|
+
},
|
|
307
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
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
|
+
return /*#__PURE__*/ (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
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
403
|
+
...field,
|
|
404
|
+
fullWidth: true,
|
|
405
|
+
label: "Header value",
|
|
406
|
+
value: (_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : (_value_proxy_spec_headers = _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 })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
436
|
+
...field,
|
|
437
|
+
disabled: isReadonly,
|
|
438
|
+
// Remove the given header from the list
|
|
439
|
+
onClick: (e)=>{
|
|
440
|
+
var _value_proxy;
|
|
441
|
+
field.onChange(e);
|
|
442
|
+
const newHeaders = {
|
|
443
|
+
...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
|
|
444
|
+
};
|
|
445
|
+
delete newHeaders[headerName];
|
|
446
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
447
|
+
if (draft.proxy !== undefined) {
|
|
448
|
+
draft.proxy.spec.headers = newHeaders;
|
|
449
|
+
}
|
|
450
|
+
}));
|
|
451
|
+
},
|
|
452
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
453
|
+
})
|
|
454
|
+
})
|
|
455
|
+
})
|
|
456
|
+
]
|
|
457
|
+
}, i);
|
|
458
|
+
}),
|
|
459
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
460
|
+
item: true,
|
|
461
|
+
xs: 12,
|
|
462
|
+
sx: {
|
|
463
|
+
paddingTop: '0px !important',
|
|
464
|
+
paddingLeft: '5px !important'
|
|
465
|
+
},
|
|
466
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
467
|
+
disabled: isReadonly,
|
|
468
|
+
// Add a new (empty) header to the list
|
|
469
|
+
onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
470
|
+
if (draft.proxy !== undefined) {
|
|
471
|
+
draft.proxy.spec.headers = {
|
|
472
|
+
...draft.proxy.spec.headers,
|
|
473
|
+
'': ''
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
})),
|
|
477
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
478
|
+
})
|
|
479
|
+
})
|
|
480
|
+
]
|
|
481
|
+
}),
|
|
482
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
483
|
+
name: "Secret",
|
|
484
|
+
render: ({ field, fieldState })=>{
|
|
485
|
+
var _value_proxy, _fieldState_error;
|
|
486
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
487
|
+
...field,
|
|
488
|
+
fullWidth: true,
|
|
489
|
+
label: "Secret",
|
|
490
|
+
value: ((_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.secret) || '',
|
|
491
|
+
error: !!fieldState.error,
|
|
492
|
+
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
493
|
+
InputProps: {
|
|
494
|
+
readOnly: isReadonly
|
|
495
|
+
},
|
|
496
|
+
InputLabelProps: {
|
|
497
|
+
shrink: isReadonly ? true : undefined
|
|
498
|
+
},
|
|
499
|
+
onChange: (e)=>{
|
|
500
|
+
field.onChange(e);
|
|
501
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
502
|
+
if (draft.proxy !== undefined) {
|
|
503
|
+
draft.proxy.spec.secret = e.target.value;
|
|
504
|
+
}
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
]
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
];
|
|
514
|
+
// Use of findIndex instead of providing hardcoded values to avoid desynchronisatio or
|
|
515
|
+
// bug in case the tabs get eventually swapped in the future.
|
|
516
|
+
const directModeId = tabs.findIndex((tab)=>tab.label == strDirect);
|
|
517
|
+
const proxyModeId = tabs.findIndex((tab)=>tab.label == strProxy);
|
|
518
|
+
// In "update datasource" case, set defaultTab to the mode that this datasource is currently relying on.
|
|
519
|
+
// Otherwise (create datasource), set defaultTab to Direct access.
|
|
520
|
+
const defaultTab = value.proxy ? proxyModeId : directModeId;
|
|
521
|
+
const initialSpecDirect = {
|
|
522
|
+
directUrl: ''
|
|
523
|
+
};
|
|
524
|
+
const initialSpecProxy = {
|
|
525
|
+
proxy: {
|
|
526
|
+
kind: 'HTTPProxy',
|
|
527
|
+
spec: {
|
|
528
|
+
allowedEndpoints: [
|
|
529
|
+
// list of standard endpoints suggested by default
|
|
530
|
+
{
|
|
531
|
+
endpointPattern: '/api/v1/labels',
|
|
532
|
+
method: 'POST'
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
endpointPattern: '/api/v1/series',
|
|
536
|
+
method: 'POST'
|
|
537
|
+
},
|
|
538
|
+
{
|
|
539
|
+
endpointPattern: '/api/v1/metadata',
|
|
540
|
+
method: 'GET'
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
endpointPattern: '/api/v1/query',
|
|
544
|
+
method: 'POST'
|
|
545
|
+
},
|
|
546
|
+
{
|
|
547
|
+
endpointPattern: '/api/v1/query_range',
|
|
548
|
+
method: 'POST'
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
endpointPattern: '/api/v1/label/([a-zA-Z0-9_-]+)/values',
|
|
552
|
+
method: 'GET'
|
|
553
|
+
}
|
|
554
|
+
],
|
|
555
|
+
url: ''
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
// For better user experience, save previous states in mind for both mode.
|
|
560
|
+
// This avoids losing everything when the user changes their mind back.
|
|
561
|
+
const [previousSpecDirect, setPreviousSpecDirect] = (0, _react.useState)(initialSpecDirect);
|
|
562
|
+
const [previousSpecProxy, setPreviousSpecProxy] = (0, _react.useState)(initialSpecProxy);
|
|
563
|
+
// When changing mode, remove previous mode's config + append default values for the new mode.
|
|
564
|
+
const handleModeChange = (v)=>{
|
|
565
|
+
var _tabs_v, _tabs_v1;
|
|
566
|
+
if (((_tabs_v = tabs[v]) === null || _tabs_v === void 0 ? void 0 : _tabs_v.label) == strDirect) {
|
|
567
|
+
setPreviousSpecProxy(value);
|
|
568
|
+
onChange(previousSpecDirect);
|
|
569
|
+
} else if (((_tabs_v1 = tabs[v]) === null || _tabs_v1 === void 0 ? void 0 : _tabs_v1.label) == strProxy) {
|
|
570
|
+
setPreviousSpecDirect(value);
|
|
571
|
+
onChange(previousSpecProxy);
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
575
|
+
children: [
|
|
576
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
577
|
+
variant: "h4",
|
|
578
|
+
mb: 2,
|
|
579
|
+
children: "General Settings"
|
|
580
|
+
}),
|
|
581
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
582
|
+
fullWidth: true,
|
|
583
|
+
label: "Scrape Interval",
|
|
584
|
+
value: value.scrapeInterval || '',
|
|
585
|
+
placeholder: `Default: ${_types.DEFAULT_SCRAPE_INTERVAL}`,
|
|
586
|
+
InputProps: {
|
|
587
|
+
readOnly: isReadonly
|
|
588
|
+
},
|
|
589
|
+
InputLabelProps: {
|
|
590
|
+
shrink: isReadonly ? true : undefined
|
|
591
|
+
},
|
|
592
|
+
onChange: (e)=>onChange({
|
|
593
|
+
...value,
|
|
594
|
+
scrapeInterval: e.target.value
|
|
595
|
+
})
|
|
596
|
+
}),
|
|
597
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
598
|
+
variant: "h4",
|
|
599
|
+
mt: 2,
|
|
600
|
+
children: "HTTP Settings"
|
|
601
|
+
}),
|
|
602
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.OptionsEditorRadios, {
|
|
603
|
+
isReadonly: isReadonly,
|
|
604
|
+
tabs: tabs,
|
|
605
|
+
defaultTab: defaultTab,
|
|
606
|
+
onModeChange: handleModeChange
|
|
607
|
+
})
|
|
608
|
+
]
|
|
609
|
+
});
|
|
610
|
+
}
|