@perses-dev/dashboards 0.41.0 → 0.42.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/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
- package/dist/cjs/components/DashboardToolbar/DashboardToolbar.js +11 -9
- package/dist/cjs/components/Datasources/DatasourceEditor.js +236 -0
- package/dist/cjs/components/Datasources/EditDatasourcesButton.js +109 -0
- package/dist/cjs/components/Datasources/index.js +31 -0
- package/dist/cjs/components/EditJsonDialog/EditJsonDialog.js +12 -1
- package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +3 -41
- package/dist/cjs/components/PanelDrawer/index.js +1 -0
- package/dist/cjs/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
- package/dist/cjs/components/Variables/TemplateVariable.js +139 -51
- package/dist/cjs/components/Variables/VariableList.js +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/constants/user-interface-text.js +1 -0
- package/dist/cjs/context/DashboardProvider/DashboardProvider.js +4 -2
- package/dist/cjs/context/DatasourceStoreProvider.js +58 -6
- package/dist/cjs/context/TemplateVariableProvider/TemplateVariableProvider.js +16 -0
- package/dist/cjs/context/useDashboard.js +5 -3
- package/dist/cjs/views/ViewDashboard/DashboardApp.js +4 -0
- package/dist/cjs/views/ViewDashboard/ViewDashboard.js +2 -3
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js +2 -2
- package/dist/components/DashboardStickyToolbar/DashboardStickyToolbar.js.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.d.ts.map +1 -1
- package/dist/components/DashboardToolbar/DashboardToolbar.js +11 -9
- package/dist/components/DashboardToolbar/DashboardToolbar.js.map +1 -1
- package/dist/components/Datasources/DatasourceEditor.d.ts +8 -0
- package/dist/components/Datasources/DatasourceEditor.d.ts.map +1 -0
- package/dist/components/Datasources/DatasourceEditor.js +223 -0
- package/dist/components/Datasources/DatasourceEditor.js.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts +3 -0
- package/dist/components/Datasources/EditDatasourcesButton.d.ts.map +1 -0
- package/dist/components/Datasources/EditDatasourcesButton.js +96 -0
- package/dist/components/Datasources/EditDatasourcesButton.js.map +1 -0
- package/dist/components/Datasources/index.d.ts +3 -0
- package/dist/components/Datasources/index.d.ts.map +1 -0
- package/dist/components/Datasources/index.js +16 -0
- package/dist/components/Datasources/index.js.map +1 -0
- package/dist/components/EditJsonDialog/EditJsonDialog.js +13 -2
- package/dist/components/EditJsonDialog/EditJsonDialog.js.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
- package/dist/components/PanelDrawer/PanelEditorForm.js +3 -2
- package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
- package/dist/components/PanelDrawer/index.d.ts +1 -0
- package/dist/components/PanelDrawer/index.d.ts.map +1 -1
- package/dist/components/PanelDrawer/index.js +1 -0
- package/dist/components/PanelDrawer/index.js.map +1 -1
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js +2 -2
- package/dist/components/QuerySummaryTable/QuerySummaryTable.js.map +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts +1 -1
- package/dist/components/Variables/TemplateVariable.d.ts.map +1 -1
- package/dist/components/Variables/TemplateVariable.js +141 -53
- package/dist/components/Variables/TemplateVariable.js.map +1 -1
- package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
- package/dist/components/Variables/VariableEditor.js.map +1 -1
- package/dist/components/Variables/VariableList.js +1 -1
- package/dist/components/Variables/VariableList.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/constants/user-interface-text.d.ts +1 -0
- package/dist/constants/user-interface-text.d.ts.map +1 -1
- package/dist/constants/user-interface-text.js +1 -0
- package/dist/constants/user-interface-text.js.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts +2 -1
- package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
- package/dist/context/DashboardProvider/DashboardProvider.js +4 -2
- package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts +1 -2
- package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -1
- package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -1
- package/dist/context/DatasourceStoreProvider.d.ts +2 -1
- package/dist/context/DatasourceStoreProvider.d.ts.map +1 -1
- package/dist/context/DatasourceStoreProvider.js +59 -7
- package/dist/context/DatasourceStoreProvider.js.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts +1 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.d.ts.map +1 -1
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js +13 -0
- package/dist/context/TemplateVariableProvider/TemplateVariableProvider.js.map +1 -1
- package/dist/context/useDashboard.d.ts.map +1 -1
- package/dist/context/useDashboard.js +5 -3
- package/dist/context/useDashboard.js.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
- package/dist/views/ViewDashboard/DashboardApp.js +4 -0
- package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
- package/dist/views/ViewDashboard/ViewDashboard.js +4 -5
- package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/EditJsonDialog/EditJsonDialog.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 { FormEvent, useState } from 'react';\nimport { Alert, FormControl } from '@mui/material';\nimport { Dialog, JSONEditor } from '@perses-dev/components';\nimport { useTimeRange } from '@perses-dev/plugin-system';\nimport { useEditJsonDialog } from '../../context/DashboardProvider';\nimport { useDashboard } from '../../context/useDashboard';\n\nexport interface EditJsonDialogProps {\n disableMetadataEdition?: boolean;\n}\n\nexport const EditJsonDialog = (props: EditJsonDialogProps) => {\n const { disableMetadataEdition } = props;\n const { editJsonDialog, closeEditJsonDialog } = useEditJsonDialog();\n\n return (\n <Dialog open={!!editJsonDialog?.isOpen} scroll=\"paper\" fullWidth maxWidth=\"lg\">\n <Dialog.Header onClose={() => closeEditJsonDialog()}>Edit Dashboard JSON</Dialog.Header>\n {editJsonDialog?.isOpen && <EditJsonDialogForm disableMetadataEdition={disableMetadataEdition} />}\n </Dialog>\n );\n};\n\nconst EditJsonDialogForm = (props: EditJsonDialogProps) => {\n const { disableMetadataEdition } = props;\n const { closeEditJsonDialog } = useEditJsonDialog();\n const { setTimeRange, setRefreshInterval } = useTimeRange();\n const { dashboard, setDashboard } = useDashboard();\n const [draftDashboard, setDraftDashboard] = useState(dashboard);\n\n const handleApply = (e: FormEvent) => {\n e.preventDefault();\n setDashboard(draftDashboard);\n setTimeRange({ pastDuration: draftDashboard.spec.duration });\n setRefreshInterval(draftDashboard.spec.refreshInterval ?? '0s');\n closeEditJsonDialog();\n };\n\n return (\n <Dialog.Form onSubmit={handleApply}>\n <Dialog.Content sx={{ width: '100%' }}>\n {disableMetadataEdition && (\n <Alert sx={{ marginBottom: (theme) => theme.spacing(1) }} severity=\"warning\">\n Metadata cannot be modified or saved.\n </Alert>\n )}\n <FormControl fullWidth>\n <JSONEditor\n minHeight=\"300px\"\n maxHeight=\"70vh\"\n value={draftDashboard}\n onChange={(value) =>
|
|
1
|
+
{"version":3,"sources":["../../../src/components/EditJsonDialog/EditJsonDialog.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 { FormEvent, useState } from 'react';\nimport { Alert, FormControl } from '@mui/material';\nimport { Dialog, JSONEditor } from '@perses-dev/components';\nimport { useDatasourceStore, useTimeRange } from '@perses-dev/plugin-system';\nimport { useEditJsonDialog } from '../../context/DashboardProvider';\nimport { useDashboard } from '../../context/useDashboard';\n\nexport interface EditJsonDialogProps {\n disableMetadataEdition?: boolean;\n}\n\nexport const EditJsonDialog = (props: EditJsonDialogProps) => {\n const { disableMetadataEdition } = props;\n const { editJsonDialog, closeEditJsonDialog } = useEditJsonDialog();\n\n return (\n <Dialog open={!!editJsonDialog?.isOpen} scroll=\"paper\" fullWidth maxWidth=\"lg\">\n <Dialog.Header onClose={() => closeEditJsonDialog()}>Edit Dashboard JSON</Dialog.Header>\n {editJsonDialog?.isOpen && <EditJsonDialogForm disableMetadataEdition={disableMetadataEdition} />}\n </Dialog>\n );\n};\n\nconst EditJsonDialogForm = (props: EditJsonDialogProps) => {\n const { disableMetadataEdition } = props;\n const { closeEditJsonDialog } = useEditJsonDialog();\n const { setTimeRange, setRefreshInterval } = useTimeRange();\n const { dashboard, setDashboard } = useDashboard();\n const { setLocalDatasources } = useDatasourceStore();\n const [draftDashboard, setDraftDashboard] = useState(dashboard);\n\n const handleApply = (e: FormEvent) => {\n e.preventDefault();\n setDashboard(draftDashboard);\n setTimeRange({ pastDuration: draftDashboard.spec.duration });\n setRefreshInterval(draftDashboard.spec.refreshInterval ?? '0s');\n setLocalDatasources(draftDashboard.spec.datasources ?? {});\n closeEditJsonDialog();\n };\n\n const completeDraftDashboard = (dashboard: string | undefined) => {\n try {\n const json = JSON.parse(dashboard ?? '{}');\n setDraftDashboard(json);\n } catch (e) {\n // do nothing\n }\n };\n\n return (\n <Dialog.Form onSubmit={handleApply}>\n <Dialog.Content sx={{ width: '100%' }}>\n {disableMetadataEdition && (\n <Alert sx={{ marginBottom: (theme) => theme.spacing(1) }} severity=\"warning\">\n Metadata cannot be modified or saved.\n </Alert>\n )}\n <FormControl fullWidth>\n <JSONEditor\n minHeight=\"300px\"\n maxHeight=\"70vh\"\n value={draftDashboard}\n onChange={(value: string) => completeDraftDashboard(value)}\n />\n </FormControl>\n </Dialog.Content>\n <Dialog.Actions>\n <Dialog.PrimaryButton onClick={handleApply}>Apply</Dialog.PrimaryButton>\n </Dialog.Actions>\n </Dialog.Form>\n );\n};\n"],"names":["useState","Alert","FormControl","Dialog","JSONEditor","useDatasourceStore","useTimeRange","useEditJsonDialog","useDashboard","EditJsonDialog","props","disableMetadataEdition","editJsonDialog","closeEditJsonDialog","open","isOpen","scroll","fullWidth","maxWidth","Header","onClose","EditJsonDialogForm","setTimeRange","setRefreshInterval","dashboard","setDashboard","setLocalDatasources","draftDashboard","setDraftDashboard","handleApply","e","preventDefault","pastDuration","spec","duration","refreshInterval","datasources","completeDraftDashboard","json","JSON","parse","Form","onSubmit","Content","sx","width","marginBottom","theme","spacing","severity","minHeight","maxHeight","value","onChange","Actions","PrimaryButton","onClick"],"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,SAAoBA,QAAQ,QAAQ,QAAQ;AAC5C,SAASC,KAAK,EAAEC,WAAW,QAAQ,gBAAgB;AACnD,SAASC,MAAM,EAAEC,UAAU,QAAQ,yBAA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BAAAA,uBAAAA,YAAa;YACrCI,kBAAkBU;QACpB,EAAE,OAAOR,GAAG;QACV,aAAa;QACf;IACF;IAEA,qBACE,MAAC3B,OAAOsC;QAAKC,UAAUb;;0BACrB,MAAC1B,OAAOwC;gBAAQC,IAAI;oBAAEC,OAAO;gBAAO;;oBACjClC,wCACC,KAACV;wBAAM2C,IAAI;4BAAEE,cAAc,CAACC,QAAUA,MAAMC,QAAQ;wBAAG;wBAAGC,UAAS;kCAAU;;kCAI/E,KAAC/C;wBAAYe,SAAS;kCACpB,cAAA,KAACb;4BACC8C,WAAU;4BACVC,WAAU;4BACVC,OAAOzB;4BACP0B,UAAU,CAACD,QAAkBf,uBAAuBe;;;;;0BAI1D,KAACjD,OAAOmD;0BACN,cAAA,KAACnD,OAAOoD;oBAAcC,SAAS3B;8BAAa;;;;;AAIpD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Action } from '@perses-dev/
|
|
2
|
+
import { Action } from '@perses-dev/core';
|
|
3
3
|
import { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';
|
|
4
4
|
export interface PanelEditorFormProps {
|
|
5
5
|
initialValues: PanelEditorValues;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PanelEditorForm.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/PanelEditorForm.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AAY3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAKvF,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,CAAC,MAAM,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,eAwN1D;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
import
|
|
14
|
+
import { useState } from 'react';
|
|
15
15
|
import { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';
|
|
16
16
|
import { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';
|
|
17
17
|
import { PluginKindSelect, usePluginEditor, PanelSpecEditor, getTitleAction, getSubmitText } from '@perses-dev/plugin-system';
|
|
@@ -78,7 +78,8 @@ export function PanelEditorForm(props) {
|
|
|
78
78
|
onClose();
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const handlePanelDefinitionChange = (
|
|
81
|
+
const handlePanelDefinitionChange = (nextPanelDefStr)=>{
|
|
82
|
+
const nextPanelDef = JSON.parse(nextPanelDefStr);
|
|
82
83
|
const { kind: pluginKind , spec: pluginSpec } = nextPanelDef.spec.plugin;
|
|
83
84
|
// if panel plugin kind and spec are modified, then need to save current spec
|
|
84
85
|
if (panelDefinition.spec.plugin.kind !== pluginKind && JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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 React, { useState } from 'react';\nimport { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { PanelDefinition } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n Action,\n getTitleAction,\n getSubmitText,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { panelEditorValidationSchema, PanelEditorValidationType } from '../../validation';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const {\n initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId },\n initialAction,\n onSave,\n onClose,\n } = props;\n const panelGroups = useListPanelGroups();\n const [groupId, setGroupId] = useState(initialGroupId);\n const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialPanelDef);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind: plugin.kind, spec: plugin.spec },\n onChange: (plugin) => {\n setPlugin(plugin);\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const form = useForm<PanelEditorValidationType>({\n resolver: zodResolver(panelEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: initialPanelDef.spec.display.name,\n groupId: initialGroupId,\n description: initialPanelDef.spec.display.description,\n type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind,\n },\n });\n\n const processForm: SubmitHandler<PanelEditorValidationType> = () => {\n const values: PanelEditorValues = { groupId, panelDefinition };\n onSave(values);\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel() {\n if (\n JSON.stringify({ groupId: initialGroupId, panelDefinition: initialPanelDef }) !==\n JSON.stringify({ groupId, panelDefinition })\n ) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDef: PanelDefinition) => {\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setGroupId(+event.target.value);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"type\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginType=\"Panel\"\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n pluginEditor.onKindChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["React","useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","Controller","FormProvider","useForm","zodResolver","useListPanelGroups","panelEditorValidationSchema","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","panelDefinition","initialPanelDef","groupId","initialGroupId","initialAction","onSave","onClose","panelGroups","setGroupId","setName","setDescription","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","pluginEditor","pluginType","value","kind","onChange","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","form","resolver","mode","defaultValues","name","display","description","type","pendingKind","processForm","values","handleCancel","JSON","stringify","handlePanelDefinitionChange","nextPanelDef","pluginKind","pluginSpec","rememberCurrentSpecState","panelGroup","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","index","title","isLoading","onKindChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","isOpen","onCancel","onDiscardChanges"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA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D,yCAAAA,8BAA+BwD,CAAAA,oBAAAA,WAAWI,mBAAXJ,+BAAAA,KAAAA,IAAAA,kBAAkBM;wCAC7D1D,UAAU,CAAC2D;4CACTR,MAAMnD,SAAS2D;4CACf/D,aAAasE,aAAaP;wCAC5B;;;;;sCAKR,MAACzG;4BAAK8F,IAAI;4BAACC,IAAI;;8CACb,KAAC3F;oCAAW4E,SAAQ;oCAAKiC,cAAc;8CAAG;;8CAG1C,KAAC1G;oCAAc2G,mBAAmB5G;8CAChC,cAAA,KAACa;wCAAaK,iBAAiBA;;;;;sCAGnC,KAACxB;4BAAK8F,IAAI;4BAACC,IAAI;sCACb,cAAA,KAACxF;gCAAc2G,mBAAmB5G;0CAChC,cAAA,KAACI;oCACCc,iBAAiBA;oCACjB2F,cAAcjD;oCACdkD,iBAAiB,CAACC;wCAChBlF,WAAWkF;oCACb;oCACAC,oBAAoB,CAAC/E;wCACnBG,aAAa6E,aAAahF;oCAC5B;;;;;;;0BAMV,KAAClC;gBACCqD,aAAY;gBACZ8D,QAAQhF;gBACRiF,UAAU;oBACRhF,uBAAuB;gBACzB;gBACAiF,kBAAkB;oBAChBjF,uBAAuB;oBACvBX;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAM4D,oBAAoB,oBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/PanelEditorForm.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 { Box, Button, Grid, MenuItem, Stack, TextField, Typography } from '@mui/material';\nimport { Action, PanelDefinition } from '@perses-dev/core';\nimport { DiscardChangesConfirmationDialog, ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport {\n PluginKindSelect,\n usePluginEditor,\n PanelSpecEditor,\n getTitleAction,\n getSubmitText,\n} from '@perses-dev/plugin-system';\nimport { Controller, FormProvider, SubmitHandler, useForm } from 'react-hook-form';\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { useListPanelGroups } from '../../context';\nimport { PanelEditorValues } from '../../context/DashboardProvider/panel-editor-slice';\nimport { panelEditorValidationSchema, PanelEditorValidationType } from '../../validation';\nimport { PanelPreview } from './PanelPreview';\nimport { usePanelEditor } from './usePanelEditor';\n\nexport interface PanelEditorFormProps {\n initialValues: PanelEditorValues;\n initialAction: Action;\n onSave: (values: PanelEditorValues) => void;\n onClose: () => void;\n}\n\nexport function PanelEditorForm(props: PanelEditorFormProps) {\n const {\n initialValues: { panelDefinition: initialPanelDef, groupId: initialGroupId },\n initialAction,\n onSave,\n onClose,\n } = props;\n const panelGroups = useListPanelGroups();\n const [groupId, setGroupId] = useState(initialGroupId);\n const { panelDefinition, setName, setDescription, setQueries, setPlugin, setPanelDefinition } =\n usePanelEditor(initialPanelDef);\n const { plugin } = panelDefinition.spec;\n const [isDiscardDialogOpened, setDiscardDialogOpened] = useState<boolean>(false);\n\n // Use common plugin editor logic even though we've split the inputs up in this form\n const pluginEditor = usePluginEditor({\n pluginType: 'Panel',\n value: { kind: plugin.kind, spec: plugin.spec },\n onChange: (plugin) => {\n setPlugin(plugin);\n },\n onHideQueryEditorChange: (isHidden) => {\n setQueries(undefined, isHidden);\n },\n });\n\n const titleAction = getTitleAction(initialAction, true);\n const submitText = getSubmitText(initialAction, true);\n\n const form = useForm<PanelEditorValidationType>({\n resolver: zodResolver(panelEditorValidationSchema),\n mode: 'onBlur',\n defaultValues: {\n name: initialPanelDef.spec.display.name,\n groupId: initialGroupId,\n description: initialPanelDef.spec.display.description,\n type: pluginEditor.pendingKind ? pluginEditor.pendingKind : plugin.kind,\n },\n });\n\n const processForm: SubmitHandler<PanelEditorValidationType> = () => {\n const values: PanelEditorValues = { groupId, panelDefinition };\n onSave(values);\n };\n\n // When user click on cancel, several possibilities:\n // - create action: ask for discard approval\n // - update action: ask for discard approval if changed\n // - read action: don´t ask for discard approval\n function handleCancel() {\n if (\n JSON.stringify({ groupId: initialGroupId, panelDefinition: initialPanelDef }) !==\n JSON.stringify({ groupId, panelDefinition })\n ) {\n setDiscardDialogOpened(true);\n } else {\n onClose();\n }\n }\n\n const handlePanelDefinitionChange = (nextPanelDefStr: string) => {\n const nextPanelDef: PanelDefinition = JSON.parse(nextPanelDefStr);\n const { kind: pluginKind, spec: pluginSpec } = nextPanelDef.spec.plugin;\n // if panel plugin kind and spec are modified, then need to save current spec\n if (\n panelDefinition.spec.plugin.kind !== pluginKind &&\n JSON.stringify(panelDefinition.spec.plugin.spec) !== JSON.stringify(pluginSpec)\n ) {\n pluginEditor.rememberCurrentSpecState();\n }\n setPanelDefinition(nextPanelDef);\n };\n\n return (\n <FormProvider {...form}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n padding: (theme) => theme.spacing(1, 2),\n borderBottom: (theme) => `1px solid ${theme.palette.divider}`,\n }}\n >\n <Typography variant=\"h2\">{titleAction} Panel</Typography>\n <Stack direction=\"row\" spacing={1} marginLeft=\"auto\">\n <Button variant=\"contained\" disabled={!form.formState.isValid} onClick={form.handleSubmit(processForm)}>\n {submitText}\n </Button>\n <Button color=\"secondary\" variant=\"outlined\" onClick={handleCancel}>\n Cancel\n </Button>\n </Stack>\n </Box>\n <Box id={panelEditorFormId} sx={{ flex: 1, overflowY: 'scroll', padding: (theme) => theme.spacing(2) }}>\n <Grid container spacing={2}>\n <Grid item xs={8}>\n <Controller\n name=\"name\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n required\n fullWidth\n label=\"Name\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setName(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"groupId\"\n render={({ field, fieldState }) => (\n <TextField\n select\n {...field}\n required\n fullWidth\n label=\"Group\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setGroupId(+event.target.value);\n }}\n >\n {panelGroups.map((panelGroup, index) => (\n <MenuItem key={panelGroup.id} value={panelGroup.id}>\n {panelGroup.title ?? `Group ${index + 1}`}\n </MenuItem>\n ))}\n </TextField>\n )}\n />\n </Grid>\n <Grid item xs={8}>\n <Controller\n name=\"description\"\n render={({ field, fieldState }) => (\n <TextField\n {...field}\n fullWidth\n label=\"Description\"\n error={!!fieldState.error}\n helperText={fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n setDescription(event.target.value);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={4}>\n <Controller\n name=\"type\"\n render={({ field, fieldState }) => (\n <PluginKindSelect\n {...field}\n pluginType=\"Panel\"\n required\n fullWidth\n label=\"Type\"\n disabled={pluginEditor.isLoading}\n error={!!pluginEditor.error || !!fieldState.error}\n helperText={pluginEditor.error?.message ?? fieldState.error?.message}\n onChange={(event) => {\n field.onChange(event);\n pluginEditor.onKindChange(event);\n }}\n />\n )}\n />\n </Grid>\n <Grid item xs={12}>\n <Typography variant=\"h4\" marginBottom={1}>\n Preview\n </Typography>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelPreview panelDefinition={panelDefinition} />\n </ErrorBoundary>\n </Grid>\n <Grid item xs={12}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <PanelSpecEditor\n panelDefinition={panelDefinition}\n onJSONChange={handlePanelDefinitionChange}\n onQueriesChange={(queries) => {\n setQueries(queries);\n }}\n onPluginSpecChange={(spec) => {\n pluginEditor.onSpecChange(spec);\n }}\n />\n </ErrorBoundary>\n </Grid>\n </Grid>\n </Box>\n <DiscardChangesConfirmationDialog\n description=\"You have unapplied changes in this panel. Are you sure you want to discard these changes? Changes cannot be recovered.\"\n isOpen={isDiscardDialogOpened}\n onCancel={() => {\n setDiscardDialogOpened(false);\n }}\n onDiscardChanges={() => {\n setDiscardDialogOpened(false);\n onClose();\n }}\n />\n </FormProvider>\n );\n}\n\n/**\n * The `id` attribute added to the `PanelEditorForm` component, allowing submit buttons to live outside the form.\n */\nexport const panelEditorFormId = 'panel-editor-form';\n"],"names":["useState","Box","Button","Grid","MenuItem","Stack","TextField","Typography","DiscardChangesConfirmationDialog","ErrorAlert","ErrorBoundary","PluginKindSelect","usePluginEditor","PanelSpecEditor","getTitleAction","getSubmitText","Controller","FormProvider","useForm","zodResolver","useListPanelGroups","panelEditorValidationSchema","PanelPreview","usePanelEditor","PanelEditorForm","props","initialValues","panelDefinition","initialPanelDef","groupId","initialGroupId","initialAction","onSave","onClose","panelGroups","setGroupId","setName","setDescription","setQueries","setPlugin","setPanelDefinition","plugin","spec","isDiscardDialogOpened","setDiscardDialogOpened","pluginEditor","pluginType","value","kind","onChange","onHideQueryEditorChange","isHidden","undefined","titleAction","submitText","form","resolver","mode","defaultValues","name","display","description","type","pendingKind","processForm","values","handleCancel","JSON","stringify","handlePanelDefinitionChange","nextPanelDefStr","nextPanelDef","parse","pluginKind","pluginSpec","rememberCurrentSpecState","panelGroup","sx","alignItems","padding","theme","spacing","borderBottom","palette","divider","variant","direction","marginLeft","disabled","formState","isValid","onClick","handleSubmit","color","id","panelEditorFormId","flex","overflowY","container","item","xs","render","field","fieldState","required","fullWidth","label","error","helperText","message","event","target","select","map","index","title","isLoading","onKindChange","marginBottom","FallbackComponent","onJSONChange","onQueriesChange","queries","onPluginSpecChange","onSpecChange","isOpen","onCancel","onDiscardChanges"],"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,QAAQ,Q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4CACTR,MAAMrD,SAAS6D;4CACfjE,aAAawE,aAAaP;wCAC5B;;;;;sCAKR,MAAC3G;4BAAKgG,IAAI;4BAACC,IAAI;;8CACb,KAAC7F;oCAAW8E,SAAQ;oCAAKiC,cAAc;8CAAG;;8CAG1C,KAAC5G;oCAAc6G,mBAAmB9G;8CAChC,cAAA,KAACa;wCAAaK,iBAAiBA;;;;;sCAGnC,KAACxB;4BAAKgG,IAAI;4BAACC,IAAI;sCACb,cAAA,KAAC1F;gCAAc6G,mBAAmB9G;0CAChC,cAAA,KAACI;oCACCc,iBAAiBA;oCACjB6F,cAAcnD;oCACdoD,iBAAiB,CAACC;wCAChBpF,WAAWoF;oCACb;oCACAC,oBAAoB,CAACjF;wCACnBG,aAAa+E,aAAalF;oCAC5B;;;;;;;0BAMV,KAAClC;gBACCqD,aAAY;gBACZgE,QAAQlF;gBACRmF,UAAU;oBACRlF,uBAAuB;gBACzB;gBACAmF,kBAAkB;oBAChBnF,uBAAuB;oBACvBX;gBACF;;;;AAIR;AAEA;;CAEC,GACD,OAAO,MAAM8D,oBAAoB,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PanelDrawer/index.ts"],"names":[],"mappings":"AAaA,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/PanelDrawer/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 './PanelDrawer';\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,gBAAgB"}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/PanelDrawer/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 './PanelDrawer';\nexport * from './PanelPreview';\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,gBAAgB;AAC9B,cAAc,iBAAiB"}
|
|
@@ -17,7 +17,7 @@ import { useActiveTimeSeriesQueries, useDatasourceClient, useTimeRange } from '@
|
|
|
17
17
|
const TABLE_MAX_WIDTH = 1000;
|
|
18
18
|
export function QuerySummaryTable(props) {
|
|
19
19
|
const { showTotalQueries =true } = props;
|
|
20
|
-
const
|
|
20
|
+
const datasourceClient = useDatasourceClient({
|
|
21
21
|
kind: 'PrometheusDatasource'
|
|
22
22
|
});
|
|
23
23
|
const { absoluteTimeRange } = useTimeRange();
|
|
@@ -27,7 +27,7 @@ export function QuerySummaryTable(props) {
|
|
|
27
27
|
const activeQueries = queries.filter((query)=>query.state.status === 'loading');
|
|
28
28
|
const completedQueries = queries.filter((query)=>query.state.status === 'success');
|
|
29
29
|
const querySummary = useActiveTimeSeriesQueries();
|
|
30
|
-
if (
|
|
30
|
+
if (datasourceClient.isLoading === true) {
|
|
31
31
|
return null;
|
|
32
32
|
}
|
|
33
33
|
const warnings = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/QuerySummaryTable/QuerySummaryTable.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 {\n Box,\n Button,\n Paper,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n Stack,\n} from '@mui/material';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { useActiveTimeSeriesQueries, useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system';\n\nexport interface WarningDisplay {\n query: string;\n summary: string;\n}\n\nconst TABLE_MAX_WIDTH = 1000;\n\ninterface QuerySummaryTableProps {\n showTotalQueries?: boolean;\n}\n\nexport function QuerySummaryTable(props: QuerySummaryTableProps) {\n const { showTotalQueries = true } = props;\n const
|
|
1
|
+
{"version":3,"sources":["../../../src/components/QuerySummaryTable/QuerySummaryTable.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 {\n Box,\n Button,\n Paper,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableHead,\n TableRow,\n Typography,\n Stack,\n} from '@mui/material';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { TimeSeriesQueryDefinition, UnknownSpec } from '@perses-dev/core';\nimport { useActiveTimeSeriesQueries, useDatasourceClient, useTimeRange } from '@perses-dev/plugin-system';\n\nexport interface WarningDisplay {\n query: string;\n summary: string;\n}\n\nconst TABLE_MAX_WIDTH = 1000;\n\ninterface QuerySummaryTableProps {\n showTotalQueries?: boolean;\n}\n\nexport function QuerySummaryTable(props: QuerySummaryTableProps) {\n const { showTotalQueries = true } = props;\n const datasourceClient = useDatasourceClient({ kind: 'PrometheusDatasource' });\n const { absoluteTimeRange } = useTimeRange();\n\n // for displaying a summary of recent query results\n const queryClient = useQueryClient();\n const queries = queryClient.getQueryCache().findAll();\n const activeQueries = queries.filter((query) => query.state.status === 'loading');\n const completedQueries = queries.filter((query) => query.state.status === 'success');\n const querySummary = useActiveTimeSeriesQueries();\n\n if (datasourceClient.isLoading === true) {\n return null;\n }\n\n const warnings: WarningDisplay[] = [];\n querySummary.forEach((query) => {\n const queryData = query.state.data;\n if (queryData && queryData.metadata?.notices) {\n const queryKey = query.queryKey as [TimeSeriesQueryDefinition<UnknownSpec>];\n const warningMessage = queryData.metadata.notices[0]?.message;\n if (warningMessage) {\n warnings.push({\n query: String(queryKey[0].spec.plugin.spec.query),\n summary: warningMessage,\n });\n }\n }\n });\n\n return (\n <Stack\n spacing={1}\n mb={2}\n sx={{\n maxWidth: TABLE_MAX_WIDTH,\n }}\n >\n <Box sx={{ p: 1 }}>\n <Typography variant=\"h2\" mb={1}>\n Query Summary\n </Typography>\n <TableContainer component={Paper}>\n <Table size=\"small\" aria-label=\"query summary table\">\n <TableHead>\n <TableRow>\n <TableCell>Queries Loading</TableCell>\n <TableCell>Recent Time Series Queries</TableCell>\n {showTotalQueries && <TableCell>Total Queries</TableCell>}\n <TableCell>Start Time</TableCell>\n <TableCell>End Time</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n <TableRow>\n <TableCell>{activeQueries.length}</TableCell>\n <TableCell>{querySummary.length}</TableCell>\n {showTotalQueries && <TableCell>{completedQueries.length}</TableCell>}\n <TableCell>{absoluteTimeRange.start.toString()}</TableCell>\n <TableCell>{absoluteTimeRange.end.toString()}</TableCell>\n </TableRow>\n </TableBody>\n </Table>\n </TableContainer>\n </Box>\n\n {warnings.length > 0 && (\n <Box sx={{ p: 1, m: 0 }}>\n <Typography variant=\"h3\" mb={1}>\n Warnings\n </Typography>\n <TableContainer component={Paper} sx={{ mb: 2 }}>\n <Table size=\"small\" aria-label=\"query warnings table\">\n <TableHead>\n <TableRow>\n <TableCell>Query</TableCell>\n <TableCell>Summary</TableCell>\n </TableRow>\n </TableHead>\n <TableBody>\n {warnings.map((details, idx) => {\n return (\n <TableRow key={idx}>\n <TableCell>{details.query}</TableCell>\n <TableCell>{details.summary}</TableCell>\n </TableRow>\n );\n })}\n </TableBody>\n </Table>\n </TableContainer>\n <Button disabled variant=\"outlined\">\n TODO: Action Button\n </Button>\n </Box>\n )}\n </Stack>\n );\n}\n"],"names":["Box","Button","Paper","Table","TableBody","TableCell","TableContainer","TableHead","TableRow","Typography","Stack","useQueryClient","useActiveTimeSeriesQueries","useDatasourceClient","useTimeRange","TABLE_MAX_WIDTH","QuerySummaryTable","props","showTotalQueries","datasourceClient","kind","absoluteTimeRange","queryClient","queries","getQueryCache","findAll","activeQueries","filter","query","state","status","completedQueries","querySummary","isLoading","warnings","forEach","queryData","data","metadata","notices","queryKey","warningMessage","message","push","String","spec","plugin","summary","spacing","mb","sx","maxWidth","p","variant","component","size","aria-label","length","start","toString","end","m","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,SAAS4B,IAAI,CAACC,SAASC;wCACtB,qBACE,MAACxD;;8DACC,KAACH;8DAAW0D,QAAQnC;;8DACpB,KAACvB;8DAAW0D,QAAQhB;;;2CAFPiB;oCAKnB;;;;;kCAIN,KAAC/D;wBAAOgE,QAAQ;wBAACZ,SAAQ;kCAAW;;;;;;AAO9C"}
|
|
@@ -11,7 +11,7 @@ export declare function useListVariableState(spec: ListVariableSpec<UnknownSpec>
|
|
|
11
11
|
value: VariableValue | undefined;
|
|
12
12
|
loading: boolean;
|
|
13
13
|
options: VariableOption[] | undefined;
|
|
14
|
-
|
|
14
|
+
selectedOptions: VariableOption | VariableOption[];
|
|
15
15
|
viewOptions: VariableOption[];
|
|
16
16
|
};
|
|
17
17
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateVariable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/TemplateVariable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAGL,gBAAgB,EAEhB,WAAW,EACX,YAAY,EACZ,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA+B,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"TemplateVariable.d.ts","sourceRoot":"","sources":["../../../src/components/Variables/TemplateVariable.tsx"],"names":[],"mappings":";AAeA,OAAO,EAGL,gBAAgB,EAEhB,WAAW,EACX,YAAY,EACZ,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAA+B,cAAc,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvG,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,aAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAcF,wBAAgB,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,qBAAqB,eAWvE;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAAG,SAAS,EAC/C,KAAK,EAAE,aAAa,GAAG,SAAS,EAChC,qBAAqB,EAAE,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,GAC/D;IAED,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,cAAc,EAAE,GAAG,SAAS,CAAC;IAEtC,eAAe,EAAE,cAAc,GAAG,cAAc,EAAE,CAAC;IAEnD,WAAW,EAAE,cAAc,EAAE,CAAC;CAC/B,CA2FA"}
|
|
@@ -10,12 +10,23 @@
|
|
|
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 { useEffect, useMemo, useState } from 'react';
|
|
15
|
-
import {
|
|
15
|
+
import { LinearProgress, TextField, Autocomplete, Popper } from '@mui/material';
|
|
16
16
|
import { DEFAULT_ALL_VALUE } from '@perses-dev/core';
|
|
17
17
|
import { useListVariablePluginValues } from '@perses-dev/plugin-system';
|
|
18
18
|
import { useTemplateVariable, useTemplateVariableActions } from '../../context';
|
|
19
|
+
function variableOptionToVariableValue(options) {
|
|
20
|
+
if (options === null) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(options)) {
|
|
24
|
+
return options.map((v)=>{
|
|
25
|
+
return v.value;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return options.value;
|
|
29
|
+
}
|
|
19
30
|
export function TemplateVariable({ name , source }) {
|
|
20
31
|
var _ctx_definition;
|
|
21
32
|
const ctx = useTemplateVariable(name, source);
|
|
@@ -42,6 +53,7 @@ export function TemplateVariable({ name , source }) {
|
|
|
42
53
|
export function useListVariableState(spec, state, variablesOptionsQuery) {
|
|
43
54
|
const allowMultiple = (spec === null || spec === void 0 ? void 0 : spec.allowMultiple) === true;
|
|
44
55
|
const allowAllValue = (spec === null || spec === void 0 ? void 0 : spec.allowAllValue) === true;
|
|
56
|
+
const sort = spec === null || spec === void 0 ? void 0 : spec.sort;
|
|
45
57
|
const loading = useMemo(()=>variablesOptionsQuery.isFetching || false, [
|
|
46
58
|
variablesOptionsQuery
|
|
47
59
|
]);
|
|
@@ -53,10 +65,34 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
|
|
|
53
65
|
value
|
|
54
66
|
] : [];
|
|
55
67
|
}
|
|
56
|
-
|
|
57
|
-
|
|
68
|
+
// Sort the provided list of options according to the method defined
|
|
69
|
+
const sortedOptions = useMemo(()=>{
|
|
70
|
+
const opts = options ? [
|
|
58
71
|
...options
|
|
59
72
|
] : [];
|
|
73
|
+
if (!sort || sort === 'none') return opts;
|
|
74
|
+
switch(sort){
|
|
75
|
+
case 'alphabetical-asc':
|
|
76
|
+
return opts.sort((a, b)=>a.label > b.label ? 1 : -1);
|
|
77
|
+
case 'alphabetical-desc':
|
|
78
|
+
return opts.sort((a, b)=>a.label > b.label ? -1 : 1);
|
|
79
|
+
case 'numerical-asc':
|
|
80
|
+
return opts.sort((a, b)=>parseInt(a.label) > parseInt(b.label) ? 1 : -1);
|
|
81
|
+
case 'numerical-desc':
|
|
82
|
+
return opts.sort((a, b)=>parseInt(a.label) < parseInt(b.label) ? 1 : -1);
|
|
83
|
+
case 'alphabetical-ci-asc':
|
|
84
|
+
return opts.sort((a, b)=>a.label.toLowerCase() > b.label.toLowerCase() ? 1 : -1);
|
|
85
|
+
case 'alphabetical-ci-desc':
|
|
86
|
+
return opts.sort((a, b)=>a.label.toLowerCase() > b.label.toLowerCase() ? -1 : 1);
|
|
87
|
+
default:
|
|
88
|
+
return opts;
|
|
89
|
+
}
|
|
90
|
+
}, [
|
|
91
|
+
options,
|
|
92
|
+
sort
|
|
93
|
+
]);
|
|
94
|
+
const viewOptions = useMemo(()=>{
|
|
95
|
+
let computedOptions = sortedOptions;
|
|
60
96
|
// Add the all value if it's allowed
|
|
61
97
|
if (allowAllValue) {
|
|
62
98
|
computedOptions = [
|
|
@@ -69,8 +105,8 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
|
|
|
69
105
|
}
|
|
70
106
|
return computedOptions;
|
|
71
107
|
}, [
|
|
72
|
-
|
|
73
|
-
|
|
108
|
+
allowAllValue,
|
|
109
|
+
sortedOptions
|
|
74
110
|
]);
|
|
75
111
|
const valueIsInOptions = useMemo(()=>Boolean(viewOptions.find((v)=>{
|
|
76
112
|
if (allowMultiple) {
|
|
@@ -101,23 +137,49 @@ export function useListVariableState(spec, state, variablesOptionsQuery) {
|
|
|
101
137
|
allowMultiple,
|
|
102
138
|
allowAllValue
|
|
103
139
|
]);
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
const selectedOptions = useMemo(()=>{
|
|
141
|
+
// In the case Autocomplete.multiple equals false, Autocomplete.value expects a single object, not
|
|
142
|
+
// an array, hence this conditional
|
|
143
|
+
if (Array.isArray(value)) {
|
|
144
|
+
return viewOptions.filter((o)=>{
|
|
145
|
+
return value === null || value === void 0 ? void 0 : value.includes(o.value);
|
|
146
|
+
});
|
|
147
|
+
} else {
|
|
148
|
+
var _viewOptions_find;
|
|
149
|
+
return (_viewOptions_find = viewOptions.find((o)=>{
|
|
150
|
+
return value === o.value;
|
|
151
|
+
})) !== null && _viewOptions_find !== void 0 ? _viewOptions_find : {
|
|
152
|
+
value: '',
|
|
153
|
+
label: ''
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
}, [
|
|
157
|
+
value,
|
|
158
|
+
viewOptions
|
|
159
|
+
]);
|
|
106
160
|
return {
|
|
107
161
|
value,
|
|
108
162
|
loading,
|
|
109
163
|
options,
|
|
110
|
-
|
|
164
|
+
selectedOptions,
|
|
111
165
|
viewOptions
|
|
112
166
|
};
|
|
113
167
|
}
|
|
168
|
+
const StyledPopper = (props)=>/*#__PURE__*/ _jsx(Popper, {
|
|
169
|
+
...props,
|
|
170
|
+
sx: {
|
|
171
|
+
minWidth: 'fit-content'
|
|
172
|
+
},
|
|
173
|
+
placement: "bottom-start"
|
|
174
|
+
});
|
|
114
175
|
function ListVariable({ name , source }) {
|
|
115
176
|
var _definition_spec_display;
|
|
116
177
|
const ctx = useTemplateVariable(name, source);
|
|
117
178
|
const definition = ctx.definition;
|
|
118
179
|
const variablesOptionsQuery = useListVariablePluginValues(definition);
|
|
119
180
|
const { setVariableValue , setVariableLoading , setVariableOptions } = useTemplateVariableActions();
|
|
120
|
-
const {
|
|
181
|
+
const { selectedOptions , value , loading , options , viewOptions } = useListVariableState(definition === null || definition === void 0 ? void 0 : definition.spec, ctx.state, variablesOptionsQuery);
|
|
182
|
+
const [inputValue, setInputValue] = useState('');
|
|
121
183
|
var _definition_spec_display_name;
|
|
122
184
|
const title = (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name;
|
|
123
185
|
const allowMultiple = (definition === null || definition === void 0 ? void 0 : definition.spec.allowMultiple) === true;
|
|
@@ -153,51 +215,72 @@ function ListVariable({ name , source }) {
|
|
|
153
215
|
options,
|
|
154
216
|
source
|
|
155
217
|
]);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
218
|
+
const LETTER_HSIZE = 8; // approximation
|
|
219
|
+
const ARROW_OFFSET = 40;
|
|
220
|
+
const MIN_INPUT_WIDTH = 120;
|
|
221
|
+
const MAX_INPUT_WIDTH = 500;
|
|
222
|
+
const [inputWidth, setInputWidth] = useState(MIN_INPUT_WIDTH);
|
|
223
|
+
const handleInputResize = (newInputValue)=>{
|
|
224
|
+
const newInputValueSize = (newInputValue.length + 1) * LETTER_HSIZE + ARROW_OFFSET;
|
|
225
|
+
if (newInputValueSize < MIN_INPUT_WIDTH) {
|
|
226
|
+
setInputWidth(MIN_INPUT_WIDTH);
|
|
227
|
+
} else if (newInputValueSize > MAX_INPUT_WIDTH) {
|
|
228
|
+
setInputWidth(MAX_INPUT_WIDTH);
|
|
229
|
+
} else {
|
|
230
|
+
setInputWidth(newInputValueSize);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
234
|
+
children: [
|
|
235
|
+
/*#__PURE__*/ _jsx(Autocomplete, {
|
|
236
|
+
disablePortal: true,
|
|
237
|
+
disableCloseOnSelect: allowMultiple,
|
|
238
|
+
multiple: allowMultiple,
|
|
239
|
+
fullWidth: true,
|
|
240
|
+
limitTags: 3,
|
|
241
|
+
size: "small",
|
|
242
|
+
disableClearable: true,
|
|
243
|
+
PopperComponent: StyledPopper,
|
|
244
|
+
renderInput: (params)=>{
|
|
245
|
+
return allowMultiple ? /*#__PURE__*/ _jsx(TextField, {
|
|
246
|
+
...params,
|
|
247
|
+
label: title
|
|
248
|
+
}) : /*#__PURE__*/ _jsx(TextField, {
|
|
249
|
+
...params,
|
|
250
|
+
label: title,
|
|
251
|
+
style: {
|
|
252
|
+
width: `${inputWidth}px`
|
|
177
253
|
}
|
|
178
|
-
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
sx: {
|
|
257
|
+
'& .MuiInputBase-root': {
|
|
258
|
+
minHeight: '38px'
|
|
179
259
|
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
260
|
+
'& .MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-sizeSmall': {
|
|
261
|
+
paddingY: '5px',
|
|
262
|
+
paddingLeft: '5px'
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
value: selectedOptions,
|
|
266
|
+
onChange: (_, value)=>{
|
|
267
|
+
if ((value === null || Array.isArray(value) && value.length === 0) && allowAllValue) {
|
|
268
|
+
setVariableValue(name, DEFAULT_ALL_VALUE, source);
|
|
269
|
+
} else {
|
|
270
|
+
setVariableValue(name, variableOptionToVariableValue(value), source);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
inputValue: inputValue,
|
|
274
|
+
onInputChange: (_, newInputValue)=>{
|
|
275
|
+
setInputValue(newInputValue);
|
|
276
|
+
if (!allowMultiple) {
|
|
277
|
+
handleInputResize(newInputValue);
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
options: viewOptions
|
|
281
|
+
}),
|
|
282
|
+
loading && /*#__PURE__*/ _jsx(LinearProgress, {})
|
|
283
|
+
]
|
|
201
284
|
});
|
|
202
285
|
}
|
|
203
286
|
function TextVariable({ name , source }) {
|
|
@@ -224,6 +307,11 @@ function TextVariable({ name , source }) {
|
|
|
224
307
|
label: (_definition_spec_display_name = (_definition_spec_display = definition === null || definition === void 0 ? void 0 : definition.spec.display) === null || _definition_spec_display === void 0 ? void 0 : _definition_spec_display.name) !== null && _definition_spec_display_name !== void 0 ? _definition_spec_display_name : name,
|
|
225
308
|
InputProps: {
|
|
226
309
|
readOnly: (_definition_spec_constant = definition === null || definition === void 0 ? void 0 : definition.spec.constant) !== null && _definition_spec_constant !== void 0 ? _definition_spec_constant : false
|
|
310
|
+
},
|
|
311
|
+
sx: {
|
|
312
|
+
'& .MuiInputBase-root': {
|
|
313
|
+
minHeight: '38px'
|
|
314
|
+
}
|
|
227
315
|
}
|
|
228
316
|
});
|
|
229
317
|
}
|