feat: disable tabs

This commit is contained in:
Fine 2023-12-12 16:35:17 +08:00
parent 2a9fde6805
commit 7bb719d9b6
2 changed files with 54 additions and 29 deletions

View File

@ -65,7 +65,7 @@ html.dark {
--el-color-primary: #409eff; --el-color-primary: #409eff;
--theme-background: #212224; --theme-background: #212224;
--font-color: #fafbfc; --font-color: #fafbfc;
--disabled-color: #ccc; --disabled-color: #999;
--dashboard-tool-bg: #000; --dashboard-tool-bg: #000;
--text-color-placeholder: #ccc; --text-color-placeholder: #ccc;
--border-color: #262629; --border-color: #262629;

View File

@ -15,12 +15,12 @@ limitations under the License. -->
<template> <template>
<div class="flex-h tab-header"> <div class="flex-h tab-header">
<div class="tabs scroll_bar_style" @click="handleClick"> <div class="tabs scroll_bar_style" @click="handleClick">
<template v-for="(child, idx) in data.children || []">
<span <span
v-for="(child, idx) in data.children || []"
:key="idx" :key="idx"
:class="{ active: activeTabIndex === idx }" :class="{ active: activeTabIndex === idx }"
@click="clickTabs($event, idx)" @click="clickTabs($event, idx)"
v-show="child.enable !== false" v-if="child.enable !== false"
> >
<input <input
@click="editTabName($event, idx)" @click="editTabName($event, idx)"
@ -39,6 +39,17 @@ limitations under the License. -->
v-if="dashboardStore.editMode && canEditTabName" v-if="dashboardStore.editMode && canEditTabName"
/> />
</span> </span>
</template>
<template v-for="(child, idx) in data.children || []">
<span
:key="idx"
:style="{ width: getStringWidth(child.name) + 'px' }"
v-if="child.enable === false"
class="tab-diabled"
>
{{ child.name }}
</span>
</template>
<span class="tab-icons"> <span class="tab-icons">
<el-tooltip content="Copy Link" placement="bottom"> <el-tooltip content="Copy Link" placement="bottom">
<i @click="copyLink"> <i @click="copyLink">
@ -126,7 +137,6 @@ limitations under the License. -->
default: () => ({ children: [] }), default: () => ({ children: [] }),
}, },
active: { type: Boolean, default: false }, active: { type: Boolean, default: false },
needQuery: { type: Boolean, default: false },
}; };
export default defineComponent({ export default defineComponent({
name: "Tab", name: "Tab",
@ -151,9 +161,7 @@ limitations under the License. -->
dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i); dashboardStore.setActiveTabIndex(activeTabIndex.value, props.data.i);
} }
// if (props.needQuery || !dashboardStore.currentDashboard.id) { queryExpressions();
// queryExpressions();
// }
function clickTabs(e: Event, idx: number) { function clickTabs(e: Event, idx: number) {
e.stopPropagation(); e.stopPropagation();
@ -246,16 +254,20 @@ limitations under the License. -->
for (const child of tabsProps.children || []) { for (const child of tabsProps.children || []) {
child.expression && metrics.push(child.expression); child.expression && metrics.push(child.expression);
} }
if (!metrics.length) {
return;
}
const params: { [key: string]: any } = (await useExpressionsQueryProcessor({ metrics })) || {}; const params: { [key: string]: any } = (await useExpressionsQueryProcessor({ metrics })) || {};
for (const child of tabsProps.children || []) { for (const child of tabsProps.children || []) {
if (params.source[child.expression || ""]) { if (params.source[child.expression || ""]) {
child.enable = !!Number(params.source[child.expression || ""]); child.enable = !!Number(params.source[child.expression || ""]);
} else { } else {
child.enable = true; child.enable = false;
} }
} }
dashboardStore.setConfigs(tabsProps); dashboardStore.setConfigs(tabsProps);
console.log(props.data);
} }
watch( watch(
@ -332,6 +344,7 @@ limitations under the License. -->
white-space: nowrap; white-space: nowrap;
overflow-y: hidden; overflow-y: hidden;
padding: 0 10px; padding: 0 10px;
display: inline-flex;
span { span {
display: inline-block; display: inline-block;
@ -354,6 +367,18 @@ limitations under the License. -->
background-color: $theme-background; 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 { .tab-icons {
i { i {
margin-right: 3px; margin-right: 3px;