Skip to content

Commit

Permalink
chore: sync
Browse files Browse the repository at this point in the history
  • Loading branch information
HSunboy committed Jun 7, 2024
2 parents 5c3a2eb + 26908a6 commit 2d64a04
Show file tree
Hide file tree
Showing 30 changed files with 1,390 additions and 1,105 deletions.
2 changes: 1 addition & 1 deletion src/common/network/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export async function previewSqlStatements(data: {
const res = await request.post('api/v2/dlm/previewSqlStatements', {
data,
});
return res?.data?.contents || [];
return res?.data?.contents;
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/component/SelectTransfer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ export default function SelectTransfer(props: IProps) {
checkable
selectable={false}
checkedKeys={checkedKeys}
onCheck={(v) => setCheckedKeys(v as string[])}
onCheck={(v) => {
setCheckedKeys([...(checkedKeys || []), ...(v as string[])]);
}}
height={274}
treeData={sourceDisplayTreeData}
/>
Expand Down Expand Up @@ -155,7 +157,7 @@ export default function SelectTransfer(props: IProps) {
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
wordBreak: "break-all"
wordBreak: 'break-all',
}}
title={node.title}
>
Expand Down
280 changes: 143 additions & 137 deletions src/component/Task/DataArchiveTask/CreateModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import type { ModalStore } from '@/store/modal';
import { useDBSession } from '@/store/sessionManager/hooks';
import { isClient } from '@/util/env';
import { formatMessage } from '@/util/intl';
import { mbToKb, kbToMb, hourToMilliSeconds } from '@/util/utils';
import { mbToKb, kbToMb, hourToMilliSeconds, milliSecondsToHour } from '@/util/utils';
import { FieldTimeOutlined } from '@ant-design/icons';
import { Button, Checkbox, DatePicker, Drawer, Form, Modal, Radio, Space, InputNumber } from 'antd';
import { inject, observer } from 'mobx-react';
Expand Down Expand Up @@ -213,7 +213,7 @@ const CreateModal: React.FC<IProps> = (props) => {
triggerStrategy,
startAt: undefined,
description,
timeoutMillis: hourToMilliSeconds(timeoutMillis),
timeoutMillis: milliSecondsToHour(timeoutMillis),
syncTableStructure,
};

Expand Down Expand Up @@ -406,10 +406,12 @@ const CreateModal: React.FC<IProps> = (props) => {
.then(async (values) => {
const { variables, tables: _tables, archiveRange } = values;
_tables?.map((i) => {
i.partitions = i?.partitions
?.replace(/[\r\n]+/g, '')
?.split(',')
?.filter(Boolean);
i.partitions = i?.partitions?.length
? i?.partitions
?.replace(/[\r\n]+/g, '')
?.split(',')
?.filter(Boolean)
: [];
});
const parameters = {
variables: getVariables(variables),
Expand Down Expand Up @@ -521,152 +523,156 @@ const CreateModal: React.FC<IProps> = (props) => {
handleCancel(hasEdit);
}}
>
<Form
form={form}
name="basic"
layout="vertical"
requiredMark="optional"
initialValues={defaultValue}
onFieldsChange={handleFieldsChange}
>
<Space align="start">
<DatabaseSelect
type={TaskType.DATA_ARCHIVE}
disabled={isEdit}
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.SourceDatabase',
})}
/*源端数据库*/ projectId={projectId}
onChange={handleDBChange}
/>
{dataArchiveVisible ? (
<Form
form={form}
name="basic"
layout="vertical"
requiredMark="optional"
initialValues={defaultValue}
onFieldsChange={handleFieldsChange}
>
<Space align="start">
<DatabaseSelect
type={TaskType.DATA_ARCHIVE}
disabled={isEdit}
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.SourceDatabase',
})}
/*源端数据库*/ projectId={projectId}
onChange={handleDBChange}
/>

<DatabaseSelect
type={TaskType.DATA_ARCHIVE}
<DatabaseSelect
type={TaskType.DATA_ARCHIVE}
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.TargetDatabase',
})}
/*目标数据库*/ name="targetDataBaseId"
projectId={projectId}
/>
</Space>
<Space direction="vertical" size={24} style={{ width: '100%' }}>
<ArchiveRange enabledTargetTable tables={tables} form={form} />
<VariableConfig form={form} />
</Space>
<Form.Item name="deleteAfterMigration" valuePropName="checked">
<Checkbox>
<Space>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.CleanUpArchivedDataFrom',
}) /*清理源端已归档数据*/
}

<span className={styles.desc}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.IfYouCleanUpThe',
}) /*若您进行清理,默认立即清理且不做备份;清理任务完成后支持回滚*/
}
</span>
</Space>
</Checkbox>
</Form.Item>
<Form.Item
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.TargetDatabase',
id: 'odc.DataArchiveTask.CreateModal.ExecutionMethod',
})}
/*目标数据库*/ name="targetDataBaseId"
projectId={projectId}
/>
</Space>
<Space direction="vertical" size={24} style={{ width: '100%' }}>
<ArchiveRange enabledTargetTable tables={tables} form={form} />
<VariableConfig form={form} />
</Space>
<Form.Item name="deleteAfterMigration" valuePropName="checked">
<Checkbox>
<Space>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.CleanUpArchivedDataFrom',
}) /*清理源端已归档数据*/
}

<span className={styles.desc}>
/*执行方式*/ name="triggerStrategy"
required
>
<Radio.Group>
<Radio.Button value={TaskExecStrategy.START_NOW}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.IfYouCleanUpThe',
}) /*若您进行清理,默认立即清理且不做备份;清理任务完成后支持回滚*/
id: 'odc.DataArchiveTask.CreateModal.ExecuteNow',
}) /*立即执行*/
}
</span>
</Space>
</Checkbox>
</Form.Item>
<Form.Item
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ExecutionMethod',
})}
/*执行方式*/ name="triggerStrategy"
required
>
<Radio.Group>
<Radio.Button value={TaskExecStrategy.START_NOW}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ExecuteNow',
}) /*立即执行*/
}
</Radio.Button>
{!isClient() ? (
<Radio.Button value={TaskExecStrategy.START_AT}>
</Radio.Button>
{!isClient() ? (
<Radio.Button value={TaskExecStrategy.START_AT}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ScheduledExecution',
}) /*定时执行*/
}
</Radio.Button>
) : null}
<Radio.Button value={TaskExecStrategy.TIMER}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ScheduledExecution',
}) /*定时执行*/
id: 'odc.DataArchiveTask.CreateModal.PeriodicExecution',
}) /*周期执行*/
}
</Radio.Button>
) : null}
<Radio.Button value={TaskExecStrategy.TIMER}>
{
formatMessage({
id: 'odc.DataArchiveTask.CreateModal.PeriodicExecution',
}) /*周期执行*/
</Radio.Group>
</Form.Item>
<Form.Item shouldUpdate noStyle>
{({ getFieldValue }) => {
const triggerStrategy = getFieldValue('triggerStrategy') || [];
if (triggerStrategy === TaskExecStrategy.START_AT) {
return (
<Form.Item
name="startAt"
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ExecutionTime',
})}
/*执行时间*/ required
>
<DatePicker showTime suffixIcon={<FieldTimeOutlined />} />
</Form.Item>
);
}
</Radio.Button>
</Radio.Group>
</Form.Item>
<Form.Item shouldUpdate noStyle>
{({ getFieldValue }) => {
const triggerStrategy = getFieldValue('triggerStrategy') || [];
if (triggerStrategy === TaskExecStrategy.START_AT) {
return (
<Form.Item
name="startAt"
label={formatMessage({
id: 'odc.DataArchiveTask.CreateModal.ExecutionTime',
})}
/*执行时间*/ required
>
<DatePicker showTime suffixIcon={<FieldTimeOutlined />} />
</Form.Item>
);
}
if (triggerStrategy === TaskExecStrategy.TIMER) {
return (
<Form.Item>
<Crontab
ref={crontabRef}
initialValue={crontab}
onValueChange={handleCrontabChange}
/>
</Form.Item>
);
}
return null;
}}
</Form.Item>
<FormItemPanel
label={
formatMessage({
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.TaskSetting',
}) /* 任务设置 */
}
keepExpand
>
<TaskdurationItem form={form} />
<SynchronizationItem form={form} />
<Form.Item
if (triggerStrategy === TaskExecStrategy.TIMER) {
return (
<Form.Item>
<Crontab
ref={crontabRef}
initialValue={crontab}
onValueChange={handleCrontabChange}
/>
</Form.Item>
);
}
return null;
}}
</Form.Item>
<FormItemPanel
label={
formatMessage({
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.InsertionStrategy',
}) /* 插入策略 */
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.TaskSetting',
}) /* 任务设置 */
}
name="migrationInsertAction"
rules={[
{
required: true,
message: formatMessage({
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.PleaseSelectInsertionStrategy',
}), //'请选择插入策略'
},
]}
keepExpand
>
<Radio.Group options={InsertActionOptions} />
</Form.Item>
<ThrottleFormItem />
</FormItemPanel>
<DescriptionInput />
</Form>
<TaskdurationItem form={form} />
<SynchronizationItem form={form} />
<Form.Item
label={
formatMessage({
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.InsertionStrategy',
}) /* 插入策略 */
}
name="migrationInsertAction"
rules={[
{
required: true,
message: formatMessage({
id: 'odc.src.component.Task.DataArchiveTask.CreateModal.PleaseSelectInsertionStrategy',
}), //'请选择插入策略'
},
]}
>
<Radio.Group options={InsertActionOptions} />
</Form.Item>
<ThrottleFormItem />
</FormItemPanel>
<DescriptionInput />
</Form>
) : (
<></>
)}
<SQLPreviewModal
sql={previewSql}
visible={previewModalVisible}
Expand Down
Loading

0 comments on commit 2d64a04

Please sign in to comment.