@perses-dev/prometheus-plugin 0.40.0 → 0.41.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/{PrometheusDatasourceEditor/PrometheusDatasourceEditor.js → PrometheusDatasourceEditor.js} +204 -134
- package/dist/cjs/plugins/prometheus-datasource.js +2 -1
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +2 -2
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +2 -2
- package/dist/cjs/plugins/types.js +7 -0
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -0
- package/dist/plugins/{PrometheusDatasourceEditor/PrometheusDatasourceEditor.js → PrometheusDatasourceEditor.js} +205 -135
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -0
- package/dist/plugins/prometheus-datasource.d.ts +2 -8
- 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/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +1 -1
- package/dist/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js +1 -1
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/types.d.ts +21 -0
- 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/package.json +4 -4
- package/dist/cjs/plugins/PrometheusDatasourceEditor/index.js +0 -31
- package/dist/cjs/plugins/PrometheusDatasourceEditor/types.js +0 -23
- package/dist/plugins/PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts.map +0 -1
- 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 -22
- 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
- /package/dist/plugins/{PrometheusDatasourceEditor/PrometheusDatasourceEditor.d.ts → PrometheusDatasourceEditor.d.ts} +0 -0
|
@@ -24,6 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
|
|
|
24
24
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
25
|
const _material = require("@mui/material");
|
|
26
26
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
27
|
+
const _immer = require("immer");
|
|
27
28
|
const _Minus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Minus"));
|
|
28
29
|
const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
|
|
29
30
|
const _types = require("./types");
|
|
@@ -72,14 +73,12 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
72
73
|
return newObj;
|
|
73
74
|
}
|
|
74
75
|
function PrometheusDatasourceEditor(props) {
|
|
75
|
-
var _value_proxy, _value_proxy1, _value_proxy2, _value_proxy3;
|
|
76
|
+
var _value_proxy, _value_proxy1, _value_proxy2, _value_proxy3, _value_proxy4;
|
|
76
77
|
const { value , onChange , isReadonly } = props;
|
|
77
78
|
const strDirect = 'Direct access';
|
|
78
79
|
const strProxy = 'Proxy';
|
|
79
|
-
// TODO refactor with useImmer to avoid doing so much destructuring? feasibility & performances to be checked
|
|
80
80
|
// utilitary function used for headers when renaming a property
|
|
81
|
-
// -> TODO it would be cleaner to manipulate headers as
|
|
82
|
-
// This could be a pure frontend trick, but change in the backend datamodel should also be considered
|
|
81
|
+
// -> TODO it would be cleaner to manipulate headers as an intermediary list instead, to avoid doing this.
|
|
83
82
|
const buildNewHeaders = (oldHeaders, oldName, newName)=>{
|
|
84
83
|
if (oldHeaders === undefined) return oldHeaders;
|
|
85
84
|
const keys = Object.keys(oldHeaders);
|
|
@@ -109,10 +108,11 @@ function PrometheusDatasourceEditor(props) {
|
|
|
109
108
|
InputLabelProps: {
|
|
110
109
|
shrink: isReadonly ? true : undefined
|
|
111
110
|
},
|
|
112
|
-
onChange: (e)=>
|
|
113
|
-
|
|
114
|
-
directUrl
|
|
115
|
-
})
|
|
111
|
+
onChange: (e)=>{
|
|
112
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
113
|
+
draft.directUrl = e.target.value;
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
116
|
})
|
|
117
117
|
})
|
|
118
118
|
},
|
|
@@ -130,80 +130,180 @@ function PrometheusDatasourceEditor(props) {
|
|
|
130
130
|
InputLabelProps: {
|
|
131
131
|
shrink: isReadonly ? true : undefined
|
|
132
132
|
},
|
|
133
|
-
onChange: (e)=>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
proxy
|
|
137
|
-
...value.proxy,
|
|
138
|
-
spec: {
|
|
139
|
-
...value.proxy.spec,
|
|
140
|
-
url: e.target.value
|
|
141
|
-
}
|
|
142
|
-
}
|
|
133
|
+
onChange: (e)=>{
|
|
134
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
135
|
+
if (draft.proxy !== undefined) {
|
|
136
|
+
draft.proxy.spec.url = e.target.value;
|
|
143
137
|
}
|
|
144
|
-
})
|
|
138
|
+
}));
|
|
139
|
+
},
|
|
140
|
+
sx: {
|
|
141
|
+
mb: 2
|
|
142
|
+
}
|
|
145
143
|
}),
|
|
146
144
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
147
145
|
variant: "h4",
|
|
148
|
-
|
|
149
|
-
mb: 1,
|
|
146
|
+
mb: 2,
|
|
150
147
|
children: "Allowed endpoints"
|
|
151
148
|
}),
|
|
152
|
-
/*#__PURE__*/ (0, _jsxruntime.
|
|
149
|
+
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
153
150
|
container: true,
|
|
154
151
|
spacing: 2,
|
|
155
152
|
mb: 2,
|
|
156
|
-
children:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
153
|
+
children: [
|
|
154
|
+
((_value_proxy1 = value.proxy) === null || _value_proxy1 === void 0 ? void 0 : _value_proxy1.spec.allowedEndpoints) && ((_value_proxy2 = value.proxy) === null || _value_proxy2 === void 0 ? void 0 : _value_proxy2.spec.allowedEndpoints.length) != 0 ? value.proxy.spec.allowedEndpoints.map(({ endpointPattern , method }, i)=>{
|
|
155
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
156
|
+
children: [
|
|
157
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
158
|
+
item: true,
|
|
159
|
+
xs: 8,
|
|
160
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
161
|
+
fullWidth: true,
|
|
162
|
+
label: "Endpoint pattern",
|
|
163
|
+
value: endpointPattern,
|
|
164
|
+
InputProps: {
|
|
165
|
+
readOnly: isReadonly
|
|
166
|
+
},
|
|
167
|
+
InputLabelProps: {
|
|
168
|
+
shrink: isReadonly ? true : undefined
|
|
169
|
+
},
|
|
170
|
+
onChange: (e)=>{
|
|
171
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
172
|
+
if (draft.proxy !== undefined) {
|
|
173
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
174
|
+
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)=>{
|
|
175
|
+
if (i === itemIndex) {
|
|
176
|
+
return {
|
|
177
|
+
endpointPattern: e.target.value,
|
|
178
|
+
method: item.method
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
return item;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}));
|
|
186
|
+
}
|
|
187
|
+
})
|
|
188
|
+
}),
|
|
189
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
190
|
+
item: true,
|
|
191
|
+
xs: 3,
|
|
192
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
193
|
+
select: true,
|
|
194
|
+
fullWidth: true,
|
|
195
|
+
label: "Method",
|
|
196
|
+
value: method,
|
|
197
|
+
InputProps: {
|
|
198
|
+
readOnly: isReadonly
|
|
199
|
+
},
|
|
200
|
+
InputLabelProps: {
|
|
201
|
+
shrink: isReadonly ? true : undefined
|
|
202
|
+
},
|
|
203
|
+
onChange: (e)=>{
|
|
204
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
205
|
+
if (draft.proxy !== undefined) {
|
|
206
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
207
|
+
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)=>{
|
|
208
|
+
if (i === itemIndex) {
|
|
209
|
+
return {
|
|
210
|
+
endpointPattern: item.endpointPattern,
|
|
211
|
+
method: e.target.value
|
|
212
|
+
};
|
|
213
|
+
} else {
|
|
214
|
+
return item;
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}));
|
|
219
|
+
},
|
|
220
|
+
children: [
|
|
221
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
222
|
+
value: "GET",
|
|
223
|
+
children: "GET"
|
|
224
|
+
}),
|
|
225
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
226
|
+
value: "POST",
|
|
227
|
+
children: "POST"
|
|
228
|
+
}),
|
|
229
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
230
|
+
value: "PUT",
|
|
231
|
+
children: "PUT"
|
|
232
|
+
}),
|
|
233
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
234
|
+
value: "PATCH",
|
|
235
|
+
children: "PATCH"
|
|
236
|
+
}),
|
|
237
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
|
|
238
|
+
value: "DELETE",
|
|
239
|
+
children: "DELETE"
|
|
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
|
+
// Remove the given allowed endpoint from the list
|
|
250
|
+
onClick: ()=>{
|
|
251
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
252
|
+
if (draft.proxy !== undefined) {
|
|
253
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
254
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
255
|
+
...((_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) === null || _draft_proxy_spec_allowedEndpoints === void 0 ? void 0 : _draft_proxy_spec_allowedEndpoints.filter((item, itemIndex)=>{
|
|
256
|
+
return itemIndex !== i;
|
|
257
|
+
})) || []
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
}));
|
|
261
|
+
},
|
|
262
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
263
|
+
})
|
|
189
264
|
})
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
265
|
+
]
|
|
266
|
+
}, i);
|
|
267
|
+
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
268
|
+
item: true,
|
|
269
|
+
xs: 4,
|
|
270
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
271
|
+
sx: {
|
|
272
|
+
fontStyle: 'italic'
|
|
273
|
+
},
|
|
198
274
|
children: "None"
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
275
|
+
})
|
|
276
|
+
}),
|
|
277
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
278
|
+
item: true,
|
|
279
|
+
xs: 12,
|
|
280
|
+
sx: {
|
|
281
|
+
paddingTop: '0px !important',
|
|
282
|
+
paddingLeft: '5px !important'
|
|
283
|
+
},
|
|
284
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
285
|
+
disabled: isReadonly,
|
|
286
|
+
// Add a new (empty) allowed endpoint to the list
|
|
287
|
+
onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
288
|
+
if (draft.proxy !== undefined) {
|
|
289
|
+
var _draft_proxy_spec_allowedEndpoints;
|
|
290
|
+
draft.proxy.spec.allowedEndpoints = [
|
|
291
|
+
...(_draft_proxy_spec_allowedEndpoints = draft.proxy.spec.allowedEndpoints) !== null && _draft_proxy_spec_allowedEndpoints !== void 0 ? _draft_proxy_spec_allowedEndpoints : [],
|
|
292
|
+
{
|
|
293
|
+
endpointPattern: '',
|
|
294
|
+
method: ''
|
|
295
|
+
}
|
|
296
|
+
];
|
|
297
|
+
}
|
|
298
|
+
})),
|
|
299
|
+
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
300
|
+
})
|
|
301
|
+
})
|
|
302
|
+
]
|
|
203
303
|
}),
|
|
204
304
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
205
305
|
variant: "h4",
|
|
206
|
-
mb:
|
|
306
|
+
mb: 2,
|
|
207
307
|
children: "Request Headers"
|
|
208
308
|
}),
|
|
209
309
|
/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid, {
|
|
@@ -211,7 +311,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
211
311
|
spacing: 2,
|
|
212
312
|
mb: 2,
|
|
213
313
|
children: [
|
|
214
|
-
((
|
|
314
|
+
((_value_proxy3 = value.proxy) === null || _value_proxy3 === void 0 ? void 0 : _value_proxy3.spec.headers) && Object.keys(value.proxy.spec.headers).map((headerName, i)=>{
|
|
215
315
|
var _value_proxy_spec_headers, _value_proxy;
|
|
216
316
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
217
317
|
children: [
|
|
@@ -228,18 +328,11 @@ function PrometheusDatasourceEditor(props) {
|
|
|
228
328
|
InputLabelProps: {
|
|
229
329
|
shrink: isReadonly ? true : undefined
|
|
230
330
|
},
|
|
231
|
-
onChange: (e)=>onChange({
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
proxy: {
|
|
235
|
-
...value.proxy,
|
|
236
|
-
spec: {
|
|
237
|
-
...value.proxy.spec,
|
|
238
|
-
headers: buildNewHeaders(value.proxy.spec.headers, headerName, e.target.value)
|
|
239
|
-
}
|
|
240
|
-
}
|
|
331
|
+
onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
332
|
+
if (draft.proxy !== undefined) {
|
|
333
|
+
draft.proxy.spec.headers = buildNewHeaders(draft.proxy.spec.headers, headerName, e.target.value);
|
|
241
334
|
}
|
|
242
|
-
})
|
|
335
|
+
}))
|
|
243
336
|
})
|
|
244
337
|
}),
|
|
245
338
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -255,21 +348,14 @@ function PrometheusDatasourceEditor(props) {
|
|
|
255
348
|
InputLabelProps: {
|
|
256
349
|
shrink: isReadonly ? true : undefined
|
|
257
350
|
},
|
|
258
|
-
onChange: (e)=>onChange({
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
...value.proxy.spec,
|
|
265
|
-
headers: {
|
|
266
|
-
...value.proxy.spec.headers,
|
|
267
|
-
[headerName]: e.target.value
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
351
|
+
onChange: (e)=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
352
|
+
if (draft.proxy !== undefined) {
|
|
353
|
+
draft.proxy.spec.headers = {
|
|
354
|
+
...draft.proxy.spec.headers,
|
|
355
|
+
[headerName]: e.target.value
|
|
356
|
+
};
|
|
271
357
|
}
|
|
272
|
-
})
|
|
358
|
+
}))
|
|
273
359
|
})
|
|
274
360
|
}),
|
|
275
361
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -277,24 +363,18 @@ function PrometheusDatasourceEditor(props) {
|
|
|
277
363
|
xs: 1,
|
|
278
364
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
279
365
|
disabled: isReadonly,
|
|
366
|
+
// Remove the given header from the list
|
|
280
367
|
onClick: ()=>{
|
|
281
368
|
var _value_proxy;
|
|
282
369
|
const newHeaders = {
|
|
283
370
|
...(_value_proxy = value.proxy) === null || _value_proxy === void 0 ? void 0 : _value_proxy.spec.headers
|
|
284
371
|
};
|
|
285
372
|
delete newHeaders[headerName];
|
|
286
|
-
onChange({
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
proxy: {
|
|
290
|
-
...value.proxy,
|
|
291
|
-
spec: {
|
|
292
|
-
...value.proxy.spec,
|
|
293
|
-
headers: newHeaders
|
|
294
|
-
}
|
|
295
|
-
}
|
|
373
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
374
|
+
if (draft.proxy !== undefined) {
|
|
375
|
+
draft.proxy.spec.headers = newHeaders;
|
|
296
376
|
}
|
|
297
|
-
});
|
|
377
|
+
}));
|
|
298
378
|
},
|
|
299
379
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
300
380
|
})
|
|
@@ -306,25 +386,20 @@ function PrometheusDatasourceEditor(props) {
|
|
|
306
386
|
item: true,
|
|
307
387
|
xs: 12,
|
|
308
388
|
sx: {
|
|
309
|
-
paddingTop: '
|
|
389
|
+
paddingTop: '0px !important',
|
|
390
|
+
paddingLeft: '5px !important'
|
|
310
391
|
},
|
|
311
392
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
312
393
|
disabled: isReadonly,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
proxy
|
|
317
|
-
...
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
headers: {
|
|
321
|
-
...value.proxy.spec.headers,
|
|
322
|
-
'': ''
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
}
|
|
394
|
+
// Add a new (empty) header to the list
|
|
395
|
+
onClick: ()=>onChange((0, _immer.produce)(value, (draft)=>{
|
|
396
|
+
if (draft.proxy !== undefined) {
|
|
397
|
+
draft.proxy.spec.headers = {
|
|
398
|
+
...draft.proxy.spec.headers,
|
|
399
|
+
'': ''
|
|
400
|
+
};
|
|
326
401
|
}
|
|
327
|
-
}),
|
|
402
|
+
})),
|
|
328
403
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
|
|
329
404
|
})
|
|
330
405
|
})
|
|
@@ -333,25 +408,20 @@ function PrometheusDatasourceEditor(props) {
|
|
|
333
408
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
334
409
|
fullWidth: true,
|
|
335
410
|
label: "Secret",
|
|
336
|
-
value: ((
|
|
411
|
+
value: ((_value_proxy4 = value.proxy) === null || _value_proxy4 === void 0 ? void 0 : _value_proxy4.spec.secret) || '',
|
|
337
412
|
InputProps: {
|
|
338
413
|
readOnly: isReadonly
|
|
339
414
|
},
|
|
340
415
|
InputLabelProps: {
|
|
341
416
|
shrink: isReadonly ? true : undefined
|
|
342
417
|
},
|
|
343
|
-
onChange: (e)=>
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
proxy
|
|
347
|
-
...value.proxy,
|
|
348
|
-
spec: {
|
|
349
|
-
...value.proxy.spec,
|
|
350
|
-
secret: e.target.value
|
|
351
|
-
}
|
|
352
|
-
}
|
|
418
|
+
onChange: (e)=>{
|
|
419
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
420
|
+
if (draft.proxy !== undefined) {
|
|
421
|
+
draft.proxy.spec.secret = e.target.value;
|
|
353
422
|
}
|
|
354
|
-
})
|
|
423
|
+
}));
|
|
424
|
+
}
|
|
355
425
|
})
|
|
356
426
|
]
|
|
357
427
|
})
|
|
@@ -372,7 +442,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
372
442
|
kind: 'HTTPProxy',
|
|
373
443
|
spec: {
|
|
374
444
|
allowedEndpoints: [
|
|
375
|
-
//
|
|
445
|
+
// list of standard endpoints suggested by default
|
|
376
446
|
{
|
|
377
447
|
endpointPattern: '/api/v1/labels',
|
|
378
448
|
method: 'POST'
|
|
@@ -421,7 +491,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
421
491
|
children: [
|
|
422
492
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
423
493
|
variant: "h4",
|
|
424
|
-
mb:
|
|
494
|
+
mb: 2,
|
|
425
495
|
children: "General Settings"
|
|
426
496
|
}),
|
|
427
497
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
@@ -25,13 +25,14 @@ const _PrometheusDatasourceEditor = require("./PrometheusDatasourceEditor");
|
|
|
25
25
|
/**
|
|
26
26
|
* Creates a PrometheusClient for a specific datasource spec.
|
|
27
27
|
*/ const createClient = (spec, options)=>{
|
|
28
|
-
const { directUrl ,
|
|
28
|
+
const { directUrl , proxy } = spec;
|
|
29
29
|
const { proxyUrl } = options;
|
|
30
30
|
// Use the direct URL if specified, but fallback to the proxyUrl by default if not specified
|
|
31
31
|
const datasourceUrl = directUrl !== null && directUrl !== void 0 ? directUrl : proxyUrl;
|
|
32
32
|
if (datasourceUrl === undefined) {
|
|
33
33
|
throw new Error('No URL specified for Prometheus client. You can use directUrl in the spec to configure it.');
|
|
34
34
|
}
|
|
35
|
+
const specHeaders = proxy === null || proxy === void 0 ? void 0 : proxy.spec.headers;
|
|
35
36
|
// Could think about this becoming a class, although it definitely doesn't have to be
|
|
36
37
|
return {
|
|
37
38
|
options: {
|
|
@@ -26,7 +26,7 @@ const _material = require("@mui/material");
|
|
|
26
26
|
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
27
27
|
const _model = require("../../model");
|
|
28
28
|
const _components = require("../../components");
|
|
29
|
-
const
|
|
29
|
+
const _types = require("../types");
|
|
30
30
|
const _queryeditormodel = require("./query-editor-model");
|
|
31
31
|
function PrometheusTimeSeriesQueryEditor(props) {
|
|
32
32
|
const { onChange , value } = props;
|
|
@@ -39,7 +39,7 @@ function PrometheusTimeSeriesQueryEditor(props) {
|
|
|
39
39
|
const { format , handleFormatChange , handleFormatBlur } = (0, _queryeditormodel.useFormatState)(props);
|
|
40
40
|
const { minStep , handleMinStepChange , handleMinStepBlur } = (0, _queryeditormodel.useMinStepState)(props);
|
|
41
41
|
var _ref;
|
|
42
|
-
const minStepPlaceholder = (_ref = minStep !== null && minStep !== void 0 ? minStep : datasourceResource && (datasourceResource === null || datasourceResource === void 0 ? void 0 : datasourceResource.plugin.spec).scrapeInterval) !== null && _ref !== void 0 ? _ref :
|
|
42
|
+
const minStepPlaceholder = (_ref = minStep !== null && minStep !== void 0 ? minStep : datasourceResource && (datasourceResource === null || datasourceResource === void 0 ? void 0 : datasourceResource.plugin.spec).scrapeInterval) !== null && _ref !== void 0 ? _ref : _types.DEFAULT_SCRAPE_INTERVAL;
|
|
43
43
|
const handleDatasourceChange = (next)=>{
|
|
44
44
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
45
45
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
@@ -25,7 +25,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
25
25
|
const _datefns = require("date-fns");
|
|
26
26
|
const _model = require("../../model");
|
|
27
27
|
const _utils = require("../../utils");
|
|
28
|
-
const
|
|
28
|
+
const _types = require("../types");
|
|
29
29
|
const getTimeSeriesData = async (spec, context)=>{
|
|
30
30
|
var _response_data;
|
|
31
31
|
if (spec.query === undefined || spec.query === null || spec.query === '') {
|
|
@@ -37,7 +37,7 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
37
37
|
var _spec_datasource;
|
|
38
38
|
const datasource = await context.datasourceStore.getDatasource((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
|
|
39
39
|
var _datasource_plugin_spec_scrapeInterval;
|
|
40
|
-
const datasourceScrapeInterval = Math.trunc((0, _datefns.milliseconds)((0, _core.parseDurationString)((_datasource_plugin_spec_scrapeInterval = datasource.plugin.spec.scrapeInterval) !== null && _datasource_plugin_spec_scrapeInterval !== void 0 ? _datasource_plugin_spec_scrapeInterval :
|
|
40
|
+
const datasourceScrapeInterval = Math.trunc((0, _datefns.milliseconds)((0, _core.parseDurationString)((_datasource_plugin_spec_scrapeInterval = datasource.plugin.spec.scrapeInterval) !== null && _datasource_plugin_spec_scrapeInterval !== void 0 ? _datasource_plugin_spec_scrapeInterval : _types.DEFAULT_SCRAPE_INTERVAL)) / 1000);
|
|
41
41
|
var _getDurationStringSeconds;
|
|
42
42
|
const minStep = (_getDurationStringSeconds = (0, _model.getDurationStringSeconds)(spec.minStep)) !== null && _getDurationStringSeconds !== void 0 ? _getDurationStringSeconds : datasourceScrapeInterval;
|
|
43
43
|
const timeRange = (0, _model.getPrometheusTimeRange)(context.timeRange);
|
|
@@ -14,3 +14,10 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_SCRAPE_INTERVAL", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return DEFAULT_SCRAPE_INTERVAL;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const DEFAULT_SCRAPE_INTERVAL = '1m';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrometheusDatasourceEditor.d.ts","sourceRoot":"","sources":["../../src/plugins/PrometheusDatasourceEditor.tsx"],"names":[],"mappings":";AAoBA,OAAO,EAA2B,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAE5E,MAAM,WAAW,+BAA+B;IAC9C,KAAK,EAAE,wBAAwB,CAAC;IAChC,QAAQ,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,eAsZhF"}
|