Skip to content

Commit 2952808

Browse files
committed
PullRequest: 446 fix/dev-4.3.0-2571
Merge branch 'fix/dev-4.3.0-2571 of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.0 https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/446 Signed-off-by: 晓康 <[email protected]> * Fixes oceanbase/odc#2556 * Fixes oceanbase/odc#2575 * Fixes oceanbase/odc#2571 * Fixes oceanbase/odc#2139
1 parent f2eb2d8 commit 2952808

File tree

7 files changed

+101
-53
lines changed

7 files changed

+101
-53
lines changed

src/component/Crontab/utils.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,19 @@ const cronLabelMap = {
5353
};
5454

5555
enum CRON_SPEED {
56+
perSecond = 'perSecond',
57+
minutely = 'minutely',
58+
hourly = 'hourly',
5659
daily = 'daily',
5760
weekly = 'weekly',
5861
monthly = 'monthly',
5962
yearly = 'yearly',
6063
}
6164

6265
const cronSpeedLabelMap = {
66+
[CRON_SPEED.perSecond]: '每秒',
67+
[CRON_SPEED.minutely]: '每分',
68+
[CRON_SPEED.hourly]: '每小时',
6369
[CRON_SPEED.daily]: formatMessage({
6470
id: 'odc.component.Crontab.utils.EveryDay',
6571
}),
@@ -78,7 +84,17 @@ const cronSpeedLabelMap = {
7884
//每年
7985
};
8086

87+
const CronInputName2cronSpeedLabelMap = {
88+
[CronInputName.second]: CRON_SPEED.perSecond,
89+
[CronInputName.minute]: CRON_SPEED.minutely,
90+
[CronInputName.hour]: CRON_SPEED.hourly,
91+
[CronInputName.dayOfMonth]: CRON_SPEED.daily,
92+
[CronInputName.dayOfWeek]: CRON_SPEED.weekly,
93+
[CronInputName.month]: CRON_SPEED.monthly,
94+
};
95+
8196
const reg = /[*?]/;
97+
const everyReg = /[*]/;
8298
const charsReg = /[#L]/;
8399

84100
const CronFieldKeys = [
@@ -176,6 +192,10 @@ export const getCronPlan = (values: string) => {
176192

177193
const getCronLabel = (name: CronInputName, value: number | string) => {
178194
const [label] = cronLabelMap[name];
195+
// 处理 *
196+
if (everyReg?.test(value.toString())) {
197+
return cronSpeedLabelMap[CRON_SPEED[CronInputName2cronSpeedLabelMap[name]]];
198+
}
179199
// 周
180200
if (name === CronInputName.dayOfWeek) {
181201
let weekLabel = weekOptions?.find((item) => item.value === Number(value))?.label;
@@ -432,6 +452,9 @@ class Translator {
432452
?.map((node) => {
433453
let str = '';
434454
if (reg?.test(node.value)) {
455+
if (everyReg?.test(node.value)) {
456+
return (str = getCronLabel(name as CronInputName, node.value));
457+
}
435458
return;
436459
}
437460
if (node.interval) {

src/component/Task/DetailModal.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,25 @@ const DetailModal: React.FC<IProps> = React.memo((props) => {
213213

214214
const loadTaskData = async () => {
215215
clearTimeout(clockRef.current);
216-
if (!task || isLoop) {
217-
getTask();
218-
}
219-
if (detailType === TaskDetailType.LOG) {
220-
getLog();
221-
} else if (hasResult) {
222-
getResult();
223-
}
216+
try {
217+
if (!task || isLoop) {
218+
getTask();
219+
}
220+
if (detailType === TaskDetailType.LOG) {
221+
getLog();
222+
} else if (hasResult) {
223+
getResult();
224+
}
224225

225-
if (detailType === TaskDetailType.EXECUTE_RECORD) {
226-
getExecuteRecord();
227-
}
228-
if (isLoop) {
229-
clockRef.current = setTimeout(() => {
230-
loadTaskData();
231-
}, 5000);
232-
}
226+
if (detailType === TaskDetailType.EXECUTE_RECORD) {
227+
getExecuteRecord();
228+
}
229+
if (isLoop) {
230+
clockRef.current = setTimeout(() => {
231+
loadTaskData();
232+
}, 5000);
233+
}
234+
} catch (err) {}
233235
};
234236

235237
const loadCycleTaskData = async (args?: ITableLoadOptions) => {

src/component/Task/component/CommonDetailModal/LogModal.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { formatMessage } from '@/util/intl';
1717

1818
import { getCycleTaskLog } from '@/common/network/task';
1919
import TaskLog from '@/component/Task/component/Log';
20-
import { CommonTaskLogType } from '@/d.ts';
20+
import { CommonTaskLogType, SubTaskStatus } from '@/d.ts';
2121
import type { ILog } from '@/component/Task/component/Log';
2222
import { Drawer } from 'antd';
2323
import { useRequest } from 'ahooks';
@@ -27,9 +27,10 @@ interface IProps {
2727
recordId: number;
2828
visible: boolean;
2929
onClose: () => void;
30+
status?: SubTaskStatus;
3031
}
3132
const LogModal: React.FC<IProps> = function (props) {
32-
const { visible, scheduleId, recordId, onClose } = props;
33+
const { visible, scheduleId, recordId, onClose, status } = props;
3334
const [logType, setLogType] = useState<CommonTaskLogType>(CommonTaskLogType.ALL);
3435
const [loading, setLoading] = useState(false);
3536
const [log, setLog] = useState<ILog>(null);
@@ -42,6 +43,12 @@ const LogModal: React.FC<IProps> = function (props) {
4243
[logType]: res,
4344
});
4445
setLoading(false);
46+
if (
47+
status &&
48+
[SubTaskStatus.CANCELED, SubTaskStatus.FAILED, SubTaskStatus.DONE].includes(status)
49+
) {
50+
cancel();
51+
}
4552
}
4653
},
4754
{

src/component/Task/component/CommonDetailModal/TaskExecuteRecord.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
TaskRecordParameters,
2626
TaskType,
2727
IResponseData,
28+
SubTaskStatus,
2829
} from '@/d.ts';
2930
import { formatMessage } from '@/util/intl';
3031
import { getFormatDateTime } from '@/util/utils';
@@ -82,7 +83,7 @@ const getConnectionColumns = (params: {
8283
showLog: boolean;
8384
onReloadList: () => void;
8485
onDetailVisible: (task: TaskRecord<TaskRecordParameters>, visible: boolean) => void;
85-
onLogVisible: (recordId: number, visible: boolean) => void;
86+
onLogVisible: (recordId: number, visible: boolean, status: SubTaskStatus) => void;
8687
onExcecuteDetailVisible: (recordId: number, visible: boolean) => void;
8788
}) => {
8889
const {
@@ -185,6 +186,7 @@ const TaskExecuteRecord: React.FC<IProps> = (props) => {
185186
const [detailId, setDetailId] = useState(null);
186187
const [detailVisible, setDetailVisible] = useState(false);
187188
const [logVisible, setLogVisible] = useState(false);
189+
const [status, setStatus] = useState<SubTaskStatus>(null);
188190
const [excecuteDetailVisible, setExcecuteDetailVisible] = useState<boolean>(false);
189191
const tableRef = useRef();
190192
const taskId = task?.id;
@@ -198,9 +200,14 @@ const TaskExecuteRecord: React.FC<IProps> = (props) => {
198200
setDetailVisible(visible);
199201
};
200202

201-
const handleLogVisible = (recordId: number, visible: boolean = false) => {
203+
const handleLogVisible = (
204+
recordId: number,
205+
visible: boolean = false,
206+
status: SubTaskStatus = null,
207+
) => {
202208
setLogVisible(visible);
203209
setDetailId(recordId);
210+
setStatus(status);
204211
};
205212

206213
const handleCloseLog = () => {
@@ -263,6 +270,7 @@ const TaskExecuteRecord: React.FC<IProps> = (props) => {
263270
scheduleId={task?.id}
264271
recordId={detailId}
265272
onClose={handleCloseLog}
273+
status={status}
266274
/>
267275
<ExcecuteDetailModal
268276
visible={excecuteDetailVisible}

src/component/Task/component/CommonDetailModal/TaskTools.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
TaskRecord,
2828
TaskRecordParameters,
2929
SubTaskType,
30+
ICycleSubTaskDetailRecord,
3031
} from '@/d.ts';
3132
import type { ModalStore } from '@/store/modal';
3233
import type { SettingStore } from '@/store/setting';
@@ -43,13 +44,16 @@ interface IProps {
4344
isDetailModal?: boolean;
4445
showRollback?: boolean;
4546
taskId: number;
46-
record: TaskRecord<TaskRecordParameters> | TaskDetail<TaskRecordParameters>;
47+
record:
48+
| TaskRecord<TaskRecordParameters>
49+
| TaskDetail<TaskRecordParameters>
50+
| ICycleSubTaskDetailRecord;
4751
disabledSubmit?: boolean;
4852
result?: ITaskResult;
4953
showLog?: boolean;
5054
onReloadList: () => void;
5155
onDetailVisible: (record: TaskRecord<TaskRecordParameters>, visible: boolean) => void;
52-
onLogVisible: (recordId: number, visible: boolean) => void;
56+
onLogVisible: (recordId: number, visible: boolean, status: SubTaskStatus) => void;
5357
onExcecuteDetailVisible: (recordId: number, visible: boolean) => void;
5458
onClose?: () => void;
5559
}
@@ -150,7 +154,7 @@ const ActionBar: React.FC<IProps> = inject(
150154
}
151155
};
152156
const handleLogVisible = async () => {
153-
onLogVisible(record.id, true);
157+
onLogVisible(record.id, true, record?.status as SubTaskStatus);
154158
};
155159
const handleExcuteDetailVisible = () => {
156160
onExcecuteDetailVisible(record.id, true);

src/component/Task/component/Log/index.tsx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,19 @@ const TaskLog: React.FC<{
5858
}),
5959
key: CommonTaskLogType.ALL,
6060
children: (
61-
<Spin spinning={isLoading}>
62-
<Log
63-
enableHighLight
64-
language="java"
65-
value={log?.[CommonTaskLogType.ALL] ?? ''}
66-
ignoreCase={true}
67-
downloadUrl={downloadUrl}
68-
enableDownload={enableDataExport}
69-
enableCopy={enableDataExport}
70-
defaultPosition="end"
71-
searchTrigger="change"
72-
style={{ height: '100%' }}
73-
/>
74-
</Spin>
61+
<Log
62+
enableHighLight
63+
language="java"
64+
value={log?.[CommonTaskLogType.ALL] ?? ''}
65+
ignoreCase={true}
66+
downloadUrl={downloadUrl}
67+
enableDownload={enableDataExport}
68+
enableCopy={enableDataExport}
69+
defaultPosition="end"
70+
searchTrigger="change"
71+
style={{ height: '100%' }}
72+
loading={isLoading}
73+
/>
7574
),
7675
},
7776
{
@@ -80,20 +79,19 @@ const TaskLog: React.FC<{
8079
}),
8180
key: CommonTaskLogType.WARN,
8281
children: (
83-
<Spin spinning={isLoading}>
84-
<Log
85-
enableHighLight
86-
language="java"
87-
value={log?.[CommonTaskLogType.WARN] ?? ''}
88-
ignoreCase={true}
89-
downloadUrl={downloadUrl}
90-
enableDownload={enableDataExport}
91-
enableCopy={enableDataExport}
92-
defaultPosition="end"
93-
searchTrigger="change"
94-
style={{ height: '100%' }}
95-
/>
96-
</Spin>
82+
<Log
83+
enableHighLight
84+
language="java"
85+
value={log?.[CommonTaskLogType.WARN] ?? ''}
86+
ignoreCase={true}
87+
downloadUrl={downloadUrl}
88+
enableDownload={enableDataExport}
89+
enableCopy={enableDataExport}
90+
defaultPosition="end"
91+
searchTrigger="change"
92+
style={{ height: '100%' }}
93+
loading={isLoading}
94+
/>
9795
),
9896
},
9997
]}

src/page/Datasource/Info/NewDataBaseButton/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,20 @@ export default function NewDataBaseButton({
6565
form.resetFields();
6666
setProjectInfo(null);
6767
}
68+
69+
const getProjectDetails = async (projectId: number) => {
70+
const res = await getProject(projectId);
71+
res && setProjectInfo(res);
72+
};
73+
6874
useEffect(() => {
6975
if (open) {
7076
form.resetFields();
7177
if (projectId) {
7278
form.setFieldsValue({
7379
projectId: projectId,
7480
});
81+
getProjectDetails(projectId);
7582
}
7683
}
7784
switch (mode) {
@@ -152,8 +159,7 @@ export default function NewDataBaseButton({
152159
onValuesChange={async (changedValues, allValues) => {
153160
if (changedValues.hasOwnProperty('projectId')) {
154161
if (changedValues.projectId) {
155-
const res = await getProject(changedValues.projectId);
156-
res && setProjectInfo(res);
162+
getProjectDetails(changedValues.projectId);
157163
} else {
158164
setProjectInfo(null);
159165
}

0 commit comments

Comments
 (0)