Skip to content

Commit

Permalink
fix(frontend): redis整机替换bug TencentBlueKing#7596
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaCattt authored and hLinx committed Nov 8, 2024
1 parent 65f3594 commit 0ddf4f7
Show file tree
Hide file tree
Showing 24 changed files with 3,740 additions and 3,699 deletions.
16 changes: 13 additions & 3 deletions dbm-ui/frontend/src/components/instance-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
checkType: 'ip' | 'instance';
checkKey: keyof IValue;
activePanelId?: string;
fieldFormat?: Record<string, Record<string, string>>;
checkInstances?: (params: any) => Promise<any[] | ListBase<any[]>>;
};
previewConfig?: {
Expand Down Expand Up @@ -369,7 +370,7 @@
role: 'redis_master',
field: 'ip',
},
columnsChecked: ['ip', 'cloud_area', 'status', 'host_name', 'os_name'],
columnsChecked: ['ip', 'role', 'cloud_area', 'status', 'host_name', 'os_name'],
statusFilter: (data: RedisHostModel) => !data.isMasterFailover,
isRemotePagination: true,
},
Expand All @@ -385,11 +386,11 @@
tableConfig: {
getTableList: getRedisMachineList,
firsrColumn: {
label: 'master Ip',
label: 'IP',
role: 'redis_master',
field: 'ip',
},
columnsChecked: ['ip', 'cloud_area', 'status', 'host_name', 'os_name'],
columnsChecked: ['ip', 'role', 'cloud_area', 'status', 'host_name', 'os_name'],
statusFilter: (data: RedisHostModel) => !data.isMasterFailover,
isRemotePagination: false,
},
Expand All @@ -398,6 +399,15 @@
checkType: 'ip',
checkKey: 'ip',
activePanelId: 'redis',
fieldFormat: {
// column绑定的field
role: {
// 接口返回值->展示值
master: 'redis_master',
slave: 'redis_slave',
proxy: 'proxy',
},
},
},
previewConfig: {
displayKey: 'ip',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -192,7 +190,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: firstColumnField,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
<BkLoading :loading="inputState.isLoading">
<RenderManualHost
:active-panel-id="manualConfig.activePanelId"
:field-format="manualConfig.fieldFormat"
:firsr-column="firsrColumn"
is-manul
:last-values="lastValues"
Expand All @@ -93,6 +94,7 @@
</div>
</template>
<script setup lang="ts" generic="T extends IValue">
import _ from 'lodash';
import { useI18n } from 'vue-i18n';

import { useGlobalBizs } from '@stores';
Expand Down Expand Up @@ -131,7 +133,10 @@

const inputState = reactive({
values: '',
placeholder: t('请输入IP_Port_如_1_1_1_1_10000_多个可使用换行_空格或_分隔'),
placeholder:
props.manualConfig.checkType === 'instance'
? t('请输入IP_Port_如_1_1_1_1_10000_多个可使用换行_空格或_分隔')
: t('请输入IP_如_1_1_1_1_多个可使用换行_空格或_分隔'),
isLoading: false,
tableData: [] as T[],
});
Expand Down Expand Up @@ -222,12 +227,19 @@
// });
// }
const res = await (props.manualConfig.checkInstances as (params: any) => Promise<any[]>)(params);
// 去重
let uniqRes = _.uniqBy(res, props.manualConfig.checkKey);
if (props.manualConfig.checkType === 'instance') {
// 接口实例有两种字段
uniqRes = _.uniqBy(res, 'instance_address');
}

const legalInstances = [];
for (let i = lines.length - 1; i >= 0; i--) {
const item = lines[i];
const infos = res[i];
const infos = uniqRes[i];
const remove = lines.splice(i, 1);
const isExisted = res.find((existItem) => existItem[props.manualConfig.checkKey] === item);
const isExisted = uniqRes.find((existItem) => existItem[props.manualConfig.checkKey] === item);
if (!isExisted) {
newLines.push(...remove);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
type InstanceSelectorValues,
type IValue,
Expand All @@ -42,6 +40,7 @@
} from '../../../../Index.vue';

type TableConfigType = Required<PanelListType[number]>['tableConfig'];
type ManualConfigType = Required<PanelListType[number]>['manualConfig'];

interface DataRow {
data: T,
Expand All @@ -55,6 +54,7 @@
firsrColumn?: TableConfigType['firsrColumn'],
roleFilterList?: TableConfigType['roleFilterList'],
disabledRowConfig?: TableConfigType['disabledRowConfig'],
fieldFormat?: ManualConfigType['fieldFormat'];
statusFilter?: TableConfigType['statusFilter'],
}

Expand All @@ -68,6 +68,7 @@
statusFilter: undefined,
activePanelId: 'tendbcluster',
disabledRowConfig: undefined,
fieldFormat: undefined,
roleFilterList: undefined,
getTableList: undefined,
});
Expand Down Expand Up @@ -159,14 +160,15 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
label: t('角色'),
field: 'role',
showOverflowTooltip: true,
filter: props.roleFilterList,
render: ({ data }: DataRow) => <span>{props.fieldFormat?.role ? props.fieldFormat.role[data.role] : data.role}</span>
},
{
label: t('实例状态'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
} from '@components/instance-selector/Index.vue';
import { activePanelInjectionKey } from '@components/instance-selector/Index.vue';

import { firstLetterToUpper } from '@utils';

import { useTableData } from './useTableData';

type TableConfigType = Required<PanelListType[number]>['tableConfig'];
Expand Down Expand Up @@ -191,7 +189,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -216,7 +214,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -211,7 +209,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -215,7 +213,7 @@
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label
? firstLetterToUpper(props.firsrColumn.label)
? props.firsrColumn.label
: t('实例'),
field: props.firsrColumn?.field
? props.firsrColumn.field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -190,7 +188,7 @@
{
fixed: 'left',
width: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -184,7 +182,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -216,7 +214,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -208,7 +206,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@

import DbStatus from '@components/db-status/index.vue';

import { firstLetterToUpper } from '@utils';

import {
activePanelInjectionKey,
type InstanceSelectorValues,
Expand Down Expand Up @@ -183,7 +181,7 @@
{
fixed: 'left',
minWidth: 160,
label: props.firsrColumn?.label ? firstLetterToUpper(props.firsrColumn.label) : t('实例'),
label: props.firsrColumn?.label ? props.firsrColumn.label : t('实例'),
field: props.firsrColumn?.field ? props.firsrColumn.field : 'instance_address',
},
{
Expand Down
Loading

0 comments on commit 0ddf4f7

Please sign in to comment.