From cdb776866aec1d9f67822744eec01ba8aa67bc9d Mon Sep 17 00:00:00 2001 From: Qiuxia Fan Date: Sat, 26 Mar 2022 20:48:49 +0800 Subject: [PATCH] delete config --- src/views/dashboard/data.ts | 2 +- .../related/topology/components/Metrics.vue | 3 +- .../related/topology/components/Settings.vue | 45 ++++++++++++++++--- 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index c9b061a4..265b8251 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -244,7 +244,7 @@ export enum LegendOpt { } export const DepthList = [1, 2, 3, 4, 5].map((item: number) => ({ value: item, - label: item, + label: String(item), })); export const Status = [ { label: "All", value: "ALL" }, diff --git a/src/views/dashboard/related/topology/components/Metrics.vue b/src/views/dashboard/related/topology/components/Metrics.vue index 0a79ce95..d4c6bbfd 100644 --- a/src/views/dashboard/related/topology/components/Metrics.vue +++ b/src/views/dashboard/related/topology/components/Metrics.vue @@ -119,10 +119,11 @@ function changeMetric(val: string) { currentIndex.value = index || 0; const config = getMetricConfig.value; - currentConfig.value = config[index] || { + currentConfig.value = { unit: "", label: "", calculation: "", + ...config[index], }; } watch( diff --git a/src/views/dashboard/related/topology/components/Settings.vue b/src/views/dashboard/related/topology/components/Settings.vue index ed485ccc..97cb00d6 100644 --- a/src/views/dashboard/related/topology/components/Settings.vue +++ b/src/views/dashboard/related/topology/components/Settings.vue @@ -416,10 +416,22 @@ function updateSettings(config?: { [key: string]: MetricConfigOpt[] }) { dashboardStore.selectWidget({ ...dashboardStore.selectedGrid, ...param }); dashboardStore.setConfigs({ ...dashboardStore.selectedGrid, ...param }); emit("update", param); + console.log(dashboardStore.selectedGrid); } function updateLinkServerMetrics(options: Option[] | any) { - states.linkServerMetrics = options.map((d: Option) => d.value); - changeLinkServerMetrics(); + const opt = options.map((d: Option) => d.value); + const index = states.linkServerMetrics.findIndex( + (d: any) => !opt.includes(d) + ); + states.linkServerMetrics = opt; + if (index < 0) { + changeLinkServerMetrics(); + return; + } + const config = ( + dashboardStore.selectedGrid.linkServerMetricConfig || [] + ).splice(index, 1); + changeLinkServerMetrics({ linkServerMetricConfig: config }); } async function changeLinkServerMetrics(config?: { [key: string]: MetricConfigOpt[]; @@ -432,8 +444,19 @@ async function changeLinkServerMetrics(config?: { topologyStore.getLinkServerMetrics(states.linkServerMetrics); } function updateLinkClientMetrics(options: Option[] | any) { - states.linkClientMetrics = options.map((d: Option) => d.value); - changeLinkClientMetrics(); + const opt = options.map((d: Option) => d.value); + const index = states.linkClientMetrics.findIndex( + (d: any) => !opt.includes(d) + ); + states.linkClientMetrics = opt; + if (index < 0) { + changeLinkClientMetrics(); + return; + } + const config = ( + dashboardStore.selectedGrid.linkClientMetricConfig || [] + ).splice(index, 1); + changeLinkClientMetrics({ linkClientMetricConfig: config }); } async function changeLinkClientMetrics(config?: { [key: string]: MetricConfigOpt[]; @@ -446,8 +469,18 @@ async function changeLinkClientMetrics(config?: { topologyStore.getLinkClientMetrics(states.linkClientMetrics); } function updateNodeMetrics(options: Option[] | any) { - states.nodeMetrics = options.map((d: Option) => d.value); - changeNodeMetrics(); + const opt = options.map((d: Option) => d.value); + const index = states.nodeMetrics.findIndex((d: any) => !opt.includes(d)); + states.nodeMetrics = opt; + if (index < 0) { + changeNodeMetrics(); + return; + } + const config = (dashboardStore.selectedGrid.nodeMetricConfig || []).splice( + index, + 1 + ); + changeNodeMetrics({ nodeMetricConfig: config }); } async function changeNodeMetrics(config?: { [key: string]: MetricConfigOpt[];