@perses-dev/plugin-system 0.53.0 → 0.54.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/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +2 -2
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +50 -22
- package/dist/cjs/context/ValidationProvider.js +5 -4
- package/dist/cjs/model/index.js +2 -0
- package/dist/cjs/model/log-volume-utils.js +124 -0
- package/dist/cjs/remote/PluginRuntime.js +11 -10
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +6 -6
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +7 -7
- package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +2 -2
- package/dist/cjs/utils/csv-export.js +248 -0
- package/dist/cjs/utils/index.js +1 -0
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.d.ts +1 -1
- package/dist/components/DatasourceSelect/DatasourceSelect.js.map +1 -1
- package/dist/components/HTTPSettingsEditor/HTTPSettingsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +1 -1
- package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js +1 -1
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +2 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +50 -22
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts +1 -1
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/context/ValidationProvider.d.ts +2 -1
- package/dist/context/ValidationProvider.d.ts.map +1 -1
- package/dist/context/ValidationProvider.js +3 -2
- package/dist/context/ValidationProvider.js.map +1 -1
- package/dist/model/datasource.d.ts +1 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/explore.d.ts +1 -1
- package/dist/model/explore.js.map +1 -1
- package/dist/model/index.d.ts +2 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +2 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.js +1 -1
- package/dist/model/legend.js.map +1 -1
- package/dist/model/log-queries.d.ts +2 -1
- package/dist/model/log-queries.d.ts.map +1 -1
- package/dist/model/log-queries.js.map +1 -1
- package/dist/model/log-volume-utils.d.ts +6 -0
- package/dist/model/log-volume-utils.d.ts.map +1 -0
- package/dist/model/log-volume-utils.js +119 -0
- package/dist/model/log-volume-utils.js.map +1 -0
- package/dist/model/panels.d.ts +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.d.ts +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugins.d.ts +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/profile-queries.d.ts +1 -1
- package/dist/model/profile-queries.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +1 -1
- package/dist/model/trace-queries.js.map +1 -1
- package/dist/model/variables.d.ts +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/remote/PluginRuntime.d.ts.map +1 -1
- package/dist/remote/PluginRuntime.js +11 -10
- package/dist/remote/PluginRuntime.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +1 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviders.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeSettingsProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.js +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts +1 -1
- package/dist/runtime/UsageMetricsProvider.d.ts.map +1 -1
- package/dist/runtime/UsageMetricsProvider.js +1 -1
- package/dist/runtime/UsageMetricsProvider.js.map +1 -1
- package/dist/runtime/builtin-variables.d.ts +1 -1
- package/dist/runtime/builtin-variables.js.map +1 -1
- package/dist/runtime/datasources.d.ts +1 -1
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/item-actions.js +1 -1
- package/dist/runtime/item-actions.js.map +1 -1
- package/dist/runtime/log-queries.d.ts +1 -1
- package/dist/runtime/log-queries.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +1 -1
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/profile-queries.d.ts +1 -1
- package/dist/runtime/profile-queries.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +1 -1
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +1 -1
- package/dist/runtime/trace-queries.js.map +1 -1
- package/dist/test/mock-data.d.ts +1 -1
- package/dist/test/mock-data.js.map +1 -1
- package/dist/test/utils.js +1 -1
- package/dist/test/utils.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/action.js.map +1 -1
- package/dist/utils/csv-export.d.ts +39 -0
- package/dist/utils/csv-export.d.ts.map +1 -0
- package/dist/utils/csv-export.js +214 -0
- package/dist/utils/csv-export.js.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +9 -6
|
@@ -34,7 +34,7 @@ const _PlusCircleOutline = /*#__PURE__*/ _interop_require_default(require("mdi-m
|
|
|
34
34
|
const _MinusCircleOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/MinusCircleOutline"));
|
|
35
35
|
const _material = require("@mui/material");
|
|
36
36
|
const _components = require("@perses-dev/components");
|
|
37
|
-
const
|
|
37
|
+
const _spec = require("@perses-dev/spec");
|
|
38
38
|
const _react = require("react");
|
|
39
39
|
const _constants = require("../../constants");
|
|
40
40
|
const _runtime = require("../../runtime");
|
|
@@ -100,7 +100,7 @@ function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefresh
|
|
|
100
100
|
setRefreshInterval
|
|
101
101
|
]);
|
|
102
102
|
const fromDurationToMillis = (strDuration)=>{
|
|
103
|
-
const duration = (0,
|
|
103
|
+
const duration = (0, _spec.parseDurationString)(strDuration);
|
|
104
104
|
const millis = // eslint-disable-next-line prettier/prettier
|
|
105
105
|
((duration.seconds ?? 0) + (duration.minutes ?? 0) * 60 + (duration.hours ?? 0) * 3600 + (duration.days ?? 0) * 86400 + (duration.weeks ?? 0) * 7 * 86400 + (duration.months ?? 0) * 30.436875 * 86400 + // avg month duration is ok for zoom purposes
|
|
106
106
|
(duration.years ?? 0) * 365.2425 * 86400) * // avg year duration is ok for zoom purposes
|
|
@@ -137,6 +137,10 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
137
137
|
control: control,
|
|
138
138
|
name: 'spec.allowAllValue'
|
|
139
139
|
});
|
|
140
|
+
const _customAllValue = (0, _reacthookform.useWatch)({
|
|
141
|
+
control: control,
|
|
142
|
+
name: 'spec.customAllValue'
|
|
143
|
+
});
|
|
140
144
|
const sortMethod = (0, _reacthookform.useWatch)({
|
|
141
145
|
control: control,
|
|
142
146
|
name: 'spec.sort'
|
|
@@ -333,30 +337,54 @@ function ListVariableEditorForm({ action, control }) {
|
|
|
333
337
|
variant: "caption",
|
|
334
338
|
children: "Enables an option to include all variable values"
|
|
335
339
|
}),
|
|
336
|
-
_allowAllValue && /*#__PURE__*/ (0, _jsxruntime.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
onChange: (event)=>{
|
|
353
|
-
if (event.target.value === '') {
|
|
354
|
-
field.onChange(undefined);
|
|
355
|
-
} else {
|
|
356
|
-
field.onChange(event);
|
|
340
|
+
_allowAllValue && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
|
|
341
|
+
spacing: 1,
|
|
342
|
+
children: [
|
|
343
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.FormControlLabel, {
|
|
344
|
+
label: "Use Custom All Value",
|
|
345
|
+
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
346
|
+
checked: _customAllValue !== undefined,
|
|
347
|
+
readOnly: action === 'read',
|
|
348
|
+
onChange: (event)=>{
|
|
349
|
+
if (action === 'read') return;
|
|
350
|
+
const isEnabled = event.target.checked;
|
|
351
|
+
if (isEnabled) {
|
|
352
|
+
form.setValue('spec.customAllValue', '');
|
|
353
|
+
} else {
|
|
354
|
+
form.setValue('spec.customAllValue', undefined);
|
|
355
|
+
}
|
|
357
356
|
}
|
|
358
|
-
}
|
|
357
|
+
})
|
|
358
|
+
}),
|
|
359
|
+
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
|
|
360
|
+
variant: "caption",
|
|
361
|
+
sx: {
|
|
362
|
+
mt: -0.5
|
|
363
|
+
},
|
|
364
|
+
children: 'Enable to set a custom value when "All" is selected'
|
|
365
|
+
}),
|
|
366
|
+
_customAllValue !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
|
|
367
|
+
control: control,
|
|
368
|
+
name: "spec.customAllValue",
|
|
369
|
+
render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
370
|
+
...field,
|
|
371
|
+
fullWidth: true,
|
|
372
|
+
label: "Custom All Value",
|
|
373
|
+
InputLabelProps: {
|
|
374
|
+
shrink: action === 'read' ? true : undefined
|
|
375
|
+
},
|
|
376
|
+
InputProps: {
|
|
377
|
+
readOnly: action === 'read'
|
|
378
|
+
},
|
|
379
|
+
error: !!fieldState.error,
|
|
380
|
+
helperText: fieldState.error?.message,
|
|
381
|
+
value: field.value ?? '',
|
|
382
|
+
onChange: (event)=>{
|
|
383
|
+
field.onChange(event.target.value || '');
|
|
384
|
+
}
|
|
385
|
+
})
|
|
359
386
|
})
|
|
387
|
+
]
|
|
360
388
|
})
|
|
361
389
|
]
|
|
362
390
|
})
|
|
@@ -33,6 +33,7 @@ _export(exports, {
|
|
|
33
33
|
});
|
|
34
34
|
const _jsxruntime = require("react/jsx-runtime");
|
|
35
35
|
const _react = require("react");
|
|
36
|
+
const _spec = require("@perses-dev/spec");
|
|
36
37
|
const _core = require("@perses-dev/core");
|
|
37
38
|
const ValidationSchemasContext = /*#__PURE__*/ (0, _react.createContext)(undefined);
|
|
38
39
|
function useValidationSchemas() {
|
|
@@ -44,16 +45,16 @@ function useValidationSchemas() {
|
|
|
44
45
|
}
|
|
45
46
|
function ValidationProvider({ children }) {
|
|
46
47
|
const [datasourceEditorSchema, setDatasourceEditorSchema] = (0, _react.useState)(_core.datasourceDefinitionSchema);
|
|
47
|
-
const [panelEditorSchema, setPanelEditorSchema] = (0, _react.useState)(
|
|
48
|
-
const [variableEditorSchema, setVariableEditorSchema] = (0, _react.useState)(
|
|
48
|
+
const [panelEditorSchema, setPanelEditorSchema] = (0, _react.useState)(_spec.panelEditorSchema); // TODO I don't get why this does not compile
|
|
49
|
+
const [variableEditorSchema, setVariableEditorSchema] = (0, _react.useState)(_spec.variableDefinitionSchema);
|
|
49
50
|
function setDatasourceEditorSchemaPlugin(pluginSchema) {
|
|
50
51
|
setDatasourceEditorSchema((0, _core.buildDatasourceDefinitionSchema)(pluginSchema));
|
|
51
52
|
}
|
|
52
53
|
function setPanelEditorSchemaPlugin(pluginSchema) {
|
|
53
|
-
setPanelEditorSchema((0,
|
|
54
|
+
setPanelEditorSchema((0, _spec.buildPanelEditorSchema)(pluginSchema));
|
|
54
55
|
}
|
|
55
56
|
function setVariableEditorSchemaPlugin(pluginSchema) {
|
|
56
|
-
setVariableEditorSchema((0,
|
|
57
|
+
setVariableEditorSchema((0, _spec.buildVariableDefinitionSchema)(pluginSchema));
|
|
57
58
|
}
|
|
58
59
|
return /*#__PURE__*/ (0, _jsxruntime.jsx)(ValidationSchemasContext.Provider, {
|
|
59
60
|
value: {
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -16,6 +16,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
_export_star(require("./datasource"), exports);
|
|
18
18
|
_export_star(require("./legend"), exports);
|
|
19
|
+
_export_star(require("./log-queries"), exports);
|
|
20
|
+
_export_star(require("./log-volume-utils"), exports);
|
|
19
21
|
_export_star(require("./panels"), exports);
|
|
20
22
|
_export_star(require("./plugins"), exports);
|
|
21
23
|
_export_star(require("./plugin-base"), exports);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
// Target number of bars for log volume histogram
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "calculateVolumeInterval", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function() {
|
|
21
|
+
return calculateVolumeInterval;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const TARGET_HISTOGRAM_BARS = 40;
|
|
25
|
+
// Standard intervals for histogram calculations (in milliseconds)
|
|
26
|
+
const STANDARD_INTERVALS = [
|
|
27
|
+
{
|
|
28
|
+
ms: 1000,
|
|
29
|
+
label: '1s'
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
ms: 2000,
|
|
33
|
+
label: '2s'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
ms: 5000,
|
|
37
|
+
label: '5s'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
ms: 10000,
|
|
41
|
+
label: '10s'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
ms: 15000,
|
|
45
|
+
label: '15s'
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
ms: 30000,
|
|
49
|
+
label: '30s'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
ms: 60000,
|
|
53
|
+
label: '1m'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
ms: 120000,
|
|
57
|
+
label: '2m'
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
ms: 300000,
|
|
61
|
+
label: '5m'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
ms: 600000,
|
|
65
|
+
label: '10m'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
ms: 900000,
|
|
69
|
+
label: '15m'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
ms: 1800000,
|
|
73
|
+
label: '30m'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
ms: 3600000,
|
|
77
|
+
label: '1h'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
ms: 7200000,
|
|
81
|
+
label: '2h'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
ms: 21600000,
|
|
85
|
+
label: '6h'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
ms: 43200000,
|
|
89
|
+
label: '12h'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
ms: 86400000,
|
|
93
|
+
label: '1d'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
ms: 604800000,
|
|
97
|
+
label: '7d'
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
ms: 2592000000,
|
|
101
|
+
label: '30d'
|
|
102
|
+
}
|
|
103
|
+
];
|
|
104
|
+
function calculateVolumeInterval(timeRangeMs) {
|
|
105
|
+
// Prefer smallest interval that produces 20-100 bars (optimal range)
|
|
106
|
+
for (const interval of STANDARD_INTERVALS){
|
|
107
|
+
const barCount = timeRangeMs / interval.ms;
|
|
108
|
+
if (barCount >= 20 && barCount <= 100) {
|
|
109
|
+
return interval.label;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Fallback: find closest to target if no interval fits optimal range
|
|
113
|
+
let bestInterval = STANDARD_INTERVALS[STANDARD_INTERVALS.length - 1];
|
|
114
|
+
let bestDistance = Infinity;
|
|
115
|
+
for (const interval of STANDARD_INTERVALS){
|
|
116
|
+
const barCount = timeRangeMs / interval.ms;
|
|
117
|
+
const distance = Math.abs(barCount - TARGET_HISTOGRAM_BARS);
|
|
118
|
+
if (distance < bestDistance) {
|
|
119
|
+
bestDistance = distance;
|
|
120
|
+
bestInterval = interval;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return bestInterval.label;
|
|
124
|
+
}
|
|
@@ -147,44 +147,45 @@ const getPluginRuntime = ()=>{
|
|
|
147
147
|
requiredVersion: '^5.5.0'
|
|
148
148
|
}
|
|
149
149
|
},
|
|
150
|
+
// TODO should we add @perses-dev/spec here ?
|
|
150
151
|
'@perses-dev/core': {
|
|
151
|
-
version: '0.53.
|
|
152
|
+
version: '0.53.1',
|
|
152
153
|
lib: ()=>require('@perses-dev/core'),
|
|
153
154
|
shareConfig: {
|
|
154
155
|
singleton: true,
|
|
155
|
-
requiredVersion: '^0.53.
|
|
156
|
+
requiredVersion: '^0.53.1'
|
|
156
157
|
}
|
|
157
158
|
},
|
|
158
159
|
'@perses-dev/components': {
|
|
159
|
-
version: '0.53.
|
|
160
|
+
version: '0.53.1',
|
|
160
161
|
lib: ()=>require('@perses-dev/components'),
|
|
161
162
|
shareConfig: {
|
|
162
163
|
singleton: true,
|
|
163
|
-
requiredVersion: '^0.53.
|
|
164
|
+
requiredVersion: '^0.53.1'
|
|
164
165
|
}
|
|
165
166
|
},
|
|
166
167
|
'@perses-dev/plugin-system': {
|
|
167
|
-
version: '0.53.
|
|
168
|
+
version: '0.53.1',
|
|
168
169
|
lib: ()=>require('@perses-dev/plugin-system'),
|
|
169
170
|
shareConfig: {
|
|
170
171
|
singleton: true,
|
|
171
|
-
requiredVersion: '^0.53.
|
|
172
|
+
requiredVersion: '^0.53.1'
|
|
172
173
|
}
|
|
173
174
|
},
|
|
174
175
|
'@perses-dev/explore': {
|
|
175
|
-
version: '0.53.
|
|
176
|
+
version: '0.53.1',
|
|
176
177
|
lib: ()=>require('@perses-dev/explore'),
|
|
177
178
|
shareConfig: {
|
|
178
179
|
singleton: true,
|
|
179
|
-
requiredVersion: '
|
|
180
|
+
requiredVersion: '^0.53.1'
|
|
180
181
|
}
|
|
181
182
|
},
|
|
182
183
|
'@perses-dev/dashboards': {
|
|
183
|
-
version: '0.53.
|
|
184
|
+
version: '0.53.1',
|
|
184
185
|
lib: ()=>require('@perses-dev/dashboards'),
|
|
185
186
|
shareConfig: {
|
|
186
187
|
singleton: true,
|
|
187
|
-
requiredVersion: '
|
|
188
|
+
requiredVersion: '^0.53.1'
|
|
188
189
|
}
|
|
189
190
|
},
|
|
190
191
|
// Below are the shared modules that are used by the plugins, this can be part of the SDK
|
|
@@ -39,7 +39,7 @@ _export(exports, {
|
|
|
39
39
|
});
|
|
40
40
|
const _jsxruntime = require("react/jsx-runtime");
|
|
41
41
|
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
|
|
42
|
-
const
|
|
42
|
+
const _spec = require("@perses-dev/spec");
|
|
43
43
|
const _reactquery = require("@tanstack/react-query");
|
|
44
44
|
const _refreshinterval = require("./refresh-interval");
|
|
45
45
|
function _getRequireWildcardCache(nodeInterop) {
|
|
@@ -97,21 +97,21 @@ function useTimeRange() {
|
|
|
97
97
|
function useSuggestedStepMs(width) {
|
|
98
98
|
const { absoluteTimeRange } = useTimeRange();
|
|
99
99
|
if (width === undefined) return 0;
|
|
100
|
-
return (0,
|
|
100
|
+
return (0, _spec.getSuggestedStepMs)(absoluteTimeRange, width);
|
|
101
101
|
}
|
|
102
102
|
function TimeRangeProvider(props) {
|
|
103
103
|
const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;
|
|
104
104
|
const queryClient = (0, _reactquery.useQueryClient)();
|
|
105
|
-
const [absoluteTimeRange, setAbsoluteTimeRange] = (0, _react.useState)((0,
|
|
105
|
+
const [absoluteTimeRange, setAbsoluteTimeRange] = (0, _react.useState)((0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange);
|
|
106
106
|
const handleSetTimeRange = (0, _react.useCallback)((value)=>{
|
|
107
107
|
setTimeRange(value);
|
|
108
|
-
setAbsoluteTimeRange((0,
|
|
108
|
+
setAbsoluteTimeRange((0, _spec.isRelativeTimeRange)(value) ? (0, _spec.toAbsoluteTimeRange)(value) : value);
|
|
109
109
|
}, [
|
|
110
110
|
setTimeRange
|
|
111
111
|
]);
|
|
112
112
|
// Refresh is called when clicking on the refresh button, it refreshes all queries including variables
|
|
113
113
|
const refresh = (0, _react.useCallback)(()=>{
|
|
114
|
-
setAbsoluteTimeRange((0,
|
|
114
|
+
setAbsoluteTimeRange((0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange);
|
|
115
115
|
queryClient.invalidateQueries({
|
|
116
116
|
queryKey: [
|
|
117
117
|
'query'
|
|
@@ -138,7 +138,7 @@ function TimeRangeProvider(props) {
|
|
|
138
138
|
]);
|
|
139
139
|
// Auto refresh is only refreshing queries of panels
|
|
140
140
|
const autoRefresh = (0, _react.useCallback)(()=>{
|
|
141
|
-
setAbsoluteTimeRange((0,
|
|
141
|
+
setAbsoluteTimeRange((0, _spec.isRelativeTimeRange)(timeRange) ? (0, _spec.toAbsoluteTimeRange)(timeRange) : timeRange);
|
|
142
142
|
queryClient.invalidateQueries({
|
|
143
143
|
queryKey: [
|
|
144
144
|
'query'
|
|
@@ -58,7 +58,7 @@ _export(exports, {
|
|
|
58
58
|
const _react = require("react");
|
|
59
59
|
const _usequeryparams = require("use-query-params");
|
|
60
60
|
const _datefns = require("date-fns");
|
|
61
|
-
const
|
|
61
|
+
const _spec = require("@perses-dev/spec");
|
|
62
62
|
/* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
|
|
63
63
|
// '' or []
|
|
64
64
|
if (!input || input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
|
|
@@ -78,7 +78,7 @@ function encodeTimeRangeValue(timeOptionValue) {
|
|
|
78
78
|
return timeOptionValue;
|
|
79
79
|
}
|
|
80
80
|
if (typeof timeOptionValue === 'string') {
|
|
81
|
-
if ((0,
|
|
81
|
+
if ((0, _spec.isDurationString)(timeOptionValue)) {
|
|
82
82
|
return timeOptionValue;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -87,7 +87,7 @@ function encodeTimeRangeValue(timeOptionValue) {
|
|
|
87
87
|
function decodeTimeRangeValue(input) {
|
|
88
88
|
const paramString = getEncodedValue(input);
|
|
89
89
|
if (!paramString) return null;
|
|
90
|
-
return (0,
|
|
90
|
+
return (0, _spec.isDurationString)(paramString) ? paramString : new Date(Number(paramString));
|
|
91
91
|
}
|
|
92
92
|
const TimeRangeParam = {
|
|
93
93
|
encode: encodeTimeRangeValue,
|
|
@@ -121,7 +121,7 @@ function useInitialTimeRange(dashboardDuration) {
|
|
|
121
121
|
return initialTimeRange;
|
|
122
122
|
}
|
|
123
123
|
const startStr = start.toString();
|
|
124
|
-
if ((0,
|
|
124
|
+
if ((0, _spec.isDurationString)(startStr)) {
|
|
125
125
|
initialTimeRange = {
|
|
126
126
|
pastDuration: startStr
|
|
127
127
|
};
|
|
@@ -148,7 +148,7 @@ function useTimeRangeParams(initialTimeRange) {
|
|
|
148
148
|
(0, _react.useEffect)(()=>{
|
|
149
149
|
// when dashboard loaded with no params, default to dashboard duration
|
|
150
150
|
if (!paramsLoaded && !start) {
|
|
151
|
-
if ((0,
|
|
151
|
+
if ((0, _spec.isRelativeTimeRange)(initialTimeRange)) {
|
|
152
152
|
setQuery({
|
|
153
153
|
start: initialTimeRange.pastDuration,
|
|
154
154
|
end: undefined
|
|
@@ -163,7 +163,7 @@ function useTimeRangeParams(initialTimeRange) {
|
|
|
163
163
|
setQuery
|
|
164
164
|
]);
|
|
165
165
|
const setTimeRange = (0, _react.useCallback)((value)=>{
|
|
166
|
-
if ((0,
|
|
166
|
+
if ((0, _spec.isRelativeTimeRange)(value)) {
|
|
167
167
|
setQuery({
|
|
168
168
|
start: value.pastDuration,
|
|
169
169
|
end: undefined
|
|
@@ -190,7 +190,7 @@ function useInitialRefreshInterval(dashboardDuration) {
|
|
|
190
190
|
return initialTimeRange;
|
|
191
191
|
}
|
|
192
192
|
const startStr = refresh.toString();
|
|
193
|
-
if ((0,
|
|
193
|
+
if ((0, _spec.isDurationString)(startStr)) {
|
|
194
194
|
initialTimeRange = startStr;
|
|
195
195
|
}
|
|
196
196
|
return initialTimeRange;
|
|
@@ -20,11 +20,11 @@ Object.defineProperty(exports, "getRefreshIntervalInMs", {
|
|
|
20
20
|
return getRefreshIntervalInMs;
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
|
-
const
|
|
23
|
+
const _spec = require("@perses-dev/spec");
|
|
24
24
|
const _datefns = require("date-fns");
|
|
25
25
|
function getRefreshIntervalInMs(refreshInterval) {
|
|
26
26
|
if (refreshInterval !== undefined && refreshInterval !== null) {
|
|
27
|
-
return (0, _datefns.milliseconds)((0,
|
|
27
|
+
return (0, _datefns.milliseconds)((0, _spec.parseDurationString)(refreshInterval));
|
|
28
28
|
}
|
|
29
29
|
return 0;
|
|
30
30
|
}
|