diff --git a/src/views/dashboard/configuration/Tab.vue b/src/views/dashboard/configuration/Tab.vue index 130a8ffc..bac45826 100644 --- a/src/views/dashboard/configuration/Tab.vue +++ b/src/views/dashboard/configuration/Tab.vue @@ -43,7 +43,7 @@ limitations under the License. --> child.children.find( (item: any) => item.type === WidgetType.Widget && - !(Object.keys(ListEntity).includes(item.graph.type as string) && child.children === 1), + !(Object.keys(ListEntity).includes(item.graph.type as string) && child.children.length === 1), ), ), ); @@ -52,7 +52,7 @@ limitations under the License. --> expressions[child.name] = child.expression || ""; } function changeExpression(name: string) { - if (!expressions[name].includes("is_present")) { + if (expressions[name] && !expressions[name].includes("is_present")) { ElMessage.error("Only support the is_present function"); return; } diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index cafdaf5b..dee10cd0 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -126,9 +126,8 @@ limitations under the License. --> import type { PropType } from "vue"; import type { LayoutConfig } from "@/types/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard"; - import { useSelectorStore } from "@/store/modules/selectors"; import controls from "./tab"; - import { dragIgnoreFrom, WidgetType, ListEntity } from "../data"; + import { dragIgnoreFrom, WidgetType } from "../data"; import copy from "@/utils/copy"; import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor"; @@ -148,7 +147,6 @@ limitations under the License. --> setup(props) { const { t } = useI18n(); const dashboardStore = useDashboardStore(); - const selectorStore = useSelectorStore(); const route = useRoute(); const activeTabIndex = ref(Number(route.params.activeTabIndex) || 0); const activeTabWidget = ref(""); @@ -254,19 +252,7 @@ limitations under the License. --> const tabsProps = props.data; const metrics = []; for (const child of tabsProps.children || []) { - if (child.expression) { - const expList = parseTabsExpression(child.expression); - for (const exp of expList) { - let isList = false; - let item = child.children.find((d: any) => d.expressions.join(", ").includes(exp)); - if (item && item.graph && Object.keys(ListEntity).includes(item.graph.type as string)) { - isList = true; - } - if (item && !isList) { - metrics.push(child.expression); - } - } - } + child.expression && metrics.push(child.expression); } if (!metrics.length) { return; @@ -284,12 +270,6 @@ limitations under the License. --> dashboardStore.setConfigs(tabsProps); } - function parseTabsExpression(inputString: string) { - const resultString = inputString.replace(/is_present\(|\)/g, ""); - const result = resultString.replace(/\s/g, "").split(","); - - return result || []; - } watch( () => (props.data.children || []).map((d: any) => d.expression),