Skip to content

Commit

Permalink
feat(frontend): 工具箱支持资源池协议变更_mysql添加proxy #8076
Browse files Browse the repository at this point in the history
  • Loading branch information
JustaCattt committed Dec 12, 2024
1 parent 203d034 commit 2f28bf0
Show file tree
Hide file tree
Showing 7 changed files with 161 additions and 151 deletions.
3 changes: 0 additions & 3 deletions dbm-ui/frontend/src/components/editable-table/Column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,7 @@
.bk-editable-table-field-cell {
position: relative;
display: flex;
height: 100%;
min-height: 40px;
align-items: center;
}
.bk-editable-table-column-error {
Expand Down
8 changes: 3 additions & 5 deletions dbm-ui/frontend/src/components/editable-table/edit/Input.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,9 @@
});
const handleBlur = async () => {
const result = await columnContext?.validate('blur');
if (result) {
columnContext?.blur();
emits('blur');
}
columnContext?.validate('blur');
columnContext?.blur();
emits('blur');
};
const handleFocus = () => {
Expand Down
4 changes: 2 additions & 2 deletions dbm-ui/frontend/src/components/resource-host-owner/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
const { t } = useI18n();
const isForBiz = computed(() => props.data.for_biz.bk_biz_id);
const isForDb = computed(() => props.data.resource_type && props.data.resource_type !== 'PUBLIC');
const isForBiz = computed(() => props.data?.for_biz.bk_biz_id);
const isForDb = computed(() => props.data?.resource_type && props.data.resource_type !== 'PUBLIC');
</script>
<style lang="less">
.resource-host-owner {
Expand Down
10 changes: 6 additions & 4 deletions dbm-ui/frontend/src/components/resource-host-selector/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
<HostAgentStatus :data="data.agent_status" />
</template>
</BkTableColumn>
<BkTableColumn
<!-- <BkTableColumn
field="bk_cpu"
:label="t('资源归属')"
:min-width="300">
<template #default="{ data }">
<ResourceHostOwner :data="data" />
</template>
</BkTableColumn>
</BkTableColumn> -->
<BkTableColumn
field="rack_id"
:label="t('机架')"
Expand Down Expand Up @@ -157,8 +157,8 @@
import DiskPopInfo from '@components/disk-pop-info/DiskPopInfo.vue';
import HostAgentStatus from '@components/host-agent-status/Index.vue';
import ResourceHostOwner from '@components/resource-host-owner/Index.vue';
// import ResourceHostOwner from '@components/resource-host-owner/Index.vue';
import PanelTab from './components/PanelTab.vue';
import useSearchSelectData from './hooks/use-search-select-data';
Expand All @@ -176,7 +176,7 @@
(e: 'change', value: IValue[]): void;
}
interface IValue {
export interface IValue {
bk_biz_id: number;
bk_cloud_id: number;
bk_host_id: number;
Expand Down Expand Up @@ -251,6 +251,8 @@
bk_host_id: item.bk_host_id,
ip: item.ip,
}));
console.log(modelValue.value, 'modelValue.value');
emits('change', modelValue.value);
};
Expand Down
49 changes: 32 additions & 17 deletions dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_ADD_SLAVE/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
<RenderCluster
v-model="item.cluster"
@batch-edit="handleBatchEdit" />
<RenderHost v-model="item.slaveIp" />
<RenderHost
v-model="item.slave"
:model="item" />
<EditableTableColumn
fixed="right"
:label="t('操作')"
Expand Down Expand Up @@ -108,26 +110,45 @@
cluster: {
id?: number;
domain?: string;
cloudId?: number;
relatedClusters?: {
id: number;
domain: string;
}[];
};
slave: {
bk_biz_id: number;
bk_cloud_id: number;
bk_host_id: number;
ip: string;
};
slaveIp: string;
}>,
) => ({
cluster: {
id: data.cluster?.id ?? 0,
domain: data.cluster?.domain ?? '',
cloudId: data.cluster?.cloudId ?? 0,
relatedClusters: data.cluster?.relatedClusters ?? [],
},
slave: {
bk_biz_id: data.slave?.bk_biz_id ?? window.PROJECT_CONFIG.BIZ_ID,
bk_cloud_id: data.slave?.bk_cloud_id ?? 0,
bk_host_id: data.slave?.bk_host_id ?? 0,
ip: data.slave?.ip ?? '',
},
slaveIp: data.slaveIp ?? '',
});

export type DataRow = ReturnType<typeof createData>;

const dataModel = reactive([createData()]);
const backupSource = ref<'local' | 'remote'>('local');

const rules = {
'cluster.domain': [
{
validator: (value: string) => dataModel.some((item) => item.cluster.domain === value),
validator: (value: string) =>
dataModel.filter(
(item) =>
item.cluster.domain === value || item.cluster.relatedClusters.some((item) => item.domain === value),
).length < 2,
message: t('目标集群重复'),
trigger: 'blur',
},
Expand All @@ -138,7 +159,7 @@
backup_source: 'local' | 'remote';
infos: {
cluster_ids: number[];
new_proxy: {
new_slave: {
bk_biz_id: number;
bk_cloud_id: number;
bk_host_id: number;
Expand All @@ -155,27 +176,22 @@
createTicketRun({
backup_source: backupSource.value,
infos: dataModel.map((item) => ({
cluster_ids: [item.cluster.id],
new_proxy: {
bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,
bk_cloud_id: item.cluster.cloudId,
bk_host_id: 0,
ip: item.slaveIp,
},
cluster_ids: [item.cluster.id, ...item.cluster.relatedClusters.map((item) => item.id)],
new_slave: item.slave,
})),
});
};

const handleAppend = (index: number) => {
dataModel.splice(index, 0, createData());
dataModel.splice(index + 1, 0, createData());
};

const handleRemove = (index: number) => {
dataModel.splice(index, 1);
};

const handleClone = (index: number) => {
dataModel.splice(index, 0, createData(dataModel[index]));
dataModel.splice(index + 1, 0, createData(dataModel[index]));
};

const handleReset = () => {
Expand All @@ -188,7 +204,6 @@
cluster: {
id: item.id,
domain: item.master_domain,
cloudId: item.bk_cloud_id,
},
}),
);
Expand Down
Loading

0 comments on commit 2f28bf0

Please sign in to comment.