diff --git a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js
index efbc945..735195c 100644
--- a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js
+++ b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js
@@ -10,14 +10,57 @@ import {
ProFormDependency
} from '@ant-design/pro-form';
import { BellOutlined } from '@ant-design/icons'
-
+import { parseHumanReadable } from 'cron-js-parser';
import '../../style.less';
function StepThree(props) {
const { prev, next, dataSourceFilter, editData } = props;
const formRef = React.createRef();
- const initialValues = editData ? editData : {
+ const initialValues = editData ? editData : {}
+ const testCron = () => {
+ try {
+ let lang = 'zh_CN' //english
+ let obj = {
+ atSeconds: [1, 5, 10],
+ runEveryXMins: {
+ startAt: 10,
+ every: 10
+ },
+ runEveryHourInRange: {
+ from: 2,
+ to: 20
+ },
+ isEveryDay: true,
+ atYears: [2020, 2022]
+ };
+ console.log(parseHumanReadable("0 15 10 ? * *", obj, lang))
+ } catch (err) {
+ console.log('Error: ' + err.message);
+ }
+ }
+ const checkCron = async (rule, value) => {
+ try {
+ let lang = 'zh_CN' //english
+ let obj = {
+ atSeconds: [1, 5, 10],
+ runEveryXMins: {
+ startAt: 10,
+ every: 10
+ },
+ runEveryHourInRange: {
+ from: 2,
+ to: 20
+ },
+ isEveryDay: true,
+ atYears: [2020, 2022]
+ };
+ console.log(parseHumanReadable(value, obj, lang))
+ return Promise.resolve();
+ } catch (err) {
+ return Promise.reject(new Error('请输入正确的cron表达式!'));
+ }
}
+
const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 16 } };
return <>
请输入该计划任务执行时间
@@ -70,12 +113,13 @@ function StepThree(props) {
测试}
+ addonAfter={}
/>
{
+ try {
+ let lang = 'zh_CN' //english
+ let obj = {
+ atSeconds: [1, 5, 10],
+ runEveryXMins: {
+ startAt: 10,
+ every: 10
+ },
+ runEveryHourInRange: {
+ from: 2,
+ to: 20
+ },
+ isEveryDay: true,
+ atYears: [2020, 2022]
+ };
+ return (parseHumanReadable(value, obj, lang))
+ } catch (err) {
+ return '-'
+ }
+ }
+
+ const onFinish = (values) => {
+ const dataToSave = {
+ taskName: values?.taskName,
+ retryCount: values?.retryCount,
+ retryTime: values?.retryTime,
+ retried: values?.retried ? true : false,
+ dataSourceId: values?.dataSourceId,
+ cron: values?.cron,
+ }
+
+ if (editData) {
+ dispatch(actions.metadataAcquisition.modifyTask(editData?.id, dataToSave)).then(res => {
+ if (res.success) {
+ setVisible(false);
+ setEditData(null);
+ queryData();
+ }
+ })
+ } else {
+ dataToSave.enabled = true;
+ dataToSave.autoReleased = true;
+ dataToSave.storageStrategy = "增量";
+ dispatch(actions.metadataAcquisition.addTask(dataToSave)).then(res => {
+ if (res.success) {
+ setVisible(false);
+ setEditData(null);
+ queryData();
+ }
+ })
+ }
+
+ }
+
const columns = [
{
title: '任务名称',
@@ -65,24 +121,40 @@ function AcquisitionTask(props) {
},
{
title: '执行周期',
- dataIndex: 'dataSourceName',
+ dataIndex: 'cron',
+ // render: (text, record) => {
+ // return transCron(record?.cron);
+ // }
},
{
title: '重复次数',
dataIndex: 'retryCount',
},
{
- title: '时间间隔',
+ title: '时间间隔(分钟)',
dataIndex: 'retryTime',
},
{
title: '操作',
- width: 160,
+ width: 300,
key: 'option',
valueType: 'option',
render: (text, record) => {
const options = [];
+ options.push( {
+
+ }} style={{ marginRight: 8 }}>立即执行)
+
+ const enabledText = record?.enabled ? '禁用' : '启用';
+ options.push( {
+ dispatch(actions.metadataAcquisition.modifyTask(record?.id, { enabled: !record?.enabled }, '采集任务' + enabledText)).then(res => {
+ if (res.success) {
+ queryData();
+ }
+ })
+ }} style={{ marginRight: 8 }}>{enabledText})
+
options.push( {
const adapterInfo = adapters?.find(x => x.id == record?.adapter)
setVisible(true)
@@ -107,39 +179,6 @@ function AcquisitionTask(props) {
},
];
- const onFinish = (values) => {
- const dataToSave = {
- taskName: values?.taskName,
- retryCount: values?.retryCount,
- retryTime: values?.retryTime,
- retried: values?.retried ? true : false,
- dataSourceId: values?.dataSourceId,
- cron: values?.cron,
- }
-
- if (editData) {
- dispatch(actions.metadataAcquisition.modifyTask(editData?.id, dataToSave)).then(res => {
- if (res.success) {
- setVisible(false);
- setEditData(null);
- queryData();
- }
- })
- } else {
- dataToSave.enabled = true;
- dataToSave.autoReleased = true;
- dataToSave.storageStrategy = "增量";
- dispatch(actions.metadataAcquisition.addTask(dataToSave)).then(res => {
- if (res.success) {
- setVisible(false);
- setEditData(null);
- queryData();
- }
- })
- }
-
- }
-
return
diff --git a/web/package.json b/web/package.json
index 7d1c11f..1f3db63 100644
--- a/web/package.json
+++ b/web/package.json
@@ -73,6 +73,7 @@
"ali-oss": "^6.17.1",
"antd": "^4.24.5",
"args": "^5.0.1",
+ "cron-js-parser": "^1.0.17",
"cross-env": "^7.0.3",
"crypto-js": "^4.1.1",
"echarts": "^5.4.1",
@@ -91,4 +92,4 @@
"webpack-dev-server": "^3.11.2",
"xlsx": "^0.16.9"
}
-}
\ No newline at end of file
+}