From 60795553f452ffa3392cf889aec2fad21d035a16 Mon Sep 17 00:00:00 2001 From: rivery Date: Wed, 14 Dec 2022 15:25:15 +0800 Subject: [PATCH] fix: some bugs in 1230iterration --- src/components/Charts/LineChart.tsx | 2 +- src/components/DashboardCard/LineCard.tsx | 2 +- src/components/Service/ServiceCardEdit/index.tsx | 8 +------- src/pages/MachineDashboard/Cards/DiskCard.tsx | 1 + src/pages/MachineDashboard/Detail/index.tsx | 2 +- src/store/models/service.ts | 9 +++++---- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/Charts/LineChart.tsx b/src/components/Charts/LineChart.tsx index 64c63269..8593d0c5 100644 --- a/src/components/Charts/LineChart.tsx +++ b/src/components/Charts/LineChart.tsx @@ -286,7 +286,7 @@ function LineChart(props: IProps, ref) { items.map(item => { let value = item.value; if (options.valueType === VALUE_TYPE.numberSecond) { - value = `${value}/s`; + value = `${Math.round(+value * 100) / 100}/s`; } return { ...item, diff --git a/src/components/DashboardCard/LineCard.tsx b/src/components/DashboardCard/LineCard.tsx index c54af2cf..5004bf01 100644 --- a/src/components/DashboardCard/LineCard.tsx +++ b/src/components/DashboardCard/LineCard.tsx @@ -25,7 +25,7 @@ function LineCard(props: IProps) { }, [loading, chartRef.current]); useEffect(() => { - if (baseLine && chartRef.current) { + if (baseLine != undefined && chartRef.current) { chartRef.current.updateBaseline(baseLine); } }, [baseLine, chartRef.current]); diff --git a/src/components/Service/ServiceCardEdit/index.tsx b/src/components/Service/ServiceCardEdit/index.tsx index 7a1eed79..c89c9ae9 100644 --- a/src/components/Service/ServiceCardEdit/index.tsx +++ b/src/components/Service/ServiceCardEdit/index.tsx @@ -39,12 +39,6 @@ function ServiceCardEdit(props: IProps) { const handlePanelConfigUpdate = (values: any) => { const { period, space, metric, aggregation, baseLine } = values; - // const metricTypeList = curServiceMetricItems.find( - // item => item.metric === metric, - // )?.aggregations; - // const metricType = metricTypeList?.find( - // type => type === aggregation, - // ); const _config = cloneDeep(panelConfig); _config[editType][editIndex] = { period, @@ -54,7 +48,7 @@ function ServiceCardEdit(props: IProps) { space, }; onPanelConfigUpdate(_config); - localStorage.setItem('panelConfig', JSON.stringify(_config)); + // localStorage.setItem('panelConfig', JSON.stringify(_config)); onClose(); }; diff --git a/src/pages/MachineDashboard/Cards/DiskCard.tsx b/src/pages/MachineDashboard/Cards/DiskCard.tsx index fbc37475..df6cb2a4 100644 --- a/src/pages/MachineDashboard/Cards/DiskCard.tsx +++ b/src/pages/MachineDashboard/Cards/DiskCard.tsx @@ -11,6 +11,7 @@ const mapState = (state: IRootState) => { const { aliasConfig } = state.app; const { instanceList } = metricsFilterValues; + return { // According to type, only the detail increases total diskUsageDetails: diskStat diff --git a/src/pages/MachineDashboard/Detail/index.tsx b/src/pages/MachineDashboard/Detail/index.tsx index d4711a20..d3189de7 100644 --- a/src/pages/MachineDashboard/Detail/index.tsx +++ b/src/pages/MachineDashboard/Detail/index.tsx @@ -134,7 +134,7 @@ function Detail(props: IProps) { }) } Promise.all(metricCharts.map((chart, i) => { - if (curMetricOptions.find(m => m.metric === chart.metric.metric)) { + if (curMetricOptions.length === 0 || curMetricOptions.find(m => m.metric === chart.metric.metric)) { return getPromise(chart); } else { return Promise.resolve(dataSources[i]); diff --git a/src/store/models/service.ts b/src/store/models/service.ts index 33c9a419..9f780937 100644 --- a/src/store/models/service.ts +++ b/src/store/models/service.ts @@ -1,7 +1,7 @@ import { createModel } from '@rematch/core'; import _ from 'lodash'; import serviceApi from '@/config/service'; -import { IPanelConfig, IServicePanelConfig, ServiceMetricsPanelValue, ServiceName } from '@/utils/interface'; +import { IPanelConfig, ServiceMetricsPanelValue } from '@/utils/interface'; import { DEFAULT_SERVICE_PANEL_CONFIG } from '@/utils/service'; import { getProperStep } from '@/utils/dashboard'; import { unique } from '@/utils'; @@ -17,9 +17,10 @@ interface IState { export function SereviceModelWrapper(serviceApi) { return createModel({ state: { - panelConfig: localStorage.getItem('panelConfig') - ? JSON.parse(localStorage.getItem('panelConfig')!) - : DEFAULT_SERVICE_PANEL_CONFIG, + // panelConfig: localStorage.getItem('panelConfig') + // ? JSON.parse(localStorage.getItem('panelConfig')!) + // : DEFAULT_SERVICE_PANEL_CONFIG, + panelConfig: DEFAULT_SERVICE_PANEL_CONFIG, instanceList: [], metricsFilterValues: InitMetricsFilterValues },