|
|
@ -4,7 +4,7 @@ import { connect } from 'react-redux'; |
|
|
|
import ProTable from '@ant-design/pro-table'; |
|
|
|
import moment from 'moment'; |
|
|
|
import TaskModal from '../components/taskModal'; |
|
|
|
import { RELATION_DATABASE_TOOL_CONFIG } from '../constants/adapter'; |
|
|
|
import { parseHumanReadable } from 'cron-js-parser'; |
|
|
|
|
|
|
|
import './style.less'; |
|
|
|
function AcquisitionTask(props) { |
|
|
@ -35,6 +35,62 @@ function AcquisitionTask(props) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
//cron表达式转中文
|
|
|
|
const transCron = (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] |
|
|
|
}; |
|
|
|
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(<a onClick={() => { |
|
|
|
|
|
|
|
}} style={{ marginRight: 8 }}>立即执行</a>) |
|
|
|
|
|
|
|
const enabledText = record?.enabled ? '禁用' : '启用'; |
|
|
|
options.push(<a onClick={() => { |
|
|
|
dispatch(actions.metadataAcquisition.modifyTask(record?.id, { enabled: !record?.enabled }, '采集任务' + enabledText)).then(res => { |
|
|
|
if (res.success) { |
|
|
|
queryData(); |
|
|
|
} |
|
|
|
}) |
|
|
|
}} style={{ marginRight: 8 }}>{enabledText}</a>) |
|
|
|
|
|
|
|
options.push(<a onClick={() => { |
|
|
|
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 <Spin spinning={loading}> |
|
|
|
<Row className='protable-title'> |
|
|
|
<Col span={12}><Button type='primary' onClick={() => { setVisible(true) }}>新建</Button></Col> |
|
|
|