diff --git a/src/views/dashboard/related/topology/components/Metrics.vue b/src/views/dashboard/related/topology/components/Metrics.vue index d4c6bbfd..d2507b6d 100644 --- a/src/views/dashboard/related/topology/components/Metrics.vue +++ b/src/views/dashboard/related/topology/components/Metrics.vue @@ -117,7 +117,7 @@ function changeMetric(val: string) { currentMetric.value = val; const index = metrics.value.findIndex((d: Option) => d.value === val); currentIndex.value = index || 0; - const config = getMetricConfig.value; + const config = getMetricConfig.value || []; currentConfig.value = { unit: "", @@ -125,6 +125,7 @@ function changeMetric(val: string) { calculation: "", ...config[index], }; + console.log(currentConfig.value); } watch( () => props.type, @@ -134,14 +135,15 @@ watch( }); metrics.value = m.length ? m : [{ label: "", value: "" }]; currentMetric.value = metrics.value[0].value; - const config = getMetricConfig.value; + const config = getMetricConfig.value || []; currentIndex.value = 0; - currentConfig.value = config[0] || { + currentConfig.value = { unit: "", label: "", calculation: "", + ...config[0], }; - console.log(currentConfig.value); + console.log(config); } ); diff --git a/src/views/dashboard/related/topology/components/Settings.vue b/src/views/dashboard/related/topology/components/Settings.vue index 97cb00d6..0cb8b41f 100644 --- a/src/views/dashboard/related/topology/components/Settings.vue +++ b/src/views/dashboard/related/topology/components/Settings.vue @@ -416,7 +416,6 @@ 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) { const opt = options.map((d: Option) => d.value); @@ -428,9 +427,8 @@ function updateLinkServerMetrics(options: Option[] | any) { changeLinkServerMetrics(); return; } - const config = ( - dashboardStore.selectedGrid.linkServerMetricConfig || [] - ).splice(index, 1); + const origin = dashboardStore.selectedGrid.linkServerMetricConfig || []; + const config = origin.length === 1 ? [] : origin.splice(index, 1); changeLinkServerMetrics({ linkServerMetricConfig: config }); } async function changeLinkServerMetrics(config?: { @@ -453,9 +451,8 @@ function updateLinkClientMetrics(options: Option[] | any) { changeLinkClientMetrics(); return; } - const config = ( - dashboardStore.selectedGrid.linkClientMetricConfig || [] - ).splice(index, 1); + const origin = dashboardStore.selectedGrid.linkClientMetricConfig || []; + const config = origin.length === 1 ? [] : origin.splice(index, 1); changeLinkClientMetrics({ linkClientMetricConfig: config }); } async function changeLinkClientMetrics(config?: { @@ -476,10 +473,8 @@ function updateNodeMetrics(options: Option[] | any) { changeNodeMetrics(); return; } - const config = (dashboardStore.selectedGrid.nodeMetricConfig || []).splice( - index, - 1 - ); + const origin = dashboardStore.selectedGrid.nodeMetricConfig || []; + const config = origin.length === 1 ? [] : origin.splice(index, 1); changeNodeMetrics({ nodeMetricConfig: config }); } async function changeNodeMetrics(config?: {