From dd4e106c1c85808ae5f93efc9670b8359037e773 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 16 Jan 2024 17:55:24 +0800 Subject: [PATCH] fix: config --- src/views/dashboard/List.vue | 10 +++++----- .../related/topology/config/Metrics.vue | 20 +++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index 05a31b65..40e76bb9 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -315,19 +315,19 @@ limitations under the License. --> } loading.value = true; for (const item of arr) { - const { layer, name, entity, isRoot, children, isDefault } = item.configuration; + const { layer, name, entity, isRoot, children, isDefault, expressions, expressionsConfig } = item.configuration; const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id); const p: DashboardItem = { name: name.split(" ").join("-"), layer: layer, entity: entity, - isRoot: false, - isDefault: false, + isRoot: isRoot || false, + isDefault: isDefault || false, + expressions: expressions, + expressionsConfig: expressionsConfig, }; if (index > -1) { p.id = item.id; - p.isRoot = isRoot; - p.isDefault = isDefault; } dashboardStore.setCurrentDashboard(p); dashboardStore.setLayout(children); diff --git a/src/views/dashboard/related/topology/config/Metrics.vue b/src/views/dashboard/related/topology/config/Metrics.vue index 12b7263d..6a5d6f7f 100644 --- a/src/views/dashboard/related/topology/config/Metrics.vue +++ b/src/views/dashboard/related/topology/config/Metrics.vue @@ -110,11 +110,6 @@ limitations under the License. --> return m.length ? m : [{ label: "", value: "" }]; }); const currentMetric = ref(metricList.value[0].value); - const currentConfig = ref<{ unit: string; calculation: string; label: string }>({ - unit: "", - calculation: "", - label: "", - }); const currentIndex = ref(0); const getMetricConfig = computed(() => { if (props.type === "hierarchyServicesConfig") { @@ -125,7 +120,12 @@ limitations under the License. --> }, ConfigFieldTypes.ISDEFAULT, ); - return (dashboard && dashboard.expressionsConfig) || []; + if (!dashboard) { + return []; + } + const config = dashboard.expressionsConfig || []; + + return config || []; } let config = []; @@ -143,6 +143,14 @@ limitations under the License. --> return config || []; }); + const currentConfig = ref<{ unit: string; calculation: string; label: string }>( + getMetricConfig.value[0] || { + unit: "", + calculation: "", + label: "", + }, + ); + function changeConfigs(param: { [key: string]: string }) { const metricConfig = getMetricConfig.value || []; metricConfig[currentIndex.value] = {