Skip to content

Commit

Permalink
fix(frontend): tendbcluster、doris的tab缺失 #8175
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 25356
  • Loading branch information
royalpioneer committed Nov 29, 2024
1 parent 4e4fb9a commit 474ec11
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 13 deletions.
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/components/editable-info/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
v-overflow-tips
class="base-info__value text-overflow">
<Component
:is="config.render"
:is="config.render(data)"
v-if="config.render" />
<template v-else>{{ data[config.key] || '--' }}</template>
</span>
Expand Down Expand Up @@ -100,7 +100,7 @@
isEdit?: boolean;
isCopy?: boolean;
isRequired?: boolean;
render?: () => VNode | string | null;
render?: (data: Record<string, any>) => VNode | string | null;
};

export type EditEmitData = {
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/frontend/src/locales/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -3680,5 +3680,6 @@
"错误日志": "错误日志",
"点击上传": "点击上传",
"请选择本地 SQL 文件": "请选择本地 SQL 文件",
"实际内存分配比率": "实际内存分配比率",
"这行勿动!新增翻译请在上一行添加!": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface State {
isEmpty: boolean;
version: string;
data: ServiceReturnType<typeof getLevelConfig> & { charset?: string };
deployInfo: ServiceReturnType<typeof getLevelConfig> & { charset?: string };
}
/**
* 获取参数管理基本信息
Expand Down Expand Up @@ -77,6 +78,13 @@ export const useBaseDetails = (immediateFetch = true, confName = 'db_version') =
description: '',
charset: '',
},
deployInfo: {
conf_items: [],
version: '',
name: '',
description: '',
charset: '',
},
});

const fetchParams = computed(() => getFetchParams('version'));
Expand Down Expand Up @@ -113,8 +121,9 @@ export const useBaseDetails = (immediateFetch = true, confName = 'db_version') =

state.loading = true;
getLevelConfig(params)
.then((res) => {
res.conf_items.forEach((item) => {
.then((result) => {
state.deployInfo = result;
result.conf_items.forEach((item) => {
if (item.conf_name === confName) {
state.version = item.conf_value ?? '';
} else if (item.conf_name === 'charset') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<DetailsBase
class="config-details-content"
:data="data"
:deploy-info="deployInfo"
:fetch-params="fetchParams"
:level="ConfLevels.MODULE"
:loading="false"
Expand All @@ -38,20 +39,24 @@
import DetailsBase from '@views/db-configure/components/DetailsBase.vue';

type PlatConfDetailsParams = ServiceParameters<typeof getConfigBaseDetails>;
type DetailData = ServiceReturnType<typeof getLevelConfig>;

interface Props {
data?: ServiceReturnType<typeof getLevelConfig>;
data?: Partial<DetailData>;
deployInfo?: Partial<DetailData>;
loading?: boolean;
fetchParams?: PlatConfDetailsParams | ServiceParameters<typeof getLevelConfig>;
}

const props = withDefaults(defineProps<Props>(), {
data: () =>
({
conf_items: [] as NonNullable<Props['data']>['conf_items'],
}) as NonNullable<Props['data']>,
data: () => ({
conf_items: [] as DetailData['conf_items'],
}),
loading: false,
fetchParams: () => ({}) as PlatConfDetailsParams,
deployInfo: () => ({
conf_items: [] as DetailData['conf_items'],
}),
});

const route = useRoute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<template v-if="tab.name !== 'publish' && configParams !== null">
<ConfigDetails
:data="state.data"
:deploy-info="state.deployInfo"
:fetch-params="configParams"
:loading="state.loadingDetails" />
</template>
Expand Down
56 changes: 52 additions & 4 deletions dbm-ui/frontend/src/views/db-configure/components/DetailsBase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
:title="$t('基础信息')">
<EditInfo
:columns="baseInfoColumns"
:data="data"
:data="detailData"
@save="handleSaveEditInfo" />
</DbCard>
<DbCard
Expand Down Expand Up @@ -78,7 +78,7 @@
</div>
</template>

<script setup lang="ts">
<script setup lang="tsx">
import { useI18n } from 'vue-i18n';

import {
Expand All @@ -88,7 +88,7 @@
updatePlatformConfig,
} from '@services/source/configs';

import { ConfLevels, type ConfLevelValues } from '@common/const';
import { ClusterTypes, ConfLevels, type ConfLevelValues } from '@common/const';

import EditInfo, { type EditEmitData } from '@components/editable-info/index.vue';

Expand All @@ -98,16 +98,18 @@
import ReadonlyTable from './ReadonlyTable.vue';

type PlatConfDetailsParams = ServiceParameters<typeof getConfigBaseDetails>;
type DetailData = ServiceReturnType<typeof getLevelConfig> & { charset?: string };

interface Props {
data?: ServiceReturnType<typeof getLevelConfig> & { charset?: string };
data?: Partial<DetailData>;
loading?: boolean;
fetchParams?: PlatConfDetailsParams | ServiceParameters<typeof getLevelConfig>;
stickyTop?: number;
level?: ConfLevelValues;
title?: string;
extraParametersCards?: ExtraConfListItem[];
routeParams?: Record<string, any>;
deployInfo?: Partial<DetailData>;
}

interface Emits {
Expand All @@ -127,6 +129,10 @@
title: '',
extraParametersCards: () => [],
routeParams: () => ({}),
deployInfo: () =>
({
conf_items: [] as DetailData['conf_items'],
}),
});

const emits = defineEmits<Emits>();
Expand All @@ -138,6 +144,9 @@

const clusterType = ref(props.data.version);

const isSqlServer = computed(() =>
[ClusterTypes.SQLSERVER_SINGLE, ClusterTypes.SQLSERVER_HA].includes(props.routeParams.clusterType),
);
const tabs = computed(() => {
if (!state.version) {
return [props.data.version];
Expand Down Expand Up @@ -189,8 +198,47 @@
key: 'charset',
});
}
if (isSqlServer.value) {
baseColumns[0].push(
...[
{
label: t('实际内存分配比率'),
key: 'buffer_percent',
},
{
label: t('主从方式'),
key: 'sync_type',
render: (data) => <span> {data.sync_type === 'mirroring' ? t('镜像') : data.sync_type} </span>
},
],
);
baseColumns[1].push(
...[
{
label: t('最大系统保留内存'),
key: 'max_remain_mem_gb',
},
{
label: t('操作系统版本'),
key: 'system_version',
},
],
);
}
return baseColumns;
});
const detailData = computed(() => {
if (isSqlServer.value) {
return {
...props.data,
...props.deployInfo.conf_items.reduce<Record<string, string>>((acc, item) => {
acc[item.conf_name] = item.conf_value!;
return acc;
}, {}),
};
}
return props.data;
});

watch(
() => props.data.version,
Expand Down

0 comments on commit 474ec11

Please sign in to comment.