From b8cf8fea4b3f3a85f28921a71533d1c5182ad0a9 Mon Sep 17 00:00:00 2001 From: Fine Date: Mon, 11 Dec 2023 15:54:17 +0800 Subject: [PATCH] feat: update --- src/views/dashboard/configuration/Tab.vue | 6 ++++++ src/views/dashboard/controls/Tab.vue | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/views/dashboard/configuration/Tab.vue b/src/views/dashboard/configuration/Tab.vue index 2d81a363..7be6e1b7 100644 --- a/src/views/dashboard/configuration/Tab.vue +++ b/src/views/dashboard/configuration/Tab.vue @@ -28,12 +28,18 @@ limitations under the License. --> import { useI18n } from "vue-i18n"; import { ref } from "vue"; import { useDashboardStore } from "@/store/modules/dashboard"; + import { ElMessage } from "element-plus"; + const { t } = useI18n(); const dashboardStore = useDashboardStore(); const originConfig = dashboardStore.selectedGrid; const expressions = ref(originConfig.expressions); function changeConfig() { + if (!expressions.value.includes("is_present")) { + ElMessage.error("Only support the is_present function"); + return; + } const { selectedGrid } = dashboardStore; dashboardStore.selectWidget({ ...selectedGrid, expressions: expressions.value }); diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 0225695b..687589e0 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -117,6 +117,7 @@ limitations under the License. --> import controls from "./tab"; import { dragIgnoreFrom } from "../data"; import copy from "@/utils/copy"; + import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor"; const props = { data: { @@ -124,6 +125,7 @@ limitations under the License. --> default: () => ({ children: [] }), }, active: { type: Boolean, default: false }, + needQuery: { type: Boolean, default: false }, }; export default defineComponent({ name: "Tab", @@ -148,6 +150,10 @@ limitations under the License. --> dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i); } + // if (props.needQuery || !dashboardStore.currentDashboard.id) { + // queryExpressions(); + // } + function clickTabs(e: Event, idx: number) { e.stopPropagation(); activeTabIndex.value = idx; @@ -232,6 +238,18 @@ limitations under the License. --> dashboardStore.setConfigPanel(true); dashboardStore.selectWidget(props.data); } + + async function queryExpressions() { + const params = (await useExpressionsQueryProcessor({ metrics: [props.data.expressions] })) || {}; + console.log(params); + } + + watch( + () => props.data.expressions, + () => { + queryExpressions(); + }, + ); watch( () => dashboardStore.activedGridItem, (data) => {