From 5450f4c01879d086836328a74d1c26b1af8396bb Mon Sep 17 00:00:00 2001 From: Fine Date: Thu, 14 Dec 2023 18:05:07 +0800 Subject: [PATCH] feat: update --- src/assets/icons/add_iframe.svg | 2 +- src/assets/icons/demand.svg | 2 +- src/assets/icons/event.svg | 2 +- src/views/dashboard/controls/Tab.vue | 38 +++++++++++++++++----------- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/assets/icons/add_iframe.svg b/src/assets/icons/add_iframe.svg index 5fa776c0..a24b9967 100644 --- a/src/assets/icons/add_iframe.svg +++ b/src/assets/icons/add_iframe.svg @@ -12,4 +12,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/demand.svg b/src/assets/icons/demand.svg index 4b1b60db..1d4861fd 100644 --- a/src/assets/icons/demand.svg +++ b/src/assets/icons/demand.svg @@ -13,4 +13,4 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - \ No newline at end of file + \ No newline at end of file diff --git a/src/assets/icons/event.svg b/src/assets/icons/event.svg index 93bf25ec..b4cedb14 100644 --- a/src/assets/icons/event.svg +++ b/src/assets/icons/event.svg @@ -12,4 +12,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index eed6c74a..d6663d29 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -129,7 +129,7 @@ limitations under the License. --> import controls from "./tab"; import { dragIgnoreFrom, WidgetType, ListEntity } from "../data"; import copy from "@/utils/copy"; - import { useExpressionsQueryProcessor } from "@/hooks/useExpressionsProcessor"; + import { useExpressionsQueryProcessor, useExpressionsQueryPodsMetrics } from "@/hooks/useExpressionsProcessor"; const props = { data: { @@ -250,9 +250,8 @@ limitations under the License. --> async function queryExpressions() { const tabsProps = props.data; - console.log(tabsProps); const metrics = []; - const listMetrics = []; + const listExp = []; for (const child of tabsProps.children || []) { let isList = false; if (child.expression) { @@ -260,31 +259,40 @@ limitations under the License. --> for (const exp of expList) { const item = child.children.find((d: any) => d.expressions.includes(exp)); - if (item && item.graph && ListEntity.includes(item.graph.type)) { + if (item && item.graph && Object.keys(ListEntity).includes(item.graph.type as string)) { + isList = true; + } + if (child.children.find((d: any) => d.subExpressions && d.subExpressions.includes(exp))) { isList = true; } } if (isList) { - listMetrics.push(child.expression); + listExp.push(child.expression); } else { metrics.push(child.expression); } } } - if (![...metrics, ...listMetrics].length) { + if (![...metrics, ...listExp].length) { return; } - 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 || ""]) && - !!child.children.find((item: { type: string }) => item.type === WidgetType.Widget); - } else { - child.enable = true; + if (metrics.length) { + 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 || ""]) && + !!child.children.find((item: { type: string }) => item.type === WidgetType.Widget); + } else { + child.enable = true; + } } } + + // if (listExp.length) { + // await useExpressionsQueryPodsMetrics({}); + // } + console.log(tabsProps); dashboardStore.setConfigs(tabsProps); }