@perses-dev/plugin-system 0.34.0 → 0.36.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.
Files changed (40) hide show
  1. package/dist/cjs/components/CalculationSelector/CalculationSelector.js +1 -6
  2. package/dist/cjs/components/LegendOptionsEditor/LegendOptionsEditor.js +77 -10
  3. package/dist/cjs/model/legend.js +28 -0
  4. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +11 -11
  5. package/dist/cjs/runtime/TimeRangeProvider/query-params.js +80 -1
  6. package/dist/cjs/runtime/template-variables.js +0 -2
  7. package/dist/cjs/runtime/time-series-queries.js +5 -2
  8. package/dist/cjs/stories/shared-utils/decorators/WithTimeRange.js +1 -0
  9. package/dist/components/CalculationSelector/CalculationSelector.d.ts.map +1 -1
  10. package/dist/components/CalculationSelector/CalculationSelector.js +2 -7
  11. package/dist/components/CalculationSelector/CalculationSelector.js.map +1 -1
  12. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.d.ts.map +1 -1
  13. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js +81 -14
  14. package/dist/components/LegendOptionsEditor/LegendOptionsEditor.js.map +1 -1
  15. package/dist/model/legend.d.ts +9 -2
  16. package/dist/model/legend.d.ts.map +1 -1
  17. package/dist/model/legend.js +33 -1
  18. package/dist/model/legend.js.map +1 -1
  19. package/dist/model/time-series-queries.d.ts +1 -0
  20. package/dist/model/time-series-queries.d.ts.map +1 -1
  21. package/dist/model/time-series-queries.js.map +1 -1
  22. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +5 -1
  23. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  24. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +12 -12
  25. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  26. package/dist/runtime/TimeRangeProvider/query-params.d.ts +12 -0
  27. package/dist/runtime/TimeRangeProvider/query-params.d.ts.map +1 -1
  28. package/dist/runtime/TimeRangeProvider/query-params.js +82 -1
  29. package/dist/runtime/TimeRangeProvider/query-params.js.map +1 -1
  30. package/dist/runtime/template-variables.d.ts +0 -1
  31. package/dist/runtime/template-variables.d.ts.map +1 -1
  32. package/dist/runtime/template-variables.js +0 -1
  33. package/dist/runtime/template-variables.js.map +1 -1
  34. package/dist/runtime/time-series-queries.d.ts +1 -1
  35. package/dist/runtime/time-series-queries.d.ts.map +1 -1
  36. package/dist/runtime/time-series-queries.js +5 -2
  37. package/dist/runtime/time-series-queries.js.map +1 -1
  38. package/dist/stories/shared-utils/decorators/WithTimeRange.js +1 -0
  39. package/dist/stories/shared-utils/decorators/WithTimeRange.js.map +1 -1
  40. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.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 { Autocomplete, Switch, SwitchProps, TextField } from '@mui/material';\nimport { DEFAULT_LEGEND, getLegendMode, getLegendPosition } from '@perses-dev/core';\nimport { ErrorAlert, OptionsEditorControl } from '@perses-dev/components';\nimport {\n LEGEND_MODE_CONFIG,\n LEGEND_POSITIONS_CONFIG,\n LegendSpecOptions,\n LegendSingleSelectConfig,\n validateLegendSpec,\n} from '../../model';\n\ntype LegendPositionOption = LegendSingleSelectConfig & { id: LegendSpecOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendSpecOptions['position'],\n ...config,\n };\n});\n\ntype LegendModeOption = LegendSingleSelectConfig & { id: LegendSpecOptions['mode'] };\n\nconst MODE_OPTIONS: LegendModeOption[] = Object.entries(LEGEND_MODE_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendSpecOptions['mode'],\n ...config,\n };\n});\n\nexport interface LegendOptionsEditorProps {\n value?: LegendSpecOptions;\n onChange: (legend?: LegendSpecOptions) => void;\n}\n\nexport function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps) {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption) => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const handleLegendModeChange = (_: unknown, newValue: LegendModeOption) => {\n onChange({\n ...value,\n position: currentPosition,\n mode: newValue.id,\n });\n };\n\n const isValidLegend = validateLegendSpec(value);\n const currentPosition = getLegendPosition(value?.position);\n const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];\n\n const currentMode = getLegendMode(value?.mode);\n const legendModeConfig = LEGEND_MODE_CONFIG[currentMode];\n\n return (\n <>\n {!isValidLegend && <ErrorAlert error={{ name: 'invalid-legend', message: 'Invalid legend spec' }} />}\n <OptionsEditorControl\n label=\"Show\"\n control={<Switch checked={value !== undefined} onChange={handleLegendShowChange} />}\n />\n <OptionsEditorControl\n label=\"Position\"\n control={\n <Autocomplete\n value={{\n ...legendPositionConfig,\n id: currentPosition,\n }}\n options={POSITION_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleLegendPositionChange}\n disabled={value === undefined}\n disableClearable\n ></Autocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Mode\"\n control={\n <Autocomplete\n value={{\n ...legendModeConfig,\n id: currentMode,\n }}\n options={MODE_OPTIONS}\n isOptionEqualToValue={(option, value) => option.id === value.id}\n renderInput={(params) => <TextField {...params} />}\n onChange={handleLegendModeChange}\n disabled={value === undefined}\n disableClearable\n ></Autocomplete>\n }\n />\n </>\n );\n}\n"],"names":["Autocomplete","Switch","TextField","DEFAULT_LEGEND","getLegendMode","getLegendPosition","ErrorAlert","OptionsEditorControl","LEGEND_MODE_CONFIG","LEGEND_POSITIONS_CONFIG","validateLegendSpec","POSITION_OPTIONS","Object","entries","map","id","config","MODE_OPTIONS","LegendOptionsEditor","value","onChange","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","handleLegendModeChange","currentPosition","mode","isValidLegend","legendPositionConfig","currentMode","legendModeConfig","error","name","message","label","control","options","isOptionEqualToValue","option","renderInput","params","disabled","disableClearable"],"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;AAAA,SAASA,YAAY,EAAEC,MAAM,EAAeC,SAAS,QAAQ,eAAe,CAAC;AAC7E,SAASC,cAAc,EAAEC,aAAa,EAAEC,iBAAiB,QAAQ,kBAAkB,CAAC;AACpF,SAASC,UAAU,EAAEC,oBAAoB,QAAQ,wBAAwB,CAAC;AAC1E,SACEC,kBAAkB,EAClBC,uBAAuB,EAGvBC,kBAAkB,QACb,aAAa,CAAC;AAIrB,MAAMC,gBAAgB,GAA2BC,MAAM,CAACC,OAAO,CAACJ,uBAAuB,CAAC,CAACK,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC7G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAIH,MAAMC,YAAY,GAAuBL,MAAM,CAACC,OAAO,CAACL,kBAAkB,CAAC,CAACM,GAAG,C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AM;0BAAI;oBAClDzB,QAAQ,EAAES,sBAAsB;oBAChCiB,QAAQ,EAAE3B,KAAK,KAAKO,SAAS;oBAC7BqB,gBAAgB;kBACF;cAElB;;MACD,CACH;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../../src/components/LegendOptionsEditor/LegendOptionsEditor.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 { Switch, SwitchProps } from '@mui/material';\nimport { DEFAULT_LEGEND, getLegendMode, getLegendPosition, getLegendSize } from '@perses-dev/core';\nimport { ErrorAlert, OptionsEditorControl, SettingsAutocomplete } from '@perses-dev/components';\nimport {\n LEGEND_MODE_CONFIG,\n LEGEND_POSITIONS_CONFIG,\n LegendSpecOptions,\n LegendSingleSelectConfig,\n validateLegendSpec,\n LEGEND_VALUE_CONFIG,\n LegendValue,\n LEGEND_SIZE_CONFIG,\n} from '../../model';\n\ntype LegendPositionOption = LegendSingleSelectConfig & { id: LegendSpecOptions['position'] };\n\nconst POSITION_OPTIONS: LegendPositionOption[] = Object.entries(LEGEND_POSITIONS_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendSpecOptions['position'],\n ...config,\n };\n});\n\ntype LegendModeOption = LegendSingleSelectConfig & { id: Required<LegendSpecOptions>['mode'] };\n\nconst MODE_OPTIONS: LegendModeOption[] = Object.entries(LEGEND_MODE_CONFIG).map(([id, config]) => {\n return {\n id: id as Required<LegendSpecOptions>['mode'],\n ...config,\n };\n});\n\ntype LegendSizeOption = LegendSingleSelectConfig & { id: Required<LegendSpecOptions>['size'] };\n\nconst SIZE_OPTIONS: LegendSizeOption[] = Object.entries(LEGEND_SIZE_CONFIG).map(([id, config]) => {\n return {\n id: id as Required<LegendSpecOptions>['size'],\n ...config,\n };\n});\n\ntype LegendValueOption = LegendSingleSelectConfig & { id: LegendValue };\nconst VALUE_OPTIONS: LegendValueOption[] = Object.entries(LEGEND_VALUE_CONFIG).map(([id, config]) => {\n return {\n id: id as LegendValue,\n ...config,\n };\n});\n\nexport interface LegendOptionsEditorProps {\n value?: LegendSpecOptions;\n onChange: (legend?: LegendSpecOptions) => void;\n}\n\nexport function LegendOptionsEditor({ value, onChange }: LegendOptionsEditorProps) {\n const handleLegendShowChange: SwitchProps['onChange'] = (_: unknown, checked: boolean) => {\n // legend is hidden when legend obj is undefined\n const legendValue = checked === true ? { position: DEFAULT_LEGEND.position } : undefined;\n onChange(legendValue);\n };\n\n const handleLegendPositionChange = (_: unknown, newValue: LegendPositionOption) => {\n onChange({\n ...value,\n position: newValue.id,\n });\n };\n\n const handleLegendModeChange = (_: unknown, newValue: LegendModeOption) => {\n onChange({\n ...value,\n position: currentPosition,\n mode: newValue.id,\n });\n };\n\n const handleLegendSizeChange = (_: unknown, newValue: LegendSizeOption) => {\n onChange({\n ...value,\n position: currentPosition,\n size: newValue.id,\n });\n };\n\n const handleLegendValueChange = (_: unknown, newValue: LegendValueOption[]) => {\n onChange({\n ...value,\n position: currentPosition,\n values: newValue.map((value) => {\n return value.id;\n }),\n });\n };\n\n const isValidLegend = validateLegendSpec(value);\n const currentPosition = getLegendPosition(value?.position);\n const legendPositionConfig = LEGEND_POSITIONS_CONFIG[currentPosition];\n\n const currentMode = getLegendMode(value?.mode);\n const legendModeConfig = LEGEND_MODE_CONFIG[currentMode];\n\n const currentSize = getLegendSize(value?.size);\n const legendSizeConfig = LEGEND_SIZE_CONFIG[currentSize];\n\n const currentValues = value?.values || [];\n const legendValuesConfig = currentValues.reduce((result, item) => {\n const config = LEGEND_VALUE_CONFIG[item];\n if (config) {\n result.push({ ...config, id: item });\n }\n return result;\n }, [] as LegendValueOption[]);\n\n return (\n <>\n {!isValidLegend && <ErrorAlert error={{ name: 'invalid-legend', message: 'Invalid legend spec' }} />}\n <OptionsEditorControl\n label=\"Show\"\n control={<Switch checked={value !== undefined} onChange={handleLegendShowChange} />}\n />\n <OptionsEditorControl\n label=\"Position\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendPositionConfig,\n id: currentPosition,\n }}\n options={POSITION_OPTIONS}\n onChange={handleLegendPositionChange}\n disabled={value === undefined}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Mode\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendModeConfig,\n id: currentMode,\n }}\n options={MODE_OPTIONS}\n onChange={handleLegendModeChange}\n disabled={value === undefined}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Size\"\n control={\n <SettingsAutocomplete\n value={{\n ...legendSizeConfig,\n id: currentSize,\n }}\n options={SIZE_OPTIONS}\n onChange={handleLegendSizeChange}\n // TODO: enable sizes for list mode when we normalize the layout of\n // lists to more closely match tables.\n disabled={value === undefined || currentMode !== 'Table'}\n disableClearable\n ></SettingsAutocomplete>\n }\n />\n <OptionsEditorControl\n label=\"Values\"\n control={\n // For some reason, the inferred option type doesn't always seem to work\n // quite right when `multiple` is true. Explicitly setting the generics\n // to work around this.\n <SettingsAutocomplete<LegendValueOption, true, true>\n multiple={true}\n disableCloseOnSelect\n disableClearable\n value={legendValuesConfig}\n options={VALUE_OPTIONS}\n onChange={handleLegendValueChange}\n disabled={value === undefined || currentMode !== 'Table'}\n limitTags={1}\n ChipProps={{\n size: 'small',\n }}\n />\n }\n />\n </>\n );\n}\n"],"names":["Switch","DEFAULT_LEGEND","getLegendMode","getLegendPosition","getLegendSize","ErrorAlert","OptionsEditorControl","SettingsAutocomplete","LEGEND_MODE_CONFIG","LEGEND_POSITIONS_CONFIG","validateLegendSpec","LEGEND_VALUE_CONFIG","LEGEND_SIZE_CONFIG","POSITION_OPTIONS","Object","entries","map","id","config","MODE_OPTIONS","SIZE_OPTIONS","VALUE_OPTIONS","LegendOptionsEditor","value","onChange","handleLegendShowChange","_","checked","legendValue","position","undefined","handleLegendPositionChange","newValue","handleLegendModeChange","currentPosition","mode","handleLegendSizeChange","size","handleLegendValueChange","values","isValidLegend","legendPositionConfig","currentMode","legendModeConfig","currentSize","legendSizeConfig","currentValues","legendValuesConfig","reduce","result","item","push","error","name","message","label","control","options","disabled","disableClearable","multiple","disableCloseOnSelect","limitTags","ChipProps"],"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;AAAA,SAASA,MAAM,QAAqB,eAAe,CAAC;AACpD,SAASC,cAAc,EAAEC,aAAa,EAAEC,iBAAiB,EAAEC,aAAa,QAAQ,kBAAkB,CAAC;AACnG,SAASC,UAAU,EAAEC,oBAAoB,EAAEC,oBAAoB,QAAQ,wBAAwB,CAAC;AAChG,SACEC,kBAAkB,EAClBC,uBAAuB,EAGvBC,kBAAkB,EAClBC,mBAAmB,EAEnBC,kBAAkB,QACb,aAAa,CAAC;AAIrB,MAAMC,gBAAgB,GAA2BC,MAAM,CAACC,OAAO,CAACN,uBAAuB,CAAC,CAACO,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAC7G,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,AAAC;AAIH,MAAMC,YAAY,GAAuBL,MAAM,CAACC,OAAO,CAACP,kBAAkB,CAAC,CAACQ,GAAG,CAAC,CAAC,CAACC,EAAE,EAAEC,MAAM,CAAC,GAAK;IAChG,OAAO;QACLD,EAAE,EAAEA,EAAE;QACN,GAAGC,MAAM;KACV,CAAC;AACJ,CAAC,CAAC,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B;gBACnBiD,KAAK,EAAC,MAAM;gBACZC,OAAO,gBACL,KAACjD,oBAAoB;oBACnBgB,KAAK,EAAE;wBACL,GAAGsB,gBAAgB;wBACnB5B,EAAE,EAAE2B,WAAW;qBAChB;oBACDa,OAAO,EAAErC,YAAY;oBACrBI,QAAQ,EAAEY,sBAAsB;oBAChC,mEAAmE;oBACnE,sCAAsC;oBACtCsB,QAAQ,EAAEnC,KAAK,KAAKO,SAAS,IAAIY,WAAW,KAAK,OAAO;oBACxDiB,gBAAgB;kBACM;cAE1B;0BACF,KAACrD,oBAAoB;gBACnBiD,KAAK,EAAC,QAAQ;gBACdC,OAAO,EACL,wEAAwE;gBACxE,uEAAuE;gBACvE,uBAAuB;8BACvB,KAACjD,oBAAoB;oBACnBqD,QAAQ,EAAE,IAAI;oBACdC,oBAAoB;oBACpBF,gBAAgB;oBAChBpC,KAAK,EAAEwB,kBAAkB;oBACzBU,OAAO,EAAEpC,aAAa;oBACtBG,QAAQ,EAAEc,uBAAuB;oBACjCoB,QAAQ,EAAEnC,KAAK,KAAKO,SAAS,IAAIY,WAAW,KAAK,OAAO;oBACxDoB,SAAS,EAAE,CAAC;oBACZC,SAAS,EAAE;wBACT1B,IAAI,EAAE,OAAO;qBACd;kBACD;cAEJ;;MACD,CACH;AACJ,CAAC"}
@@ -1,9 +1,16 @@
1
- import { LegendMode, LegendOptionsBase, LegendPositions } from '@perses-dev/core';
2
- export declare type LegendSpecOptions = LegendOptionsBase;
1
+ import { CalculationType, LegendMode, LegendOptionsBase, LegendPositions, LegendSize } from '@perses-dev/core';
2
+ export declare const legendValues: CalculationType[];
3
+ export declare type LegendValue = (typeof legendValues)[number];
4
+ export interface LegendSpecOptions extends LegendOptionsBase {
5
+ values?: LegendValue[];
6
+ }
3
7
  export declare type LegendSingleSelectConfig = {
4
8
  label: string;
9
+ description?: string;
5
10
  };
6
11
  export declare const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>>;
7
12
  export declare const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>>;
13
+ export declare const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>>;
14
+ export declare const LEGEND_VALUE_CONFIG: Partial<Record<"First" | "Last" | "FirstNumber" | "LastNumber" | "Mean" | "Sum" | "Min" | "Max", LegendSingleSelectConfig>>;
8
15
  export declare function validateLegendSpec(legend?: LegendOptionsBase): boolean;
9
16
  //# sourceMappingURL=legend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAS1B,oBAAY,iBAAiB,GAAG,iBAAiB,CAAC;AAElD,oBAAY,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAG/F,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,iBAAiB,WAa5D"}
1
+ {"version":3,"file":"legend.d.ts","sourceRoot":"","sources":["../../src/model/legend.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,eAAe,EAGf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAU1B,eAAO,MAAM,YAAY,EAAE,eAAe,EASzC,CAAC;AACF,oBAAY,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAKxD,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC1D,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;CACxB;AAED,oBAAY,wBAAwB,GAAG;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAG/F,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAGrF,CAAC;AAEF,eAAO,MAAM,mBAAmB,6HAIgC,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,MAAM,CAAC,EAAE,iBAAiB,WAgB5D"}
@@ -10,7 +10,24 @@
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 { isValidLegendMode, isValidLegendPosition } from '@perses-dev/core';
13
+ import { CALCULATIONS_CONFIG, isValidLegendMode, isValidLegendPosition, isValidLegendSize } from '@perses-dev/core';
14
+ // This file contains legend-related model code specific to panel plugin specs.
15
+ // See the `core` package for common/shared legend model code and the
16
+ // `components` package for legend model code specific to the Legend component.
17
+ // Explicity listing the calculations we intend to use for legend values because
18
+ // we want them ordered in a specific way, and it may be possible in the future
19
+ // that we only use a subset of calculations for the legend because the calculations
20
+ // are also used by other features.
21
+ export const legendValues = [
22
+ 'Mean',
23
+ 'First',
24
+ 'FirstNumber',
25
+ 'Last',
26
+ 'LastNumber',
27
+ 'Min',
28
+ 'Max',
29
+ 'Sum'
30
+ ];
14
31
  export const LEGEND_POSITIONS_CONFIG = {
15
32
  Bottom: {
16
33
  label: 'Bottom'
@@ -27,6 +44,18 @@ export const LEGEND_MODE_CONFIG = {
27
44
  label: 'Table'
28
45
  }
29
46
  };
47
+ export const LEGEND_SIZE_CONFIG = {
48
+ Small: {
49
+ label: 'Small'
50
+ },
51
+ Medium: {
52
+ label: 'Medium'
53
+ }
54
+ };
55
+ export const LEGEND_VALUE_CONFIG = legendValues.reduce((config, value)=>{
56
+ config[value] = CALCULATIONS_CONFIG[value];
57
+ return config;
58
+ }, {});
30
59
  export function validateLegendSpec(legend) {
31
60
  if (legend === undefined) {
32
61
  // undefined is valid since this is how legend is hidden by default
@@ -38,6 +67,9 @@ export function validateLegendSpec(legend) {
38
67
  if (legend.mode && !isValidLegendMode(legend.mode)) {
39
68
  return false;
40
69
  }
70
+ if (legend.size && !isValidLegendSize(legend.size)) {
71
+ return false;
72
+ }
41
73
  return true;
42
74
  }
43
75
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/legend.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\nimport {\n LegendMode,\n LegendOptionsBase,\n LegendPositions,\n isValidLegendMode,\n isValidLegendPosition,\n} from '@perses-dev/core';\n\n// This file contains legend-related model code specific to panel plugin specs.\n// See the `core` package for common/shared legend model code and the\n// `components` package for legend model code specific to the Legend component.\n\n// Note: explicitly defining different options for the legend spec and\n// legend component that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport type LegendSpecOptions = LegendOptionsBase;\n\nexport type LegendSingleSelectConfig = {\n label: string;\n};\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>> = {\n Bottom: { label: 'Bottom' },\n Right: { label: 'Right' },\n};\n\nexport const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>> = {\n List: { label: 'List' },\n Table: { label: 'Table' },\n};\n\nexport function validateLegendSpec(legend?: LegendOptionsBase) {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n if (legend.mode && !isValidLegendMode(legend.mode)) {\n return false;\n }\n\n return true;\n}\n"],"names":["isValidLegendMode","isValidLegendPosition","LEGEND_POSITIONS_CONFIG","Bottom","label","Right","LEGEND_MODE_CONFIG","List","Table","validateLegendSpec","legend","undefined","position","mode"],"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,SAIEA,iBAAiB,EACjBC,qBAAqB,QAChB,kBAAkB,CAAC;AAe1B,OAAO,MAAMC,uBAAuB,GAAgE;IAClGC,MAAM,EAAE;QAAEC,KAAK,EAAE,QAAQ;KAAE;IAC3BC,KAAK,EAAE;QAAED,KAAK,EAAE,OAAO;KAAE;CAC1B,CAAC;AAEF,OAAO,MAAME,kBAAkB,GAA2D;IACxFC,IAAI,EAAE;QAAEH,KAAK,EAAE,MAAM;KAAE;IACvBI,KAAK,EAAE;QAAEJ,KAAK,EAAE,OAAO;KAAE;CAC1B,CAAC;AAEF,OAAO,SAASK,kBAAkB,CAACC,MAA0B,EAAE;IAC7D,IAAIA,MAAM,KAAKC,SAAS,EAAE;QACxB,mEAAmE;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAACV,qBAAqB,CAACS,MAAM,CAACE,QAAQ,CAAC,EAAE;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAIF,MAAM,CAACG,IAAI,IAAI,CAACb,iBAAiB,CAACU,MAAM,CAACG,IAAI,CAAC,EAAE;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"sources":["../../src/model/legend.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\nimport {\n CALCULATIONS_CONFIG,\n CalculationType,\n LegendMode,\n LegendOptionsBase,\n LegendPositions,\n isValidLegendMode,\n isValidLegendPosition,\n LegendSize,\n isValidLegendSize,\n} from '@perses-dev/core';\n\n// This file contains legend-related model code specific to panel plugin specs.\n// See the `core` package for common/shared legend model code and the\n// `components` package for legend model code specific to the Legend component.\n\n// Explicity listing the calculations we intend to use for legend values because\n// we want them ordered in a specific way, and it may be possible in the future\n// that we only use a subset of calculations for the legend because the calculations\n// are also used by other features.\nexport const legendValues: CalculationType[] = [\n 'Mean',\n 'First',\n 'FirstNumber',\n 'Last',\n 'LastNumber',\n 'Min',\n 'Max',\n 'Sum',\n];\nexport type LegendValue = (typeof legendValues)[number];\n\n// Note: explicitly defining different options for the legend spec and\n// legend component that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport interface LegendSpecOptions extends LegendOptionsBase {\n values?: LegendValue[];\n}\n\nexport type LegendSingleSelectConfig = {\n label: string;\n description?: string;\n};\n\nexport const LEGEND_POSITIONS_CONFIG: Readonly<Record<LegendPositions, LegendSingleSelectConfig>> = {\n Bottom: { label: 'Bottom' },\n Right: { label: 'Right' },\n};\n\nexport const LEGEND_MODE_CONFIG: Readonly<Record<LegendMode, LegendSingleSelectConfig>> = {\n List: { label: 'List' },\n Table: { label: 'Table' },\n};\n\nexport const LEGEND_SIZE_CONFIG: Readonly<Record<LegendSize, LegendSingleSelectConfig>> = {\n Small: { label: 'Small' },\n Medium: { label: 'Medium' },\n};\n\nexport const LEGEND_VALUE_CONFIG = legendValues.reduce((config, value) => {\n config[value] = CALCULATIONS_CONFIG[value];\n\n return config;\n}, {} as Partial<Record<LegendValue, LegendSingleSelectConfig>>);\n\nexport function validateLegendSpec(legend?: LegendOptionsBase) {\n if (legend === undefined) {\n // undefined is valid since this is how legend is hidden by default\n return true;\n }\n if (!isValidLegendPosition(legend.position)) {\n return false;\n }\n if (legend.mode && !isValidLegendMode(legend.mode)) {\n return false;\n }\n if (legend.size && !isValidLegendSize(legend.size)) {\n return false;\n }\n\n return true;\n}\n"],"names":["CALCULATIONS_CONFIG","isValidLegendMode","isValidLegendPosition","isValidLegendSize","legendValues","LEGEND_POSITIONS_CONFIG","Bottom","label","Right","LEGEND_MODE_CONFIG","List","Table","LEGEND_SIZE_CONFIG","Small","Medium","LEGEND_VALUE_CONFIG","reduce","config","value","validateLegendSpec","legend","undefined","position","mode","size"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SACEA,mBAAmB,EAKnBC,iBAAiB,EACjBC,qBAAqB,EAErBC,iBAAiB,QACZ,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,qEAAqE;AACrE,+EAA+E;AAE/E,gFAAgF;AAChF,+EAA+E;AAC/E,oFAAoF;AACpF,mCAAmC;AACnC,OAAO,MAAMC,YAAY,GAAsB;IAC7C,MAAM;IACN,OAAO;IACP,aAAa;IACb,MAAM;IACN,YAAY;IACZ,KAAK;IACL,KAAK;IACL,KAAK;CACN,CAAC;AAeF,OAAO,MAAMC,uBAAuB,GAAgE;IAClGC,MAAM,EAAE;QAAEC,KAAK,EAAE,QAAQ;KAAE;IAC3BC,KAAK,EAAE;QAAED,KAAK,EAAE,OAAO;KAAE;CAC1B,CAAC;AAEF,OAAO,MAAME,kBAAkB,GAA2D;IACxFC,IAAI,EAAE;QAAEH,KAAK,EAAE,MAAM;KAAE;IACvBI,KAAK,EAAE;QAAEJ,KAAK,EAAE,OAAO;KAAE;CAC1B,CAAC;AAEF,OAAO,MAAMK,kBAAkB,GAA2D;IACxFC,KAAK,EAAE;QAAEN,KAAK,EAAE,OAAO;KAAE;IACzBO,MAAM,EAAE;QAAEP,KAAK,EAAE,QAAQ;KAAE;CAC5B,CAAC;AAEF,OAAO,MAAMQ,mBAAmB,GAAGX,YAAY,CAACY,MAAM,CAAC,CAACC,MAAM,EAAEC,KAAK,GAAK;IACxED,MAAM,CAACC,KAAK,CAAC,GAAGlB,mBAAmB,CAACkB,KAAK,CAAC,CAAC;IAE3C,OAAOD,MAAM,CAAC;AAChB,CAAC,EAAE,EAAE,CAA2D,CAAC;AAEjE,OAAO,SAASE,kBAAkB,CAACC,MAA0B,EAAE;IAC7D,IAAIA,MAAM,KAAKC,SAAS,EAAE;QACxB,mEAAmE;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAACnB,qBAAqB,CAACkB,MAAM,CAACE,QAAQ,CAAC,EAAE;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAIF,MAAM,CAACG,IAAI,IAAI,CAACtB,iBAAiB,CAACmB,MAAM,CAACG,IAAI,CAAC,EAAE;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAIH,MAAM,CAACI,IAAI,IAAI,CAACrB,iBAAiB,CAACiB,MAAM,CAACI,IAAI,CAAC,EAAE;QAClD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -27,6 +27,7 @@ export interface TimeSeriesQueryContext {
27
27
  variableState: VariableStateMap;
28
28
  datasourceStore: DatasourceStore;
29
29
  refreshKey: string;
30
+ refreshIntervalInMs: number;
30
31
  }
31
32
  export declare type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;
32
33
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,aAAK,iCAAiC,GAAG;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAExF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,iCAAiC,CAAC;CAC5F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,oBAAY,mBAAmB,GAAG,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC"}
1
+ {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,aAAK,iCAAiC,GAAG;IACvC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,qBAAqB,CAAC,IAAI,GAAG,WAAW,CAAE,SAAQ,MAAM,CAAC,IAAI,CAAC;IAC7E,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAExF,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,sBAAsB,KAAK,iCAAiC,CAAC;CAC5F;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,EAAE,gBAAgB,CAAC;IAChC,eAAe,EAAE,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;CAC7B;AAED,oBAAY,mBAAmB,GAAG,KAAK,CAAC,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/time-series-queries.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\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\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,WAmC2F"}
1
+ {"version":3,"sources":["../../src/model/time-series-queries.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\nimport { Query, QueryKey } from '@tanstack/react-query';\nimport { AbsoluteTimeRange, UnknownSpec, TimeSeriesData } from '@perses-dev/core';\nimport { DatasourceStore, VariableStateMap } from '../runtime';\nimport { Plugin } from './plugin-base';\n\n/**\n * An object containing all the dependencies of a TimeSeriesQuery.\n */\ntype TimeSeriesQueryPluginDependencies = {\n /**\n * Returns a list of variables name this time series query depends on.\n */\n variables?: string[];\n};\n\n/**\n * A plugin for running time series queries.\n */\nexport interface TimeSeriesQueryPlugin<Spec = UnknownSpec> extends Plugin<Spec> {\n getTimeSeriesData: (spec: Spec, ctx: TimeSeriesQueryContext) => Promise<TimeSeriesData>;\n\n dependsOn?: (spec: Spec, ctx: TimeSeriesQueryContext) => TimeSeriesQueryPluginDependencies;\n}\n\n/**\n * Context available to TimeSeriesQuery plugins at runtime.\n */\nexport interface TimeSeriesQueryContext {\n suggestedStepMs?: number;\n timeRange: AbsoluteTimeRange;\n variableState: VariableStateMap;\n datasourceStore: DatasourceStore;\n refreshKey: string;\n refreshIntervalInMs: number;\n}\n\nexport type TimeSeriesDataQuery = Query<TimeSeriesData, unknown, TimeSeriesData, QueryKey>;\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,WAoC2F"}
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- import { AbsoluteTimeRange, TimeRangeValue } from '@perses-dev/core';
2
+ import { AbsoluteTimeRange, DurationString, TimeRangeValue } from '@perses-dev/core';
3
3
  export interface TimeRangeProviderProps {
4
4
  initialTimeRange: TimeRangeValue;
5
+ initialRefreshInterval?: DurationString;
5
6
  enabledURLParams?: boolean;
6
7
  children?: React.ReactNode;
7
8
  }
@@ -11,6 +12,9 @@ export interface TimeRange {
11
12
  setTimeRange: (value: TimeRangeValue) => void;
12
13
  refresh: () => void;
13
14
  refreshKey: string;
15
+ refreshInterval?: DurationString;
16
+ refreshIntervalInMs: number;
17
+ setRefreshInterval: (value: DurationString) => void;
14
18
  }
15
19
  export declare const TimeRangeContext: React.Context<TimeRange | undefined>;
16
20
  export declare function useTimeRangeContext(): TimeRange;
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAuB,cAAc,EAAuB,MAAM,kBAAkB,CAAC;AAG/G,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,cAAc,CAAC;IACjC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,cAMlC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAGxC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eAuB9D"}
1
+ {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoE,MAAM,OAAO,CAAC;AACzF,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,sBAAsB;IACrC,gBAAgB,EAAE,cAAc,CAAC;IACjC,sBAAsB,CAAC,EAAE,cAAc,CAAC;IACxC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,cAMlC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,eA8B9D"}
@@ -13,7 +13,7 @@
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React, { useMemo, useState, useCallback, createContext, useContext } from 'react';
15
15
  import { isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/core';
16
- import { useSetTimeRangeParams } from './query-params';
16
+ import { useSetRefreshIntervalParams, useSetTimeRangeParams } from './query-params';
17
17
  export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
18
18
  export function useTimeRangeContext() {
19
19
  const ctx = useContext(TimeRangeContext);
@@ -25,20 +25,14 @@ export function useTimeRangeContext() {
25
25
  /**
26
26
  * Get and set the current resolved time range at runtime.
27
27
  */ export function useTimeRange() {
28
- const { timeRange , absoluteTimeRange , setTimeRange , refresh , refreshKey } = useTimeRangeContext();
29
- return {
30
- timeRange,
31
- absoluteTimeRange,
32
- setTimeRange,
33
- refresh,
34
- refreshKey
35
- };
28
+ return useTimeRangeContext();
36
29
  }
37
30
  /**
38
31
  * Provider implementation that supplies the time range state at runtime.
39
32
  */ export function TimeRangeProvider(props) {
40
- const { initialTimeRange , enabledURLParams , children } = props;
33
+ const { initialTimeRange , initialRefreshInterval , enabledURLParams , children } = props;
41
34
  const { timeRange , setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);
35
+ const { refreshInterval , setRefreshInterval , refreshIntervalInMs } = useSetRefreshIntervalParams(initialRefreshInterval, enabledURLParams);
42
36
  const [refreshKey, setRefreshKey] = useState(0);
43
37
  const refresh = useCallback(()=>{
44
38
  setRefreshKey(refreshKey + 1);
@@ -52,13 +46,19 @@ export function useTimeRangeContext() {
52
46
  setTimeRange,
53
47
  absoluteTimeRange,
54
48
  refresh,
55
- refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshKey}`
49
+ refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshInterval}:${refreshKey}`,
50
+ refreshInterval,
51
+ refreshIntervalInMs,
52
+ setRefreshInterval
56
53
  };
57
54
  }, [
58
55
  timeRange,
59
56
  setTimeRange,
60
57
  refresh,
61
- refreshKey
58
+ refreshKey,
59
+ refreshInterval,
60
+ refreshIntervalInMs,
61
+ setRefreshInterval
62
62
  ]);
63
63
  return /*#__PURE__*/ _jsx(TimeRangeContext.Provider, {
64
64
  value: ctx,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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, { useMemo, useState, useCallback, createContext, useContext } from 'react';\nimport { AbsoluteTimeRange, isRelativeTimeRange, TimeRangeValue, toAbsoluteTimeRange } from '@perses-dev/core';\nimport { useSetTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n enabledURLParams?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n const { timeRange, absoluteTimeRange, setTimeRange, refresh, refreshKey } = useTimeRangeContext();\n return { timeRange, absoluteTimeRange, setTimeRange, refresh, refreshKey };\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, enabledURLParams, children } = props;\n\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);\n\n const [refreshKey, setRefreshKey] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshKey(refreshKey + 1);\n }, [refreshKey]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n return {\n timeRange,\n setTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshKey}`,\n };\n }, [timeRange, setTimeRange, refresh, refreshKey]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","useMemo","useState","useCallback","createContext","useContext","isRelativeTimeRange","toAbsoluteTimeRange","useSetTimeRangeParams","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","timeRange","absoluteTimeRange","setTimeRange","refresh","refreshKey","TimeRangeProvider","props","initialTimeRange","enabledURLParams","children","setRefreshKey","start","end","Provider","value"],"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;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AACzF,SAA4BC,mBAAmB,EAAkBC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC/G,SAASC,qBAAqB,QAAQ,gBAAgB,CAAC;AAgBvD,OAAO,MAAMC,gBAAgB,iBAAGL,aAAa,CAAwBM,SAAS,CAAC,CAAC;AAEhF,OAAO,SAASC,mBAAmB,GAAG;IACpC,MAAMC,GAAG,GAAGP,UAAU,CAACI,gBAAgB,CAAC,AAAC;IACzC,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED;;CAEC,GACD,OAAO,SAASE,YAAY,GAAc;IACxC,MAAM,EAAEC,SAAS,CAAA,EAAEC,iBAAiB,CAAA,EAAEC,YAAY,CAAA,EAAEC,OAAO,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGR,mBAAmB,EAAE,AAAC;IAClG,OAAO;QAAEI,SAAS;QAAEC,iBAAiB;QAAEC,YAAY;QAAEC,OAAO;QAAEC,UAAU;KAAE,CAAC;AAC7E,CAAC;AAED;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,gBAAgB,CAAA,EAAEC,gBAAgB,CAAA,EAAEC,QAAQ,CAAA,EAAE,GAAGH,KAAK,AAAC;IAE/D,MAAM,EAAEN,SAAS,CAAA,EAAEE,YAAY,CAAA,EAAE,GAAGT,qBAAqB,CAACc,gBAAgB,EAAEC,gBAAgB,CAAC,AAAC;IAE9F,MAAM,CAACJ,UAAU,EAAEM,aAAa,CAAC,GAAGvB,QAAQ,CAAC,CAAC,CAAC,AAAC;IAEhD,MAAMgB,OAAO,GAAGf,WAAW,CAAC,IAAM;QAChCsB,aAAa,CAACN,UAAU,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC,EAAE;QAACA,UAAU;KAAC,CAAC,AAAC;IAEjB,MAAMP,GAAG,GAAGX,OAAO,CAAC,IAAM;QACxB,MAAMe,iBAAiB,GAAGV,mBAAmB,CAACS,SAAS,CAAC,GAAGR,mBAAmB,CAACQ,SAAS,CAAC,GAAGA,SAAS,AAAC;QACtG,OAAO;YACLA,SAAS;YACTE,YAAY;YACZD,iBAAiB;YACjBE,OAAO;YACPC,UAAU,EAAE,CAAC,EAAEH,iBAAiB,CAACU,KAAK,CAAC,CAAC,EAAEV,iBAAiB,CAACW,GAAG,CAAC,CAAC,EAAER,UAAU,CAAC,CAAC;SAChF,CAAC;IACJ,CAAC,EAAE;QAACJ,SAAS;QAAEE,YAAY;QAAEC,OAAO;QAAEC,UAAU;KAAC,CAAC,AAAC;IAEnD,qBAAO,KAACV,gBAAgB,CAACmB,QAAQ;QAACC,KAAK,EAAEjB,GAAG;kBAAGY,QAAQ;MAA6B,CAAC;AACvF,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.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, { useMemo, useState, useCallback, createContext, useContext } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n isRelativeTimeRange,\n TimeRangeValue,\n toAbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { useSetRefreshIntervalParams, useSetTimeRangeParams } from './query-params';\n\nexport interface TimeRangeProviderProps {\n initialTimeRange: TimeRangeValue;\n initialRefreshInterval?: DurationString;\n enabledURLParams?: boolean;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { initialTimeRange, initialRefreshInterval, enabledURLParams, children } = props;\n\n const { timeRange, setTimeRange } = useSetTimeRangeParams(initialTimeRange, enabledURLParams);\n const { refreshInterval, setRefreshInterval, refreshIntervalInMs } = useSetRefreshIntervalParams(\n initialRefreshInterval,\n enabledURLParams\n );\n\n const [refreshKey, setRefreshKey] = useState(0);\n\n const refresh = useCallback(() => {\n setRefreshKey(refreshKey + 1);\n }, [refreshKey]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(timeRange) ? toAbsoluteTimeRange(timeRange) : timeRange;\n return {\n timeRange,\n setTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${refreshInterval}:${refreshKey}`,\n refreshInterval,\n refreshIntervalInMs,\n setRefreshInterval,\n };\n }, [timeRange, setTimeRange, refresh, refreshKey, refreshInterval, refreshIntervalInMs, setRefreshInterval]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","useMemo","useState","useCallback","createContext","useContext","isRelativeTimeRange","toAbsoluteTimeRange","useSetRefreshIntervalParams","useSetTimeRangeParams","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","TimeRangeProvider","props","initialTimeRange","initialRefreshInterval","enabledURLParams","children","timeRange","setTimeRange","refreshInterval","setRefreshInterval","refreshIntervalInMs","refreshKey","setRefreshKey","refresh","absoluteTimeRange","start","end","Provider","value"],"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;AAAA,OAAOA,KAAK,IAAIC,OAAO,EAAEC,QAAQ,EAAEC,WAAW,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO,CAAC;AACzF,SAGEC,mBAAmB,EAEnBC,mBAAmB,QACd,kBAAkB,CAAC;AAC1B,SAASC,2BAA2B,EAAEC,qBAAqB,QAAQ,gBAAgB,CAAC;AAoBpF,OAAO,MAAMC,gBAAgB,iBAAGN,aAAa,CAAwBO,SAAS,CAAC,CAAC;AAEhF,OAAO,SAASC,mBAAmB,GAAG;IACpC,MAAM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AAED,iBAAiB,CAACE,GAAG,CAAC,CAAC,EAAER,eAAe,CAAC,CAAC,EAAEG,UAAU,CAAC,CAAC;YAClGH,eAAe;YACfE,mBAAmB;YACnBD,kBAAkB;SACnB,CAAC;IACJ,CAAC,EAAE;QAACH,SAAS;QAAEC,YAAY;QAAEM,OAAO;QAAEF,UAAU;QAAEH,eAAe;QAAEE,mBAAmB;QAAED,kBAAkB;KAAC,CAAC,AAAC;IAE7G,qBAAO,KAACf,gBAAgB,CAACuB,QAAQ;QAACC,KAAK,EAAErB,GAAG;kBAAGQ,QAAQ;MAA6B,CAAC;AACvF,CAAC"}
@@ -13,6 +13,9 @@ export declare const timeRangeQueryConfig: {
13
13
  start: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
14
14
  end: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
15
15
  };
16
+ export declare const refreshIntervalQueryConfig: {
17
+ refresh: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
18
+ };
16
19
  /**
17
20
  * Gets the initial time range taking into account URL params and dashboard JSON duration
18
21
  * Sets start query param if it is empty on page load
@@ -22,4 +25,13 @@ export declare function useInitialTimeRange(dashboardDuration: DurationString):
22
25
  * Returns time range getter and setter, set enabledURLParams to false to disable query string serialization
23
26
  */
24
27
  export declare function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, enabledURLParams?: boolean): Pick<TimeRange, 'timeRange' | 'setTimeRange'>;
28
+ /**
29
+ * Gets the initial refresh interval taking into account URL params and dashboard JSON duration
30
+ * Sets refresh query param if it is empty on page load
31
+ */
32
+ export declare function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString;
33
+ /**
34
+ * Returns refresh interval getter and setter, set enabledURLParams to false to disable query string serialization
35
+ */
36
+ export declare function useSetRefreshIntervalParams(initialRefreshInterval?: DurationString, enabledURLParams?: boolean): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval' | 'refreshIntervalInMs'>;
25
37
  //# sourceMappingURL=query-params.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,cAAc,EAChC,gBAAgB,UAAO,GACtB,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAAC,CAqC/C"}
1
+ {"version":3,"file":"query-params.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/query-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,cAAc,EAChC,gBAAgB,UAAO,GACtB,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,cAAc,CAAC,CAqC/C;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAc3F;AAaD;;GAEG;AACH,wBAAgB,2BAA2B,CACzC,sBAAsB,CAAC,EAAE,cAAc,EACvC,gBAAgB,UAAO,GACtB,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC,CAqCnF"}
@@ -13,7 +13,7 @@
13
13
  import { useMemo, useCallback, useEffect, useState } from 'react';
14
14
  import { useQueryParams } from 'use-query-params';
15
15
  import { getUnixTime, isDate } from 'date-fns';
16
- import { isRelativeTimeRange, isDurationString } from '@perses-dev/core';
16
+ import { isRelativeTimeRange, isDurationString, parseDurationString } from '@perses-dev/core';
17
17
  /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
18
18
  if (input == null) {
19
19
  return input;
@@ -63,6 +63,9 @@ export const timeRangeQueryConfig = {
63
63
  start: TimeRangeParam,
64
64
  end: TimeRangeParam
65
65
  };
66
+ export const refreshIntervalQueryConfig = {
67
+ refresh: TimeRangeParam
68
+ };
66
69
  /**
67
70
  * Gets the initial time range taking into account URL params and dashboard JSON duration
68
71
  * Sets start query param if it is empty on page load
@@ -149,5 +152,83 @@ export const timeRangeQueryConfig = {
149
152
  setTimeRange: setTimeRange
150
153
  };
151
154
  }
155
+ /**
156
+ * Gets the initial refresh interval taking into account URL params and dashboard JSON duration
157
+ * Sets refresh query param if it is empty on page load
158
+ */ export function useInitialRefreshInterval(dashboardDuration) {
159
+ const [query] = useQueryParams(refreshIntervalQueryConfig, {
160
+ updateType: 'replaceIn'
161
+ });
162
+ const { refresh } = query;
163
+ return useMemo(()=>{
164
+ let initialTimeRange = dashboardDuration;
165
+ if (!refresh) {
166
+ return initialTimeRange;
167
+ }
168
+ const startStr = refresh.toString();
169
+ if (isDurationString(startStr)) {
170
+ initialTimeRange = startStr;
171
+ }
172
+ return initialTimeRange;
173
+ }, [
174
+ dashboardDuration,
175
+ refresh
176
+ ]);
177
+ }
178
+ function getRefreshIntervalInMs(refreshInterval) {
179
+ let refreshIntervalInMs = 0;
180
+ if (refreshInterval) {
181
+ const refreshIntervalDuration = parseDurationString(refreshInterval);
182
+ if (refreshIntervalDuration && refreshIntervalDuration.seconds) {
183
+ refreshIntervalInMs = (refreshIntervalDuration === null || refreshIntervalDuration === void 0 ? void 0 : refreshIntervalDuration.seconds) * 1000;
184
+ }
185
+ }
186
+ return refreshIntervalInMs;
187
+ }
188
+ /**
189
+ * Returns refresh interval getter and setter, set enabledURLParams to false to disable query string serialization
190
+ */ export function useSetRefreshIntervalParams(initialRefreshInterval, enabledURLParams = true) {
191
+ const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, {
192
+ updateType: 'replaceIn'
193
+ });
194
+ // determine whether initial param had previously been populated to fix back btn
195
+ const [paramsLoaded, setParamsLoaded] = useState(false);
196
+ // optional fallback when app does not want query string as source of truth
197
+ // this occurs when enabledURLParams is set to false on TimeRangeProvider
198
+ const [refreshIntervalState, setRefreshIntervalState] = useState(initialRefreshInterval);
199
+ const { refresh } = query;
200
+ useEffect(()=>{
201
+ // when dashboard loaded with no params, default to dashboard duration
202
+ if (enabledURLParams && !paramsLoaded && !refresh) {
203
+ setQuery({
204
+ refresh: initialRefreshInterval
205
+ });
206
+ setParamsLoaded(true);
207
+ }
208
+ }, [
209
+ initialRefreshInterval,
210
+ enabledURLParams,
211
+ paramsLoaded,
212
+ refresh,
213
+ setQuery
214
+ ]);
215
+ const setRefreshInterval = useCallback((refresh)=>setQuery({
216
+ refresh
217
+ }), [
218
+ setQuery
219
+ ]);
220
+ if (!enabledURLParams) {
221
+ return {
222
+ refreshInterval: refreshIntervalState,
223
+ setRefreshInterval: setRefreshIntervalState,
224
+ refreshIntervalInMs: getRefreshIntervalInMs(refreshIntervalState)
225
+ };
226
+ }
227
+ return {
228
+ refreshInterval: initialRefreshInterval,
229
+ setRefreshInterval: setRefreshInterval,
230
+ refreshIntervalInMs: getRefreshIntervalInMs(initialRefreshInterval)
231
+ };
232
+ }
152
233
 
153
234
  //# sourceMappingURL=query-params.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.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\nimport { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n if (input == null) {\n return input;\n }\n // '' or []\n if (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== ''))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str == null) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (paramString == null) return paramString;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (valueA == null || valueB == null) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, set enabledURLParams to false to disable query string serialization\n */\nexport function useSetTimeRangeParams(\n initialTimeRange: TimeRangeValue,\n enabledURLParams = true\n): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n // optional fallback when app does not want query string as source of truth\n // this occurs when enabledURLParams is set to false on TimeRangeProvider\n const [timeRangeState, setTimeRangeState] = useState<TimeRangeValue>(initialTimeRange);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (enabledURLParams && !paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, enabledURLParams, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n if (!enabledURLParams) {\n return { timeRange: timeRangeState, setTimeRange: setTimeRangeState };\n }\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useSetTimeRangeParams","enabledURLParams","setQuery","paramsLoaded","setParamsLoaded","timeRangeState","setTimeRangeState","undefined","setTimeRange","value","timeRange"],"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,OAAO,EAAEC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAClE,SAASC,cAAc,QAA0B,kBAAkB,CAAC;AACpE,SAASC,WAAW,EAAEC,MAAM,QAAQ,UAAU,CAAC;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,kBAAkB,CAAC;AAK1B,iGAAiG,GACjG,SAASC,eAAe,CACtBC,KAAuD,EACvDC,gBAA0B,EACC;IAC3B,IAAID,KAAK,IAAI,IAAI,EAAE;QACjB,OAAOA,KAAK,CAAC;IACf,CAAC;IACD,WAAW;IACX,IAAIA,KAAK,CAACE,MAAM,KAAK,CAAC,IAAK,CAAA,CAACD,gBAAgB,IAAKA,gBAAgB,IAAID,KAAK,KAAK,EAAE,AAAC,CAAA,AAAC,EAAE;QACnF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAMG,GAAG,GAAGH,KAAK,YAAYI,KAAK,GAAGJ,KAAK,CAAC,CAAC,CAAC,GAAGA,KAAK,AAAC;IACtD,IAAIG,GAAG,IAAI,IAAI,EAAE;QACf,OA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rE,CAAC"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/query-params.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\nimport { useMemo, useCallback, useEffect, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n parseDurationString,\n} from '@perses-dev/core';\nimport { TimeRange } from './TimeRangeProvider';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n if (input == null) {\n return input;\n }\n // '' or []\n if (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== ''))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str == null) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (paramString == null) return paramString;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (valueA == null || valueB == null) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\nexport const refreshIntervalQueryConfig = {\n refresh: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, set enabledURLParams to false to disable query string serialization\n */\nexport function useSetTimeRangeParams(\n initialTimeRange: TimeRangeValue,\n enabledURLParams = true\n): Pick<TimeRange, 'timeRange' | 'setTimeRange'> {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n // optional fallback when app does not want query string as source of truth\n // this occurs when enabledURLParams is set to false on TimeRangeProvider\n const [timeRangeState, setTimeRangeState] = useState<TimeRangeValue>(initialTimeRange);\n\n const { start } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (enabledURLParams && !paramsLoaded && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n setParamsLoaded(true);\n }\n }\n }, [initialTimeRange, enabledURLParams, paramsLoaded, start, setQuery]);\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n if (!enabledURLParams) {\n return { timeRange: timeRangeState, setTimeRange: setTimeRangeState };\n }\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n\n/**\n * Gets the initial refresh interval taking into account URL params and dashboard JSON duration\n * Sets refresh query param if it is empty on page load\n */\nexport function useInitialRefreshInterval(dashboardDuration: DurationString): DurationString {\n const [query] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n const { refresh } = query;\n return useMemo(() => {\n let initialTimeRange: DurationString = dashboardDuration;\n if (!refresh) {\n return initialTimeRange;\n }\n const startStr = refresh.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = startStr;\n }\n return initialTimeRange;\n }, [dashboardDuration, refresh]);\n}\n\nfunction getRefreshIntervalInMs(refreshInterval?: DurationString) {\n let refreshIntervalInMs = 0;\n if (refreshInterval) {\n const refreshIntervalDuration = parseDurationString(refreshInterval);\n if (refreshIntervalDuration && refreshIntervalDuration.seconds) {\n refreshIntervalInMs = refreshIntervalDuration?.seconds * 1000;\n }\n }\n return refreshIntervalInMs;\n}\n\n/**\n * Returns refresh interval getter and setter, set enabledURLParams to false to disable query string serialization\n */\nexport function useSetRefreshIntervalParams(\n initialRefreshInterval?: DurationString,\n enabledURLParams = true\n): Pick<TimeRange, 'refreshInterval' | 'setRefreshInterval' | 'refreshIntervalInMs'> {\n const [query, setQuery] = useQueryParams(refreshIntervalQueryConfig, { updateType: 'replaceIn' });\n\n // determine whether initial param had previously been populated to fix back btn\n const [paramsLoaded, setParamsLoaded] = useState<boolean>(false);\n\n // optional fallback when app does not want query string as source of truth\n // this occurs when enabledURLParams is set to false on TimeRangeProvider\n const [refreshIntervalState, setRefreshIntervalState] = useState<DurationString | undefined>(initialRefreshInterval);\n\n const { refresh } = query;\n\n useEffect(() => {\n // when dashboard loaded with no params, default to dashboard duration\n if (enabledURLParams && !paramsLoaded && !refresh) {\n setQuery({ refresh: initialRefreshInterval });\n setParamsLoaded(true);\n }\n }, [initialRefreshInterval, enabledURLParams, paramsLoaded, refresh, setQuery]);\n\n const setRefreshInterval: TimeRange['setRefreshInterval'] = useCallback(\n (refresh: DurationString) => setQuery({ refresh }),\n [setQuery]\n );\n\n if (!enabledURLParams) {\n return {\n refreshInterval: refreshIntervalState,\n setRefreshInterval: setRefreshIntervalState,\n refreshIntervalInMs: getRefreshIntervalInMs(refreshIntervalState),\n };\n }\n return {\n refreshInterval: initialRefreshInterval,\n setRefreshInterval: setRefreshInterval,\n refreshIntervalInMs: getRefreshIntervalInMs(initialRefreshInterval),\n };\n}\n"],"names":["useMemo","useCallback","useEffect","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","parseDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","refreshIntervalQueryConfig","refresh","useInitialTimeRange","dashboardDuration","query","updateType","initialTimeRange","pastDuration","startStr","useSetTimeRangeParams","enabledURLParams","setQuery","paramsLoaded","setParamsLoaded","timeRangeState","setTimeRangeState","undefined","setTimeRange","value","timeRange","useInitialRefreshInterval","getRefreshIntervalInMs","refreshInterval","refreshIntervalInMs","refreshIntervalDuration","seconds","useSetRefreshIntervalParams","initialRefreshInterval","refreshIntervalState","setR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,CAA6ByD,sBAAsB,CAAC,AAAC;IAErH,MAAM,EAAE1B,OAAO,CAAA,EAAE,GAAGG,KAAK,AAAC;IAE1BnC,SAAS,CAAC,IAAM;QACd,sEAAsE;QACtE,IAAIyC,gBAAgB,IAAI,CAACE,YAAY,IAAI,CAACX,OAAO,EAAE;YACjDU,QAAQ,CAAC;gBAAEV,OAAO,EAAE0B,sBAAsB;aAAE,CAAC,CAAC;YAC9Cd,eAAe,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,EAAE;QAACc,sBAAsB;QAAEjB,gBAAgB;QAAEE,YAAY;QAAEX,OAAO;QAAEU,QAAQ;KAAC,CAAC,CAAC;IAEhF,MAAMmB,kBAAkB,GAAoC9D,WAAW,CACrE,CAACiC,OAAuB,GAAKU,QAAQ,CAAC;YAAEV,OAAO;SAAE,CAAC,EAClD;QAACU,QAAQ;KAAC,CACX,AAAC;IAEF,IAAI,CAACD,gBAAgB,EAAE;QACrB,OAAO;YACLY,eAAe,EAAEM,oBAAoB;YACrCE,kBAAkB,EAAED,uBAAuB;YAC3CN,mBAAmB,EAAEF,sBAAsB,CAACO,oBAAoB,CAAC;SAClE,CAAC;IACJ,CAAC;IACD,OAAO;QACLN,eAAe,EAAEK,sBAAsB;QACvCG,kBAAkB,EAAEA,kBAAkB;QACtCP,mBAAmB,EAAEF,sBAAsB,CAACM,sBAAsB,CAAC;KACpE,CAAC;AACJ,CAAC"}
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { VariableName, VariableValue } from '@perses-dev/core';
3
3
  import { VariableOption } from '../model';
4
- export declare const DEFAULT_ALL_VALUE: "$__all";
5
4
  export declare type VariableState = {
6
5
  value: VariableValue;
7
6
  options?: VariableOption[];
@@ -1 +1 @@
1
- {"version":3,"file":"template-variables.d.ts","sourceRoot":"","sources":["../../src/runtime/template-variables.ts"],"names":[],"mappings":";AAcA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAA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AmBzD;AAGD,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKvF"}
@@ -12,7 +12,6 @@
12
12
  // limitations under the License.
13
13
  import { createContext, useContext, useMemo } from 'react';
14
14
  import { parseTemplateVariables, replaceTemplateVariables } from '../utils';
15
- export const DEFAULT_ALL_VALUE = '$__all';
16
15
  export const TemplateVariableContext = createContext(undefined);
17
16
  function useTemplateVariableContext() {
18
17
  const ctx = useContext(TemplateVariableContext);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/template-variables.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\nimport { createContext, useContext, useMemo } from 'react';\nimport { VariableName, VariableValue } from '@perses-dev/core';\nimport { VariableOption } from '../model';\nimport { parseTemplateVariables, replaceTemplateVariables } from '../utils';\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n\nexport type VariableState = {\n value: VariableValue;\n options?: VariableOption[];\n loading: boolean;\n error?: Error;\n};\n\nexport type VariableStateMap = Record<VariableName, VariableState>;\n\nexport type TemplateVariableSrv = {\n state: VariableStateMap;\n};\n\nexport const TemplateVariableContext = createContext<TemplateVariableSrv | undefined>(undefined);\n\nfunction useTemplateVariableContext() {\n const ctx = useContext(TemplateVariableContext);\n if (ctx === undefined) {\n throw new Error('No TemplateVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useTemplateVariableValues(names?: string[]) {\n const { state } = useTemplateVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n\n// Convenience hook for replacing template variables in a string\nexport function useReplaceVariablesInString(str: string | undefined): string | undefined {\n const variablesInString = str ? parseTemplateVariables(str) : [];\n const variableValues = useTemplateVariableValues(variablesInString);\n if (!str) return undefined;\n return replaceTemplateVariables(str, variableValues);\n}\n"],"names":["createContext","useContext","useMemo","parseTemplateVariables","replaceTemplateVariables","DEFAULT_ALL_VALUE","TemplateVariableContext","undefined","useTemplateVariableContext","ctx","Error","useTemplateVariableValues","names","state","values","forEach","name","s","useReplaceVariablesInString","str","variablesInString","variableValues"],"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,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAG3D,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,UAAU,CAAC;AAC5E,OAAO,MAAMC,iBAAiB,GAAG,QAAQ,AAAS,CAAC;AAenD,OAAO,MAAMC,uBAAuB,GAAGN,aAAa,CAAkCO,SAAS,CAAC,CAAC;AAEjG,SAASC,0BAA0B,GAAG;IACpC,MAAMC,GAAG,GAAGR,UAAU,CAACK,uBAAuB,CAAC,AAAC;IAChD,IAAIG,GAAG,KAAKF,SAAS,EAAE;QACrB,MAAM,IAAIG,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IACD,OAAOD,GAAG,CAAC;AACb,CAAC;AAED,OAAO,SAASE,yBAAyB,CAACC,KAAgB,EAAE;IAC1D,MAAM,EAAEC,KAAK,CAAA,EAAE,GAAGL,0BAA0B,EAAE,AAAC;IAE/C,MAAMM,MAAM,GAAGZ,OAAO,CAAC,IAAM;QAC3B,MAAMY,MAAM,GAAqB,EAAE,AAAC;QACpCF,KAAK,aAALA,KAAK,WAAS,GAAdA,KAAAA,CAAc,GAAdA,KAAK,CAAEG,OAAO,CAAC,CAACC,IAAI,GAAK;YACvB,MAAMC,CAAC,GAAGJ,KAAK,CAACG,IAAI,CAAC,AAAC;YACtB,IAAIC,CAAC,EAAE;gBACLH,MAAM,CAACE,IAAI,CAAC,GAAGC,CAAC,CAAC;YACnB,CAAC;QACH,CAAC,CAAC,CAAC;QACH,OAAOH,MAAM,CAAC;IAChB,CAAC,EAAE;QAACD,KAAK;QAAED,KAAK;KAAC,CAAC,AAAC;IAEnB,IAAIA,KAAK,KAAKL,SAAS,EAAE;QACvB,OAAOM,KAAK,CAAC;IACf,CAAC;IAED,OAAOC,MAAM,CAAC;AAChB,CAAC;AAED,gEAAgE;AAChE,OAAO,SAASI,2BAA2B,CAACC,GAAuB,EAAsB;IACvF,MAAMC,iBAAiB,GAAGD,GAAG,GAAGhB,sBAAsB,CAACgB,GAAG,CAAC,GAAG,EAAE,AAAC;IACjE,MAAME,cAAc,GAAGV,yBAAyB,CAACS,iBAAiB,CAAC,AAAC;IACpE,IAAI,CAACD,GAAG,EAAE,OAAOZ,SAAS,CAAC;IAC3B,OAAOH,wBAAwB,CAACe,GAAG,EAAEE,cAAc,CAAC,CAAC;AACvD,CAAC"}
1
+ {"version":3,"sources":["../../src/runtime/template-variables.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\nimport { createContext, useContext, useMemo } from 'react';\nimport { VariableName, VariableValue } from '@perses-dev/core';\nimport { VariableOption } from '../model';\nimport { parseTemplateVariables, replaceTemplateVariables } from '../utils';\n\nexport type VariableState = {\n value: VariableValue;\n options?: VariableOption[];\n loading: boolean;\n error?: Error;\n};\n\nexport type VariableStateMap = Record<VariableName, VariableState>;\n\nexport type TemplateVariableSrv = {\n state: VariableStateMap;\n};\n\nexport const TemplateVariableContext = createContext<TemplateVariableSrv | undefined>(undefined);\n\nfunction useTemplateVariableContext() {\n const ctx = useContext(TemplateVariableContext);\n if (ctx === undefined) {\n throw new Error('No TemplateVariableContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\nexport function useTemplateVariableValues(names?: string[]) {\n const { state } = useTemplateVariableContext();\n\n const values = useMemo(() => {\n const values: VariableStateMap = {};\n names?.forEach((name) => {\n const s = state[name];\n if (s) {\n values[name] = s;\n }\n });\n return values;\n }, [state, names]);\n\n if (names === undefined) {\n return state;\n }\n\n return values;\n}\n\n// Convenience hook for replacing template variables in a string\nexport function useReplaceVariablesInString(str: string | undefined): string | undefined {\n const variablesInString = str ? parseTemplateVariables(str) : [];\n const variableValues = useTemplateVariableValues(variablesInString);\n if (!str) return undefined;\n return replaceTemplateVariables(str, variableValues);\n}\n"],"names":["createContext","useContext","useMemo","parseTemplateVariables","replaceTemplateVariables","TemplateVariableContext","undefined","useTemplateVariableContext","ctx","Error","useTemplateVariableValues","names","state","values","forEach","name","s","useReplaceVariablesInString","str","variablesInString","variableValues"],"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,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO,CAAC;AAG3D,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,UAAU,CAAC;AAe5E,OAAO,MAAMC,uBAAuB,GAAGL,aAAa,CAAkCM,SAAS,CAAC,CA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+12,7 @@ export declare const useTimeSeriesQuery: (definition: TimeSeriesQueryDefinition,
12
12
  /**
13
13
  * Runs multiple time series queries using plugins and returns the results.
14
14
  */
15
- export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions): import("@tanstack/react-query").UseQueryResult<TimeSeriesData, unknown>[];
15
+ export declare function useTimeSeriesQueries(definitions: TimeSeriesQueryDefinition[], options?: UseTimeSeriesQueryOptions): import("@tanstack/react-query").UseQueryResult<unknown, unknown>[];
16
16
  /**
17
17
  * Get active time series queries for query results summary
18
18
  */
@@ -1 +1 @@
1
- {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAA+C,UAAU,EAAY,MAAM,uBAAuB,CAAC;AAC1G,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAiD,MAAM,UAAU,CAAC;AAM9F,MAAM,WAAW,yBAAyB;IACxC,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,qBAAqB,oBAAoB,CAAC;AAmDvD;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAgB,yBAAyB,YAAY,yBAAyB,4EAkB5G,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,yBAAyB,EAAE,EAAE,OAAO,CAAC,EAAE,yBAAyB,6EA0BjH;AAkBD;;GAEG;AACH,wBAAgB,0BAA0B,0BAIzC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,yBAW3D"}
1
+ {"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/runtime/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAKL,UAAU,EAGX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,yBAAyB,EAAe,cAAc,EAAE,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