@perses-dev/prometheus-plugin 0.43.0-rc2 → 0.44.0-rc0
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 +1 -1
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/model/index.js +0 -1
- package/dist/cjs/model/parse-sample-values.js +3 -3
- package/dist/cjs/model/prometheus-client.js +8 -8
- package/dist/cjs/model/prometheus-selectors.js +3 -3
- package/dist/cjs/model/time.js +4 -4
- package/dist/cjs/plugins/MatcherEditor.js +1 -1
- package/dist/cjs/plugins/PrometheusDatasourceEditor.js +24 -26
- package/dist/cjs/plugins/prometheus-datasource.js +2 -2
- package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +1 -1
- package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +2 -2
- package/dist/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +7 -7
- package/dist/cjs/plugins/prometheus-time-series-query/get-time-series-data.js +6 -4
- package/dist/cjs/plugins/prometheus-time-series-query/query-editor-model.js +6 -6
- package/dist/cjs/plugins/prometheus-variables.js +10 -10
- package/dist/cjs/utils/utils.js +4 -4
- 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/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.js +3 -3
- package/dist/model/prometheus-client.js.map +1 -1
- package/dist/model/prometheus-selectors.js.map +1 -1
- package/dist/model/time.js +1 -1
- 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.d.ts +1 -2
- package/dist/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
- package/dist/plugins/PrometheusDatasourceEditor.js +21 -25
- package/dist/plugins/PrometheusDatasourceEditor.js.map +1 -1
- package/dist/plugins/prometheus-datasource.js +2 -2
- package/dist/plugins/prometheus-datasource.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts +1 -2
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js +1 -1
- package/dist/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts +1 -2
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js +2 -2
- package/dist/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js.map +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 +7 -7
- 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 +6 -4
- package/dist/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/dist/plugins/prometheus-time-series-query/query-editor-model.d.ts +1 -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 +3 -3
- 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 +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 +10 -10
- package/dist/plugins/prometheus-variables.js.map +1 -1
- package/dist/plugins/types.d.ts +3 -3
- package/dist/plugins/types.d.ts.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.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/package.json +4 -4
- package/dist/cjs/model/templating.js +0 -28
- 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
|
@@ -31,7 +31,7 @@ function _interop_require_default(obj) {
|
|
|
31
31
|
default: obj
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function PromQLEditor({ completeConfig
|
|
34
|
+
function PromQLEditor({ completeConfig, ...rest }) {
|
|
35
35
|
const theme = (0, _material.useTheme)();
|
|
36
36
|
const isDarkMode = theme.palette.mode === 'dark';
|
|
37
37
|
const promQLExtension = (0, _react.useMemo)(()=>{
|
package/dist/cjs/index.js
CHANGED
|
@@ -21,11 +21,8 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
return
|
|
26
|
-
},
|
|
27
|
-
StaticListVariable: function() {
|
|
28
|
-
return _variable.StaticListVariable;
|
|
24
|
+
PrometheusDatasource: function() {
|
|
25
|
+
return _prometheusdatasource.PrometheusDatasource;
|
|
29
26
|
},
|
|
30
27
|
PrometheusLabelNamesVariable: function() {
|
|
31
28
|
return _prometheusvariables.PrometheusLabelNamesVariable;
|
|
@@ -36,8 +33,11 @@ _export(exports, {
|
|
|
36
33
|
PrometheusPromQLVariable: function() {
|
|
37
34
|
return _prometheusvariables.PrometheusPromQLVariable;
|
|
38
35
|
},
|
|
39
|
-
|
|
40
|
-
return
|
|
36
|
+
PrometheusTimeSeriesQuery: function() {
|
|
37
|
+
return _prometheustimeseriesquery.PrometheusTimeSeriesQuery;
|
|
38
|
+
},
|
|
39
|
+
StaticListVariable: function() {
|
|
40
|
+
return _variable.StaticListVariable;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
const _prometheustimeseriesquery = require("./plugins/prometheus-time-series-query");
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -18,7 +18,6 @@ _export_star(require("./api-types"), exports);
|
|
|
18
18
|
_export_star(require("./parse-sample-values"), exports);
|
|
19
19
|
_export_star(require("./prometheus-client"), exports);
|
|
20
20
|
_export_star(require("./prometheus-selectors"), exports);
|
|
21
|
-
_export_star(require("./templating"), exports);
|
|
22
21
|
_export_star(require("./time"), exports);
|
|
23
22
|
function _export_star(from, to) {
|
|
24
23
|
Object.keys(from).forEach(function(k) {
|
|
@@ -21,11 +21,11 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
parseValueTuple: function() {
|
|
25
|
-
return parseValueTuple;
|
|
26
|
-
},
|
|
27
24
|
parseSampleValue: function() {
|
|
28
25
|
return parseSampleValue;
|
|
26
|
+
},
|
|
27
|
+
parseValueTuple: function() {
|
|
28
|
+
return parseValueTuple;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
function parseValueTuple(data) {
|
|
@@ -21,23 +21,23 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
fetchResults: function() {
|
|
25
|
+
return fetchResults;
|
|
26
|
+
},
|
|
24
27
|
healthCheck: function() {
|
|
25
28
|
return healthCheck;
|
|
26
29
|
},
|
|
27
30
|
instantQuery: function() {
|
|
28
31
|
return instantQuery;
|
|
29
32
|
},
|
|
30
|
-
rangeQuery: function() {
|
|
31
|
-
return rangeQuery;
|
|
32
|
-
},
|
|
33
33
|
labelNames: function() {
|
|
34
34
|
return labelNames;
|
|
35
35
|
},
|
|
36
36
|
labelValues: function() {
|
|
37
37
|
return labelValues;
|
|
38
38
|
},
|
|
39
|
-
|
|
40
|
-
return
|
|
39
|
+
rangeQuery: function() {
|
|
40
|
+
return rangeQuery;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
const _core = require("@perses-dev/core");
|
|
@@ -64,7 +64,7 @@ function labelNames(params, queryOptions) {
|
|
|
64
64
|
return fetchWithPost('/api/v1/labels', params, queryOptions);
|
|
65
65
|
}
|
|
66
66
|
function labelValues(params, queryOptions) {
|
|
67
|
-
const { labelName
|
|
67
|
+
const { labelName, ...searchParams } = params;
|
|
68
68
|
// In case label name is empty, we'll receive a 404, so we can replace it by an empty list, which is less confusing.
|
|
69
69
|
// Note that an empty list is the prometheus result if the label does not exist.
|
|
70
70
|
if (labelName.length === 0) {
|
|
@@ -78,7 +78,7 @@ function labelValues(params, queryOptions) {
|
|
|
78
78
|
return fetchWithGet(apiURI, searchParams, queryOptions);
|
|
79
79
|
}
|
|
80
80
|
function fetchWithGet(apiURI, params, queryOptions) {
|
|
81
|
-
const { datasourceUrl
|
|
81
|
+
const { datasourceUrl } = queryOptions;
|
|
82
82
|
let url = `${datasourceUrl}${apiURI}`;
|
|
83
83
|
const urlParams = createSearchParams(params).toString();
|
|
84
84
|
if (urlParams !== '') {
|
|
@@ -89,7 +89,7 @@ function fetchWithGet(apiURI, params, queryOptions) {
|
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
function fetchWithPost(apiURI, params, queryOptions) {
|
|
92
|
-
const { datasourceUrl
|
|
92
|
+
const { datasourceUrl, headers } = queryOptions;
|
|
93
93
|
const url = `${datasourceUrl}${apiURI}`;
|
|
94
94
|
const init = {
|
|
95
95
|
method: 'POST',
|
|
@@ -21,12 +21,12 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
PROM_DATASOURCE_KIND: function() {
|
|
25
|
-
return PROM_DATASOURCE_KIND;
|
|
26
|
-
},
|
|
27
24
|
DEFAULT_PROM: function() {
|
|
28
25
|
return DEFAULT_PROM;
|
|
29
26
|
},
|
|
27
|
+
PROM_DATASOURCE_KIND: function() {
|
|
28
|
+
return PROM_DATASOURCE_KIND;
|
|
29
|
+
},
|
|
30
30
|
isDefaultPromSelector: function() {
|
|
31
31
|
return isDefaultPromSelector;
|
|
32
32
|
},
|
package/dist/cjs/model/time.js
CHANGED
|
@@ -21,20 +21,20 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
+
getDurationStringSeconds: function() {
|
|
25
|
+
return getDurationStringSeconds;
|
|
26
|
+
},
|
|
24
27
|
getPrometheusTimeRange: function() {
|
|
25
28
|
return getPrometheusTimeRange;
|
|
26
29
|
},
|
|
27
30
|
getRangeStep: function() {
|
|
28
31
|
return getRangeStep;
|
|
29
|
-
},
|
|
30
|
-
getDurationStringSeconds: function() {
|
|
31
|
-
return getDurationStringSeconds;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const _core = require("@perses-dev/core");
|
|
35
35
|
const _datefns = require("date-fns");
|
|
36
36
|
function getPrometheusTimeRange(timeRange) {
|
|
37
|
-
const { start
|
|
37
|
+
const { start, end } = timeRange;
|
|
38
38
|
return {
|
|
39
39
|
start: Math.ceil((0, _datefns.getUnixTime)(start)),
|
|
40
40
|
end: Math.ceil((0, _datefns.getUnixTime)(end))
|
|
@@ -29,7 +29,7 @@ function _interop_require_default(obj) {
|
|
|
29
29
|
default: obj
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
function MatcherEditor({ matchers
|
|
32
|
+
function MatcherEditor({ matchers, onChange, isReadonly }) {
|
|
33
33
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
34
34
|
spacing: 1,
|
|
35
35
|
mb: 2,
|
|
@@ -55,7 +55,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
55
55
|
if (cache && cache.has(obj)) {
|
|
56
56
|
return cache.get(obj);
|
|
57
57
|
}
|
|
58
|
-
var newObj = {
|
|
58
|
+
var newObj = {
|
|
59
|
+
__proto__: null
|
|
60
|
+
};
|
|
59
61
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
62
|
for(var key in obj){
|
|
61
63
|
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
@@ -75,7 +77,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
75
77
|
}
|
|
76
78
|
function PrometheusDatasourceEditor(props) {
|
|
77
79
|
var _value_proxy, _value_proxy1, _value_proxy2;
|
|
78
|
-
const { value
|
|
80
|
+
const { value, onChange, isReadonly } = props;
|
|
79
81
|
const strDirect = 'Direct access';
|
|
80
82
|
const strProxy = 'Proxy';
|
|
81
83
|
// utilitary function used for headers when renaming a property
|
|
@@ -100,9 +102,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
100
102
|
label: strDirect,
|
|
101
103
|
content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
102
104
|
name: "URL",
|
|
103
|
-
render: ({ field
|
|
105
|
+
render: ({ field, fieldState })=>{
|
|
104
106
|
var _fieldState_error;
|
|
105
|
-
/*#__PURE__*/
|
|
107
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
106
108
|
...field,
|
|
107
109
|
fullWidth: true,
|
|
108
110
|
label: "URL",
|
|
@@ -131,9 +133,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
131
133
|
children: [
|
|
132
134
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
133
135
|
name: "URL",
|
|
134
|
-
render: ({ field
|
|
136
|
+
render: ({ field, fieldState })=>{
|
|
135
137
|
var _value_proxy, _fieldState_error;
|
|
136
|
-
/*#__PURE__*/
|
|
138
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
137
139
|
...field,
|
|
138
140
|
fullWidth: true,
|
|
139
141
|
label: "URL",
|
|
@@ -170,7 +172,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
170
172
|
spacing: 2,
|
|
171
173
|
mb: 2,
|
|
172
174
|
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
|
|
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)=>{
|
|
174
176
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_react.Fragment, {
|
|
175
177
|
children: [
|
|
176
178
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid, {
|
|
@@ -178,9 +180,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
178
180
|
xs: 8,
|
|
179
181
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
180
182
|
name: `Endpoint pattern ${i}`,
|
|
181
|
-
render: ({ field
|
|
183
|
+
render: ({ field, fieldState })=>{
|
|
182
184
|
var _fieldState_error;
|
|
183
|
-
/*#__PURE__*/
|
|
185
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
184
186
|
...field,
|
|
185
187
|
fullWidth: true,
|
|
186
188
|
label: "Endpoint pattern",
|
|
@@ -220,9 +222,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
220
222
|
xs: 3,
|
|
221
223
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
222
224
|
name: `Method ${i}`,
|
|
223
|
-
render: ({ field
|
|
225
|
+
render: ({ field, fieldState })=>{
|
|
224
226
|
var _fieldState_error;
|
|
225
|
-
/*#__PURE__*/
|
|
227
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
|
|
226
228
|
...field,
|
|
227
229
|
select: true,
|
|
228
230
|
fullWidth: true,
|
|
@@ -285,8 +287,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
285
287
|
xs: 1,
|
|
286
288
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
287
289
|
name: `Remove Endpoint ${i}`,
|
|
288
|
-
render: ({ field
|
|
289
|
-
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
290
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
290
291
|
...field,
|
|
291
292
|
disabled: isReadonly,
|
|
292
293
|
// Remove the given allowed endpoint from the list
|
|
@@ -304,8 +305,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
304
305
|
}));
|
|
305
306
|
},
|
|
306
307
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
307
|
-
})
|
|
308
|
-
}
|
|
308
|
+
})
|
|
309
309
|
})
|
|
310
310
|
})
|
|
311
311
|
]
|
|
@@ -365,9 +365,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
365
365
|
xs: 4,
|
|
366
366
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
367
367
|
name: `Header name ${i}`,
|
|
368
|
-
render: ({ field
|
|
368
|
+
render: ({ field, fieldState })=>{
|
|
369
369
|
var _fieldState_error;
|
|
370
|
-
/*#__PURE__*/
|
|
370
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
371
371
|
...field,
|
|
372
372
|
fullWidth: true,
|
|
373
373
|
label: "Header name",
|
|
@@ -397,13 +397,13 @@ function PrometheusDatasourceEditor(props) {
|
|
|
397
397
|
xs: 7,
|
|
398
398
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
399
399
|
name: `Header value ${i}`,
|
|
400
|
-
render: ({ field
|
|
400
|
+
render: ({ field, fieldState })=>{
|
|
401
401
|
var _value_proxy_spec_headers, _value_proxy, _fieldState_error;
|
|
402
|
-
/*#__PURE__*/
|
|
402
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
403
403
|
...field,
|
|
404
404
|
fullWidth: true,
|
|
405
405
|
label: "Header value",
|
|
406
|
-
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
407
|
error: !!fieldState.error,
|
|
408
408
|
helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
|
|
409
409
|
InputProps: {
|
|
@@ -432,8 +432,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
432
432
|
xs: 1,
|
|
433
433
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
434
434
|
name: `Remove Header ${i}`,
|
|
435
|
-
render: ({ field
|
|
436
|
-
/*#__PURE__*/ return (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
435
|
+
render: ({ field })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
|
|
437
436
|
...field,
|
|
438
437
|
disabled: isReadonly,
|
|
439
438
|
// Remove the given header from the list
|
|
@@ -451,8 +450,7 @@ function PrometheusDatasourceEditor(props) {
|
|
|
451
450
|
}));
|
|
452
451
|
},
|
|
453
452
|
children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Minus.default, {})
|
|
454
|
-
})
|
|
455
|
-
}
|
|
453
|
+
})
|
|
456
454
|
})
|
|
457
455
|
})
|
|
458
456
|
]
|
|
@@ -483,9 +481,9 @@ function PrometheusDatasourceEditor(props) {
|
|
|
483
481
|
}),
|
|
484
482
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
485
483
|
name: "Secret",
|
|
486
|
-
render: ({ field
|
|
484
|
+
render: ({ field, fieldState })=>{
|
|
487
485
|
var _value_proxy, _fieldState_error;
|
|
488
|
-
/*#__PURE__*/
|
|
486
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
489
487
|
...field,
|
|
490
488
|
fullWidth: true,
|
|
491
489
|
label: "Secret",
|
|
@@ -25,8 +25,8 @@ 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
|
|
29
|
-
const { proxyUrl
|
|
28
|
+
const { directUrl, proxy } = spec;
|
|
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) {
|
package/dist/cjs/plugins/prometheus-time-series-query/DashboardPrometheusTimeSeriesQueryEditor.js
CHANGED
|
@@ -26,7 +26,7 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
26
26
|
const _model = require("../../model");
|
|
27
27
|
const _components = require("../../components");
|
|
28
28
|
function DashboardPrometheusTimeSeriesQueryEditor(props) {
|
|
29
|
-
const { selectedDatasource
|
|
29
|
+
const { selectedDatasource, handleDatasourceChange, promURL, query, handleQueryChange, handleQueryBlur, format, handleFormatBlur, handleMinStepChange, handleFormatChange, handleMinStepBlur, minStepPlaceholder, minStep } = props;
|
|
30
30
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
31
31
|
spacing: 2,
|
|
32
32
|
children: [
|
package/dist/cjs/plugins/prometheus-time-series-query/ExplorePrometheusTimeSeriesQueryEditor.js
CHANGED
|
@@ -26,8 +26,8 @@ const _pluginsystem = require("@perses-dev/plugin-system");
|
|
|
26
26
|
const _model = require("../../model");
|
|
27
27
|
const _components = require("../../components");
|
|
28
28
|
function ExplorePrometheusTimeSeriesQueryEditor(props) {
|
|
29
|
-
const { selectedDatasource
|
|
30
|
-
const { project
|
|
29
|
+
const { selectedDatasource, handleDatasourceChange, promURL, query, handleQueryChange, handleQueryBlur, format, handleFormatBlur, handleMinStepChange, handleFormatChange, handleMinStepBlur, minStepPlaceholder, minStep } = props;
|
|
30
|
+
const { project, setProject } = (0, _pluginsystem.useProjectStore)();
|
|
31
31
|
const handleProjectChange = (next)=>{
|
|
32
32
|
handleDatasourceChange(_model.DEFAULT_PROM);
|
|
33
33
|
return setProject(next);
|
|
@@ -29,15 +29,15 @@ const _queryeditormodel = require("./query-editor-model");
|
|
|
29
29
|
const _DashboardPrometheusTimeSeriesQueryEditor = require("./DashboardPrometheusTimeSeriesQueryEditor");
|
|
30
30
|
const _ExplorePrometheusTimeSeriesQueryEditor = require("./ExplorePrometheusTimeSeriesQueryEditor");
|
|
31
31
|
function PrometheusTimeSeriesQueryEditor(props) {
|
|
32
|
-
const { onChange
|
|
33
|
-
const { datasource
|
|
32
|
+
const { onChange, value, isExplore } = props;
|
|
33
|
+
const { datasource } = value;
|
|
34
34
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
35
|
-
const { data: client
|
|
35
|
+
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
36
36
|
const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
37
|
-
const { data: datasourceResource
|
|
38
|
-
const { query
|
|
39
|
-
const { format
|
|
40
|
-
const { minStep
|
|
37
|
+
const { data: datasourceResource } = (0, _pluginsystem.useDatasource)(selectedDatasource);
|
|
38
|
+
const { query, handleQueryChange, handleQueryBlur } = (0, _queryeditormodel.useQueryState)(props);
|
|
39
|
+
const { format, handleFormatChange, handleFormatBlur } = (0, _queryeditormodel.useFormatState)(props);
|
|
40
|
+
const { minStep, handleMinStepChange, handleMinStepBlur } = (0, _queryeditormodel.useMinStepState)(props);
|
|
41
41
|
var _ref;
|
|
42
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)=>{
|
|
@@ -39,11 +39,13 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
39
39
|
var _datasource_plugin_spec_scrapeInterval;
|
|
40
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
|
-
const minStep = (_getDurationStringSeconds = (0, _model.getDurationStringSeconds)(
|
|
42
|
+
const minStep = (_getDurationStringSeconds = (0, _model.getDurationStringSeconds)(// resolve any variable that may have been provided
|
|
43
|
+
// TODO add a validation check to make sure the variable is a DurationString, to avoid the back & forth cast here
|
|
44
|
+
(0, _pluginsystem.replaceTemplateVariables)(spec.minStep, context.variableState))) !== null && _getDurationStringSeconds !== void 0 ? _getDurationStringSeconds : datasourceScrapeInterval;
|
|
43
45
|
const timeRange = (0, _model.getPrometheusTimeRange)(context.timeRange);
|
|
44
46
|
const step = (0, _model.getRangeStep)(timeRange, minStep, undefined, context.suggestedStepMs); // TODO: resolution
|
|
45
47
|
// Align the time range so that it's a multiple of the step
|
|
46
|
-
let { start
|
|
48
|
+
let { start, end } = timeRange;
|
|
47
49
|
const utcOffsetSec = new Date().getTimezoneOffset() * 60;
|
|
48
50
|
const alignedEnd = Math.floor((end + utcOffsetSec) / step) * step - utcOffsetSec;
|
|
49
51
|
const alignedStart = Math.floor((start + utcOffsetSec) / step) * step - utcOffsetSec;
|
|
@@ -102,9 +104,9 @@ const getTimeSeriesData = async (spec, context)=>{
|
|
|
102
104
|
},
|
|
103
105
|
stepMs: step * 1000,
|
|
104
106
|
series: result.map((value)=>{
|
|
105
|
-
const { metric
|
|
107
|
+
const { metric, values } = value;
|
|
106
108
|
// Account for seriesNameFormat from query editor when determining name to show in legend, tooltip, etc.
|
|
107
|
-
const { name
|
|
109
|
+
const { name, formattedName } = (0, _utils.getFormattedPrometheusSeriesName)(query, metric, seriesNameFormat);
|
|
108
110
|
return {
|
|
109
111
|
name,
|
|
110
112
|
values: values.map(_model.parseValueTuple),
|
|
@@ -21,20 +21,20 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
useQueryState: function() {
|
|
25
|
-
return useQueryState;
|
|
26
|
-
},
|
|
27
24
|
useFormatState: function() {
|
|
28
25
|
return useFormatState;
|
|
29
26
|
},
|
|
30
27
|
useMinStepState: function() {
|
|
31
28
|
return useMinStepState;
|
|
29
|
+
},
|
|
30
|
+
useQueryState: function() {
|
|
31
|
+
return useQueryState;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const _react = require("react");
|
|
35
35
|
const _immer = require("immer");
|
|
36
36
|
function useQueryState(props) {
|
|
37
|
-
const { onChange
|
|
37
|
+
const { onChange, value } = props;
|
|
38
38
|
// Local copy of the query's value
|
|
39
39
|
const [query, setQuery] = (0, _react.useState)(value.query);
|
|
40
40
|
// This is basically "getDerivedStateFromProps" to make sure if spec's value changes external to this component,
|
|
@@ -63,7 +63,7 @@ function useQueryState(props) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
function useFormatState(props) {
|
|
66
|
-
const { onChange
|
|
66
|
+
const { onChange, value } = props;
|
|
67
67
|
// TODO: reusable hook or helper util instead of duplicating from useQueryState
|
|
68
68
|
const [format, setFormat] = (0, _react.useState)(value.seriesNameFormat);
|
|
69
69
|
const [lastSyncedFormat, setLastSyncedFormat] = (0, _react.useState)(value.seriesNameFormat);
|
|
@@ -89,7 +89,7 @@ function useFormatState(props) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
function useMinStepState(props) {
|
|
92
|
-
const { onChange
|
|
92
|
+
const { onChange, value } = props;
|
|
93
93
|
// TODO: reusable hook or helper util instead of duplicating from useQueryState
|
|
94
94
|
const [minStep, setMinStep] = (0, _react.useState)(value.minStep);
|
|
95
95
|
const [lastSyncedMinStep, setLastSyncedMinStep] = (0, _react.useState)(value.minStep);
|
|
@@ -39,8 +39,8 @@ const _model = require("../model");
|
|
|
39
39
|
const _components = require("../components");
|
|
40
40
|
const _MatcherEditor = require("./MatcherEditor");
|
|
41
41
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
42
|
-
const { onChange
|
|
43
|
-
const { datasource
|
|
42
|
+
const { onChange, value } = props;
|
|
43
|
+
const { datasource } = value;
|
|
44
44
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
45
45
|
const handleDatasourceChange = (next)=>{
|
|
46
46
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
@@ -101,8 +101,8 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
104
|
-
const { onChange
|
|
105
|
-
const { datasource
|
|
104
|
+
const { onChange, value } = props;
|
|
105
|
+
const { datasource } = value;
|
|
106
106
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
107
107
|
const handleDatasourceChange = (next)=>{
|
|
108
108
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
@@ -149,10 +149,10 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
function PrometheusPromQLVariableEditor(props) {
|
|
152
|
-
const { onChange
|
|
153
|
-
const { datasource
|
|
152
|
+
const { onChange, value } = props;
|
|
153
|
+
const { datasource } = value;
|
|
154
154
|
const selectedDatasource = datasource !== null && datasource !== void 0 ? datasource : _model.DEFAULT_PROM;
|
|
155
|
-
const { data: client
|
|
155
|
+
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
156
156
|
const promURL = client === null || client === void 0 ? void 0 : client.options.datasourceUrl;
|
|
157
157
|
const handleDatasourceChange = (next)=>{
|
|
158
158
|
if ((0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
@@ -251,7 +251,7 @@ const PrometheusLabelNamesVariable = {
|
|
|
251
251
|
const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
|
|
252
252
|
const match = spec.matchers ? spec.matchers.map((m)=>(0, _pluginsystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
|
|
253
253
|
const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
|
|
254
|
-
const { data: options
|
|
254
|
+
const { data: options } = await client.labelNames({
|
|
255
255
|
'match[]': match,
|
|
256
256
|
...timeRange
|
|
257
257
|
});
|
|
@@ -275,7 +275,7 @@ const PrometheusLabelValuesVariable = {
|
|
|
275
275
|
const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
|
|
276
276
|
const match = pluginDef.matchers ? pluginDef.matchers.map((m)=>(0, _pluginsystem.replaceTemplateVariables)(m, ctx.variables)) : undefined;
|
|
277
277
|
const timeRange = (0, _model.getPrometheusTimeRange)(ctx.timeRange);
|
|
278
|
-
const { data: options
|
|
278
|
+
const { data: options } = await client.labelValues({
|
|
279
279
|
labelName: (0, _pluginsystem.replaceTemplateVariables)(pluginDef.labelName, ctx.variables),
|
|
280
280
|
'match[]': match,
|
|
281
281
|
...timeRange
|
|
@@ -300,7 +300,7 @@ const PrometheusPromQLVariable = {
|
|
|
300
300
|
var _spec_datasource;
|
|
301
301
|
const client = await ctx.datasourceStore.getDatasourceClient((_spec_datasource = spec.datasource) !== null && _spec_datasource !== void 0 ? _spec_datasource : _model.DEFAULT_PROM);
|
|
302
302
|
// TODO we may want to manage a range query as well.
|
|
303
|
-
const { data: options
|
|
303
|
+
const { data: options } = await client.instantQuery({
|
|
304
304
|
query: (0, _pluginsystem.replaceTemplateVariables)(spec.expr, ctx.variables)
|
|
305
305
|
});
|
|
306
306
|
const labelName = (0, _pluginsystem.replaceTemplateVariables)(spec.labelName, ctx.variables);
|
package/dist/cjs/utils/utils.js
CHANGED
|
@@ -24,11 +24,11 @@ _export(exports, {
|
|
|
24
24
|
formatSeriesName: function() {
|
|
25
25
|
return formatSeriesName;
|
|
26
26
|
},
|
|
27
|
-
getUniqueKeyForPrometheusResult: function() {
|
|
28
|
-
return getUniqueKeyForPrometheusResult;
|
|
29
|
-
},
|
|
30
27
|
getFormattedPrometheusSeriesName: function() {
|
|
31
28
|
return getFormattedPrometheusSeriesName;
|
|
29
|
+
},
|
|
30
|
+
getUniqueKeyForPrometheusResult: function() {
|
|
31
|
+
return getUniqueKeyForPrometheusResult;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
const _core = require("@perses-dev/core");
|
|
@@ -56,7 +56,7 @@ function formatSeriesName(inputFormat, seriesLabels) {
|
|
|
56
56
|
});
|
|
57
57
|
return `{${labelStrings.join(',')}}`;
|
|
58
58
|
}
|
|
59
|
-
function getUniqueKeyForPrometheusResult(metricLabels, { removeExprWrap
|
|
59
|
+
function getUniqueKeyForPrometheusResult(metricLabels, { removeExprWrap } = {}) {
|
|
60
60
|
const metricNameKey = '__name__';
|
|
61
61
|
if (metricLabels) {
|
|
62
62
|
if (Object.prototype.hasOwnProperty.call(metricLabels, metricNameKey)) {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ReactCodeMirrorProps } from '@uiw/react-codemirror';
|
|
3
2
|
import { CompleteConfiguration } from '@prometheus-io/codemirror-promql';
|
|
4
|
-
export
|
|
3
|
+
export type PromQLEditorProps = {
|
|
5
4
|
completeConfig: CompleteConfiguration;
|
|
6
5
|
} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;
|
|
7
|
-
export declare function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps): JSX.Element;
|
|
6
|
+
export declare function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
//# sourceMappingURL=PromQL.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromQL.d.ts","sourceRoot":"","sources":["../../src/components/PromQL.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PromQL.d.ts","sourceRoot":"","sources":["../../src/components/PromQL.tsx"],"names":[],"mappings":"AAaA,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAmB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAK1F,MAAM,MAAM,iBAAiB,GAAG;IAAE,cAAc,EAAE,qBAAqB,CAAA;CAAE,GAAG,IAAI,CAC9E,oBAAoB,EACpB,OAAO,GAAG,YAAY,CACvB,CAAC;AAEF,wBAAgB,YAAY,CAAC,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE,iBAAiB,2CAqB1E"}
|
|
@@ -16,7 +16,7 @@ import { PromQLExtension } from '@prometheus-io/codemirror-promql';
|
|
|
16
16
|
import { EditorView } from '@codemirror/view';
|
|
17
17
|
import { useTheme } from '@mui/material';
|
|
18
18
|
import { useMemo } from 'react';
|
|
19
|
-
export function PromQLEditor({ completeConfig
|
|
19
|
+
export function PromQLEditor({ completeConfig, ...rest }) {
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
const isDarkMode = theme.palette.mode === 'dark';
|
|
22
22
|
const promQLExtension = useMemo(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/PromQL.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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme } from '@mui/material';\nimport { useMemo } from 'react';\n\nexport type PromQLEditorProps = { completeConfig: CompleteConfiguration } & Omit<\n ReactCodeMirrorProps,\n 'theme' | 'extensions'\n>;\n\nexport function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[EditorView.lineWrapping, promQLExtension]}\n />\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","useMemo","PromQLEditor","completeConfig","rest","theme","isDarkMode","palette","mode","promQLExtension","activateLinter","setComplete","asExtension","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping"],"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,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,OAAO,QAAQ,QAAQ;AAOhC,OAAO,SAASC,aAAa,EAAEC,
|
|
1
|
+
{"version":3,"sources":["../../src/components/PromQL.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 CodeMirror, { ReactCodeMirrorProps } from '@uiw/react-codemirror';\nimport { PromQLExtension, CompleteConfiguration } from '@prometheus-io/codemirror-promql';\nimport { EditorView } from '@codemirror/view';\nimport { useTheme } from '@mui/material';\nimport { useMemo } from 'react';\n\nexport type PromQLEditorProps = { completeConfig: CompleteConfiguration } & Omit<\n ReactCodeMirrorProps,\n 'theme' | 'extensions'\n>;\n\nexport function PromQLEditor({ completeConfig, ...rest }: PromQLEditorProps) {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n return (\n <CodeMirror\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[EditorView.lineWrapping, promQLExtension]}\n />\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","useMemo","PromQLEditor","completeConfig","rest","theme","isDarkMode","palette","mode","promQLExtension","activateLinter","setComplete","asExtension","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping"],"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,OAAOA,gBAA0C,wBAAwB;AACzE,SAASC,eAAe,QAA+B,mCAAmC;AAC1F,SAASC,UAAU,QAAQ,mBAAmB;AAC9C,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,OAAO,QAAQ,QAAQ;AAOhC,OAAO,SAASC,aAAa,EAAEC,cAAc,EAAE,GAAGC,MAAyB;IACzE,MAAMC,QAAQL;IACd,MAAMM,aAAaD,MAAME,OAAO,CAACC,IAAI,KAAK;IAE1C,MAAMC,kBAAkBR,QAAQ;QAC9B,OAAO,IAAIH,kBAAkBY,cAAc,CAAC,OAAOC,WAAW,CAACR,gBAAgBS,WAAW;IAC5F,GAAG;QAACT;KAAe;IAEnB,qBACE,KAACN;QACE,GAAGO,IAAI;QACRS,OAAO;YAAEC,QAAQ,CAAC,UAAU,EAAET,MAAME,OAAO,CAACQ,OAAO,CAAC,CAAC;QAAC;QACtDV,OAAOC,aAAa,SAAS;QAC7BU,YAAY;YACVC,qBAAqB;YACrBC,2BAA2B;YAC3BC,YAAY;QACd;QACAC,YAAY;YAACrB,WAAWsB,YAAY;YAAEZ;SAAgB;;AAG5D"}
|