Skip to content

Commit

Permalink
perf(frontend): redis工具箱重构_重建从库 TencentBlueKing#8840
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves committed Dec 27, 2024
1 parent 308b4f3 commit 0b0f5f9
Showing 1 changed file with 36 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@
</div>
</EditBlock>
</EditableTableColumn>
<EditableTableColumn
<!-- <EditableTableColumn
field="cluster.cluster_type_name"
:label="t('规格需求')"
:max-width="200"
:min-width="200">
</EditableTableColumn>
</EditableTableColumn> -->
<SpecBlockColumn
:data="item.host.spec_config"
is-ignore-counts
:label="t('当前规格')"
:placeholder="t('输入集群后自动生成')" />
<EditableTableColumn
field="cluster.cluster_type_name"
:label="t('故障从库实例数量')"
Expand Down Expand Up @@ -135,6 +140,7 @@
queryMasterSlavePairs,
} from '@services/source/redisToolbox';
import { createTicket } from '@services/source/ticket';
import type { MachineSpecConfig } from '@services/types';

import { useTicketDetail } from '@hooks';

Expand All @@ -149,6 +155,7 @@

import TicketRemark from '@views/db-manage/common/TicketRemark.vue';
import OperationColumn from '@views/db-manage/common/toolbox-field/operation-column/Index.vue';
import SpecBlockColumn from '@views/db-manage/common/toolbox-field/spec-block-column/Index.vue';
import EditHostColumn from '@views/db-manage/redis/common/toolbox-field/edit-host/Index.vue';

interface IDataRow {
Expand All @@ -171,9 +178,7 @@
immute_domain: string;
cluster_type: string;
}[];
spec_config?: {
id?: number;
};
spec_config?: MachineSpecConfig
related_instances?: {
status: string
}[],
Expand Down Expand Up @@ -505,37 +510,50 @@
// 根据表格数据生成提交单据请求参数
const generateRequestParam = () => {
const clusterMap: Record<string, IDataRow[]> = {};
tableData.value.forEach((item) => {
if (item.slaveIp) {
const clusterName = item.host.domain;
tableData.value.forEach((tableItem) => {
if (tableItem.host.ip) {
const clusterName = tableItem.host.related_clusters!.map(relatedClusterItem => relatedClusterItem.immute_domain).join(',');
if (!clusterMap[clusterName]) {
clusterMap[clusterName] = [item];
clusterMap[clusterName] = [tableItem];
} else {
clusterMap[clusterName].push(item);
clusterMap[clusterName].push(tableItem);
}
}
});
const keys = Object.keys(clusterMap);
const infos = keys.map((domain) => {
const sameArr = clusterMap[domain];
const clusterIds = sameArr[0].host.related_clusters!.map(item => item.id)
const { ip: masterIp, bk_cloud_id: bkCloudId, bk_host_id: bkHostId } = slaveMasterMap[sameArr[0].host.ip!]
const infoItem = {
cluster_ids: sameArr[0].clusterIds,
bk_cloud_id: sameArr[0].bkCloudId,
pairs: [],
cluster_ids: clusterIds,
bk_cloud_id: bkCloudId,
pairs: [] as {
redis_master: {
ip: string,
bk_cloud_id: number,
bk_host_id: number,
},
redis_slave: {
spec_id: number,
count: number,
old_slave_ip: string;
}
}[]
};
const specId = sameArr[0].spec?.id;
const specId = sameArr[0].host.spec_config?.id;
if (specId !== undefined) {
sameArr.forEach((item) => {
const pair = {
redis_master: {
ip: item.masterIp,
bk_cloud_id: sameArr[0].bkCloudId,
bk_host_id: sameArr[0].bkHostId,
ip: masterIp,
bk_cloud_id: bkCloudId,
bk_host_id: bkHostId,
},
redis_slave: {
spec_id: specId,
count: 1,
old_slave_ip: item.slaveIp,
old_slave_ip: item.host.ip!,
},
};
infoItem.pairs.push(pair);
Expand Down

0 comments on commit 0b0f5f9

Please sign in to comment.