@perses-dev/plugin-system 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/CalculationSelector/CalculationSelector.js +7 -5
- package/dist/cjs/components/CalculationSelector/index.js +10 -8
- package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +350 -0
- package/dist/cjs/components/DatasourceEditorForm/index.js +30 -0
- package/dist/cjs/components/DatasourceSelect.js +137 -25
- package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +19 -17
- package/dist/cjs/components/LegendOptionsEditor/index.js +10 -8
- package/dist/cjs/components/OptionsEditorRadios/OptionsEditorRadios.js +25 -30
- package/dist/cjs/components/OptionsEditorRadios/index.js +10 -8
- package/dist/cjs/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +7 -5
- package/dist/cjs/components/OptionsEditorTabPanel/index.js +10 -8
- package/dist/cjs/components/OptionsEditorTabs/OptionsEditorTabs.js +13 -11
- package/dist/cjs/components/OptionsEditorTabs/index.js +10 -8
- package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +60 -19
- package/dist/cjs/components/PanelSpecEditor/index.js +10 -8
- package/dist/cjs/components/PluginEditor/PluginEditor.js +25 -32
- package/dist/cjs/components/PluginEditor/index.js +11 -9
- package/dist/cjs/components/PluginEditor/plugin-editor-api.js +8 -6
- package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -14
- package/dist/cjs/components/PluginKindSelect/index.js +10 -8
- package/dist/cjs/components/PluginRegistry/PluginRegistry.js +11 -9
- package/dist/cjs/components/PluginRegistry/index.js +10 -8
- package/dist/cjs/components/PluginRegistry/plugin-indexes.js +7 -3
- package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +9 -7
- package/dist/cjs/components/PluginSpecEditor/index.js +10 -8
- package/dist/cjs/components/ProjectSelect.js +96 -0
- package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
- package/dist/cjs/components/TimeRangeControls/index.js +30 -0
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +45 -49
- package/dist/cjs/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +23 -21
- package/dist/cjs/components/TimeSeriesQueryEditor/index.js +10 -8
- package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +143 -0
- package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +96 -0
- package/dist/cjs/components/TraceQueryEditor/index.js +30 -0
- package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +445 -230
- package/dist/cjs/components/Variables/VariableEditorForm/VariablePreview.js +38 -32
- package/dist/cjs/components/Variables/VariableEditorForm/index.js +11 -9
- package/dist/cjs/components/Variables/VariableEditorForm/variable-editor-form-model.js +36 -37
- package/dist/cjs/components/Variables/index.js +11 -9
- package/dist/cjs/components/Variables/variable-model.js +24 -17
- package/dist/cjs/components/index.js +24 -19
- package/dist/cjs/constants/index.js +10 -8
- package/dist/cjs/constants/user-interface-text.js +7 -2
- package/dist/cjs/context/ProjectStoreProvider.js +78 -0
- package/dist/cjs/context/index.js +30 -0
- package/dist/cjs/context/query-params.js +49 -0
- package/dist/cjs/index.js +17 -13
- package/dist/cjs/model/index.js +18 -15
- package/dist/cjs/model/legend.js +32 -20
- package/dist/cjs/model/panels.js +2 -2
- package/dist/cjs/model/plugin-base.js +2 -2
- package/dist/cjs/model/plugin-loading.js +3 -1
- package/dist/cjs/model/trace-queries.js +16 -0
- package/dist/cjs/runtime/DataQueriesProvider/DataQueriesProvider.js +67 -35
- package/dist/cjs/runtime/DataQueriesProvider/index.js +11 -9
- package/dist/cjs/runtime/DataQueriesProvider/model.js +81 -0
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +55 -27
- package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +43 -0
- package/dist/cjs/runtime/TimeRangeProvider/index.js +12 -9
- package/dist/cjs/runtime/TimeRangeProvider/query-params.js +45 -59
- package/dist/cjs/runtime/TimeRangeProvider/refresh-interval.js +30 -0
- package/dist/cjs/runtime/builtin-variables.js +81 -0
- package/dist/cjs/runtime/datasources.js +31 -12
- package/dist/cjs/runtime/index.js +17 -13
- package/dist/cjs/runtime/plugin-registry.js +44 -14
- package/dist/cjs/runtime/template-variables.js +51 -13
- package/dist/cjs/runtime/time-series-queries.js +43 -31
- package/dist/cjs/runtime/trace-queries.js +76 -0
- package/dist/cjs/stories/shared-utils/decorators/WithDataQueries.js +7 -5
- package/dist/cjs/stories/shared-utils/decorators/WithPluginRegistry.js +21 -16
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +42 -0
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +31 -13
- package/dist/cjs/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js +6 -4
- package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +9 -7
- package/dist/cjs/stories/shared-utils/decorators/index.js +15 -12
- package/dist/cjs/stories/shared-utils/index.js +10 -8
- package/dist/cjs/test/index.js +11 -8
- package/dist/cjs/test/mock-data.js +80 -0
- package/dist/cjs/test/render.js +13 -11
- package/dist/cjs/test/test-plugins/bert/index.js +16 -12
- package/dist/cjs/test/test-plugins/ernie/index.js +15 -11
- package/dist/cjs/test/test-plugins/index.js +14 -10
- package/dist/cjs/test-utils/index.js +10 -8
- package/dist/cjs/test-utils/mock-plugin-registry.js +9 -5
- package/dist/cjs/utils/action.js +43 -0
- package/dist/cjs/utils/index.js +11 -8
- package/dist/cjs/utils/variables.js +26 -8
- package/dist/cjs/validation/datasource.js +30 -0
- package/dist/cjs/validation/duration.js +25 -0
- package/dist/cjs/validation/index.js +34 -0
- package/dist/cjs/validation/resource.js +24 -0
- package/dist/cjs/validation/role.js +86 -0
- package/dist/cjs/validation/rolebinding.js +55 -0
- package/dist/cjs/validation/secret.js +176 -0
- package/dist/cjs/validation/user.js +46 -0
- package/dist/cjs/validation/variable.js +48 -0
- package/dist/components/CalculationSelector/CalculationSelector.d.ts +1 -2
- package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js +1 -1
- package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
- package/dist/components/CalculationSelector/index.js.map +1 -1
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts +14 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +342 -0
- package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -0
- package/dist/components/DatasourceEditorForm/index.d.ts +2 -0
- package/dist/components/DatasourceEditorForm/index.d.ts.map +1 -0
- package/dist/components/DatasourceEditorForm/index.js +15 -0
- package/dist/components/DatasourceEditorForm/index.js.map +1 -0
- package/dist/components/DatasourceSelect.d.ts +8 -3
- package/dist/components/DatasourceSelect.d.ts.map +1 -1
- package/dist/components/DatasourceSelect.js +120 -23
- package/dist/components/DatasourceSelect.js.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts +1 -2
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +3 -3
- package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
- package/dist/components/LegendOptionsEditor/index.js.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts +5 -5
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.d.ts.map +1 -1
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js +18 -25
- package/dist/components/OptionsEditorRadios/OptionsEditorRadios.js.map +1 -1
- package/dist/components/OptionsEditorRadios/index.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js +1 -1
- package/dist/components/OptionsEditorTabPanel/OptionsEditorTabPanel.js.map +1 -1
- package/dist/components/OptionsEditorTabPanel/index.js.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts +3 -3
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.d.ts.map +1 -1
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js +3 -3
- package/dist/components/OptionsEditorTabs/OptionsEditorTabs.js.map +1 -1
- package/dist/components/OptionsEditorTabs/index.js.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts +2 -3
- package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js +50 -11
- package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
- package/dist/components/PanelSpecEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.d.ts +1 -2
- package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
- package/dist/components/PluginEditor/PluginEditor.js +17 -26
- package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
- package/dist/components/PluginEditor/index.js.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.d.ts +3 -3
- package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
- package/dist/components/PluginEditor/plugin-editor-api.js +5 -5
- package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +3 -3
- package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
- package/dist/components/PluginKindSelect/PluginKindSelect.js +23 -14
- package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
- package/dist/components/PluginKindSelect/index.js.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.d.ts +4 -4
- package/dist/components/PluginRegistry/PluginRegistry.d.ts.map +1 -1
- package/dist/components/PluginRegistry/PluginRegistry.js +3 -3
- package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
- package/dist/components/PluginRegistry/index.js.map +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js +1 -1
- package/dist/components/PluginRegistry/plugin-indexes.js.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +2 -2
- package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js +3 -3
- package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
- package/dist/components/PluginSpecEditor/index.js.map +1 -1
- package/dist/components/ProjectSelect.d.ts +14 -0
- package/dist/components/ProjectSelect.d.ts.map +1 -0
- package/dist/components/ProjectSelect.js +91 -0
- package/dist/components/ProjectSelect.js.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
- package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
- package/dist/components/TimeRangeControls/index.d.ts +2 -0
- package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
- package/dist/components/TimeRangeControls/index.js +15 -0
- package/dist/components/TimeRangeControls/index.js.map +1 -0
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +1 -2
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js +38 -44
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +1 -2
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js +3 -3
- package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +1 -1
- package/dist/components/TimeSeriesQueryEditor/index.js.map +1 -1
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +8 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js +130 -0
- package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +12 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.js +83 -0
- package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +1 -0
- package/dist/components/TraceQueryEditor/index.d.ts +2 -0
- package/dist/components/TraceQueryEditor/index.d.ts.map +1 -0
- package/dist/components/TraceQueryEditor/index.js +15 -0
- package/dist/components/TraceQueryEditor/index.js.map +1 -0
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts +10 -8
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +395 -184
- package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts +2 -3
- package/dist/components/Variables/VariableEditorForm/VariablePreview.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js +4 -4
- package/dist/components/Variables/VariableEditorForm/VariablePreview.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/index.js.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts +8 -19
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js +30 -35
- package/dist/components/Variables/VariableEditorForm/variable-editor-form-model.js.map +1 -1
- package/dist/components/Variables/index.js.map +1 -1
- package/dist/components/Variables/variable-model.d.ts.map +1 -1
- package/dist/components/Variables/variable-model.js +9 -10
- package/dist/components/Variables/variable-model.js.map +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +2 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +4 -1
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/ProjectStoreProvider.d.ts +16 -0
- package/dist/context/ProjectStoreProvider.d.ts.map +1 -0
- package/dist/context/ProjectStoreProvider.js +56 -0
- package/dist/context/ProjectStoreProvider.js.map +1 -0
- package/dist/context/index.d.ts +2 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +15 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/query-params.d.ts +5 -0
- package/dist/context/query-params.d.ts.map +1 -0
- package/dist/context/query-params.js +41 -0
- package/dist/context/query-params.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/model/datasource.d.ts +2 -1
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +3 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/legend.d.ts +3 -3
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +14 -14
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.d.ts +3 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/plugin-base.js.map +1 -1
- package/dist/model/plugin-loading.js.map +1 -1
- package/dist/model/plugins.d.ts +6 -4
- package/dist/model/plugins.d.ts.map +1 -1
- package/dist/model/plugins.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +2 -2
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/trace-queries.d.ts +19 -0
- package/dist/model/trace-queries.d.ts.map +1 -0
- package/dist/model/trace-queries.js +15 -0
- package/dist/model/trace-queries.js.map +1 -0
- package/dist/model/variables.d.ts +2 -2
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +3 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts +6 -6
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js +52 -28
- package/dist/runtime/DataQueriesProvider/DataQueriesProvider.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/index.js.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.d.ts +18 -13
- package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
- package/dist/runtime/DataQueriesProvider/model.js +67 -1
- package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +9 -4
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +37 -20
- package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts +9 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js +30 -0
- package/dist/runtime/TimeRangeProvider/TimeRangeProviderWithQueryParams.js.map +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts +1 -0
- package/dist/runtime/TimeRangeProvider/index.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/index.js +1 -0
- package/dist/runtime/TimeRangeProvider/index.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.d.ts +5 -5
- package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
- package/dist/runtime/TimeRangeProvider/query-params.js +13 -45
- package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts +7 -0
- package/dist/runtime/TimeRangeProvider/refresh-interval.d.ts.map +1 -0
- package/dist/runtime/TimeRangeProvider/refresh-interval.js +25 -0
- package/dist/runtime/TimeRangeProvider/refresh-interval.js.map +1 -0
- package/dist/runtime/builtin-variables.d.ts +11 -0
- package/dist/runtime/builtin-variables.d.ts.map +1 -0
- package/dist/runtime/builtin-variables.js +59 -0
- package/dist/runtime/builtin-variables.js.map +1 -0
- package/dist/runtime/datasources.d.ts +42 -7
- package/dist/runtime/datasources.d.ts.map +1 -1
- package/dist/runtime/datasources.js +15 -7
- package/dist/runtime/datasources.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/plugin-registry.d.ts +5 -3
- package/dist/runtime/plugin-registry.d.ts.map +1 -1
- package/dist/runtime/plugin-registry.js +22 -5
- package/dist/runtime/plugin-registry.js.map +1 -1
- package/dist/runtime/template-variables.d.ts +6 -5
- package/dist/runtime/template-variables.d.ts.map +1 -1
- package/dist/runtime/template-variables.js +36 -9
- package/dist/runtime/template-variables.js.map +1 -1
- package/dist/runtime/time-series-queries.d.ts +3 -3
- package/dist/runtime/time-series-queries.d.ts.map +1 -1
- package/dist/runtime/time-series-queries.js +21 -19
- package/dist/runtime/time-series-queries.js.map +1 -1
- package/dist/runtime/trace-queries.d.ts +14 -0
- package/dist/runtime/trace-queries.d.ts.map +1 -0
- package/dist/runtime/trace-queries.js +61 -0
- package/dist/runtime/trace-queries.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithDataQueries.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithDataQueries.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts +1 -2
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js +2 -1
- package/dist/stories/shared-utils/decorators/WithPluginRegistry.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts +12 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.d.ts.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js +39 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemBuiltinVariables.js.map +1 -0
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js +24 -8
- package/dist/stories/shared-utils/decorators/WithPluginSystemDatasourceStore.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts +2 -3
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithPluginSystemTemplateVariables.js.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts +4 -5
- package/dist/stories/shared-utils/decorators/WithTimeRange.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/WithTimeRange.js +2 -2
- package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
- package/dist/stories/shared-utils/decorators/index.d.ts +1 -0
- package/dist/stories/shared-utils/decorators/index.d.ts.map +1 -1
- package/dist/stories/shared-utils/decorators/index.js +1 -0
- package/dist/stories/shared-utils/decorators/index.js.map +1 -1
- package/dist/stories/shared-utils/index.js.map +1 -1
- package/dist/test/index.d.ts +1 -0
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -0
- package/dist/test/index.js.map +1 -1
- package/dist/test/mock-data.d.ts +4 -0
- package/dist/test/mock-data.d.ts.map +1 -0
- package/dist/test/mock-data.js +64 -0
- package/dist/test/mock-data.js.map +1 -0
- package/dist/test/render.d.ts +1 -1
- package/dist/test/render.d.ts.map +1 -1
- package/dist/test/render.js +2 -2
- package/dist/test/render.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/test/test-plugins/bert/index.js +2 -2
- package/dist/test/test-plugins/bert/index.js.map +1 -1
- package/dist/test/test-plugins/ernie/index.js +2 -2
- package/dist/test/test-plugins/ernie/index.js.map +1 -1
- package/dist/test/test-plugins/index.js.map +1 -1
- package/dist/test-utils/index.js.map +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts +1 -1
- package/dist/test-utils/mock-plugin-registry.d.ts.map +1 -1
- package/dist/test-utils/mock-plugin-registry.js +3 -3
- package/dist/test-utils/mock-plugin-registry.js.map +1 -1
- package/dist/utils/action.d.ts +4 -0
- package/dist/utils/action.d.ts.map +1 -0
- package/dist/utils/action.js +27 -0
- package/dist/utils/action.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/dist/utils/variables.d.ts.map +1 -1
- package/dist/utils/variables.js +17 -5
- package/dist/utils/variables.js.map +1 -1
- package/dist/validation/datasource.d.ts +19 -0
- package/dist/validation/datasource.d.ts.map +1 -0
- package/dist/validation/datasource.js +22 -0
- package/dist/validation/datasource.js.map +1 -0
- package/dist/validation/duration.d.ts +3 -0
- package/dist/validation/duration.d.ts.map +1 -0
- package/dist/validation/duration.js +17 -0
- package/dist/validation/duration.js.map +1 -0
- package/dist/validation/index.d.ts +6 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +19 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/validation/resource.d.ts +3 -0
- package/dist/validation/resource.d.ts.map +1 -0
- package/dist/validation/resource.js +16 -0
- package/dist/validation/resource.js.map +1 -0
- package/dist/validation/role.d.ts +228 -0
- package/dist/validation/role.d.ts.map +1 -0
- package/dist/validation/role.js +67 -0
- package/dist/validation/role.js.map +1 -0
- package/dist/validation/rolebinding.d.ts +137 -0
- package/dist/validation/rolebinding.d.ts.map +1 -0
- package/dist/validation/rolebinding.js +47 -0
- package/dist/validation/rolebinding.js.map +1 -0
- package/dist/validation/secret.d.ts +964 -0
- package/dist/validation/secret.d.ts.map +1 -0
- package/dist/validation/secret.js +157 -0
- package/dist/validation/secret.js.map +1 -0
- package/dist/validation/user.d.ts +93 -0
- package/dist/validation/user.d.ts.map +1 -0
- package/dist/validation/user.js +38 -0
- package/dist/validation/user.js.map +1 -0
- package/dist/validation/variable.d.ts +96 -0
- package/dist/validation/variable.d.ts.map +1 -0
- package/dist/validation/variable.js +40 -0
- package/dist/validation/variable.js.map +1 -0
- package/package.json +9 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectSelect.d.ts","sourceRoot":"","sources":["../../src/components/ProjectSelect.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAU,WAAW,EAAiC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD,KAAK,eAAe,GAAG,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;AAEzD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IACpF,QAAQ,EAAE,CAAC,IAAI,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,eAAe,CAAC;CACxB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAmCtD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Select, MenuItem, Stack, ListItemText } from '@mui/material';
|
|
15
|
+
import { useProjectList } from '../context';
|
|
16
|
+
/**
|
|
17
|
+
* Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for
|
|
18
|
+
* the input deal with a `ProjectSelector`.
|
|
19
|
+
*/ export function ProjectSelect(props) {
|
|
20
|
+
const { onChange, value, ...others } = props;
|
|
21
|
+
const { data, isLoading } = useProjectList();
|
|
22
|
+
// While loading available values, just use an empty string so MUI select doesn't warn about values out of range
|
|
23
|
+
const optionValue = isLoading ? '' : projectToOptionValue(value);
|
|
24
|
+
// When the user makes a selection, convert the string option value back to a DatasourceSelector
|
|
25
|
+
const handleChange = (e)=>{
|
|
26
|
+
const next = optionValueToSelector(e.target.value);
|
|
27
|
+
onChange(next);
|
|
28
|
+
};
|
|
29
|
+
// TODO:
|
|
30
|
+
// - Does this need a loading indicator of some kind?
|
|
31
|
+
// - The group's edit link is not clickable once selected.
|
|
32
|
+
// - The group's edit link is disabled if datasource is overridden.
|
|
33
|
+
// Ref: https://github.com/mui/material-ui/issues/36572
|
|
34
|
+
return /*#__PURE__*/ _jsxs(Select, {
|
|
35
|
+
...others,
|
|
36
|
+
value: optionValue,
|
|
37
|
+
onChange: handleChange,
|
|
38
|
+
children: [
|
|
39
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
40
|
+
value: 'none',
|
|
41
|
+
children: /*#__PURE__*/ _jsx(Stack, {
|
|
42
|
+
direction: "row",
|
|
43
|
+
alignItems: "center",
|
|
44
|
+
justifyContent: "space-between",
|
|
45
|
+
width: "100%",
|
|
46
|
+
height: 32,
|
|
47
|
+
children: /*#__PURE__*/ _jsx(ListItemText, {
|
|
48
|
+
children: "None"
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
}),
|
|
52
|
+
data === null || data === void 0 ? void 0 : data.map((project)=>[
|
|
53
|
+
/*#__PURE__*/ _jsx(MenuItem, {
|
|
54
|
+
value: project.metadata.name,
|
|
55
|
+
children: /*#__PURE__*/ _jsx(Stack, {
|
|
56
|
+
direction: "row",
|
|
57
|
+
alignItems: "center",
|
|
58
|
+
justifyContent: "space-between",
|
|
59
|
+
width: "100%",
|
|
60
|
+
height: 32,
|
|
61
|
+
children: /*#__PURE__*/ _jsx(ListItemText, {
|
|
62
|
+
children: project.metadata.name
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
}, project.metadata.name)
|
|
66
|
+
])
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Given a ProjectSelectItemSelector,
|
|
72
|
+
* returns a string value that can be used as a Select input value.
|
|
73
|
+
* @param selector
|
|
74
|
+
*/ function projectToOptionValue(project) {
|
|
75
|
+
var _project_metadata_name;
|
|
76
|
+
return (_project_metadata_name = project.metadata.name) !== null && _project_metadata_name !== void 0 ? _project_metadata_name : 'none';
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Given an option value name,
|
|
80
|
+
* returns a ProjectResource to be used by the query data model.
|
|
81
|
+
* @param optionValue
|
|
82
|
+
*/ function optionValueToSelector(optionValue) {
|
|
83
|
+
return {
|
|
84
|
+
kind: 'Project',
|
|
85
|
+
metadata: {
|
|
86
|
+
name: optionValue
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
//# sourceMappingURL=ProjectSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/components/ProjectSelect.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Select, SelectProps, MenuItem, Stack, ListItemText } from '@mui/material';\nimport { ProjectResource } from '@perses-dev/core';\nimport { useProjectList } from '../context';\n\n// Props on MUI Select that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface ProjectSelectProps extends Omit<SelectProps<string>, OmittedMuiProps> {\n onChange: (next: ProjectResource) => void;\n value: ProjectResource;\n}\n\n/**\n * Displays a MUI input for selecting a Project of a particular kind. Note: The 'value' and `onChange` handler for\n * the input deal with a `ProjectSelector`.\n */\nexport function ProjectSelect(props: ProjectSelectProps) {\n const { onChange, value, ...others } = props;\n\n const { data, isLoading } = useProjectList();\n\n // While loading available values, just use an empty string so MUI select doesn't warn about values out of range\n const optionValue = isLoading ? '' : projectToOptionValue(value);\n\n // When the user makes a selection, convert the string option value back to a DatasourceSelector\n const handleChange: SelectProps<string>['onChange'] = (e) => {\n const next = optionValueToSelector(e.target.value);\n onChange(next);\n };\n\n // TODO:\n // - Does this need a loading indicator of some kind?\n // - The group's edit link is not clickable once selected.\n // - The group's edit link is disabled if datasource is overridden.\n // Ref: https://github.com/mui/material-ui/issues/36572\n return (\n <Select {...others} value={optionValue} onChange={handleChange}>\n <MenuItem value={'none'}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>None</ListItemText>\n </Stack>\n </MenuItem>\n {data?.map((project: ProjectResource) => [\n <MenuItem key={project.metadata.name} value={project.metadata.name}>\n <Stack direction=\"row\" alignItems=\"center\" justifyContent=\"space-between\" width=\"100%\" height={32}>\n <ListItemText>{project.metadata.name}</ListItemText>\n </Stack>\n </MenuItem>,\n ])}\n </Select>\n );\n}\n\n/**\n * Given a ProjectSelectItemSelector,\n * returns a string value that can be used as a Select input value.\n * @param selector\n */\nfunction projectToOptionValue(project: ProjectResource): string {\n return project.metadata.name ?? 'none';\n}\n\n/**\n * Given an option value name,\n * returns a ProjectResource to be used by the query data model.\n * @param optionValue\n */\nfunction optionValueToSelector(optionValue: string): ProjectResource {\n return {\n kind: 'Project',\n metadata: {\n name: optionValue,\n },\n };\n}\n"],"names":["Select","MenuItem","Stack","ListItemText","useProjectList","ProjectSelect","props","onChange","value","others","data","isLoading","optionValue","projectToOptionValue","handleChange","e","next","optionValueToSelector","target","direction","alignItems","justifyContent","width","height","map","project","metadata","name","kind"],"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,SAASA,MAAM,EAAeC,QAAQ,EAAEC,KAAK,EAAEC,YAAY,QAAQ,gBAAgB;AAEnF,SAASC,cAAc,QAAQ,aAAa;AAW5C;;;CAGC,GACD,OAAO,SAASC,cAAcC,KAAyB;IACrD,MAAM,EAAEC,QAAQ,EAAEC,KAAK,EAAE,GAAGC,QAAQ,GAAGH;IAEvC,MAAM,EAAEI,IAAI,EAAEC,SAAS,EAAE,GAAGP;IAE5B,gHAAgH;IAChH,MAAMQ,cAAcD,YAAY,KAAKE,qBAAqBL;IAE1D,gGAAgG;IAChG,MAAMM,eAAgD,CAACC;QACrD,MAAMC,OAAOC,sBAAsBF,EAAEG,MAAM,CAACV,KAAK;QACjDD,SAASS;IACX;IAEA,QAAQ;IACR,sDAAsD;IACtD,2DAA2D;IAC3D,oEAAoE;IACpE,0DAA0D;IAC1D,qBACE,MAAChB;QAAQ,GAAGS,MAAM;QAAED,OAAOI;QAAaL,UAAUO;;0BAChD,KAACb;gBAASO,OAAO;0BACf,cAAA,KAACN;oBAAMiB,WAAU;oBAAMC,YAAW;oBAASC,gBAAe;oBAAgBC,OAAM;oBAAOC,QAAQ;8BAC7F,cAAA,KAACpB;kCAAa;;;;YAGjBO,iBAAAA,2BAAAA,KAAMc,GAAG,CAAC,CAACC,UAA6B;kCACvC,KAACxB;wBAAqCO,OAAOiB,QAAQC,QAAQ,CAACC,IAAI;kCAChE,cAAA,KAACzB;4BAAMiB,WAAU;4BAAMC,YAAW;4BAASC,gBAAe;4BAAgBC,OAAM;4BAAOC,QAAQ;sCAC7F,cAAA,KAACpB;0CAAcsB,QAAQC,QAAQ,CAACC,IAAI;;;uBAFzBF,QAAQC,QAAQ,CAACC,IAAI;iBAKrC;;;AAGP;AAEA;;;;CAIC,GACD,SAASd,qBAAqBY,OAAwB;QAC7CA;IAAP,OAAOA,CAAAA,yBAAAA,QAAQC,QAAQ,CAACC,IAAI,cAArBF,oCAAAA,yBAAyB;AAClC;AAEA;;;;CAIC,GACD,SAASR,sBAAsBL,WAAmB;IAChD,OAAO;QACLgB,MAAM;QACNF,UAAU;YACRC,MAAMf;QACR;IACF;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TimeOption } from '@perses-dev/components';
|
|
2
|
+
export declare const DEFAULT_TIME_RANGE_OPTIONS: TimeOption[];
|
|
3
|
+
export declare const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[];
|
|
4
|
+
interface TimeRangeControlsProps {
|
|
5
|
+
heightPx?: number;
|
|
6
|
+
showTimeRangeSelector?: boolean;
|
|
7
|
+
showRefreshButton?: boolean;
|
|
8
|
+
showRefreshInterval?: boolean;
|
|
9
|
+
timePresets?: TimeOption[];
|
|
10
|
+
}
|
|
11
|
+
export declare function TimeRangeControls({ heightPx, showTimeRangeSelector, showRefreshButton, showRefreshInterval, timePresets, }: TimeRangeControlsProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=TimeRangeControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TimeRangeControls.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"names":[],"mappings":"AAeA,OAAO,EAIL,UAAU,EAEX,MAAM,wBAAwB,CAAC;AAMhC,eAAO,MAAM,0BAA0B,EAAE,UAAU,EAUlD,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,UAAU,EAOxD,CAAC;AAIF,UAAU,sBAAsB;IAE9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,qBAA4B,EAC5B,iBAAwB,EACxB,mBAA0B,EAC1B,WAAwC,GACzC,EAAE,sBAAsB,2CAiDxB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import RefreshIcon from 'mdi-material-ui/Refresh';
|
|
15
|
+
import { Stack } from '@mui/material';
|
|
16
|
+
import { DateTimeRangePicker, RefreshIntervalPicker, InfoTooltip, ToolbarIconButton } from '@perses-dev/components';
|
|
17
|
+
import { useCallback } from 'react';
|
|
18
|
+
import { TOOLTIP_TEXT } from '../../constants';
|
|
19
|
+
import { useTimeRange } from '../../runtime';
|
|
20
|
+
export const DEFAULT_TIME_RANGE_OPTIONS = [
|
|
21
|
+
{
|
|
22
|
+
value: {
|
|
23
|
+
pastDuration: '5m'
|
|
24
|
+
},
|
|
25
|
+
display: 'Last 5 minutes'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: {
|
|
29
|
+
pastDuration: '15m'
|
|
30
|
+
},
|
|
31
|
+
display: 'Last 15 minutes'
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
value: {
|
|
35
|
+
pastDuration: '30m'
|
|
36
|
+
},
|
|
37
|
+
display: 'Last 30 minutes'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
value: {
|
|
41
|
+
pastDuration: '1h'
|
|
42
|
+
},
|
|
43
|
+
display: 'Last 1 hour'
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
value: {
|
|
47
|
+
pastDuration: '6h'
|
|
48
|
+
},
|
|
49
|
+
display: 'Last 6 hours'
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: {
|
|
53
|
+
pastDuration: '12h'
|
|
54
|
+
},
|
|
55
|
+
display: 'Last 12 hours'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: {
|
|
59
|
+
pastDuration: '24h'
|
|
60
|
+
},
|
|
61
|
+
display: 'Last 1 day'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
value: {
|
|
65
|
+
pastDuration: '7d'
|
|
66
|
+
},
|
|
67
|
+
display: 'Last 7 days'
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
value: {
|
|
71
|
+
pastDuration: '14d'
|
|
72
|
+
},
|
|
73
|
+
display: 'Last 14 days'
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
export const DEFAULT_REFRESH_INTERVAL_OPTIONS = [
|
|
77
|
+
{
|
|
78
|
+
value: {
|
|
79
|
+
pastDuration: '0s'
|
|
80
|
+
},
|
|
81
|
+
display: 'Off'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: {
|
|
85
|
+
pastDuration: '5s'
|
|
86
|
+
},
|
|
87
|
+
display: '5s'
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
value: {
|
|
91
|
+
pastDuration: '10s'
|
|
92
|
+
},
|
|
93
|
+
display: '10s'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
value: {
|
|
97
|
+
pastDuration: '15s'
|
|
98
|
+
},
|
|
99
|
+
display: '15s'
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
value: {
|
|
103
|
+
pastDuration: '30s'
|
|
104
|
+
},
|
|
105
|
+
display: '30s'
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
value: {
|
|
109
|
+
pastDuration: '60s'
|
|
110
|
+
},
|
|
111
|
+
display: '1m'
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
const DEFAULT_HEIGHT = '34px';
|
|
115
|
+
export function TimeRangeControls({ heightPx, showTimeRangeSelector = true, showRefreshButton = true, showRefreshInterval = true, timePresets = DEFAULT_TIME_RANGE_OPTIONS }) {
|
|
116
|
+
const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();
|
|
117
|
+
// Convert height to a string, then use the string for styling
|
|
118
|
+
const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;
|
|
119
|
+
// add time preset if one does not match duration given in time range
|
|
120
|
+
if ('pastDuration' in timeRange && !timePresets.some((option)=>option.value.pastDuration === timeRange['pastDuration'])) {
|
|
121
|
+
timePresets.push({
|
|
122
|
+
value: {
|
|
123
|
+
pastDuration: timeRange['pastDuration']
|
|
124
|
+
},
|
|
125
|
+
display: `Last ${timeRange['pastDuration']}`
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// set the new refresh interval both in the dashboard context & as query param
|
|
129
|
+
const handleRefreshIntervalChange = useCallback((duration)=>{
|
|
130
|
+
setRefreshInterval(duration);
|
|
131
|
+
}, [
|
|
132
|
+
setRefreshInterval
|
|
133
|
+
]);
|
|
134
|
+
return /*#__PURE__*/ _jsxs(Stack, {
|
|
135
|
+
direction: "row",
|
|
136
|
+
spacing: 1,
|
|
137
|
+
children: [
|
|
138
|
+
showTimeRangeSelector && /*#__PURE__*/ _jsx(DateTimeRangePicker, {
|
|
139
|
+
timeOptions: timePresets,
|
|
140
|
+
value: timeRange,
|
|
141
|
+
onChange: setTimeRange,
|
|
142
|
+
height: height
|
|
143
|
+
}),
|
|
144
|
+
showRefreshButton && /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
145
|
+
description: TOOLTIP_TEXT.refresh,
|
|
146
|
+
children: /*#__PURE__*/ _jsx(ToolbarIconButton, {
|
|
147
|
+
"aria-label": TOOLTIP_TEXT.refresh,
|
|
148
|
+
onClick: refresh,
|
|
149
|
+
sx: {
|
|
150
|
+
height
|
|
151
|
+
},
|
|
152
|
+
children: /*#__PURE__*/ _jsx(RefreshIcon, {})
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
showRefreshInterval && /*#__PURE__*/ _jsx(InfoTooltip, {
|
|
156
|
+
description: TOOLTIP_TEXT.refreshInterval,
|
|
157
|
+
children: /*#__PURE__*/ _jsx(RefreshIntervalPicker, {
|
|
158
|
+
timeOptions: DEFAULT_REFRESH_INTERVAL_OPTIONS,
|
|
159
|
+
value: refreshInterval,
|
|
160
|
+
onChange: handleRefreshIntervalChange,
|
|
161
|
+
height: height
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
]
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
//# sourceMappingURL=TimeRangeControls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/TimeRangeControls.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport RefreshIcon from 'mdi-material-ui/Refresh';\nimport { Stack } from '@mui/material';\nimport {\n DateTimeRangePicker,\n RefreshIntervalPicker,\n InfoTooltip,\n TimeOption,\n ToolbarIconButton,\n} from '@perses-dev/components';\nimport { DurationString } from '@perses-dev/core';\nimport { useCallback } from 'react';\nimport { TOOLTIP_TEXT } from '../../constants';\nimport { useTimeRange } from '../../runtime';\n\nexport const DEFAULT_TIME_RANGE_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '5m' }, display: 'Last 5 minutes' },\n { value: { pastDuration: '15m' }, display: 'Last 15 minutes' },\n { value: { pastDuration: '30m' }, display: 'Last 30 minutes' },\n { value: { pastDuration: '1h' }, display: 'Last 1 hour' },\n { value: { pastDuration: '6h' }, display: 'Last 6 hours' },\n { value: { pastDuration: '12h' }, display: 'Last 12 hours' },\n { value: { pastDuration: '24h' }, display: 'Last 1 day' },\n { value: { pastDuration: '7d' }, display: 'Last 7 days' },\n { value: { pastDuration: '14d' }, display: 'Last 14 days' },\n];\n\nexport const DEFAULT_REFRESH_INTERVAL_OPTIONS: TimeOption[] = [\n { value: { pastDuration: '0s' }, display: 'Off' },\n { value: { pastDuration: '5s' }, display: '5s' },\n { value: { pastDuration: '10s' }, display: '10s' },\n { value: { pastDuration: '15s' }, display: '15s' },\n { value: { pastDuration: '30s' }, display: '30s' },\n { value: { pastDuration: '60s' }, display: '1m' },\n];\n\nconst DEFAULT_HEIGHT = '34px';\n\ninterface TimeRangeControlsProps {\n // The controls look best at heights >= 28 pixels\n heightPx?: number;\n showTimeRangeSelector?: boolean;\n showRefreshButton?: boolean;\n showRefreshInterval?: boolean;\n timePresets?: TimeOption[];\n}\n\nexport function TimeRangeControls({\n heightPx,\n showTimeRangeSelector = true,\n showRefreshButton = true,\n showRefreshInterval = true,\n timePresets = DEFAULT_TIME_RANGE_OPTIONS,\n}: TimeRangeControlsProps) {\n const { timeRange, setTimeRange, refresh, refreshInterval, setRefreshInterval } = useTimeRange();\n\n // Convert height to a string, then use the string for styling\n const height = heightPx === undefined ? DEFAULT_HEIGHT : `${heightPx}px`;\n\n // add time preset if one does not match duration given in time range\n if (\n 'pastDuration' in timeRange &&\n !timePresets.some((option) => option.value.pastDuration === timeRange['pastDuration'])\n ) {\n timePresets.push({\n value: { pastDuration: timeRange['pastDuration'] },\n display: `Last ${timeRange['pastDuration']}`,\n });\n }\n\n // set the new refresh interval both in the dashboard context & as query param\n const handleRefreshIntervalChange = useCallback(\n (duration: DurationString) => {\n setRefreshInterval(duration);\n },\n [setRefreshInterval]\n );\n\n return (\n <Stack direction=\"row\" spacing={1}>\n {showTimeRangeSelector && (\n <DateTimeRangePicker timeOptions={timePresets} value={timeRange} onChange={setTimeRange} height={height} />\n )}\n {showRefreshButton && (\n <InfoTooltip description={TOOLTIP_TEXT.refresh}>\n <ToolbarIconButton aria-label={TOOLTIP_TEXT.refresh} onClick={refresh} sx={{ height }}>\n <RefreshIcon />\n </ToolbarIconButton>\n </InfoTooltip>\n )}\n {showRefreshInterval && (\n <InfoTooltip description={TOOLTIP_TEXT.refreshInterval}>\n <RefreshIntervalPicker\n timeOptions={DEFAULT_REFRESH_INTERVAL_OPTIONS}\n value={refreshInterval}\n onChange={handleRefreshIntervalChange}\n height={height}\n />\n </InfoTooltip>\n )}\n </Stack>\n );\n}\n"],"names":["RefreshIcon","Stack","DateTimeRangePicker","RefreshIntervalPicker","InfoTooltip","ToolbarIconButton","useCallback","TOOLTIP_TEXT","useTimeRange","DEFAULT_TIME_RANGE_OPTIONS","value","pastDuration","display","DEFAULT_REFRESH_INTERVAL_OPTIONS","DEFAULT_HEIGHT","TimeRangeControls","heightPx","showTimeRangeSelector","showRefreshButton","showRefreshInterval","timePresets","timeRange","setTimeRange","refresh","refreshInterval","setRefreshInterval","height","undefined","some","option","push","handleRefreshIntervalChange","duration","direction","spacing","timeOptions","onChange","description","aria-label","onClick","sx"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/TimeRangeControls/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export * from './TimeRangeControls';
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeRangeControls/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeRangeControls';\n"],"names":[],"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,cAAc,sBAAsB"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TimeSeriesQueryDefinition, QueryDefinition } from '@perses-dev/core';
|
|
3
2
|
export interface TimeSeriesQueryEditorProps {
|
|
4
3
|
queries?: TimeSeriesQueryDefinition[];
|
|
5
4
|
onChange: (queries: QueryDefinition[]) => void;
|
|
6
5
|
}
|
|
7
|
-
export declare function TimeSeriesQueryEditor({ queries, onChange }: TimeSeriesQueryEditorProps): JSX.Element;
|
|
6
|
+
export declare function TimeSeriesQueryEditor({ queries, onChange }: TimeSeriesQueryEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
//# sourceMappingURL=TimeSeriesQueryEditor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TimeSeriesQueryEditor.d.ts","sourceRoot":"","sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAI9E,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,yBAAyB,EAAE,CAAC;IACtC,QAAQ,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,IAAI,CAAC;CAChD;AAED,wBAAgB,qBAAqB,CAAC,EAAE,OAAY,EAAE,QAAQ,EAAE,EAAE,0BAA0B,2CA+F3F"}
|
|
@@ -10,23 +10,35 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
14
|
import { useState } from 'react';
|
|
15
15
|
import { produce } from 'immer';
|
|
16
16
|
import { Button, Stack } from '@mui/material';
|
|
17
17
|
import AddIcon from 'mdi-material-ui/Plus';
|
|
18
|
-
import { usePlugin, usePluginRegistry } from '../../runtime';
|
|
18
|
+
import { TIME_SERIES_QUERY_KEY, useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';
|
|
19
19
|
import { TimeSeriesQueryInput } from './TimeSeriesQueryInput';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
20
|
+
export function TimeSeriesQueryEditor({ queries = [], onChange }) {
|
|
21
|
+
var _timeSeriesPlugins_;
|
|
22
|
+
// Build the default query plugin
|
|
23
|
+
// Use as default the plugin kind explicitly set as default or the first in the list
|
|
24
|
+
const { defaultPluginKinds } = usePluginRegistry();
|
|
25
|
+
const { data: timeSeriesPlugins } = useListPluginMetadata(TIME_SERIES_QUERY_KEY);
|
|
26
|
+
var _defaultPluginKinds_TIME_SERIES_QUERY_KEY, _ref;
|
|
27
|
+
const defaultTimeSeriesQueryKind = (_ref = (_defaultPluginKinds_TIME_SERIES_QUERY_KEY = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds[TIME_SERIES_QUERY_KEY]) !== null && _defaultPluginKinds_TIME_SERIES_QUERY_KEY !== void 0 ? _defaultPluginKinds_TIME_SERIES_QUERY_KEY : timeSeriesPlugins === null || timeSeriesPlugins === void 0 ? void 0 : (_timeSeriesPlugins_ = timeSeriesPlugins[0]) === null || _timeSeriesPlugins_ === void 0 ? void 0 : _timeSeriesPlugins_.kind) !== null && _ref !== void 0 ? _ref : '';
|
|
28
|
+
const { data: defaultQueryPlugin } = usePlugin(TIME_SERIES_QUERY_KEY, defaultTimeSeriesQueryKind, {
|
|
27
29
|
useErrorBoundary: true,
|
|
28
30
|
enabled: true
|
|
29
31
|
});
|
|
32
|
+
// This default query definition is used if no query is provided initially or when we add a new query
|
|
33
|
+
const defaultInitialQueryDefinition = {
|
|
34
|
+
kind: TIME_SERIES_QUERY_KEY,
|
|
35
|
+
spec: {
|
|
36
|
+
plugin: {
|
|
37
|
+
kind: defaultTimeSeriesQueryKind,
|
|
38
|
+
spec: (defaultQueryPlugin === null || defaultQueryPlugin === void 0 ? void 0 : defaultQueryPlugin.createInitialOptions()) || {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
30
42
|
// State for which queries are collapsed
|
|
31
43
|
// TODO: Would be easier if we had IDs for queries.
|
|
32
44
|
const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(()=>false));
|
|
@@ -45,21 +57,12 @@ export function TimeSeriesQueryEditor({ queries =[] , onChange }) {
|
|
|
45
57
|
const handleQueryAdd = ()=>{
|
|
46
58
|
if (!defaultQueryPlugin) return;
|
|
47
59
|
onChange(produce(queries, (draft)=>{
|
|
48
|
-
const queryDef = {
|
|
49
|
-
kind: DEFAULT_QUERY_PLUGIN_TYPE,
|
|
50
|
-
spec: {
|
|
51
|
-
plugin: {
|
|
52
|
-
kind: defaultTimeSeriesQueryKind,
|
|
53
|
-
spec: defaultQueryPlugin.createInitialOptions()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
60
|
if (draft) {
|
|
58
|
-
draft.push(
|
|
61
|
+
draft.push(defaultInitialQueryDefinition);
|
|
59
62
|
} else {
|
|
60
63
|
draft = [
|
|
61
64
|
...queries,
|
|
62
|
-
|
|
65
|
+
defaultInitialQueryDefinition
|
|
63
66
|
];
|
|
64
67
|
}
|
|
65
68
|
}));
|
|
@@ -89,41 +92,32 @@ export function TimeSeriesQueryEditor({ queries =[] , onChange }) {
|
|
|
89
92
|
];
|
|
90
93
|
});
|
|
91
94
|
};
|
|
92
|
-
var ref1;
|
|
93
95
|
// show one query input if queries is empty
|
|
94
96
|
const queryDefinitions = queries.length ? queries : [
|
|
95
|
-
|
|
96
|
-
kind: 'TimeSeriesQuery',
|
|
97
|
-
spec: {
|
|
98
|
-
plugin: {
|
|
99
|
-
kind: (ref1 = defaultPluginKinds === null || defaultPluginKinds === void 0 ? void 0 : defaultPluginKinds['TimeSeriesQuery']) !== null && ref1 !== void 0 ? ref1 : '',
|
|
100
|
-
spec: {
|
|
101
|
-
query: ''
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
97
|
+
defaultInitialQueryDefinition
|
|
106
98
|
];
|
|
107
|
-
return /*#__PURE__*/ _jsxs(
|
|
108
|
-
spacing: 1,
|
|
99
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
109
100
|
children: [
|
|
101
|
+
/*#__PURE__*/ _jsx(Stack, {
|
|
102
|
+
spacing: 1,
|
|
103
|
+
children: queryDefinitions.map((query, i)=>/*#__PURE__*/ _jsx(TimeSeriesQueryInput, {
|
|
104
|
+
index: i,
|
|
105
|
+
query: query,
|
|
106
|
+
isCollapsed: !!queriesCollapsed[i],
|
|
107
|
+
onChange: handleQueryChange,
|
|
108
|
+
onDelete: queries.length > 1 ? handleQueryDelete : undefined,
|
|
109
|
+
onCollapseExpand: handleQueryCollapseExpand
|
|
110
|
+
}, i))
|
|
111
|
+
}),
|
|
110
112
|
/*#__PURE__*/ _jsx(Button, {
|
|
111
113
|
variant: "contained",
|
|
112
114
|
startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
|
|
113
115
|
sx: {
|
|
114
|
-
|
|
116
|
+
marginTop: 1
|
|
115
117
|
},
|
|
116
118
|
onClick: handleQueryAdd,
|
|
117
119
|
children: "Add Query"
|
|
118
|
-
})
|
|
119
|
-
queryDefinitions.map((query, i)=>/*#__PURE__*/ _jsx(TimeSeriesQueryInput, {
|
|
120
|
-
index: i,
|
|
121
|
-
query: query,
|
|
122
|
-
isCollapsed: !!queriesCollapsed[i],
|
|
123
|
-
onChange: handleQueryChange,
|
|
124
|
-
onDelete: hasMoreThanOneQuery ? handleQueryDelete : undefined,
|
|
125
|
-
onCollapseExpand: handleQueryCollapseExpand
|
|
126
|
-
}, i))
|
|
120
|
+
})
|
|
127
121
|
]
|
|
128
122
|
});
|
|
129
123
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { TimeSeriesQueryDefinition, QueryDefinition } from '@perses-dev/core';\nimport { usePlugin, usePluginRegistry } from '../../runtime';\nimport { TimeSeriesQueryInput } from './TimeSeriesQueryInput';\n\
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useState } from 'react';\nimport { produce } from 'immer';\nimport { Button, Stack } from '@mui/material';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { TimeSeriesQueryDefinition, QueryDefinition } from '@perses-dev/core';\nimport { TIME_SERIES_QUERY_KEY, useListPluginMetadata, usePlugin, usePluginRegistry } from '../../runtime';\nimport { TimeSeriesQueryInput } from './TimeSeriesQueryInput';\n\nexport interface TimeSeriesQueryEditorProps {\n queries?: TimeSeriesQueryDefinition[];\n onChange: (queries: QueryDefinition[]) => void;\n}\n\nexport function TimeSeriesQueryEditor({ queries = [], onChange }: TimeSeriesQueryEditorProps) {\n // Build the default query plugin\n // Use as default the plugin kind explicitly set as default or the first in the list\n const { defaultPluginKinds } = usePluginRegistry();\n const { data: timeSeriesPlugins } = useListPluginMetadata(TIME_SERIES_QUERY_KEY);\n const defaultTimeSeriesQueryKind = defaultPluginKinds?.[TIME_SERIES_QUERY_KEY] ?? timeSeriesPlugins?.[0]?.kind ?? '';\n const { data: defaultQueryPlugin } = usePlugin(TIME_SERIES_QUERY_KEY, defaultTimeSeriesQueryKind, {\n useErrorBoundary: true,\n enabled: true,\n });\n\n // This default query definition is used if no query is provided initially or when we add a new query\n const defaultInitialQueryDefinition: TimeSeriesQueryDefinition = {\n kind: TIME_SERIES_QUERY_KEY,\n spec: {\n plugin: { kind: defaultTimeSeriesQueryKind, spec: defaultQueryPlugin?.createInitialOptions() || {} },\n },\n };\n\n // State for which queries are collapsed\n // TODO: Would be easier if we had IDs for queries.\n const [queriesCollapsed, setQueriesCollapsed] = useState(queries.map(() => false));\n\n // Query handlers\n const handleQueryChange = (index: number, queryDef: TimeSeriesQueryDefinition) => {\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft[index] = queryDef;\n } else {\n draft = [queryDef];\n }\n })\n );\n };\n\n const handleQueryAdd = () => {\n if (!defaultQueryPlugin) return;\n onChange(\n produce(queries, (draft) => {\n if (draft) {\n draft.push(defaultInitialQueryDefinition);\n } else {\n draft = [...queries, defaultInitialQueryDefinition];\n }\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.push(false);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryDelete = (index: number) => {\n onChange(\n produce(queries, (draft) => {\n draft.splice(index, 1);\n })\n );\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed.splice(index, 1);\n return [...queriesCollapsed];\n });\n };\n\n const handleQueryCollapseExpand = (index: number) => {\n setQueriesCollapsed((queriesCollapsed) => {\n queriesCollapsed[index] = !queriesCollapsed[index];\n return [...queriesCollapsed];\n });\n };\n\n // show one query input if queries is empty\n const queryDefinitions: TimeSeriesQueryDefinition[] = queries.length ? queries : [defaultInitialQueryDefinition];\n\n return (\n <>\n <Stack spacing={1}>\n {queryDefinitions.map((query: TimeSeriesQueryDefinition, i: number) => (\n <TimeSeriesQueryInput\n key={i}\n index={i}\n query={query}\n isCollapsed={!!queriesCollapsed[i]}\n onChange={handleQueryChange}\n onDelete={queries.length > 1 ? handleQueryDelete : undefined}\n onCollapseExpand={handleQueryCollapseExpand}\n />\n ))}\n </Stack>\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleQueryAdd}>\n Add Query\n </Button>\n </>\n );\n}\n"],"names":["useState","produce","Button","Stack","AddIcon","TIME_SERIES_QUERY_KEY","useListPluginMetadata","usePlugin","usePluginRegistry","TimeSeriesQueryInput","TimeSeriesQueryEditor","queries","onChange","timeSeriesPlugins","defaultPluginKinds","data","defaultTimeSeriesQueryKind","kind","defaultQueryPlugin","useErrorBoundary","enabled","defaultInitialQueryDefinition","spec","plugin","createInitialOptions","queriesCollapsed","setQueriesCollapsed","map","handleQueryChange","index","queryDef","draft","handleQueryAdd","push","handleQueryDelete","splice","handleQueryCollapseExpand","queryDefinitions","length","spacing","query","i","isCollapsed","onDelete","undefined","onCollapseExpand","variant","startIcon","sx","marginTop","onClick"],"mappings":"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"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { TimeSeriesQueryDefinition } from '@perses-dev/core';
|
|
3
2
|
interface TimeSeriesQueryInputProps {
|
|
4
3
|
query: TimeSeriesQueryDefinition;
|
|
@@ -8,6 +7,6 @@ interface TimeSeriesQueryInputProps {
|
|
|
8
7
|
isCollapsed?: boolean;
|
|
9
8
|
onDelete?: (index: number) => void;
|
|
10
9
|
}
|
|
11
|
-
export declare const TimeSeriesQueryInput: ({ index, query, isCollapsed, onDelete, onChange, onCollapseExpand, }: TimeSeriesQueryInputProps) => JSX.Element;
|
|
10
|
+
export declare const TimeSeriesQueryInput: ({ index, query, isCollapsed, onDelete, onChange, onCollapseExpand, }: TimeSeriesQueryInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export {};
|
|
13
12
|
//# sourceMappingURL=TimeSeriesQueryInput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimeSeriesQueryInput.d.ts","sourceRoot":"","sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TimeSeriesQueryInput.d.ts","sourceRoot":"","sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAO7D,UAAU,yBAAyB;IACjC,KAAK,EAAE,yBAAyB,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,yBAAyB,KAAK,IAAI,CAAC;IACpE,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACpC;AAED,eAAO,MAAM,oBAAoB,yEAO9B,yBAAyB,4CAsB3B,CAAC"}
|
|
@@ -17,7 +17,7 @@ import DeleteIcon from 'mdi-material-ui/DeleteOutline';
|
|
|
17
17
|
import ChevronDown from 'mdi-material-ui/ChevronDown';
|
|
18
18
|
import ChevronRight from 'mdi-material-ui/ChevronRight';
|
|
19
19
|
import { PluginEditor } from '../PluginEditor';
|
|
20
|
-
export const TimeSeriesQueryInput = ({ index
|
|
20
|
+
export const TimeSeriesQueryInput = ({ index, query, isCollapsed, onDelete, onChange, onCollapseExpand })=>{
|
|
21
21
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
22
22
|
spacing: 1,
|
|
23
23
|
children: [
|
|
@@ -62,8 +62,8 @@ export const TimeSeriesQueryInput = ({ index , query , isCollapsed , onDelete ,
|
|
|
62
62
|
/**
|
|
63
63
|
* Displays an editor for TimeSeriesQueryDefinition objects.
|
|
64
64
|
*/ function QueryEditor(props) {
|
|
65
|
-
const { value
|
|
66
|
-
const { spec: { plugin
|
|
65
|
+
const { value, onChange, ...others } = props;
|
|
66
|
+
const { spec: { plugin } } = value;
|
|
67
67
|
const handlePluginChange = (next)=>{
|
|
68
68
|
onChange(produce(value, (draft)=>{
|
|
69
69
|
draft.spec.plugin = next;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport produce from 'immer';\nimport { TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { Stack, IconButton, Typography, BoxProps, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport { PluginEditor, PluginEditorProps } from '../PluginEditor';\n\ninterface TimeSeriesQueryInputProps {\n query: TimeSeriesQueryDefinition;\n index: number;\n onChange: (index: number, query: TimeSeriesQueryDefinition) => void;\n onCollapseExpand: (index: number) => void;\n isCollapsed?: boolean;\n onDelete?: (index: number) => void;\n}\n\nexport const TimeSeriesQueryInput = ({\n index,\n query,\n isCollapsed,\n onDelete,\n onChange,\n onCollapseExpand,\n}: TimeSeriesQueryInputProps) => {\n return (\n <Stack key={index} spacing={1}>\n <Stack direction=\"row\" alignItems=\"center\" borderBottom={1} borderColor={(theme) => theme.palette.divider}>\n <IconButton size=\"small\" onClick={() => onCollapseExpand(index)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\">\n Query {index + 1}\n </Typography>\n <IconButton\n size=\"small\"\n // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible\n sx={{ marginLeft: 'auto', visibility: `${onDelete ? 'visible' : 'hidden'}` }}\n onClick={() => onDelete && onDelete(index)}\n >\n <DeleteIcon />\n </IconButton>\n </Stack>\n {!isCollapsed && <QueryEditor value={query} onChange={(next) => onChange(index, next)} />}\n </Stack>\n );\n};\n\n// Props on MUI Box that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ninterface QueryEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n value: TimeSeriesQueryDefinition;\n onChange: (next: TimeSeriesQueryDefinition) => void;\n}\n\n/**\n * Displays an editor for TimeSeriesQueryDefinition objects.\n */\nfunction QueryEditor(props: QueryEditorProps) {\n const { value, onChange, ...others } = props;\n const {\n spec: { plugin },\n } = value;\n\n const handlePluginChange: PluginEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec.plugin = next;\n })\n );\n };\n\n return (\n <Box {...others}>\n {/* If TimeSeriesQuery plugins ever have common props on the definition, the inputs could go here */}\n <PluginEditor\n pluginType=\"TimeSeriesQuery\"\n pluginKindLabel=\"Query Type\"\n value={plugin}\n onChange={handlePluginChange}\n />\n </Box>\n );\n}\n"],"names":["produce","Stack","IconButton","Typography","Box","DeleteIcon","ChevronDown","ChevronRight","PluginEditor","TimeSeriesQueryInput","index","query","isCollapsed","onDelete","onChange","onCollapseExpand","spacing","direction","alignItems","borderBottom","borderColor","theme","palette","divider","size","onClick","variant","component","sx","marginLeft","visibility","QueryEditor","value","next","props","others","spec","plugin","handlePluginChange","draft","pluginType","pluginKindLabel"],"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
|
|
1
|
+
{"version":3,"sources":["../../../src/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport produce from 'immer';\nimport { TimeSeriesQueryDefinition } from '@perses-dev/core';\nimport { Stack, IconButton, Typography, BoxProps, Box } from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport { PluginEditor, PluginEditorProps } from '../PluginEditor';\n\ninterface TimeSeriesQueryInputProps {\n query: TimeSeriesQueryDefinition;\n index: number;\n onChange: (index: number, query: TimeSeriesQueryDefinition) => void;\n onCollapseExpand: (index: number) => void;\n isCollapsed?: boolean;\n onDelete?: (index: number) => void;\n}\n\nexport const TimeSeriesQueryInput = ({\n index,\n query,\n isCollapsed,\n onDelete,\n onChange,\n onCollapseExpand,\n}: TimeSeriesQueryInputProps) => {\n return (\n <Stack key={index} spacing={1}>\n <Stack direction=\"row\" alignItems=\"center\" borderBottom={1} borderColor={(theme) => theme.palette.divider}>\n <IconButton size=\"small\" onClick={() => onCollapseExpand(index)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\">\n Query {index + 1}\n </Typography>\n <IconButton\n size=\"small\"\n // Use `visibility` to ensure that the row has the same height when delete button is visible or not visible\n sx={{ marginLeft: 'auto', visibility: `${onDelete ? 'visible' : 'hidden'}` }}\n onClick={() => onDelete && onDelete(index)}\n >\n <DeleteIcon />\n </IconButton>\n </Stack>\n {!isCollapsed && <QueryEditor value={query} onChange={(next) => onChange(index, next)} />}\n </Stack>\n );\n};\n\n// Props on MUI Box that we don't want people to pass because we're either redefining them or providing them in\n// this component\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\ninterface QueryEditorProps extends Omit<BoxProps, OmittedMuiProps> {\n value: TimeSeriesQueryDefinition;\n onChange: (next: TimeSeriesQueryDefinition) => void;\n}\n\n/**\n * Displays an editor for TimeSeriesQueryDefinition objects.\n */\nfunction QueryEditor(props: QueryEditorProps) {\n const { value, onChange, ...others } = props;\n const {\n spec: { plugin },\n } = value;\n\n const handlePluginChange: PluginEditorProps['onChange'] = (next) => {\n onChange(\n produce(value, (draft) => {\n draft.spec.plugin = next;\n })\n );\n };\n\n return (\n <Box {...others}>\n {/* If TimeSeriesQuery plugins ever have common props on the definition, the inputs could go here */}\n <PluginEditor\n pluginType=\"TimeSeriesQuery\"\n pluginKindLabel=\"Query Type\"\n value={plugin}\n onChange={handlePluginChange}\n />\n </Box>\n );\n}\n"],"names":["produce","Stack","IconButton","Typography","Box","DeleteIcon","ChevronDown","ChevronRight","PluginEditor","TimeSeriesQueryInput","index","query","isCollapsed","onDelete","onChange","onCollapseExpand","spacing","direction","alignItems","borderBottom","borderColor","theme","palette","divider","size","onClick","variant","component","sx","marginLeft","visibility","QueryEditor","value","next","props","others","spec","plugin","handlePluginChange","draft","pluginType","pluginKindLabel"],"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,aAAa,QAAQ;AAE5B,SAASC,KAAK,EAAEC,UAAU,EAAEC,UAAU,EAAYC,GAAG,QAAQ,gBAAgB;AAC7E,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,kBAAkB,+BAA+B;AACxD,SAASC,YAAY,QAA2B,kBAAkB;AAWlE,OAAO,MAAMC,uBAAuB,CAAC,EACnCC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EACU;IAC1B,qBACE,MAACd;QAAkBe,SAAS;;0BAC1B,MAACf;gBAAMgB,WAAU;gBAAMC,YAAW;gBAASC,cAAc;gBAAGC,aAAa,CAACC,QAAUA,MAAMC,OAAO,CAACC,OAAO;;kCACvG,KAACrB;wBAAWsB,MAAK;wBAAQC,SAAS,IAAMV,iBAAiBL;kCACtDE,4BAAc,KAACL,kCAAkB,KAACD;;kCAErC,MAACH;wBAAWuB,SAAQ;wBAAWC,WAAU;;4BAAK;4BACrCjB,QAAQ;;;kCAEjB,KAACR;wBACCsB,MAAK;wBACL,2GAA2G;wBAC3GI,IAAI;4BAAEC,YAAY;4BAAQC,YAAY,CAAC,EAAEjB,WAAW,YAAY,SAAS,CAAC;wBAAC;wBAC3EY,SAAS,IAAMZ,YAAYA,SAASH;kCAEpC,cAAA,KAACL;;;;YAGJ,CAACO,6BAAe,KAACmB;gBAAYC,OAAOrB;gBAAOG,UAAU,CAACmB,OAASnB,SAASJ,OAAOuB;;;OAjBtEvB;AAoBhB,EAAE;AAWF;;CAEC,GACD,SAASqB,YAAYG,KAAuB;IAC1C,MAAM,EAAEF,KAAK,EAAElB,QAAQ,EAAE,GAAGqB,QAAQ,GAAGD;IACvC,MAAM,EACJE,MAAM,EAAEC,MAAM,EAAE,EACjB,GAAGL;IAEJ,MAAMM,qBAAoD,CAACL;QACzDnB,SACEd,QAAQgC,OAAO,CAACO;YACdA,MAAMH,IAAI,CAACC,MAAM,GAAGJ;QACtB;IAEJ;IAEA,qBACE,KAAC7B;QAAK,GAAG+B,MAAM;kBAEb,cAAA,KAAC3B;YACCgC,YAAW;YACXC,iBAAgB;YAChBT,OAAOK;YACPvB,UAAUwB;;;AAIlB"}
|