From 48a37d10934c5ce29789877acfe06d4d680b2a44 Mon Sep 17 00:00:00 2001 From: Fine Date: Wed, 21 Aug 2024 16:11:27 +0800 Subject: [PATCH] feat: update tabs --- src/views/dashboard/controls/Tab.vue | 2 +- src/views/dashboard/panel/Layout.vue | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 2a7fdd00..aaf0a113 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -128,7 +128,7 @@ limitations under the License. --> import type { LayoutConfig } from "@/types/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard"; import controls from "./tab"; - import { dragIgnoreFrom, WidgetType } from "../data"; + import { dragIgnoreFrom, ListChartTypes, WidgetType } from "../data"; import copy from "@/utils/copy"; import { useDashboardQueryProcessor } from "@/hooks/useExpressionsProcessor"; diff --git a/src/views/dashboard/panel/Layout.vue b/src/views/dashboard/panel/Layout.vue index 0a78c6ae..151a662c 100644 --- a/src/views/dashboard/panel/Layout.vue +++ b/src/views/dashboard/panel/Layout.vue @@ -95,6 +95,25 @@ limitations under the License. --> } metricsValues.value = (await useDashboardQueryProcessor(configList)) || {}; } + async function queryTabsMetrics() { + const widgets = []; + + for (const item of dashboardStore.currentTabItems) { + const isList = ListChartTypes.includes(item.type || ""); + if (item.type === WidgetType.Widget && !isList) { + widgets.push(item); + } + } + const configList = widgets.map((d: LayoutConfig) => ({ + metrics: d.expressions || [], + metricConfig: d.metricConfig || [], + id: d.i, + })); + if (!widgets.length) { + return {}; + } + metricsValues.value = (await useDashboardQueryProcessor(configList)) || {}; + } onBeforeUnmount(() => { dashboardStore.setLayout([]); @@ -137,6 +156,12 @@ limitations under the License. --> } }, ); + watch( + () => dashboardStore.currentTabItems, + () => { + queryTabsMetrics(); + }, + ); return { dashboardStore, clickGrid,