Skip to content

Commit

Permalink
feat(frontend): mysql和redis支持批量编辑、行复制、备注 #4591
Browse files Browse the repository at this point in the history
  • Loading branch information
3octaves authored and jinquantianxia committed Sep 23, 2024
1 parent d040890 commit 3decb78
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 63 deletions.
5 changes: 5 additions & 0 deletions dbm-ui/frontend/src/components/batch-edit-column/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
:disabled="disabled"
has-delete-icon
:model-value="localValue as string[]"
:paste-fn="tagInputPasteFn"
@change="handleChange" />
<BkDatePicker
v-else-if="type === 'datetime'"
Expand All @@ -74,6 +75,8 @@
import type { UnwrapRef } from 'vue';
import { useI18n } from 'vue-i18n';
import { batchSplitRegex } from '@common/regex';
interface Props {
title: string;
dataList?: {
Expand Down Expand Up @@ -117,6 +120,8 @@
},
);
const tagInputPasteFn = (value: string) => value.split(batchSplitRegex).map((item) => ({ id: item }));
const handleChange = (value: UnwrapRef<typeof localValue>) => {
localValue.value = value;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ export async function generateMysqlVersionLocalUpgradeCloneData(ticketData: Tick
};
});

return Promise.resolve({ tableList });
return Promise.resolve({ tableList, remark: ticketData.remark });
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,6 @@ export async function generateMysqlVersionMigrateUpgradeCloneData(ticketData: Ti
return Promise.resolve({
tableList,
backupSource,
remark: ticketData.remark,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export function generateMysqlVersionProxyUpgradeCloneData(ticketData: TicketMode
};
});

return Promise.resolve({ tableList });
return Promise.resolve({ tableList, remark: ticketData.remark });
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function generateRedisScaleUpdownCloneData(ticketData: TicketModel<
{} as Record<number, RedisModel>,
);

return infos.map((item) => ({
const tableDataList = infos.map((item) => ({
rowKey: random(),
isLoading: false,
targetCluster: clusters[item.cluster_id].immute_domain,
Expand All @@ -53,4 +53,9 @@ export async function generateRedisScaleUpdownCloneData(ticketData: TicketModel<
switchMode: item.online_switch_type,
spec: clusterListMap[item.cluster_id].cluster_spec,
}));

return {
tableDataList,
remark: ticketData.remark,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,17 @@
import type { MySQLImportSQLFileDetails } from '@services/model/ticket/details/mysql';
import TicketModel from '@services/model/ticket/ticket';

import { random } from '@utils';

// spider SQL变更执行
export function generateSpiderSqlExecuteCloneData(ticketData: TicketModel<MySQLImportSQLFileDetails>) {
const { details } = ticketData;
return Promise.resolve({
backup: details.backup,
charset: details.charset,
ticket_mode: details.ticket_mode,
import_mode: details.import_mode,
cluster_ids: details.cluster_ids,
execute_db_infos: details.execute_objects.map((item) => ({
...item,
rowKey: random(),
})),
execute_objects: details.execute_objects,
ticket_mode: details.ticket_mode,
execute_sql_files: details.execute_sql_files as string[],
path: details.path,
remark: ticketData.remark,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
:model="formData">
<ClusterIds
v-model="formData.cluster_ids"
v-model:clusterVersionList="clusterVersionList"
v-model:cluster-version-list="clusterVersionList"
:cluster-type-list="[ClusterTypes.TENDBHA, ClusterTypes.TENDBSINGLE]" />
<ExecuteObjects
v-model="formData.execute_objects"
Expand All @@ -35,6 +35,7 @@
<RenderCharset v-model="formData.charset" />
<Backup v-model="formData.backup" />
<TicketMode v-model="formData.ticket_mode" />
<TicketRemark v-model="formData.remark" />
</DbForm>
</div>
<template #action>
Expand Down Expand Up @@ -71,6 +72,8 @@

import { ClusterTypes, DBTypes, TicketTypes } from '@common/const';

import TicketRemark from '@components/ticket-remark/Index.vue';

import Backup from '@views/db-manage/common/sql-execute/backup/Index.vue';
import RenderCharset from '@views/db-manage/common/sql-execute/charset/Index.vue';
import ClusterIds from '@views/db-manage/common/sql-execute/cluster-ids/Index.vue';
Expand All @@ -97,6 +100,7 @@
},
ticket_type: 'MYSQL_SEMANTIC_CHECK',
cluster_type: DBTypes.MYSQL,
remark: '',
});

const formRef = ref();
Expand All @@ -117,6 +121,7 @@
cluster_ids: cloneData.cluster_ids,
execute_objects: cloneData.execute_objects,
ticket_mode: cloneData.ticket_mode,
remark: cloneData.remark,
});
window.changeConfirm = true;
uploadFilePath.value = cloneData.path;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
<Component
:is="currentTable"
:backup-source="backupSource"
:remark="remark"
:table-list="tableList" />
</div>
</template>
Expand Down Expand Up @@ -96,6 +97,7 @@
type: TicketTypes.MYSQL_PROXY_UPGRADE,
onSuccess(cloneData) {
tableList.value = cloneData.tableList;
remark.value = cloneData.remark;
window.changeConfirm = true;
formData.roleType = 'haAccessLayer';
},
Expand All @@ -106,6 +108,7 @@
type: TicketTypes.MYSQL_LOCAL_UPGRADE,
onSuccess(cloneData) {
tableList.value = cloneData.tableList;
remark.value = cloneData.remark;
window.changeConfirm = true;

const isSingle = cloneData.tableList[0].clusterData.clusterType === ClusterTypes.TENDBSINGLE;
Expand All @@ -119,6 +122,7 @@
type: TicketTypes.MYSQL_MIGRATE_UPGRADE,
onSuccess(cloneData) {
backupSource.value = cloneData.backupSource;
remark.value = cloneData.remark;
window.changeConfirm = true;

formData.roleType = 'haStorageLayer';
Expand Down Expand Up @@ -152,6 +156,7 @@
];

const backupSource = ref('');
const remark = ref('');

const tableList = shallowRef<
HaAccessLayerRow[] | HaStorageLayerLocalRow[] | HaStorageLayerRemoteRow[] | SingleStorageRow[]
Expand Down Expand Up @@ -184,13 +189,15 @@
() => formData.updateType,
() => {
tableList.value = [];
remark.value = '';
if (formData.updateType === '') {
formData.updateType = 'local';
}
},
);

const handleRoleTypeChange = () => {
remark.value = '';
tableList.value = [];
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
@remove="handleRemove(index)" />
</template>
</RenderTable>
<TicketRemark v-model="localRemark" />
<ClusterSelector
v-model:is-show="isShowClusterSelector"
:cluster-types="[ClusterTypes.TENDBHA]"
Expand Down Expand Up @@ -90,7 +91,6 @@
import { findRelatedClustersByClusterIds } from '@services/source/mysqlCluster';
import { createTicket } from '@services/source/ticket';

// import { useTicketCloneInfo } from '@hooks';
import { useGlobalBizs } from '@stores';

import { ClusterTypes, TicketTypes } from '@common/const';
Expand All @@ -99,13 +99,15 @@
import ClusterSelector from '@components/cluster-selector/Index.vue';
import RenderTableHeadColumn from '@components/render-table/HeadColumn.vue';
import RenderTable from '@components/render-table/Index.vue';
import TicketRemark from '@components/ticket-remark/Index.vue';

import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

import RenderDataRow, { createRowData, type IDataRow } from './Row.vue';

interface Props {
tableList: IDataRow[];
remark: string;
}

interface Exposes {
Expand All @@ -122,6 +124,7 @@
const isShowClusterSelector = ref(false);
const rowRefs = ref();
const isSubmitting = ref(false);
const localRemark = ref('');

const selectedClusters = shallowRef<{ [key: string]: Array<TendbhaModel> }>({ [ClusterTypes.TENDBHA]: [] });

Expand All @@ -138,6 +141,16 @@
},
);

watch(
() => props.remark,
() => {
localRemark.value = props.remark;
},
{
immediate: true,
},
);

const handleShowMasterBatchSelector = () => {
isShowClusterSelector.value = true;
};
Expand Down Expand Up @@ -237,7 +250,7 @@
const infos = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise<any> }) => item.getValue()));
await createTicket({
ticket_type: TicketTypes.MYSQL_PROXY_UPGRADE,
remark: '',
remark: localRemark.value,
details: {
infos,
},
Expand All @@ -262,6 +275,7 @@

const handleReset = () => {
tableData.value = [createRowData()];
localRemark.value = '';
domainMemo = {};
selectedClusters.value[ClusterTypes.TENDBHA] = [];
window.changeConfirm = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
@remove="handleRemove(index)" />
</template>
</RenderTable>
<TicketRemark v-model="localRemark" />
<ClusterSelector
v-model:is-show="isShowClusterSelector"
:cluster-types="[ClusterTypes.TENDBHA]"
Expand Down Expand Up @@ -94,13 +95,15 @@
import ClusterSelector from '@components/cluster-selector/Index.vue';
import RenderTableHeadColumn from '@components/render-table/HeadColumn.vue';
import RenderTable from '@components/render-table/Index.vue';
import TicketRemark from '@components/ticket-remark/Index.vue';

import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

import RenderDataRow, { createRowData, type IDataRow } from './Row.vue';

interface Props {
tableList: IDataRow[];
remark: string;
}

interface Exposes {
Expand All @@ -117,6 +120,7 @@
const isShowClusterSelector = ref(false);
const rowRefs = ref();
const isSubmitting = ref(false);
const localRemark = ref('');

const selectedClusters = shallowRef<{ [key: string]: Array<TendbhaModel> }>({ [ClusterTypes.TENDBHA]: [] });

Expand All @@ -130,6 +134,16 @@
},
);

watch(
() => props.remark,
() => {
localRemark.value = props.remark;
},
{
immediate: true,
},
);

// 集群域名是否已存在表格的映射表
let domainMemo: Record<string, boolean> = {};

Expand Down Expand Up @@ -234,7 +248,7 @@
const infos = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise<any> }) => item.getValue()));
await createTicket({
ticket_type: TicketTypes.MYSQL_LOCAL_UPGRADE,
remark: '',
remark: localRemark.value,
details: {
infos,
},
Expand All @@ -259,6 +273,7 @@

const handleReset = () => {
tableData.value = [createRowData()];
localRemark.value = '';
domainMemo = {};
selectedClusters.value[ClusterTypes.TENDBHA] = [];
window.changeConfirm = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
</BkRadioGroup>
</BkFormItem>
</BkForm>
<TicketRemark v-model="localRemark" />
<ClusterSelector
v-model:is-show="isShowClusterSelector"
:cluster-types="[ClusterTypes.TENDBHA]"
Expand Down Expand Up @@ -115,6 +116,7 @@
import ClusterSelector from '@components/cluster-selector/Index.vue';
import RenderTableHeadColumn from '@components/render-table/HeadColumn.vue';
import RenderTable from '@components/render-table/Index.vue';
import TicketRemark from '@components/ticket-remark/Index.vue';

import type { InfoItem } from '@views/db-manage/redis/db-data-copy/pages/page1/Index.vue';

Expand All @@ -123,6 +125,7 @@
interface Props {
tableList: IDataRow[];
backupSource: string;
remark: string;
}

interface Exposes {
Expand All @@ -140,6 +143,7 @@
const rowRefs = ref();
const isSubmitting = ref(false);
const localBackupSource = ref('local');
const localRemark = ref('');

const selectedClusters = shallowRef<{ [key: string]: Array<TendbhaModel> }>({ [ClusterTypes.TENDBHA]: [] });

Expand All @@ -163,6 +167,16 @@
},
);

watch(
() => props.remark,
() => {
localRemark.value = props.remark;
},
{
immediate: true,
},
);

// 集群域名是否已存在表格的映射表
let domainMemo: Record<string, boolean> = {};

Expand Down Expand Up @@ -267,7 +281,7 @@
const infos = await Promise.all(rowRefs.value.map((item: { getValue: () => Promise<any> }) => item.getValue()));
await createTicket({
ticket_type: TicketTypes.MYSQL_MIGRATE_UPGRADE,
remark: '',
remark: localRemark.value,
details: {
ip_source: 'manual_input',
backup_source: localBackupSource.value,
Expand All @@ -294,6 +308,7 @@

const handleReset = () => {
tableData.value = [createRowData()];
localRemark.value = '';
domainMemo = {};
selectedClusters.value[ClusterTypes.TENDBHA] = [];
window.changeConfirm = false;
Expand Down
Loading

0 comments on commit 3decb78

Please sign in to comment.