@perses-dev/prometheus-plugin 0.56.0 → 0.57.0-beta.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/__mf/js/Prometheus.2bb892ab.js +6 -0
- package/__mf/js/async/1233.0ab88b51.js +1 -0
- package/__mf/js/async/1324.ce01eced.js +1 -0
- package/__mf/js/async/1432.0c3e4ed0.js +1 -0
- package/__mf/js/async/1490.7e5068f1.js +22 -0
- package/__mf/js/async/1605.dc180cb8.js +110 -0
- package/__mf/js/async/1616.7587ce79.js +1 -0
- package/__mf/js/async/1728.af16c4ec.js +1 -0
- package/__mf/js/async/1969.372d36b8.js +1 -0
- package/__mf/js/async/2043.d0fbb886.js +2 -0
- package/__mf/js/async/2186.e58838a5.js +38 -0
- package/__mf/js/async/2506.1e336b3b.js +1 -0
- package/__mf/js/async/2984.7182c2f5.js +1 -0
- package/__mf/js/async/2999.1d8347df.js +1 -0
- package/__mf/js/async/3184.6b4ad42e.js +1 -0
- package/__mf/js/async/3664.ba8b26b6.js +2 -0
- package/__mf/js/async/392.7cda691a.js +2 -0
- package/__mf/js/async/3963.5fef6ffb.js +1 -0
- package/__mf/js/async/3996.69a9c1dc.js +1 -0
- package/__mf/js/async/{1964.1d168a86.js → 4121.828d661d.js} +2 -2
- package/__mf/js/async/4626.173e602a.js +1 -0
- package/__mf/js/async/4987.c12b89cb.js +1 -0
- package/__mf/js/async/{8930.700a5439.js → 5002.e4f54e8e.js} +1 -1
- package/__mf/js/async/5071.e1c33fa7.js +1 -0
- package/__mf/js/async/529.2303b01b.js +1 -0
- package/__mf/js/async/5440.c13c3533.js +2 -0
- package/__mf/js/async/5501.6166367c.js +2 -0
- package/__mf/js/async/{5214.0fca84ed.js → 5587.4d72fc35.js} +1 -1
- package/__mf/js/async/5763.4ba478ff.js +1 -0
- package/__mf/js/async/5922.d1619ac1.js +1 -0
- package/__mf/js/async/6149.19799c37.js +7 -0
- package/__mf/js/async/6274.478a68f8.js +2 -0
- package/__mf/js/async/6283.181cb622.js +2 -0
- package/__mf/js/async/6969.b959b6f8.js +1 -0
- package/__mf/js/async/{4062.06f48b93.js → 7177.205c9aaf.js} +1 -1
- package/__mf/js/async/7192.d835931b.js +1 -0
- package/__mf/js/async/7894.9c5245d7.js +1 -0
- package/__mf/js/async/7968.6ac0ce96.js +1 -0
- package/__mf/js/async/7978.9532d5b8.js +1 -0
- package/__mf/js/async/8356.789e1dfb.js +1 -0
- package/__mf/js/async/8470.9b14a625.js +2 -0
- package/__mf/js/async/873.448eab23.js +1 -0
- package/__mf/js/async/8888.59eb50a2.js +1 -0
- package/__mf/js/async/9020.c19782f1.js +1 -0
- package/__mf/js/async/9184.43a8d927.js +1 -0
- package/__mf/js/async/9235.36c3cd8c.js +1 -0
- package/__mf/js/async/9351.715f25c3.js +1 -0
- package/__mf/js/async/941.53b13124.js +2 -0
- package/__mf/js/async/9518.38e38a33.js +1 -0
- package/__mf/js/async/9588.9081c7de.js +1 -0
- package/__mf/js/async/9605.a92ec9c1.js +1 -0
- package/__mf/js/async/9836.00da6086.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusDatasource.6f63e147.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusExplorer.584a073d.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.40984a4d.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.bd3eb00c.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.5cca8417.js +1 -0
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.f59141f4.js +1 -0
- package/__mf/js/main.9617b605.js +6 -0
- package/lib/bootstrap.js +1 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/components/PromQLEditor.js +4 -7
- package/lib/cjs/components/promql/ast.js +10 -10
- package/lib/cjs/components/promql/format.js +3 -3
- package/lib/cjs/components/promql/utils.js +5 -5
- package/lib/cjs/components/query.js +3 -3
- package/lib/cjs/explore/PrometheusExplorer.js +10 -6
- package/lib/cjs/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +4 -4
- package/lib/cjs/explore/PrometheusMetricsFinder/display/list/MetricList.js +3 -3
- package/lib/cjs/explore/PrometheusMetricsFinder/filter/FilterInputs.js +4 -4
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/MetricOverview.js +3 -3
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/JobTab.js +4 -4
- package/lib/cjs/explore/PrometheusMetricsFinder/overview/tabs/OverviewTab.js +4 -4
- package/lib/cjs/explore/PrometheusMetricsFinder/utils.js +5 -5
- package/lib/cjs/index-federation.js +12 -12
- package/lib/cjs/model/parse-sample-values.js +3 -3
- package/lib/cjs/model/prometheus-client.js +29 -19
- package/lib/cjs/model/prometheus-selectors.js +5 -5
- package/lib/cjs/model/time.js +4 -4
- package/lib/cjs/plugins/PrometheusDatasourceEditor.js +175 -2
- package/lib/cjs/plugins/prometheus-datasource.js +17 -9
- package/lib/cjs/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +36 -1
- package/lib/cjs/plugins/prometheus-time-series-query/query-editor-model.js +4 -4
- package/lib/cjs/plugins/prometheus-variables.js +52 -33
- package/lib/cjs/utils/utils.js +4 -4
- package/lib/components/PromQLEditor.d.ts +5 -1
- package/lib/components/PromQLEditor.d.ts.map +1 -1
- package/lib/components/PromQLEditor.js +5 -8
- package/lib/components/PromQLEditor.js.map +1 -1
- package/lib/components/TreeNode.js +1 -1
- package/lib/components/TreeNode.js.map +1 -1
- package/lib/components/promql/format.js +1 -1
- package/lib/components/promql/format.js.map +1 -1
- package/lib/explore/PrometheusExplorer.d.ts.map +1 -1
- package/lib/explore/PrometheusExplorer.js +10 -6
- package/lib/explore/PrometheusExplorer.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/PrometheusMetricsFinder.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/display/MetricChip.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/display/list/MetricList.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FilterInputs.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/filter/FinderFilters.js.map +1 -1
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js +1 -1
- package/lib/explore/PrometheusMetricsFinder/overview/MetricOverview.js.map +1 -1
- package/lib/model/prometheus-client.d.ts +1 -0
- package/lib/model/prometheus-client.d.ts.map +1 -1
- package/lib/model/prometheus-client.js +19 -9
- package/lib/model/prometheus-client.js.map +1 -1
- package/lib/plugins/MatcherEditor.js +1 -1
- package/lib/plugins/MatcherEditor.js.map +1 -1
- package/lib/plugins/PrometheusDatasourceEditor.d.ts.map +1 -1
- package/lib/plugins/PrometheusDatasourceEditor.js +135 -3
- package/lib/plugins/PrometheusDatasourceEditor.js.map +1 -1
- package/lib/plugins/prometheus-datasource.js +17 -9
- package/lib/plugins/prometheus-datasource.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js +39 -4
- package/lib/plugins/prometheus-time-series-query/PrometheusTimeSeriesQueryEditor.js.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.d.ts.map +1 -1
- package/lib/plugins/prometheus-time-series-query/get-time-series-data.js.map +1 -1
- package/lib/plugins/prometheus-variables.d.ts.map +1 -1
- package/lib/plugins/prometheus-variables.js +47 -28
- package/lib/plugins/prometheus-variables.js.map +1 -1
- package/lib/plugins/types.d.ts +1 -0
- package/lib/plugins/types.d.ts.map +1 -1
- package/lib/plugins/types.js.map +1 -1
- package/mf-manifest.json +268 -253
- package/mf-stats.json +271 -254
- package/package.json +7 -7
- package/__mf/js/Prometheus.4d0d5812.js +0 -5
- package/__mf/js/async/1339.194207db.js +0 -1
- package/__mf/js/async/1441.c735f7dd.js +0 -1
- package/__mf/js/async/1576.8eac7ce9.js +0 -1
- package/__mf/js/async/212.5fcca998.js +0 -1
- package/__mf/js/async/2292.57d8fd0d.js +0 -2
- package/__mf/js/async/3224.b63f87bf.js +0 -1
- package/__mf/js/async/3507.f1653337.js +0 -101
- package/__mf/js/async/3749.3ecd9372.js +0 -1
- package/__mf/js/async/3863.7192dfdf.js +0 -2
- package/__mf/js/async/3960.3eedafbd.js +0 -2
- package/__mf/js/async/3980.0b0d272c.js +0 -2
- package/__mf/js/async/4075.dab1b7b8.js +0 -1
- package/__mf/js/async/4238.c48b1950.js +0 -1
- package/__mf/js/async/4421.1fcb466e.js +0 -1
- package/__mf/js/async/4535.f24704ea.js +0 -1
- package/__mf/js/async/4557.f3eb9456.js +0 -2
- package/__mf/js/async/4576.f42daf99.js +0 -1
- package/__mf/js/async/4665.cad36935.js +0 -1
- package/__mf/js/async/4676.b7a22f90.js +0 -22
- package/__mf/js/async/5257.ce463cb7.js +0 -1
- package/__mf/js/async/5409.955ffd51.js +0 -1
- package/__mf/js/async/5614.cce8ba96.js +0 -1
- package/__mf/js/async/5724.794828e3.js +0 -1
- package/__mf/js/async/5774.a3fae698.js +0 -1
- package/__mf/js/async/5790.a9b31ca8.js +0 -1
- package/__mf/js/async/58.1c9a8daa.js +0 -2
- package/__mf/js/async/5981.eb502d27.js +0 -2
- package/__mf/js/async/6292.2afe0c6d.js +0 -1
- package/__mf/js/async/6341.20eccf91.js +0 -7
- package/__mf/js/async/6377.c40920f2.js +0 -2
- package/__mf/js/async/6770.7099bb3b.js +0 -1
- package/__mf/js/async/684.4495f632.js +0 -1
- package/__mf/js/async/694.8462a746.js +0 -1
- package/__mf/js/async/7272.6fa2f127.js +0 -1
- package/__mf/js/async/7376.2e948f2b.js +0 -1
- package/__mf/js/async/738.a1ffff79.js +0 -1
- package/__mf/js/async/7740.a8777825.js +0 -1
- package/__mf/js/async/8045.7f554a45.js +0 -10
- package/__mf/js/async/8164.bb3d3363.js +0 -1
- package/__mf/js/async/8216.e689c178.js +0 -1
- package/__mf/js/async/8488.cbbe542b.js +0 -1
- package/__mf/js/async/8587.40df6f5c.js +0 -1
- package/__mf/js/async/8706.89677575.js +0 -1
- package/__mf/js/async/9010.bdb2ef97.js +0 -1
- package/__mf/js/async/9173.915b80af.js +0 -2
- package/__mf/js/async/9550.642ce5ad.js +0 -38
- package/__mf/js/async/9817.70eae424.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusDatasource.45ee94e2.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusExplorer.b8e555e1.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelNamesVariable.00dfb1dd.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusLabelValuesVariable.956ef2d0.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusPromQLVariable.59f2d170.js +0 -1
- package/__mf/js/async/__federation_expose_PrometheusTimeSeriesQuery.d7143352.js +0 -1
- package/__mf/js/main.afc2ee60.js +0 -5
- /package/__mf/css/async/{1339.d3010b86.css → 1233.d3010b86.css} +0 -0
- /package/__mf/css/async/{1576.d3010b86.css → 1324.d3010b86.css} +0 -0
- /package/__mf/css/async/{4576.d3010b86.css → 9518.d3010b86.css} +0 -0
- /package/__mf/js/async/{4676.b7a22f90.js.LICENSE.txt → 1490.7e5068f1.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8045.7f554a45.js.LICENSE.txt → 1605.dc180cb8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{2292.57d8fd0d.js.LICENSE.txt → 2043.d0fbb886.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{58.1c9a8daa.js.LICENSE.txt → 3664.ba8b26b6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5981.eb502d27.js.LICENSE.txt → 392.7cda691a.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1964.1d168a86.js.LICENSE.txt → 4121.828d661d.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6377.c40920f2.js.LICENSE.txt → 5440.c13c3533.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{4557.f3eb9456.js.LICENSE.txt → 5501.6166367c.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{6341.20eccf91.js.LICENSE.txt → 6149.19799c37.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3960.3eedafbd.js.LICENSE.txt → 6274.478a68f8.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3980.0b0d272c.js.LICENSE.txt → 6283.181cb622.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{9173.915b80af.js.LICENSE.txt → 8470.9b14a625.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3863.7192dfdf.js.LICENSE.txt → 941.53b13124.js.LICENSE.txt} +0 -0
|
@@ -17,26 +17,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
function _export(target, all) {
|
|
18
18
|
for(var name in all)Object.defineProperty(target, name, {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: all
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
PrometheusLabelNamesVariableEditor
|
|
24
|
+
get PrometheusLabelNamesVariableEditor () {
|
|
25
25
|
return PrometheusLabelNamesVariableEditor;
|
|
26
26
|
},
|
|
27
|
-
PrometheusLabelValuesVariableEditor
|
|
27
|
+
get PrometheusLabelValuesVariableEditor () {
|
|
28
28
|
return PrometheusLabelValuesVariableEditor;
|
|
29
29
|
},
|
|
30
|
-
PrometheusPromQLVariableEditor
|
|
30
|
+
get PrometheusPromQLVariableEditor () {
|
|
31
31
|
return PrometheusPromQLVariableEditor;
|
|
32
32
|
},
|
|
33
|
-
capturingMatrix
|
|
33
|
+
get capturingMatrix () {
|
|
34
34
|
return capturingMatrix;
|
|
35
35
|
},
|
|
36
|
-
capturingVector
|
|
36
|
+
get capturingVector () {
|
|
37
37
|
return capturingVector;
|
|
38
38
|
},
|
|
39
|
-
stringArrayToVariableOptions
|
|
39
|
+
get stringArrayToVariableOptions () {
|
|
40
40
|
return stringArrayToVariableOptions;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
@@ -51,8 +51,6 @@ const _MatcherEditor = require("./MatcherEditor");
|
|
|
51
51
|
function PrometheusLabelValuesVariableEditor(props) {
|
|
52
52
|
const { onChange, value, value: { datasource } } = props;
|
|
53
53
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
54
|
-
const [labelValue, setLabelValue] = (0, _react.useState)(props.value.labelName);
|
|
55
|
-
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
56
54
|
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
57
55
|
if ((0, _pluginsystem.isVariableDatasource)(next) || (0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
58
56
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
@@ -67,11 +65,21 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
67
65
|
value
|
|
68
66
|
]);
|
|
69
67
|
const handleLabelChange = (0, _react.useCallback)((e)=>{
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
69
|
+
draft.labelName = e.target.value;
|
|
70
|
+
}));
|
|
71
|
+
}, [
|
|
72
|
+
onChange,
|
|
73
|
+
value
|
|
74
|
+
]);
|
|
75
|
+
const handleMatchEditorsChange = (0, _react.useCallback)((matchers)=>{
|
|
76
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
77
|
+
draft.matchers = matchers;
|
|
78
|
+
}));
|
|
79
|
+
}, [
|
|
80
|
+
onChange,
|
|
81
|
+
value
|
|
82
|
+
]);
|
|
75
83
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
76
84
|
spacing: 2,
|
|
77
85
|
children: [
|
|
@@ -89,14 +97,16 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
89
97
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
90
98
|
label: "Label Name",
|
|
91
99
|
required: true,
|
|
92
|
-
value:
|
|
100
|
+
value: props.value.labelName,
|
|
93
101
|
onChange: handleLabelChange,
|
|
94
|
-
|
|
95
|
-
|
|
102
|
+
slotProps: {
|
|
103
|
+
input: {
|
|
104
|
+
readOnly: props.isReadonly
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
}),
|
|
98
108
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
|
|
99
|
-
matchers:
|
|
109
|
+
matchers: props.value.matchers ?? [],
|
|
100
110
|
onChange: handleMatchEditorsChange,
|
|
101
111
|
isReadonly: props.isReadonly
|
|
102
112
|
})
|
|
@@ -106,7 +116,6 @@ function PrometheusLabelValuesVariableEditor(props) {
|
|
|
106
116
|
function PrometheusLabelNamesVariableEditor(props) {
|
|
107
117
|
const { onChange, value, value: { datasource } } = props;
|
|
108
118
|
const selectedDatasource = datasource ?? _model.DEFAULT_PROM;
|
|
109
|
-
const [matchersValues, setMatchersValues] = (0, _react.useState)(props.value.matchers ?? []);
|
|
110
119
|
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
111
120
|
if ((0, _pluginsystem.isVariableDatasource)(next) || (0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
112
121
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
@@ -120,9 +129,14 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
120
129
|
onChange,
|
|
121
130
|
value
|
|
122
131
|
]);
|
|
123
|
-
const handleMatchEditorChange = (0, _react.useCallback)((
|
|
124
|
-
|
|
125
|
-
|
|
132
|
+
const handleMatchEditorChange = (0, _react.useCallback)((matchers)=>{
|
|
133
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
134
|
+
draft.matchers = matchers;
|
|
135
|
+
}));
|
|
136
|
+
}, [
|
|
137
|
+
onChange,
|
|
138
|
+
value
|
|
139
|
+
]);
|
|
126
140
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
127
141
|
spacing: 2,
|
|
128
142
|
children: [
|
|
@@ -138,7 +152,7 @@ function PrometheusLabelNamesVariableEditor(props) {
|
|
|
138
152
|
})
|
|
139
153
|
}),
|
|
140
154
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_MatcherEditor.MatcherEditor, {
|
|
141
|
-
matchers:
|
|
155
|
+
matchers: props.value.matchers ?? [],
|
|
142
156
|
isReadonly: props.isReadonly,
|
|
143
157
|
onChange: handleMatchEditorChange
|
|
144
158
|
})
|
|
@@ -151,7 +165,6 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
151
165
|
const selectedDatasource = (0, _pluginsystem.useDatasourceSelectValueToSelector)(datasourceSelectValue, _model.PROM_DATASOURCE_KIND);
|
|
152
166
|
const { data: client } = (0, _pluginsystem.useDatasourceClient)(selectedDatasource);
|
|
153
167
|
const promURL = client?.options.datasourceUrl;
|
|
154
|
-
const [labelValue, setLabelValue] = (0, _react.useState)(props.value.labelName);
|
|
155
168
|
const handleDatasourceChange = (0, _react.useCallback)((next)=>{
|
|
156
169
|
if ((0, _pluginsystem.isVariableDatasource)(next) || (0, _model.isPrometheusDatasourceSelector)(next)) {
|
|
157
170
|
onChange((0, _immer.produce)(value, (draft)=>{
|
|
@@ -166,17 +179,21 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
166
179
|
onChange
|
|
167
180
|
]);
|
|
168
181
|
const handleOnBlurPromQlChange = (0, _react.useCallback)((e)=>{
|
|
169
|
-
onChange({
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
});
|
|
182
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
183
|
+
draft.expr = e.target.textContent ?? '';
|
|
184
|
+
}));
|
|
173
185
|
}, [
|
|
174
186
|
onChange,
|
|
175
187
|
value
|
|
176
188
|
]);
|
|
177
189
|
const handleLabelNameChange = (0, _react.useCallback)((e)=>{
|
|
178
|
-
|
|
179
|
-
|
|
190
|
+
onChange((0, _immer.produce)(value, (draft)=>{
|
|
191
|
+
draft.labelName = e.target.value;
|
|
192
|
+
}));
|
|
193
|
+
}, [
|
|
194
|
+
onChange,
|
|
195
|
+
value
|
|
196
|
+
]);
|
|
180
197
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
181
198
|
spacing: 2,
|
|
182
199
|
children: [
|
|
@@ -206,9 +223,11 @@ function PrometheusPromQLVariableEditor(props) {
|
|
|
206
223
|
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
207
224
|
label: "Label Name",
|
|
208
225
|
required: true,
|
|
209
|
-
value:
|
|
210
|
-
|
|
211
|
-
|
|
226
|
+
value: props.value.labelName,
|
|
227
|
+
slotProps: {
|
|
228
|
+
input: {
|
|
229
|
+
readOnly: props.isReadonly
|
|
230
|
+
}
|
|
212
231
|
},
|
|
213
232
|
onChange: handleLabelNameChange
|
|
214
233
|
})
|
package/lib/cjs/utils/utils.js
CHANGED
|
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
17
17
|
function _export(target, all) {
|
|
18
18
|
for(var name in all)Object.defineProperty(target, name, {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: all
|
|
20
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
formatSeriesName
|
|
24
|
+
get formatSeriesName () {
|
|
25
25
|
return formatSeriesName;
|
|
26
26
|
},
|
|
27
|
-
getFormattedPrometheusSeriesName
|
|
27
|
+
get getFormattedPrometheusSeriesName () {
|
|
28
28
|
return getFormattedPrometheusSeriesName;
|
|
29
29
|
},
|
|
30
|
-
getUniqueKeyForPrometheusResult
|
|
30
|
+
get getUniqueKeyForPrometheusResult () {
|
|
31
31
|
return getUniqueKeyForPrometheusResult;
|
|
32
32
|
}
|
|
33
33
|
});
|
|
@@ -6,6 +6,10 @@ export type PromQLEditorProps = {
|
|
|
6
6
|
completeConfig: CompleteConfiguration;
|
|
7
7
|
datasource: PrometheusDatasourceSelector;
|
|
8
8
|
isReadOnly?: boolean;
|
|
9
|
+
treeViewMetadata?: {
|
|
10
|
+
minStepMs: number;
|
|
11
|
+
intervalMs: number;
|
|
12
|
+
};
|
|
9
13
|
} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;
|
|
10
|
-
export declare function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }: PromQLEditorProps): ReactElement;
|
|
14
|
+
export declare function PromQLEditor({ completeConfig, datasource, isReadOnly, treeViewMetadata, ...rest }: PromQLEditorProps): ReactElement;
|
|
11
15
|
//# sourceMappingURL=PromQLEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromQLEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromQLEditor.tsx"],"names":[],"mappings":"AAaA,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAmB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAI1F,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AASxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,qBAAqB,CAAC;IACtC,UAAU,EAAE,4BAA4B,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"PromQLEditor.d.ts","sourceRoot":"","sources":["../../../src/components/PromQLEditor.tsx"],"names":[],"mappings":"AAaA,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAmB,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAI1F,OAAO,EAAE,YAAY,EAAqB,MAAM,OAAO,CAAC;AAIxD,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AASxD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,qBAAqB,CAAC;IACtC,UAAU,EAAE,4BAA4B,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,GAAG,IAAI,CAAC,oBAAoB,EAAE,OAAO,GAAG,YAAY,CAAC,CAAC;AAEvD,wBAAgB,YAAY,CAAC,EAC3B,cAAc,EACd,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,iBAAiB,GAAG,YAAY,CAsHlC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
// Copyright 2025 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +11,6 @@
|
|
|
10
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import CodeMirror from '@uiw/react-codemirror';
|
|
15
15
|
import { PromQLExtension } from '@prometheus-io/codemirror-promql';
|
|
16
16
|
import { EditorView } from '@codemirror/view';
|
|
@@ -26,7 +26,7 @@ import TreeNode from './TreeNode';
|
|
|
26
26
|
const treeViewStr = 'Tree View';
|
|
27
27
|
const treeViewOpenStr = 'Open ' + treeViewStr;
|
|
28
28
|
const treeViewCloseStr = 'Close ' + treeViewStr;
|
|
29
|
-
export function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }) {
|
|
29
|
+
export function PromQLEditor({ completeConfig, datasource, isReadOnly, treeViewMetadata, ...rest }) {
|
|
30
30
|
const theme = useTheme();
|
|
31
31
|
const isDarkMode = theme.palette.mode === 'dark';
|
|
32
32
|
const [isTreeViewVisible, setTreeViewVisible] = useState(false);
|
|
@@ -37,12 +37,9 @@ export function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }
|
|
|
37
37
|
completeConfig
|
|
38
38
|
]);
|
|
39
39
|
let queryExpr = useReplaceVariablesInString(rest.value);
|
|
40
|
-
if (queryExpr) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire
|
|
44
|
-
// queries here, so maybe we should extract this part to independant hook(s), to be reused here?
|
|
45
|
-
queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);
|
|
40
|
+
if (queryExpr && treeViewMetadata) {
|
|
41
|
+
const { minStepMs, intervalMs } = treeViewMetadata;
|
|
42
|
+
queryExpr = replacePromBuiltinVariables(queryExpr, minStepMs, intervalMs);
|
|
46
43
|
}
|
|
47
44
|
const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);
|
|
48
45
|
const handleShowTreeView = ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PromQLEditor.tsx"],"sourcesContent":["// Copyright 2025 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, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n isReadOnly?: boolean;\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({ completeConfig, datasource, isReadOnly, ...rest }: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n const readOnly = isReadOnly ?? false;\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr) {\n // TODO placeholder values for steps to be replaced with actual values\n // Looks like providing proper values involves some refactoring: currently we'd need to rely on the timeseries query context,\n // but these step values are actually computed independently / before the queries are getting fired, so it's useless to fire\n // queries here, so maybe we should extract this part to independant hook(s), to be reused here?\n queryExpr = replacePromBuiltinVariables(queryExpr, 12345, 12345);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-12px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n {/* TODO: We need to wait for this to be merged, then we need to add proper e2e for some scenarios */}\n <CodeMirror\n data-testid=\"promql_expression_editor\"\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n readOnly={readOnly}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","isReadOnly","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","readOnly","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","data-testid","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"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,UA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AU;wCAAO;;mCAF9B;;4BAKP/B,QACC,gDAAgD;0CAChD,KAAC9B;gCACC8B,OAAO;oCACLiC,MAAM,GAAGzD,YAAY,cAAc,CAAC;oCACpC0D,SAASlC,MAAMkC,OAAO;gCACxB;+CAGF,KAACF;gCACCnB,OAAO;oCACLN,SAAS,GAAGvB,MAAMmD,OAAO,CAAC,KAAK,CAAC,EAAEnD,MAAMmD,OAAO,CAAC,KAAK,GAAG,EAAEnD,MAAMmD,OAAO,CAAC,MAAM;oCAC9EC,WAAW;oCACXC,iBAAiBrD,MAAME,OAAO,CAACoD,UAAU,CAACC,OAAO;gCACnD;0CAECxC,0BACC,KAACrC,wBACCoC,oBAAoBD,qBACtB,KAACtB;oCAASiE,MAAM1C,mBAAmBD,IAAI;oCAAE4C,SAAS;oCAAOC,UAAU;oCAAG7D,YAAYA;qCAChF;;;;;;;;AAStB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PromQLEditor.tsx"],"sourcesContent":["// Copyright 2025 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, CircularProgress, InputLabel, Stack, IconButton, Tooltip } from '@mui/material';\nimport FileTreeIcon from 'mdi-material-ui/FileTree';\nimport { ReactElement, useMemo, useState } from 'react';\nimport { ErrorAlert } from '@perses-dev/components';\nimport CloseIcon from 'mdi-material-ui/Close';\nimport { useReplaceVariablesInString } from '@perses-dev/plugin-system';\nimport { PrometheusDatasourceSelector } from '../model';\nimport { replacePromBuiltinVariables } from '../plugins/prometheus-time-series-query/replace-prom-builtin-variables';\nimport { useParseQuery } from './query';\nimport TreeNode from './TreeNode';\n\nconst treeViewStr = 'Tree View';\nconst treeViewOpenStr = 'Open ' + treeViewStr;\nconst treeViewCloseStr = 'Close ' + treeViewStr;\n\nexport type PromQLEditorProps = {\n completeConfig: CompleteConfiguration;\n datasource: PrometheusDatasourceSelector;\n isReadOnly?: boolean;\n treeViewMetadata?: {\n minStepMs: number;\n intervalMs: number;\n };\n} & Omit<ReactCodeMirrorProps, 'theme' | 'extensions'>;\n\nexport function PromQLEditor({\n completeConfig,\n datasource,\n isReadOnly,\n treeViewMetadata,\n ...rest\n}: PromQLEditorProps): ReactElement {\n const theme = useTheme();\n\n const isDarkMode = theme.palette.mode === 'dark';\n const [isTreeViewVisible, setTreeViewVisible] = useState(false);\n const readOnly = isReadOnly ?? false;\n\n const promQLExtension = useMemo(() => {\n return new PromQLExtension().activateLinter(false).setComplete(completeConfig).asExtension();\n }, [completeConfig]);\n\n let queryExpr = useReplaceVariablesInString(rest.value);\n if (queryExpr && treeViewMetadata) {\n const { minStepMs, intervalMs } = treeViewMetadata;\n queryExpr = replacePromBuiltinVariables(queryExpr, minStepMs, intervalMs);\n }\n\n const { data: parseQueryResponse, isLoading, error } = useParseQuery(queryExpr ?? '', datasource, isTreeViewVisible);\n\n const handleShowTreeView = (): void => {\n setTreeViewVisible(!isTreeViewVisible);\n };\n\n return (\n <Stack position=\"relative\">\n <InputLabel // reproduce the same kind of input label that regular MUI TextFields have\n shrink\n sx={{\n position: 'absolute',\n top: '-12px',\n left: '10px',\n padding: '0 4px',\n color: theme.palette.text.primary,\n zIndex: 1,\n }}\n >\n PromQL Expression\n </InputLabel>\n {/* TODO: We need to wait for this to be merged, then we need to add proper e2e for some scenarios */}\n <CodeMirror\n data-testid=\"promql_expression_editor\"\n {...rest}\n style={{ border: `1px solid ${theme.palette.divider}` }}\n theme={isDarkMode ? 'dark' : 'light'}\n readOnly={readOnly}\n basicSetup={{\n highlightActiveLine: false,\n highlightActiveLineGutter: false,\n foldGutter: false,\n }}\n extensions={[\n EditorView.lineWrapping,\n promQLExtension,\n EditorView.theme({\n '.cm-content': {\n paddingTop: '8px',\n paddingBottom: '8px',\n paddingRight: '40px', // offset for the tree view button\n },\n }),\n ]}\n placeholder=\"Example: sum(rate(http_requests_total[5m]))\"\n />\n {queryExpr && (\n <>\n <Tooltip title={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}>\n <IconButton\n aria-label={isTreeViewVisible ? treeViewCloseStr : treeViewOpenStr}\n onClick={handleShowTreeView}\n sx={{ position: 'absolute', right: '5px', top: '5px' }}\n size=\"small\"\n key=\"tree-view-button\"\n >\n <FileTreeIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {isTreeViewVisible && (\n <div style={{ border: `1px solid ${theme.palette.divider}`, position: 'relative' }}>\n <Tooltip title={treeViewCloseStr}>\n <IconButton\n aria-label={treeViewCloseStr}\n onClick={() => setTreeViewVisible(false)}\n sx={{ position: 'absolute', top: '5px', right: '5px' }}\n size=\"small\"\n key=\"tree-view-close-button\"\n >\n <CloseIcon sx={{ fontSize: '18px' }} />\n </IconButton>\n </Tooltip>\n {error ? (\n // Here the user is able to hide the error alert\n <ErrorAlert\n error={{\n name: `${treeViewStr} not available`,\n message: error.message,\n }}\n />\n ) : (\n <div\n style={{\n padding: `${theme.spacing(1.5)} ${theme.spacing(1.5)} 0 ${theme.spacing(1.5)}`, // let paddingBottom at 0 because nodes have margin-bottom\n overflowX: 'auto',\n backgroundColor: theme.palette.background.default,\n }}\n >\n {isLoading ? (\n <CircularProgress />\n ) : parseQueryResponse?.data ? (\n <TreeNode node={parseQueryResponse.data} reverse={false} childIdx={0} datasource={datasource} />\n ) : null}\n </div>\n )}\n </div>\n )}\n </>\n )}\n </Stack>\n );\n}\n"],"names":["CodeMirror","PromQLExtension","EditorView","useTheme","CircularProgress","InputLabel","Stack","IconButton","Tooltip","FileTreeIcon","useMemo","useState","ErrorAlert","CloseIcon","useReplaceVariablesInString","replacePromBuiltinVariables","useParseQuery","TreeNode","treeViewStr","treeViewOpenStr","treeViewCloseStr","PromQLEditor","completeConfig","datasource","isReadOnly","treeViewMetadata","rest","theme","isDarkMode","palette","mode","isTreeViewVisible","setTreeViewVisible","readOnly","promQLExtension","activateLinter","setComplete","asExtension","queryExpr","value","minStepMs","intervalMs","data","parseQueryResponse","isLoading","error","handleShowTreeView","position","shrink","sx","top","left","padding","color","text","primary","zIndex","data-testid","style","border","divider","basicSetup","highlightActiveLine","highlightActiveLineGutter","foldGutter","extensions","lineWrapping","paddingTop","paddingBottom","paddingRight","placeholder","title","aria-label","onClick","right","size","fontSize","div","name","message","spacing","overflowX","backgroundColor","background","default","node","reverse","childIdx"],"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,EAAEC,gBAAgB,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,EAAEC,OAAO,QAAQ,gBAAgB;AACnG,OAAOC,kBAAkB,2BAA2B;AACpD,SAAuBC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACxD,SAASC,UAAU,QAAQ,yBAAyB;AACpD,OAAOC,eAAe,wBAAwB;AAC9C,SAASC,2BAA2B,QAAQ,4BAA4B;AAExE,SAASC,2BAA2B,QAAQ,yEAAyE;AACrH,SAASC,aAAa,QAAQ,UAAU;AACxC,OAAOC,cAAc,aAAa;AAElC,MAAMC,cAAc;AACpB,MAAMC,kBAAkB,UAAUD;AAClC,MAAME,mBAAmB,WAA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MAAM1C,mBAAmBD,IAAI;oCAAE4C,SAAS;oCAAOC,UAAU;oCAAGhE,YAAYA;qCAChF;;;;;;;;AAStB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
// Copyright 2025 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,7 +12,6 @@
|
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
14
|
// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
15
|
import { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';
|
|
16
16
|
import CircleIcon from 'mdi-material-ui/Circle';
|
|
17
17
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2025 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n – \n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <> –</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n flexGrow: 1,\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n whiteSpace: 'nowrap',\n flexShrink: 0,\n }}\n >\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","whiteSpace","overflow","textOverflow","flexGrow","flexShrink","arrow","span","style","cursor","success","size"],"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,oJAAoJ;;AAEpJ,SAASA,GAAG,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5G,OAAOC,gBAAgB,yBAAyB;AAChD,SAAuBC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACjG,OAAOC,iBAAiB,8BAA8B;AAGtD,SAAkBC,QAAQ,QAAQ,eAAe;AACjD,SAASC,YAAY,EAAEC,eAAe,QAAQ,iBAAiB;AAC/D,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,mBAAmB,qBAAqB;AAC/C,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,eAAe,QAAQ,UAAU;AAE1C,qDAAqD;AACrD,MAAMC,aAAa;AACnB,MAAMC,iBAAiBD,aAAa;AAEpC,8EAA8E;AAC9E,MAAME,gBAAgB;A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4BAAEC,QAAQ;4BAAWR,YAAY;wBAAS;;0CACrD,KAAChJ;gCACCiI,SAAQ;gCACRG,WAAU;gCACVxB,IAAI;oCAAEmC,YAAY;oCAAahB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAAC8G,OAAO,CAACzB,IAAI;gCAAC;0CAE3EtC;;0CAEH,MAAC1F;gCAAWiI,SAAQ;gCAAQG,WAAU;gCAAOxB,IAAI;oCAAEmB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAACC,IAAI,CAAC,IAAI;gCAAC;;oCAAG;oCAC3FuD;;;;;mBAvEFT;YA4ERvD,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE,8BACrC,MAAClB;gBAAWiI,SAAQ;;oBAAQ;oBAAI9F,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE;oBAAc;;iBAClF;;;AAGV;AAEA,SAAS0G,cAAc,EAAEC,IAAI,EAAoB;IAC/C,qBACE,MAACnI;QAAIoH,SAAQ;QAAOgB,YAAW;QAASpB,KAAK;QAAGM,cAAc;;0BAC5D,KAACrH;gBAAiB+J,MAAM;gBAAI3B,OAAM;;0BAClC,MAAC/H;gBAAWiI,SAAQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TreeNode.tsx"],"sourcesContent":["// Copyright 2025 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/pages/query/TreeNode.tsx\n\nimport { Box, CircularProgress, List, ListItem, Stack, Tooltip, Typography, useTheme } from '@mui/material';\nimport CircleIcon from 'mdi-material-ui/Circle';\nimport { ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport AlertCircle from 'mdi-material-ui/AlertCircle';\nimport { StatusError } from '@perses-dev/core';\nimport { PrometheusDatasourceSelector } from '../model';\nimport ASTNode, { nodeType } from './promql/ast';\nimport { escapeString, getNodeChildren } from './promql/utils';\nimport { formatNode } from './promql/format';\nimport serializeNode from './promql/serialize';\nimport { functionSignatures } from './promql/functionSignatures';\nimport { useInstantQuery } from './query';\n\n// The indentation factor for each level of the tree.\nconst nodeIndent = 5;\nconst connectorWidth = nodeIndent * 5;\n\n// max number of label names and values to show in the individual query status\nconst maxLabelNames = 10;\nconst maxLabelValues = 10;\n\ntype NodeState = 'waiting' | 'running' | 'error' | 'success';\n\n// mergeChildStates basically returns the \"worst\" state found among the children.\nconst mergeChildStates = (states: NodeState[]): NodeState => {\n if (states.includes('error')) {\n return 'error';\n }\n if (states.includes('waiting')) {\n return 'waiting';\n }\n if (states.includes('running')) {\n return 'running';\n }\n\n return 'success';\n};\n\ninterface TreeNodeProps {\n // The AST node to render.\n node: ASTNode;\n // The parent element of this node.\n parentEl?: HTMLDivElement | null;\n // Used to compute the position of the connector line between this node and its parent.\n reverse: boolean;\n // Datasource used for the node's individual query.\n datasource: PrometheusDatasourceSelector;\n // The index of this node in its parent's children.\n // Used to render the node's individual query.\n childIdx: number;\n // Function to report the node state to the parent.\n // Used to render the node's individual query.\n reportNodeState?: (childIdx: number, state: NodeState) => void;\n}\n\nexport default function TreeNode({\n node,\n parentEl,\n reverse,\n datasource,\n childIdx,\n reportNodeState,\n}: TreeNodeProps): ReactElement {\n const theme = useTheme();\n const children = getNodeChildren(node);\n\n // A normal ref won't work properly here because the ref's `current` property\n // going from `null` to defined won't trigger a re-render of the child\n // component, since it's not a React state update. So we manually have to\n // create a state update using a callback ref. See also\n // https://tkdodo.eu/blog/avoiding-use-effect-with-callback-refs\n const [nodeEl, setNodeEl] = useState<HTMLDivElement | null>(null);\n const nodeRef = useCallback((node: HTMLDivElement) => setNodeEl(node), []);\n\n const [resultStats, setResultStats] = useState<{\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n }>({\n numSeries: 0,\n labelExamples: {},\n sortedLabelCards: [],\n });\n\n const [connectorStyle, setConnectorStyle] = useState({\n borderColor: theme.palette.grey['500'],\n borderLeftStyle: 'solid',\n borderLeftWidth: 2,\n width: connectorWidth,\n left: -connectorWidth,\n });\n\n const [childStates, setChildStates] = useState<NodeState[]>(children.map(() => 'waiting'));\n const mergedChildState = useMemo(() => mergeChildStates(childStates), [childStates]);\n\n // Optimize range vector selector fetches to give us the info we're looking for\n // more cheaply. E.g. 'foo[7w]' can be expensive to fully fetch, but wrapping it\n // in 'last_over_time(foo[7w])' is cheaper and also gives us all the info we\n // need (number of series and labels).\n let queryNode = node;\n if (queryNode.type === nodeType.matrixSelector) {\n queryNode = {\n type: nodeType.call,\n func: functionSignatures.last_over_time!,\n args: [node],\n };\n }\n\n // Individual query for the current node\n const {\n data: instantQueryResponse,\n isFetching,\n error,\n } = useInstantQuery(serializeNode(queryNode) ?? '', datasource, mergedChildState === 'success');\n\n // report the node state to the parent\n useEffect(() => {\n if (reportNodeState) {\n if (mergedChildState === 'error' || error) {\n reportNodeState(childIdx, 'error');\n } else if (isFetching) {\n reportNodeState(childIdx, 'running');\n }\n }\n }, [mergedChildState, error, isFetching, reportNodeState, childIdx]);\n\n // This function is passed down to the child nodes so they can report their state.\n const childReportNodeState = useCallback(\n (childIdx: number, state: NodeState) => {\n setChildStates((prev) => {\n const newStates = [...prev];\n newStates[childIdx] = state;\n return newStates;\n });\n },\n [setChildStates]\n );\n\n // Update the size and position of tree connector lines based on the node's and its parent's position.\n useLayoutEffect(() => {\n if (parentEl === undefined) {\n // We're the root node.\n return;\n }\n\n if (parentEl === null || nodeEl === null) {\n // Either of the two connected nodes hasn't been rendered yet.\n return;\n }\n\n const parentRect = parentEl.getBoundingClientRect();\n const nodeRect = nodeEl.getBoundingClientRect();\n if (reverse) {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: 'calc(50% - 1px)',\n bottom: nodeRect.bottom - parentRect.top,\n borderTopLeftRadius: 10,\n borderTopStyle: 'solid',\n borderBottomLeftRadius: undefined,\n }));\n } else {\n setConnectorStyle((prevStyle) => ({\n ...prevStyle,\n top: parentRect.bottom - nodeRect.top,\n bottom: 'calc(50% - 1px)',\n borderBottomLeftRadius: 10,\n borderBottomStyle: 'solid',\n borderTopLeftRadius: undefined,\n }));\n }\n }, [parentEl, nodeEl, reverse, nodeRef, setConnectorStyle]);\n\n // Update the node info state based on the query result.\n useEffect(() => {\n if (instantQueryResponse?.status !== 'success') {\n return;\n }\n\n if (reportNodeState) {\n reportNodeState(childIdx, 'success');\n }\n\n let resultSeries = 0;\n // labelValuesByName records the number of times each label value appears for each label name.\n const labelValuesByName: Record<string, Record<string, number>> = {};\n const { resultType, result } = instantQueryResponse.data;\n\n if (resultType === 'scalar' || resultType === 'string') {\n resultSeries = 1;\n } else if (result && result.length > 0) {\n resultSeries = result.length;\n result.forEach((s) => {\n Object.entries(s.metric).forEach(([ln, lv]) => {\n // TODO: If we ever want to include __name__ here again, we cannot use the\n // last_over_time(foo[7d]) optimization since that removes the metric name.\n if (ln !== '__name__') {\n labelValuesByName[ln] = labelValuesByName[ln] ?? {};\n labelValuesByName[ln]![lv] = (labelValuesByName[ln]![lv] ?? 0) + 1;\n }\n });\n });\n }\n\n // labelCardinalities records the number of unique label values for each label name.\n const labelCardinalities: Record<string, number> = {};\n // labelExamples records the most common label values for each label name.\n const labelExamples: Record<string, Array<{ value: string; count: number }>> = {};\n Object.entries(labelValuesByName).forEach(([ln, lvs]) => {\n labelCardinalities[ln] = Object.keys(lvs).length;\n // Sort label values by their number of occurrences within this label name.\n labelExamples[ln] = Object.entries(lvs)\n .sort(([, aCnt], [, bCnt]) => bCnt - aCnt)\n .slice(0, maxLabelValues)\n .map(([lv, cnt]) => ({ value: lv, count: cnt }));\n });\n\n setResultStats({\n numSeries: resultSeries,\n sortedLabelCards: Object.entries(labelCardinalities).sort((a, b) => b[1] - a[1]),\n labelExamples,\n });\n }, [instantQueryResponse, reportNodeState, childIdx]);\n\n const innerNode = (\n <Stack direction=\"row\" gap={2}>\n <Box\n ref={nodeRef}\n sx={{\n position: 'relative',\n display: 'inline-block',\n padding: 1,\n marginBottom: 1.5,\n borderRadius: 2,\n backgroundColor: theme.palette.background.code,\n }}\n >\n {parentEl !== undefined && (\n // Connector line between this node and its parent.\n <Box\n sx={{\n position: 'absolute',\n display: 'inline-block',\n ...connectorStyle,\n }}\n />\n )}\n {/* The node (visible box) itself. */}\n {formatNode(node, false, 1)}\n </Box>\n {/* The node's individual query: */}\n <QueryStatus\n mergedChildState={mergedChildState}\n isFetching={isFetching}\n error={error}\n resultStats={resultStats}\n responseTime={instantQueryResponse?.responseTime}\n />\n </Stack>\n );\n\n if (node.type === nodeType.binaryExpr) {\n return (\n <div>\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[0]!}\n parentEl={nodeEl}\n reverse={true}\n datasource={datasource}\n childIdx={0}\n reportNodeState={childReportNodeState}\n />\n </Box>\n {innerNode}\n <Box ml={nodeIndent}>\n <TreeNode\n node={children[1]!}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={1}\n reportNodeState={childReportNodeState}\n />\n </Box>\n </div>\n );\n }\n\n return (\n <div>\n {innerNode}\n {children.map((child, idx) => (\n <Box ml={nodeIndent} key={idx}>\n <TreeNode\n node={child}\n parentEl={nodeEl}\n reverse={false}\n datasource={datasource}\n childIdx={idx}\n reportNodeState={childReportNodeState}\n />\n </Box>\n ))}\n </div>\n );\n}\n\ninterface QueryStatusProps {\n mergedChildState: NodeState;\n isFetching: boolean;\n error: StatusError | null;\n resultStats: {\n numSeries: number;\n labelExamples: Record<string, Array<{ value: string; count: number }>>;\n sortedLabelCards: Array<[string, number]>;\n };\n responseTime?: number;\n}\n\nfunction QueryStatus({\n mergedChildState,\n isFetching,\n error,\n resultStats,\n responseTime,\n}: QueryStatusProps): ReactElement {\n if (mergedChildState === 'waiting') {\n return <ProgressState text=\"Waiting for child query\" />;\n }\n\n if (mergedChildState === 'running') {\n return <ProgressState text=\"Running\" />;\n }\n\n if (mergedChildState === 'error') {\n return (\n <Stack>\n <AlertCircle />\n Blocked on child query error\n </Stack>\n );\n }\n\n if (isFetching) {\n return <ProgressState text=\"Loading\" />;\n }\n\n if (error) {\n return (\n <Box\n display=\"flex\"\n alignItems=\"center\"\n gap={1}\n sx={{ color: (theme) => theme.palette.error.main }}\n marginBottom={1.5}\n >\n <AlertCircle />\n <Typography variant=\"body2\">\n <strong>Error executing query:</strong> {error.message}\n </Typography>\n </Box>\n );\n }\n\n return (\n <Stack direction=\"row\" gap={1} alignItems=\"center\" marginBottom={1.5}>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n {resultStats.numSeries} result{resultStats.numSeries !== 1 && 's'}\n – \n {responseTime ? `${Math.round(responseTime)}ms` : '? ms'}\n {resultStats.sortedLabelCards.length > 0 && <> –</>}\n </Typography>\n {resultStats.sortedLabelCards.slice(0, maxLabelNames).map(([ln, cnt]) => (\n <Tooltip\n key={ln}\n title={\n <Box>\n <List dense>\n {resultStats.labelExamples[ln]?.map(({ value, count }) => (\n <ListItem\n key={value}\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n color: (theme) =>\n theme.palette.mode === 'dark' // TODO we shouldnt have to do that I guess..\n ? theme.palette.warning.dark\n : theme.palette.warning.main,\n fontFamily: 'monospace',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n flexGrow: 1,\n }}\n >\n {escapeString(value)}\n </Typography>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{\n whiteSpace: 'nowrap',\n flexShrink: 0,\n }}\n >\n ({count}x)\n </Typography>\n </ListItem>\n ))}\n {cnt > maxLabelValues && (\n <ListItem\n sx={{\n display: 'flex',\n gap: 1,\n py: 0,\n px: 0.5,\n }}\n >\n <CircleIcon sx={{ fontSize: 8 }} />\n <Typography variant=\"body2\">. . .</Typography>\n </ListItem>\n )}\n </List>\n </Box>\n }\n arrow\n >\n <span style={{ cursor: 'pointer', whiteSpace: 'nowrap' }}>\n <Typography\n variant=\"body2\"\n component=\"span\"\n sx={{ fontFamily: 'monospace', color: (theme) => theme.palette.success.main }}\n >\n {ln}\n </Typography>\n <Typography variant=\"body2\" component=\"span\" sx={{ color: (theme) => theme.palette.grey[500] }}>\n : {cnt}\n </Typography>\n </span>\n </Tooltip>\n ))}\n {resultStats.sortedLabelCards.length > maxLabelNames ? (\n <Typography variant=\"body2\">...{resultStats.sortedLabelCards.length - maxLabelNames} more...</Typography>\n ) : null}\n </Stack>\n );\n}\n\nfunction ProgressState({ text }: { text: string }): ReactElement {\n return (\n <Box display=\"flex\" alignItems=\"center\" gap={1} marginBottom={1.5}>\n <CircularProgress size={16} color=\"secondary\" />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {text}...\n </Typography>\n </Box>\n );\n}\n"],"names":["Box","CircularProgress","List","ListItem","Stack","Tooltip","Typography","useTheme","CircleIcon","useCallback","useEffect","useLayoutEffect","useMemo","useState","AlertCircle","nodeType","escapeString","getNodeChildren","formatNode","serializeNode","functionSignatures","useInstantQuery","nodeIndent","connectorWidth","maxLabelNames","maxLabelValues","mergeChildStates","states","includes","TreeNode","node","parentEl","reverse","datasource","childIdx","reportNodeState","theme","children","nodeEl","setNodeEl","nodeRef","resultStats","setResultStats","numSeries","labelExamples","sortedLabelCards","connectorStyle","setConnectorStyle","borderColor","palette","grey","borderLeftStyle","borderLeftWidth","width","left","childStates","setChildStates","map","mergedChildState","queryNode","type","matrixSelector","call","func","last_over_time","args","data","instantQueryResponse","isFetching","error","childReportNodeState","state","prev","newStates","undefined","parentRect","getBoundingClientRect","nodeRect","prevStyle","top","bottom","borderTopLeftRadius","borderTopStyle","borderBottomLeftRadius","borderBottomStyle","status","resultSeries","labelValuesByName","resultType","result","length","forEach","s","Object","entries","metric","ln","lv","labelCardinalities","lvs","keys","sort","aCnt","bCnt","slice","cnt","value","count","a","b","innerNode","direction","gap","ref","sx","position","display","padding","marginBottom","borderRadius","backgroundColor","background","code","QueryStatus","responseTime","binaryExpr","div","ml","child","idx","ProgressState","text","alignItems","color","main","variant","strong","message","component","Math","round","title","dense","py","px","fontSize","mode","warning","dark","fontFamily","whiteSpace","overflow","textOverflow","flexGrow","flexShrink","arrow","span","style","cursor","success","size"],"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,oJAAoJ;AAEpJ,SAASA,GAAG,EAAEC,gBAAgB,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,gBAAgB;AAC5G,OAAOC,gBAAgB,yBAAyB;AAChD,SAAuBC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACjG,OAAOC,iBAAiB,8BAA8B;AAGtD,SAAkBC,QAAQ,QAAQ,eAAe;AACjD,SAASC,YAAY,EAAEC,eAAe,QAAQ,iBAAiB;AAC/D,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,OAAOC,mBAAmB,qBAAqB;AAC/C,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,eAAe,QAAQ,UAAU;AAE1C,qDAAqD;AACrD,MAAMC,aAAa;AACnB,MAAMC,iBAAiBD,aA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B,KAAK;8BAEL,cAAA,MAACC;wBAAKC,OAAO;4BAAEC,QAAQ;4BAAWR,YAAY;wBAAS;;0CACrD,KAAChJ;gCACCiI,SAAQ;gCACRG,WAAU;gCACVxB,IAAI;oCAAEmC,YAAY;oCAAahB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAAC8G,OAAO,CAACzB,IAAI;gCAAC;0CAE3EtC;;0CAEH,MAAC1F;gCAAWiI,SAAQ;gCAAQG,WAAU;gCAAOxB,IAAI;oCAAEmB,OAAO,CAACjG,QAAUA,MAAMa,OAAO,CAACC,IAAI,CAAC,IAAI;gCAAC;;oCAAG;oCAC3FuD;;;;;mBAvEFT;YA4ERvD,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE,8BACrC,MAAClB;gBAAWiI,SAAQ;;oBAAQ;oBAAI9F,YAAYI,gBAAgB,CAAC6C,MAAM,GAAGlE;oBAAc;;iBAClF;;;AAGV;AAEA,SAAS0G,cAAc,EAAEC,IAAI,EAAoB;IAC/C,qBACE,MAACnI;QAAIoH,SAAQ;QAAOgB,YAAW;QAASpB,KAAK;QAAGM,cAAc;;0BAC5D,KAACrH;gBAAiB+J,MAAM;gBAAI3B,OAAM;;0BAClC,MAAC/H;gBAAWiI,SAAQ;gBAAQF,OAAM;;oBAC/BF;oBAAK;;;;;AAId"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
// Copyright 2024 The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,7 +12,6 @@
|
|
|
11
12
|
// See the License for the specific language governing permissions and
|
|
12
13
|
// limitations under the License.
|
|
13
14
|
// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/format.tsx
|
|
14
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
15
|
import React from 'react';
|
|
16
16
|
import { styled } from '@mui/material';
|
|
17
17
|
import { formatDuration, msToPrometheusDuration } from '@perses-dev/core';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/promql/format.tsx"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/format.tsx\n\nimport React, { ReactElement, ReactNode } from 'react';\nimport { styled } from '@mui/material';\nimport { formatDuration, msToPrometheusDuration } from '@perses-dev/core';\nimport ASTNode, {\n VectorSelector,\n matchType,\n vectorMatchCardinality,\n nodeType,\n StartOrEnd,\n MatrixSelector,\n} from './ast';\nimport { maybeParenthesizeBinopChild, escapeString } from './utils';\n\n// Styled components that reproduce the theming of CodeMirror:\n\nconst PromQLCode = styled('span')(() => ({\n fontFamily: '\"DejaVu Sans Mono\", monospace',\n}));\n\nconst PromQLKeyword = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#708',\n}));\n\nconst PromQLFunction = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#2a2e42',\n}));\n\nconst PromQLMetricName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e06c75' : '#2a2e42',\n}));\n\nconst PromQLLabelName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#219',\n}));\n\nconst PromQLString = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#98c379' : '#a31515',\n}));\n\nconst PromQLEllipsis = styled('span')(() => ({\n color: '#aaaaaa', // Same color for both modes as in the original CSS\n}));\n\nconst PromQLDuration = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#09885a',\n}));\n\nconst PromQLNumber = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#164',\n}));\n\nconst PromQLOperator = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#56b6c2' : '#708',\n}));\n\nexport const labelNameList = (labels: string[]): React.ReactNode[] => {\n return labels.map((l, i) => {\n return (\n <span key={i}>\n {i !== 0 && ', '}\n <PromQLLabelName>{l}</PromQLLabelName>\n </span>\n );\n });\n};\n\nconst formatAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): ReactNode => (\n <>\n {timestamp !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLNumber>{(timestamp / 1000).toFixed(3)}</PromQLNumber>\n </>\n ) : startOrEnd !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLKeyword>{startOrEnd}</PromQLKeyword>\n <span>(</span>\n <span>)</span>\n </>\n ) : (\n <></>\n )}\n {offset === 0 ? (\n <></>\n ) : offset > 0 ? (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>{formatDuration(msToPrometheusDuration(offset))}</PromQLDuration>\n </>\n ) : (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>-{formatDuration(msToPrometheusDuration(-offset))}</PromQLDuration>\n </>\n )}\n </>\n);\n\nconst formatSelector = (node: VectorSelector | MatrixSelector): ReactElement => {\n const matchLabels = node.matchers\n .filter((m) => !(m.name === '__name__' && m.type === matchType.equal && m.value === node.name))\n .map((m, i) => (\n <span key={i}>\n {i !== 0 && ','}\n <PromQLLabelName>{m.name}</PromQLLabelName>\n {m.type}\n <PromQLString>"{escapeString(m.value)}"</PromQLString>\n </span>\n ));\n\n return (\n <>\n <PromQLMetricName>{node.name}</PromQLMetricName>\n {matchLabels.length > 0 && (\n <>\n {'{'}\n <span>{matchLabels}</span>\n {'}'}\n </>\n )}\n {node.type === nodeType.matrixSelector && (\n <>\n [<PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>]\n </>\n )}\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n};\n\nconst ellipsis = <PromQLEllipsis>…</PromQLEllipsis>;\n\nconst formatNodeInternal = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactNode => {\n if (maxDepth === 0) {\n return ellipsis;\n }\n\n const childMaxDepth = maxDepth === undefined ? undefined : maxDepth - 1;\n\n switch (node.type) {\n case nodeType.aggregation:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {node.without ? (\n <>\n {' '}\n <PromQLKeyword>without</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n ) : (\n node.grouping.length > 0 && (\n <>\n {' '}\n <PromQLKeyword>by</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n )\n )}\n {showChildren && (\n <>\n <span>(</span>\n {node.param !== null && <>{formatNode(node.param, showChildren, childMaxDepth)}, </>}\n {formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n )}\n </>\n );\n case nodeType.subquery:\n return (\n <>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}[\n <PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>:\n {node.step !== 0 && <PromQLDuration>{formatDuration(msToPrometheusDuration(node.step))}</PromQLDuration>}]\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n case nodeType.parenExpr:\n return (\n <>\n <span>(</span>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n );\n case nodeType.call: {\n const children =\n childMaxDepth === undefined || childMaxDepth > 0\n ? node.args.map((arg, i) => (\n <span key={i}>\n {i !== 0 && ', '}\n {formatNode(arg, showChildren)}\n </span>\n ))\n : node.args.length > 0\n ? ellipsis\n : '';\n\n return (\n <>\n <PromQLFunction>{node.func.name}</PromQLFunction>\n {showChildren && (\n <>\n <span>(</span>\n {children}\n <span>)</span>\n </>\n )}\n </>\n );\n }\n case nodeType.matrixSelector:\n return formatSelector(node);\n case nodeType.vectorSelector:\n return formatSelector(node);\n case nodeType.numberLiteral:\n return <PromQLNumber>{node.val}</PromQLNumber>;\n case nodeType.stringLiteral:\n return <PromQLString>"{escapeString(node.val)}"</PromQLString>;\n case nodeType.unaryExpr:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n </>\n );\n case nodeType.binaryExpr: {\n let matching = <></>;\n let grouping = <></>;\n const vm = node.matching;\n if (vm !== null && (vm.labels.length > 0 || vm.on)) {\n if (vm.on) {\n matching = (\n <>\n {' '}\n <PromQLKeyword>on</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n } else {\n matching = (\n <>\n {' '}\n <PromQLKeyword>ignoring</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n }\n\n if (vm.card === vectorMatchCardinality.manyToOne || vm.card === vectorMatchCardinality.oneToMany) {\n grouping = (\n <>\n <PromQLKeyword>\n {' '}\n group_\n {vm.card === vectorMatchCardinality.manyToOne ? 'left' : 'right'}\n </PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.include)}\n <span>)</span>\n </>\n );\n }\n }\n\n return (\n <>\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.lhs), showChildren, childMaxDepth)}{' '}\n {['atan2', 'and', 'or', 'unless'].includes(node.op) ? (\n <PromQLOperator>{node.op}</PromQLOperator>\n ) : (\n <PromQLOperator>{node.op}</PromQLOperator>\n )}\n {node.bool && (\n <>\n {' '}\n <PromQLKeyword>bool</PromQLKeyword>\n </>\n )}\n {matching}\n {grouping}{' '}\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.rhs), showChildren, childMaxDepth)}\n </>\n );\n }\n case nodeType.placeholder:\n // TODO: Include possible children of placeholders somehow?\n return ellipsis;\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport const formatNode = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactElement => (\n <PromQLCode>{formatNodeInternal(node, showChildren, maxDepth)}</PromQLCode>\n);\n"],"names":["React","styled","formatDuration","msToPrometheusDuration","matchType","vectorMatchCardinality","nodeType","maybeParenthesizeBinopChild","escapeString","PromQLCode","fontFamily","PromQLKeyword","theme","color","palette","mode","PromQLFunction","PromQLMetricName","PromQLLabelName","PromQLString","PromQLEllipsis","PromQLDuration","PromQLNumber","PromQLOperator","labelNameList","labels","map","l","i","span","formatAtAndOffset","timestamp","startOrEnd","offset","toFixed","formatSelector","node","matchLabels","matchers","filter","m","name","type","equal","value","length","matrixSelector","range","ellipsis","formatNodeInternal","showChildren","maxDepth","childMaxDepth","undefined","aggregation","op","without","grouping","param","formatNode","expr","subquery","step","parenExpr","call","children","args","arg","func","vectorSelector","numberLiteral","val","stringLiteral","unaryExpr","binaryExpr","matching","vm","on","card","manyToOne","oneToMany","include","lhs","includes","bool","rhs","placeholder","Error"],"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,6IAA6I;;AAE7I,OAAOA,WAAwC,QAAQ;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,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wBACVP,gBAAgBS,WAAWpD,4BAA4B6B,KAAKmB,EAAE,EAAEnB,KAAKiD,GAAG,GAAGnC,cAAcE;;;YAGhG;QACA,KAAK9C,SAASgF,WAAW;YACvB,2DAA2D;YAC3D,OAAOtC;QACT;YACE,MAAM,IAAIuC,MAAM;IACpB;AACF;AAEA,OAAO,MAAM5B,aAAa,CAACvB,MAAec,cAAuBC,yBAC/D,KAAC1C;kBAAYwC,mBAAmBb,MAAMc,cAAcC;OACpD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/promql/format.tsx"],"sourcesContent":["// Copyright 2024 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\n// Forked from https://github.com/prometheus/prometheus/blob/65f610353919b1c7b42d3776c3a95b68046a6bba/web/ui/mantine-ui/src/promql/format.tsx\n\nimport React, { ReactElement, ReactNode } from 'react';\nimport { styled } from '@mui/material';\nimport { formatDuration, msToPrometheusDuration } from '@perses-dev/core';\nimport ASTNode, {\n VectorSelector,\n matchType,\n vectorMatchCardinality,\n nodeType,\n StartOrEnd,\n MatrixSelector,\n} from './ast';\nimport { maybeParenthesizeBinopChild, escapeString } from './utils';\n\n// Styled components that reproduce the theming of CodeMirror:\n\nconst PromQLCode = styled('span')(() => ({\n fontFamily: '\"DejaVu Sans Mono\", monospace',\n}));\n\nconst PromQLKeyword = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#708',\n}));\n\nconst PromQLFunction = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#2a2e42',\n}));\n\nconst PromQLMetricName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e06c75' : '#2a2e42',\n}));\n\nconst PromQLLabelName = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#61afef' : '#219',\n}));\n\nconst PromQLString = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#98c379' : '#a31515',\n}));\n\nconst PromQLEllipsis = styled('span')(() => ({\n color: '#aaaaaa', // Same color for both modes as in the original CSS\n}));\n\nconst PromQLDuration = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#09885a',\n}));\n\nconst PromQLNumber = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#e5c07b' : '#164',\n}));\n\nconst PromQLOperator = styled('span')(({ theme }) => ({\n color: theme.palette.mode === 'dark' ? '#56b6c2' : '#708',\n}));\n\nexport const labelNameList = (labels: string[]): React.ReactNode[] => {\n return labels.map((l, i) => {\n return (\n <span key={i}>\n {i !== 0 && ', '}\n <PromQLLabelName>{l}</PromQLLabelName>\n </span>\n );\n });\n};\n\nconst formatAtAndOffset = (timestamp: number | null, startOrEnd: StartOrEnd, offset: number): ReactNode => (\n <>\n {timestamp !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLNumber>{(timestamp / 1000).toFixed(3)}</PromQLNumber>\n </>\n ) : startOrEnd !== null ? (\n <>\n {' '}\n <PromQLOperator>@</PromQLOperator> <PromQLKeyword>{startOrEnd}</PromQLKeyword>\n <span>(</span>\n <span>)</span>\n </>\n ) : (\n <></>\n )}\n {offset === 0 ? (\n <></>\n ) : offset > 0 ? (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>{formatDuration(msToPrometheusDuration(offset))}</PromQLDuration>\n </>\n ) : (\n <>\n {' '}\n <PromQLKeyword>offset</PromQLKeyword>{' '}\n <PromQLDuration>-{formatDuration(msToPrometheusDuration(-offset))}</PromQLDuration>\n </>\n )}\n </>\n);\n\nconst formatSelector = (node: VectorSelector | MatrixSelector): ReactElement => {\n const matchLabels = node.matchers\n .filter((m) => !(m.name === '__name__' && m.type === matchType.equal && m.value === node.name))\n .map((m, i) => (\n <span key={i}>\n {i !== 0 && ','}\n <PromQLLabelName>{m.name}</PromQLLabelName>\n {m.type}\n <PromQLString>"{escapeString(m.value)}"</PromQLString>\n </span>\n ));\n\n return (\n <>\n <PromQLMetricName>{node.name}</PromQLMetricName>\n {matchLabels.length > 0 && (\n <>\n {'{'}\n <span>{matchLabels}</span>\n {'}'}\n </>\n )}\n {node.type === nodeType.matrixSelector && (\n <>\n [<PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>]\n </>\n )}\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n};\n\nconst ellipsis = <PromQLEllipsis>…</PromQLEllipsis>;\n\nconst formatNodeInternal = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactNode => {\n if (maxDepth === 0) {\n return ellipsis;\n }\n\n const childMaxDepth = maxDepth === undefined ? undefined : maxDepth - 1;\n\n switch (node.type) {\n case nodeType.aggregation:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {node.without ? (\n <>\n {' '}\n <PromQLKeyword>without</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n ) : (\n node.grouping.length > 0 && (\n <>\n {' '}\n <PromQLKeyword>by</PromQLKeyword>\n <span>(</span>\n {labelNameList(node.grouping)}\n <span>)</span>{' '}\n </>\n )\n )}\n {showChildren && (\n <>\n <span>(</span>\n {node.param !== null && <>{formatNode(node.param, showChildren, childMaxDepth)}, </>}\n {formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n )}\n </>\n );\n case nodeType.subquery:\n return (\n <>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}[\n <PromQLDuration>{formatDuration(msToPrometheusDuration(node.range))}</PromQLDuration>:\n {node.step !== 0 && <PromQLDuration>{formatDuration(msToPrometheusDuration(node.step))}</PromQLDuration>}]\n {formatAtAndOffset(node.timestamp, node.startOrEnd, node.offset)}\n </>\n );\n case nodeType.parenExpr:\n return (\n <>\n <span>(</span>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n <span>)</span>\n </>\n );\n case nodeType.call: {\n const children =\n childMaxDepth === undefined || childMaxDepth > 0\n ? node.args.map((arg, i) => (\n <span key={i}>\n {i !== 0 && ', '}\n {formatNode(arg, showChildren)}\n </span>\n ))\n : node.args.length > 0\n ? ellipsis\n : '';\n\n return (\n <>\n <PromQLFunction>{node.func.name}</PromQLFunction>\n {showChildren && (\n <>\n <span>(</span>\n {children}\n <span>)</span>\n </>\n )}\n </>\n );\n }\n case nodeType.matrixSelector:\n return formatSelector(node);\n case nodeType.vectorSelector:\n return formatSelector(node);\n case nodeType.numberLiteral:\n return <PromQLNumber>{node.val}</PromQLNumber>;\n case nodeType.stringLiteral:\n return <PromQLString>"{escapeString(node.val)}"</PromQLString>;\n case nodeType.unaryExpr:\n return (\n <>\n <PromQLOperator>{node.op}</PromQLOperator>\n {showChildren && formatNode(node.expr, showChildren, childMaxDepth)}\n </>\n );\n case nodeType.binaryExpr: {\n let matching = <></>;\n let grouping = <></>;\n const vm = node.matching;\n if (vm !== null && (vm.labels.length > 0 || vm.on)) {\n if (vm.on) {\n matching = (\n <>\n {' '}\n <PromQLKeyword>on</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n } else {\n matching = (\n <>\n {' '}\n <PromQLKeyword>ignoring</PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.labels)}\n <span>)</span>\n </>\n );\n }\n\n if (vm.card === vectorMatchCardinality.manyToOne || vm.card === vectorMatchCardinality.oneToMany) {\n grouping = (\n <>\n <PromQLKeyword>\n {' '}\n group_\n {vm.card === vectorMatchCardinality.manyToOne ? 'left' : 'right'}\n </PromQLKeyword>\n <span>(</span>\n {labelNameList(vm.include)}\n <span>)</span>\n </>\n );\n }\n }\n\n return (\n <>\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.lhs), showChildren, childMaxDepth)}{' '}\n {['atan2', 'and', 'or', 'unless'].includes(node.op) ? (\n <PromQLOperator>{node.op}</PromQLOperator>\n ) : (\n <PromQLOperator>{node.op}</PromQLOperator>\n )}\n {node.bool && (\n <>\n {' '}\n <PromQLKeyword>bool</PromQLKeyword>\n </>\n )}\n {matching}\n {grouping}{' '}\n {showChildren && formatNode(maybeParenthesizeBinopChild(node.op, node.rhs), showChildren, childMaxDepth)}\n </>\n );\n }\n case nodeType.placeholder:\n // TODO: Include possible children of placeholders somehow?\n return ellipsis;\n default:\n throw new Error('unsupported node type');\n }\n};\n\nexport const formatNode = (node: ASTNode, showChildren: boolean, maxDepth?: number): React.ReactElement => (\n <PromQLCode>{formatNodeInternal(node, showChildren, maxDepth)}</PromQLCode>\n);\n"],"names":["React","styled","formatDuration","msToPrometheusDuration","matchType","vectorMatchCardinality","nodeType","maybeParenthesizeBinopChild","escapeString","PromQLCode","fontFamily","PromQLKeyword","theme","color","palette","mode","PromQLFunction","PromQLMetricName","PromQLLabelName","PromQLString","PromQLEllipsis","PromQLDuration","PromQLNumber","PromQLOperator","labelNameList","labels","map","l","i","span","formatAtAndOffset","timestamp","startOrEnd","offset","toFixed","formatSelector","node","matchLabels","matchers","filter","m","name","type","equal","value","length","matrixSelector","range","ellipsis","formatNodeInternal","showChildren","maxDepth","childMaxDepth","undefined","aggregation","op","without","grouping","param","formatNode","expr","subquery","step","parenExpr","call","children","args","arg","func","vectorSelector","numberLiteral","val","stringLiteral","unaryExpr","binaryExpr","matching","vm","on","card","manyToOne","oneToMany","include","lhs","includes","bool","rhs","placeholder","Error"],"mappings":";AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,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AAKmB,EAAE;2CAExB,KAAChC;sCAAgBa,KAAKmB,EAAE;;wBAEzBnB,KAAKgD,IAAI,kBACR;;gCACG;8CACD,KAACzE;8CAAc;;;;wBAGlBgE;wBACAlB;wBAAU;wBACVP,gBAAgBS,WAAWpD,4BAA4B6B,KAAKmB,EAAE,EAAEnB,KAAKiD,GAAG,GAAGnC,cAAcE;;;YAGhG;QACA,KAAK9C,SAASgF,WAAW;YACvB,2DAA2D;YAC3D,OAAOtC;QACT;YACE,MAAM,IAAIuC,MAAM;IACpB;AACF;AAEA,OAAO,MAAM5B,aAAa,CAACvB,MAAec,cAAuBC,yBAC/D,KAAC1C;kBAAYwC,mBAAmBb,MAAMc,cAAcC;OACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusExplorer.d.ts","sourceRoot":"","sources":["../../../src/explore/PrometheusExplorer.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"PrometheusExplorer.d.ts","sourceRoot":"","sources":["../../../src/explore/PrometheusExplorer.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAY,MAAM,OAAO,CAAC;AA0E/C,wBAAgB,kBAAkB,IAAI,YAAY,CAwDjD"}
|