Skip to content

Commit

Permalink
fix(frontend): redis集群拓扑、访问入口问题修复 #7619
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves authored and hLinx committed Nov 12, 2024
1 parent 64451e9 commit 08ff88c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export interface ClbPolarisTargetDetails {
url: string;
}

export default class ClusterEntryDetail {
export default class ClusterEntryDetail<T extends unknown | DnsTargetDetails | ClbPolarisTargetDetails = unknown> {
cluster_entry_type: string; // 'dns' | 'clb' | 'polaris' | 'clbDns'
entry: string;
role: string;
target_details: (DnsTargetDetails | ClbPolarisTargetDetails)[];
target_details: T[];

constructor(payload = {} as ClusterEntryDetail) {
constructor(payload = {} as ClusterEntryDetail<T>) {
this.cluster_entry_type = payload.cluster_entry_type;
this.entry = payload.entry;
this.role = payload.role;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import { useI18n } from 'vue-i18n';
import { useRequest } from 'vue-request';
import type { DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details';
import ClusterEntryDetailModel, { type DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details';
import { getClusterEntries } from '@services/source/clusterEntry';
import type { DBTypes } from '@common/const';
Expand Down Expand Up @@ -121,8 +121,10 @@
type: item.cluster_entry_type,
entry: item.entry,
role: item.role,
ips: item.isDns ? (item.target_details as DnsTargetDetails[]).map((row) => row.ip).join('\n') : '',
port: item.target_details[0]?.port,
ips: item.isDns
? (item as ClusterEntryDetailModel<DnsTargetDetails>).target_details.map((row) => row.ip).join('\n')
: '',
port: (item as ClusterEntryDetailModel<DnsTargetDetails>).target_details[0]?.port,
})),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@
import { useI18n } from 'vue-i18n';
import { useRequest } from 'vue-request';
import type { ClbPolarisTargetDetails, DnsTargetDetails } from '@services/model/cluster-entry/cluster-entry-details';
import ClusterEntryDetailModel, {
type ClbPolarisTargetDetails,
type DnsTargetDetails,
} from '@services/model/cluster-entry/cluster-entry-details';
import { getClusterEntries } from '@services/source/clusterEntry';
import { getRedisPassword } from '@services/source/redis';
Expand Down Expand Up @@ -222,16 +225,16 @@
res.forEach((item) => {
if (item.target_details.length) {
if (item.isClb) {
const targetDetailItem = item.target_details[0] as ClbPolarisTargetDetails;
const targetDetailItem = (item as ClusterEntryDetailModel<ClbPolarisTargetDetails>).target_details[0];
dataObj.value.clb.list[0].value = `${targetDetailItem.clb_ip}:${targetDetailItem.port}`;
dataObj.value.clb.list[1].value = `${targetDetailItem.clb_domain}:${targetDetailItem.port}`;
} else if (item.isPolaris) {
const targetDetailItem = item.target_details[0] as ClbPolarisTargetDetails;
const targetDetailItem = (item as ClusterEntryDetailModel<ClbPolarisTargetDetails>).target_details[0];
dataObj.value.polary.list[0].value = targetDetailItem.polaris_l5;
dataObj.value.polary.list[0].shareLink = targetDetailItem.url;
dataObj.value.polary.list[1].value = `${targetDetailItem.polaris_name}:${targetDetailItem.port}`;
} else if (item.isNodeEntry) {
const targetDetailItem = item.target_details[0] as DnsTargetDetails;
const targetDetailItem = (item as ClusterEntryDetailModel<DnsTargetDetails>).target_details[0];
dataObj.value.nodes.list[0].value = `${item.entry}:${targetDetailItem.port}`;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@
import { useI18n } from 'vue-i18n';
import { useRequest } from 'vue-request';
import { type ClbPolarisTargetDetails } from '@services/model/cluster-entry/cluster-entry-details';
import ClusterEntryDetailModel, {
type ClbPolarisTargetDetails,
} from '@services/model/cluster-entry/cluster-entry-details';
import { getClusterEntries } from '@services/source/clusterEntry';
import { useCopy } from '@hooks';
Expand Down Expand Up @@ -110,11 +112,11 @@
onSuccess: (res) => {
const entryItem = res[0];
if (entryItem.isClb) {
const targetDetailItem = entryItem.target_details[0] as ClbPolarisTargetDetails;
const targetDetailItem = (entryItem as ClusterEntryDetailModel<ClbPolarisTargetDetails>).target_details[0];
dataObj.clb.list[0].value = targetDetailItem.clb_ip;
dataObj.clb.list[1].value = targetDetailItem.clb_domain;
} else if (entryItem.isPolaris) {
const targetDetailItem = entryItem.target_details[0] as ClbPolarisTargetDetails;
const targetDetailItem = (entryItem as ClusterEntryDetailModel<ClbPolarisTargetDetails>).target_details[0];
dataObj.polaris.list[0].value = targetDetailItem.polaris_l5;
dataObj.polaris.list[1].value = targetDetailItem.polaris_name;
dataObj.polaris.list[0].shareLink = targetDetailItem.url;
Expand Down

0 comments on commit 08ff88c

Please sign in to comment.