@perses-dev/gauge-chart-plugin 0.13.0 → 0.14.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/GaugeChart.d0898a25.js +7 -0
- package/__mf/js/async/121.923647b2.js +2 -0
- package/__mf/js/async/192.66cc8639.js +1 -0
- package/__mf/js/async/208.1dc9d791.js +74 -0
- package/__mf/js/async/235.3d14b76d.js +1 -0
- package/__mf/js/async/274.481c2cff.js +2 -0
- package/__mf/js/async/356.81432231.js +1 -0
- package/__mf/js/async/377.5ac59bcd.js +1 -0
- package/__mf/js/async/392.589be345.js +2 -0
- package/__mf/js/async/403.f63f0b01.js +2 -0
- package/__mf/js/async/407.549724e8.js +4 -0
- package/__mf/js/async/407.549724e8.js.LICENSE.txt +9 -0
- package/__mf/js/async/410.41a2ea21.js +1 -0
- package/__mf/js/async/458.c3d7080e.js +1 -0
- package/__mf/js/async/463.1623acc4.js +7 -0
- package/__mf/js/async/{700.e028a93e.js.LICENSE.txt → 463.1623acc4.js.LICENSE.txt} +41 -1
- package/__mf/js/async/470.a5788e56.js +2 -0
- package/__mf/js/async/496.ddfbee86.js +1 -0
- package/__mf/js/async/587.b53469e7.js +1 -0
- package/__mf/js/async/588.231edddc.js +1 -0
- package/__mf/js/async/616.56af3d9a.js +1 -0
- package/__mf/js/async/71.5c044eb7.js +1 -0
- package/__mf/js/async/710.63c7c633.js +29 -0
- package/__mf/js/async/77.84340477.js +1 -0
- package/__mf/js/async/823.ed9ab057.js +10 -0
- package/__mf/js/async/844.8884c953.js +37 -0
- package/__mf/js/async/854.23201b26.js +1 -0
- package/__mf/js/async/873.828ee17a.js +1 -0
- package/__mf/js/async/941.f2b7612e.js +2 -0
- package/__mf/js/async/963.8f8fc110.js +1 -0
- package/__mf/js/async/968.fbee556d.js +1 -0
- package/__mf/js/async/978.75bd4607.js +1 -0
- package/__mf/js/async/__federation_expose_GaugeChart.a608d5e4.js +1 -0
- package/__mf/js/async/lib-router.a426c87f.js +2 -0
- package/__mf/js/main.7041202d.js +7 -0
- package/lib/GaugeChart.d.ts +3 -3
- package/lib/GaugeChart.d.ts.map +1 -1
- package/lib/GaugeChart.js +3 -3
- package/lib/GaugeChart.js.map +1 -1
- package/lib/GaugeChartBase.d.ts +3 -3
- package/lib/GaugeChartBase.d.ts.map +1 -1
- package/lib/GaugeChartBase.js +7 -7
- package/lib/GaugeChartBase.js.map +1 -1
- package/lib/GaugeChartOptionsEditorSettings.d.ts +2 -2
- package/lib/GaugeChartOptionsEditorSettings.d.ts.map +1 -1
- package/lib/GaugeChartOptionsEditorSettings.js +7 -7
- package/lib/GaugeChartOptionsEditorSettings.js.map +1 -1
- package/lib/GaugeChartPanel.d.ts +4 -4
- package/lib/GaugeChartPanel.d.ts.map +1 -1
- package/lib/GaugeChartPanel.js +8 -8
- package/lib/GaugeChartPanel.js.map +1 -1
- package/lib/bootstrap.js +2 -2
- package/lib/gauge-chart-model.d.ts +3 -3
- package/lib/gauge-chart-model.d.ts.map +1 -1
- package/lib/gauge-chart-model.js.map +1 -1
- package/lib/getPluginModule.d.ts +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +3 -1
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index.js +6 -6
- package/lib/index.js.map +1 -1
- package/lib/setup-tests.d.ts +1 -1
- package/lib/setup-tests.d.ts.map +1 -1
- package/lib/setup-tests.js +2 -2
- package/lib/setup-tests.js.map +1 -1
- package/lib/thresholds.d.ts +1 -1
- package/lib/thresholds.d.ts.map +1 -1
- package/lib/thresholds.js +1 -1
- package/lib/thresholds.js.map +1 -1
- package/mf-manifest.json +39 -40
- package/mf-stats.json +39 -40
- package/package.json +10 -10
- package/__mf/js/GaugeChart.7e331b64.js +0 -7
- package/__mf/js/async/121.4c5f5798.js +0 -2
- package/__mf/js/async/172.afec864d.js +0 -110
- package/__mf/js/async/177.2e554778.js +0 -1
- package/__mf/js/async/187.ba6fd686.js +0 -7
- package/__mf/js/async/187.ba6fd686.js.LICENSE.txt +0 -39
- package/__mf/js/async/192.fb5cd927.js +0 -1
- package/__mf/js/async/235.b918db36.js +0 -1
- package/__mf/js/async/274.9badab92.js +0 -2
- package/__mf/js/async/356.c7cf4f79.js +0 -1
- package/__mf/js/async/377.06309086.js +0 -1
- package/__mf/js/async/392.4807325b.js +0 -2
- package/__mf/js/async/403.9db35877.js +0 -2
- package/__mf/js/async/410.4043d582.js +0 -1
- package/__mf/js/async/458.0f5bc9ee.js +0 -1
- package/__mf/js/async/470.9e955be3.js +0 -2
- package/__mf/js/async/496.dc9e951b.js +0 -1
- package/__mf/js/async/546.7850a553.js +0 -24
- package/__mf/js/async/546.7850a553.js.LICENSE.txt +0 -19
- package/__mf/js/async/558.9e9f2911.js +0 -1
- package/__mf/js/async/587.2649e50b.js +0 -1
- package/__mf/js/async/588.f25e2591.js +0 -1
- package/__mf/js/async/616.0741833f.js +0 -1
- package/__mf/js/async/700.e028a93e.js +0 -30
- package/__mf/js/async/71.57cf30f3.js +0 -1
- package/__mf/js/async/756.cbb57779.js +0 -1
- package/__mf/js/async/77.629e7e49.js +0 -1
- package/__mf/js/async/823.488b0ae9.js +0 -10
- package/__mf/js/async/854.d052322d.js +0 -1
- package/__mf/js/async/873.650a20f9.js +0 -1
- package/__mf/js/async/941.c6518e38.js +0 -2
- package/__mf/js/async/963.ab063f73.js +0 -1
- package/__mf/js/async/968.5b4a4f18.js +0 -1
- package/__mf/js/async/978.8aa2a024.js +0 -1
- package/__mf/js/async/__federation_expose_GaugeChart.b9c57db4.js +0 -1
- package/__mf/js/async/lib-router.f8568e8a.js +0 -2
- package/__mf/js/main.c44733a6.js +0 -7
- package/lib/cjs/GaugeChart.js +0 -39
- package/lib/cjs/GaugeChartBase.js +0 -196
- package/lib/cjs/GaugeChartOptionsEditorSettings.js +0 -120
- package/lib/cjs/GaugeChartPanel.js +0 -195
- package/lib/cjs/bootstrap.js +0 -26
- package/lib/cjs/env.d.js +0 -14
- package/lib/cjs/gauge-chart-model.js +0 -57
- package/lib/cjs/getPluginModule.js +0 -39
- package/lib/cjs/index-federation.js +0 -55
- package/lib/cjs/index.js +0 -41
- package/lib/cjs/setup-tests.js +0 -19
- package/lib/cjs/thresholds.js +0 -77
- /package/__mf/css/async/{187.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
- /package/__mf/js/async/{121.4c5f5798.js.LICENSE.txt → 121.923647b2.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{274.9badab92.js.LICENSE.txt → 274.481c2cff.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.4807325b.js.LICENSE.txt → 392.589be345.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{403.9db35877.js.LICENSE.txt → 403.f63f0b01.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{470.9e955be3.js.LICENSE.txt → 470.a5788e56.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{823.488b0ae9.js.LICENSE.txt → 823.ed9ab057.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{941.c6518e38.js.LICENSE.txt → 941.f2b7612e.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{lib-router.f8568e8a.js.LICENSE.txt → lib-router.a426c87f.js.LICENSE.txt} +0 -0
package/lib/GaugeChartPanel.js
CHANGED
|
@@ -11,14 +11,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import { Box, Skeleton, Stack } from
|
|
15
|
-
import { formatValue, useChartsTheme } from
|
|
16
|
-
import { CalculationsMap, DEFAULT_CALCULATION } from
|
|
17
|
-
import merge from
|
|
18
|
-
import { useMemo } from
|
|
19
|
-
import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
14
|
+
import { Box, Skeleton, Stack } from "@mui/material";
|
|
15
|
+
import { formatValue, useChartsTheme } from "@perses-dev/components";
|
|
16
|
+
import { CalculationsMap, DEFAULT_CALCULATION } from "@perses-dev/plugin-system";
|
|
17
|
+
import merge from "lodash/merge";
|
|
18
|
+
import { useMemo } from "react";
|
|
19
|
+
import { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from "./gauge-chart-model.js";
|
|
20
|
+
import { GaugeChartBase } from "./GaugeChartBase.js";
|
|
21
|
+
import { convertThresholds, defaultThresholdInput } from "./thresholds.js";
|
|
22
22
|
const EMPTY_GAUGE_SERIES = {
|
|
23
23
|
label: '',
|
|
24
24
|
value: undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/GaugeChartPanel.tsx"],"sourcesContent":["// Copyright 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 { Box, Skeleton, Stack } from '@mui/material';\nimport { FormatOptions, formatValue, useChartsTheme } from '@perses-dev/components';\nimport { CalculationsMap, DEFAULT_CALCULATION, PanelProps } from '@perses-dev/plugin-system';\nimport type { GaugeSeriesOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport { ReactElement, useMemo } from 'react';\nimport { TimeSeriesData } from '@perses-dev/spec';\nimport {\n DEFAULT_FORMAT,\n DEFAULT_MAX_PERCENT,\n DEFAULT_MAX_PERCENT_DECIMAL,\n GaugeChartOptions,\n} from './gauge-chart-model';\nimport { convertThresholds, defaultThresholdInput } from './thresholds';\nimport { GaugeChartBase, GaugeSeries } from './GaugeChartBase';\n\nconst EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined };\nconst GAUGE_MIN_WIDTH = 90;\nconst PANEL_PADDING_OFFSET = 20;\n\n/**\n * Calculate responsive progress width based on panel dimensions\n */\nfunction getResponsiveProgressWidth(width: number, height: number): number {\n const MIN_WIDTH = 10;\n const MAX_WIDTH = 48;\n const RATIO = 0.1; // 10% of the smaller dimension\n\n const minSize = Math.min(width, height);\n // Use RATIO of the smaller dimension as base, with reasonable min/max bounds\n return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(minSize * RATIO)));\n}\n\n/**\n * Responsive font size depending on number of characters and panel dimensions.\n * Uses clamp to ensure the text never overflows and scales appropriately with panel size.\n * (Value refers to the main number value displayed inside the gauge)\n */\nfunction getResponsiveValueFontSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number\n): string {\n const MIN_SIZE = 8;\n const MAX_SIZE = 64;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n\n const valueTextLength = Math.max(formattedValue.length, 6); // Ensure a minimum length to avoid overly large text for short values\n const availableSpace = Math.min(width, height);\n const fontSize = availableSpace / valueTextLength;\n\n return `clamp(${MIN_SIZE}px, ${fontSize}px, ${MAX_SIZE}px)`;\n}\n\n/**\n * Calculate responsive title font size based on panel dimensions\n * (Title refers to the text displayed below the gauge as a legend)\n */\nfunction getResponsiveTitleFontSize(width: number, height: number): number {\n const MIN_SIZE = 10;\n const MAX_SIZE = 16;\n const RATIO = 0.06; // Use 6% of the smaller dimension as base\n\n const size = Math.round(Math.min(width, height) * RATIO);\n // Scale based on panel size, with reasonable min/max bounds\n return Math.max(MIN_SIZE, Math.min(MAX_SIZE, size));\n}\n\nexport type GaugeChartPanelProps = PanelProps<GaugeChartOptions, TimeSeriesData>;\n\nexport function GaugeChartPanel(props: GaugeChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { calculation, max, legend } = pluginSpec;\n\n const { thresholds: thresholdsColors } = useChartsTheme();\n\n /* Legend setting just added to the cue schema\n This line assures that if legend setting doesn't exist (for old gauge setting records),\n The legend shows normally as before. If it exists, then it checks the show property.\n */\n const showLegend = legend?.show ?? true;\n\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n\n const thresholds = pluginSpec.thresholds ?? defaultThresholdInput;\n\n const gaugeData = useMemo((): GaugeSeries[] => {\n const seriesData: GaugeSeries[] = [];\n\n if (!CalculationsMap[calculation]) {\n console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n\n for (const result of queryResults) {\n for (const timeSeries of result.data.series) {\n seriesData.push({\n value: calculate(timeSeries.values),\n label: showLegend ? (timeSeries.formattedName ?? '') : '',\n });\n }\n }\n return seriesData;\n }, [queryResults, calculation, showLegend]);\n\n if (!contentDimensions) return null;\n\n // needed for end value of last threshold color segment\n let thresholdMax = max;\n if (thresholdMax === undefined) {\n thresholdMax = format.unit === 'percent' ? DEFAULT_MAX_PERCENT : DEFAULT_MAX_PERCENT_DECIMAL;\n }\n const axisLineColors = convertThresholds(thresholds, format, thresholdMax, thresholdsColors);\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;\n if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = GAUGE_MIN_WIDTH;\n }\n\n // Calculate responsive values based on chart dimensions\n const progressWidth = getResponsiveProgressWidth(chartWidth, contentDimensions.height);\n const axisLineWidth = Math.round(progressWidth * 0.2); // Axis line width is 20% of progress width\n const titleFontSize = getResponsiveTitleFontSize(chartWidth, contentDimensions.height);\n\n const axisLine: GaugeSeriesOption['axisLine'] = {\n show: true,\n lineStyle: {\n width: axisLineWidth,\n color: axisLineColors,\n },\n };\n\n // no data message handled inside chart component\n if (!gaugeData.length) {\n const emptyValueFontSize = getResponsiveValueFontSize(\n null,\n format,\n contentDimensions.width,\n contentDimensions.height\n );\n const emptyProgressWidth = getResponsiveProgressWidth(contentDimensions.width, contentDimensions.height);\n const emptyTitleFontSize = getResponsiveTitleFontSize(contentDimensions.width, contentDimensions.height);\n\n return (\n <GaugeChartBase\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={EMPTY_GAUGE_SERIES}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={emptyValueFontSize}\n progressWidth={emptyProgressWidth}\n titleFontSize={emptyTitleFontSize}\n />\n );\n }\n\n const hasMultipleCharts = gaugeData.length > 1;\n\n return (\n <Stack\n direction=\"row\"\n spacing={hasMultipleCharts ? 2 : 0}\n justifyContent={hasMultipleCharts ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: gaugeData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {gaugeData.map((series, seriesIndex) => {\n const fontSize = getResponsiveValueFontSize(series.value ?? null, format, chartWidth, contentDimensions.height);\n\n return (\n <Box key={`gauge-series-${seriesIndex}`}>\n <GaugeChartBase\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={fontSize}\n progressWidth={progressWidth}\n titleFontSize={titleFontSize}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n\nexport function GaugeChartLoading({ contentDimensions }: GaugeChartPanelProps): React.ReactElement | null {\n if (!contentDimensions) return null;\n return (\n <Skeleton\n sx={{ margin: '0 auto' }}\n variant=\"circular\"\n width={contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width}\n height={contentDimensions.height}\n />\n );\n}\n"],"names":["Box","Skeleton","Stack","formatValue","useChartsTheme","CalculationsMap","DEFAULT_CALCULATION","merge","useMemo","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","convertThresholds","defaultThresholdInput","GaugeChartBase","EMPTY_GAUGE_SERIES","label","value","undefined","GAUGE_MIN_WIDTH","PANEL_PADDING_OFFSET","getResponsiveProgressWidth","width","height","MIN_WIDTH","MAX_WIDTH","RATIO","minSize","Math","min","max","round","getResponsiveValueFontSize","format","MIN_SIZE","MAX_SIZE","formattedValue","valueTextLength","length","availableSpace","fontSize","getResponsiveTitleFontSize","size","GaugeChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","calculation","legend","thresholds","thresholdsColors","showLegend","show","gaugeData","seriesData","console","warn","calculate","result","timeSeries","data","series","push","values","formattedName","thresholdMax","unit","axisLineColors","chartWidth","progressWidth","axisLineWidth","titleFontSize","axisLine","lineStyle","color","emptyValueFontSize","emptyProgressWidth","emptyTitleFontSize","valueFontSize","hasMultipleCharts","direction","spacing","justifyContent","alignItems","sx","overflowX","map","seriesIndex","GaugeChartLoading","margin","variant"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,gBAAgB;AACrD,SAAwBC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB;AACpF,SAASC,eAAe,EAAEC,mBAAmB,QAAoB,4BAA4B;AAE7F,OAAOC,WAAW,eAAe;AACjC,SAAuBC,OAAO,QAAQ,QAAQ;AAE9C,SACEC,cAAc,EACdC,mBAAmB,EACnBC,2BAA2B,QAEtB,sBAAsB;AAC7B,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,eAAe;AACxE,SAASC,cAAc,QAAqB,mBAAmB;AAE/D,MAAMC,qBAAkC;IAAEC,OAAO;IAAIC,OAAOC;AAAU;AACtE,MAAMC,kBAAkB;AACx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A;oBACV5C,KAAKqC;oBACLa,eAAexC;oBACf+B,eAAeA;oBACfE,eAAeA;;eAVT,CAAC,aAAa,EAAEgB,aAAa;QAc3C;;AAGN;AAEA,OAAO,SAASC,kBAAkB,EAAE3C,iBAAiB,EAAwB;IAC3E,IAAI,CAACA,mBAAmB,OAAO;IAC/B,qBACE,KAAC9C;QACCqF,IAAI;YAAEK,QAAQ;QAAS;QACvBC,SAAQ;QACRtE,OAAOyB,kBAAkBzB,KAAK,GAAGyB,kBAAkBxB,MAAM,GAAGwB,kBAAkBxB,MAAM,GAAGwB,kBAAkBzB,KAAK;QAC9GC,QAAQwB,kBAAkBxB,MAAM;;AAGtC"}
|
|
1
|
+
{"version":3,"sources":["../../src/GaugeChartPanel.tsx"],"sourcesContent":["// Copyright 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 { Box, Skeleton, Stack } from '@mui/material';\nimport type { FormatOptions } from '@perses-dev/components';\nimport { formatValue, useChartsTheme } from '@perses-dev/components';\nimport type { PanelProps } from '@perses-dev/plugin-system';\nimport { CalculationsMap, DEFAULT_CALCULATION } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\nimport type { GaugeSeriesOption } from 'echarts';\nimport merge from 'lodash/merge';\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { GaugeChartOptions } from './gauge-chart-model';\nimport { DEFAULT_FORMAT, DEFAULT_MAX_PERCENT, DEFAULT_MAX_PERCENT_DECIMAL } from './gauge-chart-model';\nimport type { GaugeSeries } from './GaugeChartBase';\nimport { GaugeChartBase } from './GaugeChartBase';\nimport { convertThresholds, defaultThresholdInput } from './thresholds';\n\nconst EMPTY_GAUGE_SERIES: GaugeSeries = { label: '', value: undefined };\nconst GAUGE_MIN_WIDTH = 90;\nconst PANEL_PADDING_OFFSET = 20;\n\n/**\n * Calculate responsive progress width based on panel dimensions\n */\nfunction getResponsiveProgressWidth(width: number, height: number): number {\n const MIN_WIDTH = 10;\n const MAX_WIDTH = 48;\n const RATIO = 0.1; // 10% of the smaller dimension\n\n const minSize = Math.min(width, height);\n // Use RATIO of the smaller dimension as base, with reasonable min/max bounds\n return Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Math.round(minSize * RATIO)));\n}\n\n/**\n * Responsive font size depending on number of characters and panel dimensions.\n * Uses clamp to ensure the text never overflows and scales appropriately with panel size.\n * (Value refers to the main number value displayed inside the gauge)\n */\nfunction getResponsiveValueFontSize(\n value: number | null,\n format: FormatOptions,\n width: number,\n height: number,\n): string {\n const MIN_SIZE = 8;\n const MAX_SIZE = 64;\n const formattedValue = typeof value === 'number' ? formatValue(value, format) : `${value}`;\n\n const valueTextLength = Math.max(formattedValue.length, 6); // Ensure a minimum length to avoid overly large text for short values\n const availableSpace = Math.min(width, height);\n const fontSize = availableSpace / valueTextLength;\n\n return `clamp(${MIN_SIZE}px, ${fontSize}px, ${MAX_SIZE}px)`;\n}\n\n/**\n * Calculate responsive title font size based on panel dimensions\n * (Title refers to the text displayed below the gauge as a legend)\n */\nfunction getResponsiveTitleFontSize(width: number, height: number): number {\n const MIN_SIZE = 10;\n const MAX_SIZE = 16;\n const RATIO = 0.06; // Use 6% of the smaller dimension as base\n\n const size = Math.round(Math.min(width, height) * RATIO);\n // Scale based on panel size, with reasonable min/max bounds\n return Math.max(MIN_SIZE, Math.min(MAX_SIZE, size));\n}\n\nexport type GaugeChartPanelProps = PanelProps<GaugeChartOptions, TimeSeriesData>;\n\nexport function GaugeChartPanel(props: GaugeChartPanelProps): ReactElement | null {\n const { spec: pluginSpec, contentDimensions, queryResults } = props;\n const { calculation, max, legend } = pluginSpec;\n\n const { thresholds: thresholdsColors } = useChartsTheme();\n\n /* Legend setting just added to the cue schema\n This line assures that if legend setting doesn't exist (for old gauge setting records),\n The legend shows normally as before. If it exists, then it checks the show property.\n */\n const showLegend = legend?.show ?? true;\n\n // ensures all default format properties set if undef\n const format = merge({}, DEFAULT_FORMAT, pluginSpec.format);\n\n const thresholds = pluginSpec.thresholds ?? defaultThresholdInput;\n\n const gaugeData = useMemo((): GaugeSeries[] => {\n const seriesData: GaugeSeries[] = [];\n\n if (!CalculationsMap[calculation]) {\n console.warn(`Invalid GaugeChart panel calculation ${calculation}, fallback to ${DEFAULT_CALCULATION}`);\n }\n\n const calculate = CalculationsMap[calculation] ?? CalculationsMap[DEFAULT_CALCULATION];\n\n for (const result of queryResults) {\n for (const timeSeries of result.data.series) {\n seriesData.push({\n value: calculate(timeSeries.values),\n label: showLegend ? (timeSeries.formattedName ?? '') : '',\n });\n }\n }\n return seriesData;\n }, [queryResults, calculation, showLegend]);\n\n if (!contentDimensions) return null;\n\n // needed for end value of last threshold color segment\n let thresholdMax = max;\n if (thresholdMax === undefined) {\n thresholdMax = format.unit === 'percent' ? DEFAULT_MAX_PERCENT : DEFAULT_MAX_PERCENT_DECIMAL;\n }\n const axisLineColors = convertThresholds(thresholds, format, thresholdMax, thresholdsColors);\n\n // accounts for showing a separate chart for each time series\n let chartWidth = contentDimensions.width / gaugeData.length - PANEL_PADDING_OFFSET;\n if (chartWidth < GAUGE_MIN_WIDTH && gaugeData.length > 1) {\n // enables horizontal scroll when charts overflow outside of panel\n chartWidth = GAUGE_MIN_WIDTH;\n }\n\n // Calculate responsive values based on chart dimensions\n const progressWidth = getResponsiveProgressWidth(chartWidth, contentDimensions.height);\n const axisLineWidth = Math.round(progressWidth * 0.2); // Axis line width is 20% of progress width\n const titleFontSize = getResponsiveTitleFontSize(chartWidth, contentDimensions.height);\n\n const axisLine: GaugeSeriesOption['axisLine'] = {\n show: true,\n lineStyle: {\n width: axisLineWidth,\n color: axisLineColors,\n },\n };\n\n // no data message handled inside chart component\n if (!gaugeData.length) {\n const emptyValueFontSize = getResponsiveValueFontSize(\n null,\n format,\n contentDimensions.width,\n contentDimensions.height,\n );\n const emptyProgressWidth = getResponsiveProgressWidth(contentDimensions.width, contentDimensions.height);\n const emptyTitleFontSize = getResponsiveTitleFontSize(contentDimensions.width, contentDimensions.height);\n\n return (\n <GaugeChartBase\n width={contentDimensions.width}\n height={contentDimensions.height}\n data={EMPTY_GAUGE_SERIES}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={emptyValueFontSize}\n progressWidth={emptyProgressWidth}\n titleFontSize={emptyTitleFontSize}\n />\n );\n }\n\n const hasMultipleCharts = gaugeData.length > 1;\n\n return (\n <Stack\n direction=\"row\"\n spacing={hasMultipleCharts ? 2 : 0}\n justifyContent={hasMultipleCharts ? 'left' : 'center'}\n alignItems=\"center\"\n sx={{\n // so scrollbar only shows when necessary\n overflowX: gaugeData.length > 1 ? 'scroll' : 'auto',\n }}\n >\n {gaugeData.map((series, seriesIndex) => {\n const fontSize = getResponsiveValueFontSize(series.value ?? null, format, chartWidth, contentDimensions.height);\n\n return (\n <Box key={`gauge-series-${seriesIndex}`}>\n <GaugeChartBase\n width={chartWidth}\n height={contentDimensions.height}\n data={series}\n format={format}\n axisLine={axisLine}\n max={thresholdMax}\n valueFontSize={fontSize}\n progressWidth={progressWidth}\n titleFontSize={titleFontSize}\n />\n </Box>\n );\n })}\n </Stack>\n );\n}\n\nexport function GaugeChartLoading({ contentDimensions }: GaugeChartPanelProps): React.ReactElement | null {\n if (!contentDimensions) return null;\n return (\n <Skeleton\n sx={{ margin: '0 auto' }}\n variant=\"circular\"\n width={contentDimensions.width > contentDimensions.height ? contentDimensions.height : contentDimensions.width}\n height={contentDimensions.height}\n />\n );\n}\n"],"names":["Box","Skeleton","Stack","formatValue","useChartsTheme","CalculationsMap","DEFAULT_CALCULATION","merge","useMemo","DEFAULT_FORMAT","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","GaugeChartBase","convertThresholds","defaultThresholdInput","EMPTY_GAUGE_SERIES","label","value","undefined","GAUGE_MIN_WIDTH","PANEL_PADDING_OFFSET","getResponsiveProgressWidth","width","height","MIN_WIDTH","MAX_WIDTH","RATIO","minSize","Math","min","max","round","getResponsiveValueFontSize","format","MIN_SIZE","MAX_SIZE","formattedValue","valueTextLength","length","availableSpace","fontSize","getResponsiveTitleFontSize","size","GaugeChartPanel","props","spec","pluginSpec","contentDimensions","queryResults","calculation","legend","thresholds","thresholdsColors","showLegend","show","gaugeData","seriesData","console","warn","calculate","result","timeSeries","data","series","push","values","formattedName","thresholdMax","unit","axisLineColors","chartWidth","progressWidth","axisLineWidth","titleFontSize","axisLine","lineStyle","color","emptyValueFontSize","emptyProgressWidth","emptyTitleFontSize","valueFontSize","hasMultipleCharts","direction","spacing","justifyContent","alignItems","sx","overflowX","map","seriesIndex","GaugeChartLoading","margin","variant"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,GAAG,EAAEC,QAAQ,EAAEC,KAAK,QAAQ,gBAAgB;AAErD,SAASC,WAAW,EAAEC,cAAc,QAAQ,yBAAyB;AAErE,SAASC,eAAe,EAAEC,mBAAmB,QAAQ,4BAA4B;AAGjF,OAAOC,WAAW,eAAe;AAEjC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,2BAA2B,QAAQ,yBAAsB;AAEvG,SAASC,cAAc,QAAQ,sBAAmB;AAClD,SAASC,iBAAiB,EAAEC,qBAAqB,QAAQ,kBAAe;AAExE,MAAMC,qBAAkC;IAAEC,OAAO;IAAIC,OAAOC;AAAU;AACtE,MAAMC,kBAAkB;AACxB,MAAMC,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KAAKqC;oBACLa,eAAexC;oBACf+B,eAAeA;oBACfE,eAAeA;;eAVT,CAAC,aAAa,EAAEgB,aAAa;QAc3C;;AAGN;AAEA,OAAO,SAASC,kBAAkB,EAAE3C,iBAAiB,EAAwB;IAC3E,IAAI,CAACA,mBAAmB,OAAO;IAC/B,qBACE,KAAC9C;QACCqF,IAAI;YAAEK,QAAQ;QAAS;QACvBC,SAAQ;QACRtE,OAAOyB,kBAAkBzB,KAAK,GAAGyB,kBAAkBxB,MAAM,GAAGwB,kBAAkBxB,MAAM,GAAGwB,kBAAkBzB,KAAK;QAC9GC,QAAQwB,kBAAkBxB,MAAM;;AAGtC"}
|
package/lib/bootstrap.js
CHANGED
|
@@ -11,8 +11,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
-
import React from
|
|
15
|
-
import ReactDOM from
|
|
14
|
+
import React from "react";
|
|
15
|
+
import ReactDOM from "react-dom/client";
|
|
16
16
|
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
17
17
|
root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
|
|
18
18
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FormatOptions, ThresholdOptions } from '@perses-dev/components';
|
|
2
|
-
import { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
-
import { Definition } from '@perses-dev/spec';
|
|
1
|
+
import type { FormatOptions, ThresholdOptions } from '@perses-dev/components';
|
|
2
|
+
import type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
3
|
+
import type { Definition } from '@perses-dev/spec';
|
|
4
4
|
export declare const DEFAULT_FORMAT: FormatOptions;
|
|
5
5
|
export declare const DEFAULT_MAX_PERCENT = 100;
|
|
6
6
|
export declare const DEFAULT_MAX_PERCENT_DECIMAL = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gauge-chart-model.d.ts","sourceRoot":"","sources":["../../src/gauge-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"gauge-chart-model.d.ts","sourceRoot":"","sources":["../../src/gauge-chart-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,eAAO,MAAM,cAAc,EAAE,aAA2C,CAAC;AACzE,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IACzE,IAAI,EAAE,YAAY,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7B;AAED,MAAM,MAAM,4BAA4B,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;AAEjF;;GAEG;AACH,wBAAgB,8BAA8B,IAAI,iBAAiB,CAelE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/gauge-chart-model.ts"],"sourcesContent":["// Copyright 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 { FormatOptions, ThresholdOptions } from '@perses-dev/components';\nimport { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\nexport const DEFAULT_MAX_PERCENT = 100;\nexport const DEFAULT_MAX_PERCENT_DECIMAL = 1;\n\n/**\n * The schema for a GaugeChart panel.\n */\nexport interface GaugeChartDefinition extends Definition<GaugeChartOptions> {\n kind: 'GaugeChart';\n}\n\n/**\n * The Options object type supported by the GaugeChart panel plugin.\n */\nexport interface GaugeChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n thresholds?: ThresholdOptions;\n max?: number;\n legend?: { show?: boolean };\n}\n\nexport type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;\n\n/**\n * Creates the initial/empty options for a GaugeChart panel.\n */\nexport function createInitialGaugeChartOptions(): GaugeChartOptions {\n return {\n calculation: 'last-number',\n format: DEFAULT_FORMAT,\n thresholds: {\n steps: [\n {\n value: 0.8,\n },\n {\n value: 0.9,\n },\n ],\n },\n };\n}\n"],"names":["DEFAULT_FORMAT","unit","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","createInitialGaugeChartOptions","calculation","format","thresholds","steps","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC,OAAO,MAAMA,iBAAgC;IAAEC,MAAM;AAAkB,EAAE;AACzE,OAAO,MAAMC,sBAAsB,IAAI;AACvC,OAAO,MAAMC,8BAA8B,EAAE;AAsB7C;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQN;QACRO,YAAY;YACVC,OAAO;gBACL;oBACEC,OAAO;gBACT;gBACA;oBACEA,OAAO;gBACT;aACD;QACH;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/gauge-chart-model.ts"],"sourcesContent":["// Copyright 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 type { FormatOptions, ThresholdOptions } from '@perses-dev/components';\nimport type { CalculationType, OptionsEditorProps } from '@perses-dev/plugin-system';\nimport type { Definition } from '@perses-dev/spec';\n\nexport const DEFAULT_FORMAT: FormatOptions = { unit: 'percent-decimal' };\nexport const DEFAULT_MAX_PERCENT = 100;\nexport const DEFAULT_MAX_PERCENT_DECIMAL = 1;\n\n/**\n * The schema for a GaugeChart panel.\n */\nexport interface GaugeChartDefinition extends Definition<GaugeChartOptions> {\n kind: 'GaugeChart';\n}\n\n/**\n * The Options object type supported by the GaugeChart panel plugin.\n */\nexport interface GaugeChartOptions {\n calculation: CalculationType;\n format?: FormatOptions;\n thresholds?: ThresholdOptions;\n max?: number;\n legend?: { show?: boolean };\n}\n\nexport type GaugeChartOptionsEditorProps = OptionsEditorProps<GaugeChartOptions>;\n\n/**\n * Creates the initial/empty options for a GaugeChart panel.\n */\nexport function createInitialGaugeChartOptions(): GaugeChartOptions {\n return {\n calculation: 'last-number',\n format: DEFAULT_FORMAT,\n thresholds: {\n steps: [\n {\n value: 0.8,\n },\n {\n value: 0.9,\n },\n ],\n },\n };\n}\n"],"names":["DEFAULT_FORMAT","unit","DEFAULT_MAX_PERCENT","DEFAULT_MAX_PERCENT_DECIMAL","createInitialGaugeChartOptions","calculation","format","thresholds","steps","value"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAMjC,OAAO,MAAMA,iBAAgC;IAAEC,MAAM;AAAkB,EAAE;AACzE,OAAO,MAAMC,sBAAsB,IAAI;AACvC,OAAO,MAAMC,8BAA8B,EAAE;AAsB7C;;CAEC,GACD,OAAO,SAASC;IACd,OAAO;QACLC,aAAa;QACbC,QAAQN;QACRO,YAAY;YACVC,OAAO;gBACL;oBACEC,OAAO;gBACT;gBACA;oBACEA,OAAO;gBACT;aACD;QACH;IACF;AACF"}
|
package/lib/getPluginModule.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAIxF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}
|
package/lib/getPluginModule.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
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 packageJson from
|
|
13
|
+
import packageJson from "../package.json" with {
|
|
14
|
+
type: 'json'
|
|
15
|
+
};
|
|
14
16
|
/**
|
|
15
17
|
* Returns the plugin module information from package.json
|
|
16
18
|
*/ export function getPluginModule() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright 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 { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;
|
|
1
|
+
{"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["// Copyright 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 type { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\n\nimport packageJson from '../package.json' with { type: 'json' };\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","type","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,OAAOA,iBAAiB,uBAAuB;IAAEC,MAAM;AAAO,EAAE;AAEhE;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGL;IAClC,OAAO;QACLM,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
|
package/lib/index-federation.js
CHANGED
|
@@ -10,6 +10,6 @@
|
|
|
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(
|
|
13
|
+
import("./bootstrap.js");
|
|
14
14
|
|
|
15
15
|
//# sourceMappingURL=index-federation.js.map
|
package/lib/index.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
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
|
-
export * from
|
|
14
|
-
export * from
|
|
15
|
-
export * from
|
|
16
|
-
export * from
|
|
17
|
-
export { getPluginModule } from
|
|
18
|
-
export * from
|
|
13
|
+
export * from "./gauge-chart-model.js";
|
|
14
|
+
export * from "./GaugeChart.js";
|
|
15
|
+
export * from "./GaugeChartOptionsEditorSettings.js";
|
|
16
|
+
export * from "./GaugeChartPanel.js";
|
|
17
|
+
export { getPluginModule } from "./getPluginModule.js";
|
|
18
|
+
export * from "./thresholds.js";
|
|
19
19
|
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 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 './gauge-chart-model';\nexport * from './GaugeChart';\nexport * from './GaugeChartOptionsEditorSettings';\nexport * from './GaugeChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './thresholds';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["// Copyright 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 './gauge-chart-model';\nexport * from './GaugeChart';\nexport * from './GaugeChartOptionsEditorSettings';\nexport * from './GaugeChartPanel';\nexport { getPluginModule } from './getPluginModule';\nexport * from './thresholds';\n"],"names":["getPluginModule"],"mappings":"AAAA,+BAA+B;AAC/B,oEAAoE;AACpE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,sEAAsE;AACtE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,yBAAsB;AACpC,cAAc,kBAAe;AAC7B,cAAc,uCAAoC;AAClD,cAAc,uBAAoB;AAClC,SAASA,eAAe,QAAQ,uBAAoB;AACpD,cAAc,kBAAe"}
|
package/lib/setup-tests.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
2
|
//# sourceMappingURL=setup-tests.d.ts.map
|
package/lib/setup-tests.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,kCAAkC,CAAC"}
|
package/lib/setup-tests.js
CHANGED
|
@@ -10,8 +10,8 @@
|
|
|
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
|
|
13
|
+
import "@testing-library/jest-dom/vitest";
|
|
14
14
|
// Always mock e-charts during tests since we don't have a proper canvas in jsdom
|
|
15
|
-
|
|
15
|
+
vi.mock('echarts/core');
|
|
16
16
|
|
|
17
17
|
//# sourceMappingURL=setup-tests.js.map
|
package/lib/setup-tests.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\
|
|
1
|
+
{"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 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 '@testing-library/jest-dom/vitest';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\nvi.mock('echarts/core');\n"],"names":["vi","mock"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,mCAAmC;AAE1C,iFAAiF;AACjFA,GAAGC,IAAI,CAAC"}
|
package/lib/thresholds.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
|
|
1
|
+
import type { FormatOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';
|
|
2
2
|
export type GaugeColorStop = [number, string];
|
|
3
3
|
export type EChartsAxisLineColors = GaugeColorStop[];
|
|
4
4
|
export declare const defaultThresholdInput: ThresholdOptions;
|
package/lib/thresholds.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/thresholds.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/thresholds.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAe,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGlH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,cAAc,EAAE,CAAC;AAErD,eAAO,MAAM,qBAAqB,EAAE,gBAA4C,CAAC;AAEjF,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,gBAAgB,EAC5B,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,qBAAqB,GAC7B,qBAAqB,CA4BvB"}
|
package/lib/thresholds.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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 zip from
|
|
13
|
+
import zip from "lodash/zip";
|
|
14
14
|
export const defaultThresholdInput = {
|
|
15
15
|
steps: [
|
|
16
16
|
{
|
package/lib/thresholds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/thresholds.ts"],"sourcesContent":["// Copyright 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 { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette
|
|
1
|
+
{"version":3,"sources":["../../src/thresholds.ts"],"sourcesContent":["// Copyright 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 type { FormatOptions, StepOptions, ThresholdColorPalette, ThresholdOptions } from '@perses-dev/components';\nimport zip from 'lodash/zip';\n\nexport type GaugeColorStop = [number, string];\n\nexport type EChartsAxisLineColors = GaugeColorStop[];\n\nexport const defaultThresholdInput: ThresholdOptions = { steps: [{ value: 0 }] };\n\nexport function convertThresholds(\n thresholds: ThresholdOptions,\n unit: FormatOptions,\n max: number,\n palette: ThresholdColorPalette,\n): EChartsAxisLineColors {\n const defaultThresholdColor = thresholds.defaultColor ?? palette.defaultColor;\n const defaultThresholdSteps: EChartsAxisLineColors = [[0, defaultThresholdColor]];\n\n if (thresholds.steps !== undefined) {\n // https://echarts.apache.org/en/option.html#series-gauge.axisLine.lineStyle.color\n // color segments must be decimal between 0 and 1\n const segmentMax = 1;\n const valuesArr: number[] = thresholds.steps.map((step: StepOptions) => {\n if (thresholds.mode === 'percent') {\n return step.value / 100;\n }\n return step.value / max;\n });\n valuesArr.push(segmentMax);\n\n const colorsArr = thresholds.steps.map((step: StepOptions, index) => step.color ?? palette.palette[index]);\n colorsArr.unshift(defaultThresholdColor);\n\n const zippedArr = zip(valuesArr, colorsArr);\n return zippedArr.map((elem) => {\n const convertedValues = elem[0] ?? segmentMax;\n const convertedColors = elem[1] ?? defaultThresholdColor;\n return [convertedValues, convertedColors];\n });\n } else {\n return defaultThresholdSteps;\n }\n}\n"],"names":["zip","defaultThresholdInput","steps","value","convertThresholds","thresholds","unit","max","palette","defaultThresholdColor","defaultColor","defaultThresholdSteps","undefined","segmentMax","valuesArr","map","step","mode","push","colorsArr","index","color","unshift","zippedArr","elem","convertedValues","convertedColors"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAOA,SAAS,aAAa;AAM7B,OAAO,MAAMC,wBAA0C;IAAEC,OAAO;QAAC;YAAEC,OAAO;QAAE;KAAE;AAAC,EAAE;AAEjF,OAAO,SAASC,kBACdC,UAA4B,EAC5BC,IAAmB,EACnBC,GAAW,EACXC,OAA8B;IAE9B,MAAMC,wBAAwBJ,WAAWK,YAAY,IAAIF,QAAQE,YAAY;IAC7E,MAAMC,wBAA+C;QAAC;YAAC;YAAGF;SAAsB;KAAC;IAEjF,IAAIJ,WAAWH,KAAK,KAAKU,WAAW;QAClC,kFAAkF;QAClF,iDAAiD;QACjD,MAAMC,aAAa;QACnB,MAAMC,YAAsBT,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC;YAChD,IAAIX,WAAWY,IAAI,KAAK,WAAW;gBACjC,OAAOD,KAAKb,KAAK,GAAG;YACtB;YACA,OAAOa,KAAKb,KAAK,GAAGI;QACtB;QACAO,UAAUI,IAAI,CAACL;QAEf,MAAMM,YAAYd,WAAWH,KAAK,CAACa,GAAG,CAAC,CAACC,MAAmBI,QAAUJ,KAAKK,KAAK,IAAIb,QAAQA,OAAO,CAACY,MAAM;QACzGD,UAAUG,OAAO,CAACb;QAElB,MAAMc,YAAYvB,IAAIc,WAAWK;QACjC,OAAOI,UAAUR,GAAG,CAAC,CAACS;YACpB,MAAMC,kBAAkBD,IAAI,CAAC,EAAE,IAAIX;YACnC,MAAMa,kBAAkBF,IAAI,CAAC,EAAE,IAAIf;YACnC,OAAO;gBAACgB;gBAAiBC;aAAgB;QAC3C;IACF,OAAO;QACL,OAAOf;IACT;AACF"}
|
package/mf-manifest.json
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
"name": "GaugeChart",
|
|
6
6
|
"type": "app",
|
|
7
7
|
"buildInfo": {
|
|
8
|
-
"buildVersion": "0.
|
|
8
|
+
"buildVersion": "0.14.0-beta.2",
|
|
9
9
|
"buildName": "@perses-dev/gauge-chart-plugin"
|
|
10
10
|
},
|
|
11
11
|
"remoteEntry": {
|
|
12
|
-
"name": "__mf/js/GaugeChart.
|
|
12
|
+
"name": "__mf/js/GaugeChart.d0898a25.js",
|
|
13
13
|
"path": "",
|
|
14
14
|
"type": "global"
|
|
15
15
|
},
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"zip": "",
|
|
20
20
|
"api": ""
|
|
21
21
|
},
|
|
22
|
-
"globalName": "
|
|
22
|
+
"globalName": "GaugeChart_0_14_0_beta_2",
|
|
23
23
|
"pluginVersion": "2.6.0",
|
|
24
|
-
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/GaugeChart/\"; }"
|
|
24
|
+
"getPublicPath": "function() { const prefix = window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\"; return prefix + \"/plugins/GaugeChart~0.14.0-beta.2/\"; }"
|
|
25
25
|
},
|
|
26
26
|
"shared": [
|
|
27
27
|
{
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"js": {
|
|
35
35
|
"async": [],
|
|
36
36
|
"sync": [
|
|
37
|
-
"__mf/js/async/274.
|
|
37
|
+
"__mf/js/async/274.481c2cff.js"
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"css": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"js": {
|
|
55
55
|
"async": [],
|
|
56
56
|
"sync": [
|
|
57
|
-
"__mf/js/async/235.
|
|
58
|
-
"__mf/js/async/616.
|
|
59
|
-
"__mf/js/async/854.
|
|
57
|
+
"__mf/js/async/235.3d14b76d.js",
|
|
58
|
+
"__mf/js/async/616.56af3d9a.js",
|
|
59
|
+
"__mf/js/async/854.23201b26.js"
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
"css": {
|
|
@@ -76,8 +76,8 @@
|
|
|
76
76
|
"js": {
|
|
77
77
|
"async": [],
|
|
78
78
|
"sync": [
|
|
79
|
-
"__mf/js/async/587.
|
|
80
|
-
"__mf/js/async/968.
|
|
79
|
+
"__mf/js/async/587.b53469e7.js",
|
|
80
|
+
"__mf/js/async/968.fbee556d.js"
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"css": {
|
|
@@ -90,20 +90,20 @@
|
|
|
90
90
|
{
|
|
91
91
|
"id": "GaugeChart:@perses-dev/components",
|
|
92
92
|
"name": "@perses-dev/components",
|
|
93
|
-
"version": "0.
|
|
93
|
+
"version": "0.55.0-beta.7",
|
|
94
94
|
"singleton": true,
|
|
95
|
-
"requiredVersion": "^0.
|
|
95
|
+
"requiredVersion": "^0.55.0-beta.7",
|
|
96
96
|
"assets": {
|
|
97
97
|
"js": {
|
|
98
98
|
"async": [],
|
|
99
99
|
"sync": [
|
|
100
|
-
"__mf/js/async/
|
|
100
|
+
"__mf/js/async/463.1623acc4.js"
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
103
|
"css": {
|
|
104
104
|
"async": [],
|
|
105
105
|
"sync": [
|
|
106
|
-
"__mf/css/async/
|
|
106
|
+
"__mf/css/async/463.85c2cbf6.css"
|
|
107
107
|
]
|
|
108
108
|
}
|
|
109
109
|
},
|
|
@@ -112,14 +112,14 @@
|
|
|
112
112
|
{
|
|
113
113
|
"id": "GaugeChart:@perses-dev/plugin-system",
|
|
114
114
|
"name": "@perses-dev/plugin-system",
|
|
115
|
-
"version": "0.
|
|
115
|
+
"version": "0.55.0-beta.7",
|
|
116
116
|
"singleton": true,
|
|
117
|
-
"requiredVersion": "^0.
|
|
117
|
+
"requiredVersion": "^0.55.0-beta.7",
|
|
118
118
|
"assets": {
|
|
119
119
|
"js": {
|
|
120
120
|
"async": [],
|
|
121
121
|
"sync": [
|
|
122
|
-
"__mf/js/async/
|
|
122
|
+
"__mf/js/async/407.549724e8.js"
|
|
123
123
|
]
|
|
124
124
|
},
|
|
125
125
|
"css": {
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"js": {
|
|
140
140
|
"async": [],
|
|
141
141
|
"sync": [
|
|
142
|
-
"__mf/js/async/192.
|
|
142
|
+
"__mf/js/async/192.66cc8639.js"
|
|
143
143
|
]
|
|
144
144
|
},
|
|
145
145
|
"css": {
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"js": {
|
|
160
160
|
"async": [],
|
|
161
161
|
"sync": [
|
|
162
|
-
"__mf/js/async/873.
|
|
162
|
+
"__mf/js/async/873.828ee17a.js"
|
|
163
163
|
]
|
|
164
164
|
},
|
|
165
165
|
"css": {
|
|
@@ -179,7 +179,7 @@
|
|
|
179
179
|
"js": {
|
|
180
180
|
"async": [],
|
|
181
181
|
"sync": [
|
|
182
|
-
"__mf/js/async/963.
|
|
182
|
+
"__mf/js/async/963.8f8fc110.js"
|
|
183
183
|
]
|
|
184
184
|
},
|
|
185
185
|
"css": {
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
"js": {
|
|
200
200
|
"async": [],
|
|
201
201
|
"sync": [
|
|
202
|
-
"__mf/js/async/392.
|
|
202
|
+
"__mf/js/async/392.589be345.js"
|
|
203
203
|
]
|
|
204
204
|
},
|
|
205
205
|
"css": {
|
|
@@ -219,7 +219,7 @@
|
|
|
219
219
|
"js": {
|
|
220
220
|
"async": [],
|
|
221
221
|
"sync": [
|
|
222
|
-
"__mf/js/async/496.
|
|
222
|
+
"__mf/js/async/496.ddfbee86.js"
|
|
223
223
|
]
|
|
224
224
|
},
|
|
225
225
|
"css": {
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"js": {
|
|
240
240
|
"async": [],
|
|
241
241
|
"sync": [
|
|
242
|
-
"__mf/js/async/470.
|
|
242
|
+
"__mf/js/async/470.a5788e56.js"
|
|
243
243
|
]
|
|
244
244
|
},
|
|
245
245
|
"css": {
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
"js": {
|
|
260
260
|
"async": [],
|
|
261
261
|
"sync": [
|
|
262
|
-
"__mf/js/async/121.
|
|
262
|
+
"__mf/js/async/121.923647b2.js"
|
|
263
263
|
]
|
|
264
264
|
},
|
|
265
265
|
"css": {
|
|
@@ -279,8 +279,8 @@
|
|
|
279
279
|
"js": {
|
|
280
280
|
"async": [],
|
|
281
281
|
"sync": [
|
|
282
|
-
"__mf/js/async/458.
|
|
283
|
-
"__mf/js/async/77.
|
|
282
|
+
"__mf/js/async/458.c3d7080e.js",
|
|
283
|
+
"__mf/js/async/77.84340477.js"
|
|
284
284
|
]
|
|
285
285
|
},
|
|
286
286
|
"css": {
|
|
@@ -300,7 +300,7 @@
|
|
|
300
300
|
"js": {
|
|
301
301
|
"async": [],
|
|
302
302
|
"sync": [
|
|
303
|
-
"__mf/js/async/978.
|
|
303
|
+
"__mf/js/async/978.75bd4607.js"
|
|
304
304
|
]
|
|
305
305
|
},
|
|
306
306
|
"css": {
|
|
@@ -319,26 +319,25 @@
|
|
|
319
319
|
"assets": {
|
|
320
320
|
"js": {
|
|
321
321
|
"sync": [
|
|
322
|
-
"__mf/js/async/403.
|
|
323
|
-
"__mf/js/async/823.
|
|
324
|
-
"__mf/js/async/
|
|
325
|
-
"__mf/js/async/
|
|
326
|
-
"__mf/js/async/__federation_expose_GaugeChart.
|
|
322
|
+
"__mf/js/async/403.f63f0b01.js",
|
|
323
|
+
"__mf/js/async/823.ed9ab057.js",
|
|
324
|
+
"__mf/js/async/208.1dc9d791.js",
|
|
325
|
+
"__mf/js/async/844.8884c953.js",
|
|
326
|
+
"__mf/js/async/__federation_expose_GaugeChart.a608d5e4.js"
|
|
327
327
|
],
|
|
328
328
|
"async": [
|
|
329
|
-
"__mf/js/async/588.
|
|
330
|
-
"__mf/js/async/71.
|
|
331
|
-
"__mf/js/async/
|
|
332
|
-
"__mf/js/async/
|
|
333
|
-
"__mf/js/async/lib-router.
|
|
334
|
-
"__mf/js/async/356.
|
|
335
|
-
"__mf/js/async/177.2e554778.js"
|
|
329
|
+
"__mf/js/async/588.231edddc.js",
|
|
330
|
+
"__mf/js/async/71.5c044eb7.js",
|
|
331
|
+
"__mf/js/async/410.41a2ea21.js",
|
|
332
|
+
"__mf/js/async/710.63c7c633.js",
|
|
333
|
+
"__mf/js/async/lib-router.a426c87f.js",
|
|
334
|
+
"__mf/js/async/356.81432231.js"
|
|
336
335
|
]
|
|
337
336
|
},
|
|
338
337
|
"css": {
|
|
339
338
|
"sync": [],
|
|
340
339
|
"async": [
|
|
341
|
-
"__mf/css/async/
|
|
340
|
+
"__mf/css/async/463.85c2cbf6.css"
|
|
342
341
|
]
|
|
343
342
|
}
|
|
344
343
|
},
|