From 16decafa1c9925e85b3e30578998900ee80e6ed3 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 12 Dec 2023 12:08:42 +0800 Subject: [PATCH] feat: query expressions --- src/types/dashboard.d.ts | 2 +- src/views/dashboard/controls/Tab.vue | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/types/dashboard.d.ts b/src/types/dashboard.d.ts index fde95f53..cacadfba 100644 --- a/src/types/dashboard.d.ts +++ b/src/types/dashboard.d.ts @@ -36,7 +36,7 @@ export interface LayoutConfig { expressions?: string[]; metricTypes?: string[]; typesOfMQE?: string[]; - children?: { name: string; children: LayoutConfig[]; expression?: string }[]; + children?: { name: string; children: LayoutConfig[]; expression?: string; enable: boolean }[]; activedTabIndex?: number; metricConfig?: MetricConfigOpt[]; id?: string; diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 566df337..790986ea 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -149,7 +149,6 @@ limitations under the License. --> dashboardStore.setCurrentTabItems(dashboardStore.layout[l].children[activeTabIndex.value].children); dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i); } - console.log(props.data); // if (props.needQuery || !dashboardStore.currentDashboard.id) { // queryExpressions(); @@ -241,12 +240,21 @@ limitations under the License. --> } async function queryExpressions() { + const tabsProps = props.data; const metrics = []; - for (const child of props.data.children || []) { + for (const child of tabsProps.children || []) { child.expression && metrics.push(child.expression); } - const params = (await useExpressionsQueryProcessor({ metrics })) || {}; - console.log(params); + const params: { [key: string]: any } = (await useExpressionsQueryProcessor({ metrics })) || {}; + + for (const child of tabsProps.children || []) { + if (params.source[child.expression || ""]) { + child.enable = !!Number(params.source[child.expression || ""]) || true; + } else { + child.enable = true; + } + } + console.log(tabsProps); } watch(