From 7bb719d9b62a5d41752f92489a01c723f24f1490 Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 12 Dec 2023 16:35:17 +0800 Subject: [PATCH] feat: disable tabs --- src/styles/theme.scss | 2 +- src/views/dashboard/controls/Tab.vue | 81 ++++++++++++++++++---------- 2 files changed, 54 insertions(+), 29 deletions(-) diff --git a/src/styles/theme.scss b/src/styles/theme.scss index 12b1bbed..e17ab4bb 100644 --- a/src/styles/theme.scss +++ b/src/styles/theme.scss @@ -65,7 +65,7 @@ html.dark { --el-color-primary: #409eff; --theme-background: #212224; --font-color: #fafbfc; - --disabled-color: #ccc; + --disabled-color: #999; --dashboard-tool-bg: #000; --text-color-placeholder: #ccc; --border-color: #262629; diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 194c6b46..b90ad90f 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -15,30 +15,41 @@ limitations under the License. --> + @@ -126,7 +137,6 @@ limitations under the License. --> default: () => ({ children: [] }), }, active: { type: Boolean, default: false }, - needQuery: { type: Boolean, default: false }, }; export default defineComponent({ name: "Tab", @@ -151,9 +161,7 @@ limitations under the License. --> dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i); } - // if (props.needQuery || !dashboardStore.currentDashboard.id) { - // queryExpressions(); - // } + queryExpressions(); function clickTabs(e: Event, idx: number) { e.stopPropagation(); @@ -246,16 +254,20 @@ limitations under the License. --> for (const child of tabsProps.children || []) { child.expression && metrics.push(child.expression); } + if (!metrics.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 || ""]); } else { - child.enable = true; + child.enable = false; } } dashboardStore.setConfigs(tabsProps); + console.log(props.data); } watch( @@ -332,6 +344,7 @@ limitations under the License. --> white-space: nowrap; overflow-y: hidden; padding: 0 10px; + display: inline-flex; span { display: inline-block; @@ -354,6 +367,18 @@ limitations under the License. --> background-color: $theme-background; } + .tab-diabled { + max-width: 150px; + outline: none; + color: $disabled-color; + font-style: normal; + overflow: hidden; + text-overflow: ellipsis; + margin-right: 20px; + background-color: $theme-background; + cursor: not-allowed; + } + .tab-icons { i { margin-right: 3px;