Browse Source

(+)采集任务配置新增修改查询完善

master
peng.peng 2 years ago
parent
commit
d9dfdbd096
  1. 15
      api/app/lib/controllers/metadataAcquisition/task.js
  2. 1
      api/app/lib/index.js
  3. 2
      web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js
  4. 20
      web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js
  5. 3
      web/client/src/sections/metadataAcquisition/components/taskModal.js
  6. 134
      web/client/src/sections/metadataAcquisition/containers/acquisitionTask.js
  7. 11
      web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js

15
api/app/lib/controllers/metadataAcquisition/task.js

@ -38,14 +38,19 @@ function getAcquisitionTask(opts) {
let option = {
where: searchWhere,
order: [["id", "desc"]],
include: [{ model: models.DataSource }]
include: [{
model: models.DataSource,
include: [{
model: models.Adapter,
}]
}]
}
if (taskName) {
searchWhere.taskName = {
// 模糊查询
[Op.like]: '%' + taskName + '%',
};
searchWhere.$or = [
{ taskName: { $iLike: `%${taskName}%` } },
{ '$dataSource.name$': { $iLike: `%${taskName}%` } },
]
}
option.where = searchWhere

1
api/app/lib/index.js

@ -64,5 +64,6 @@ module.exports.models = function (dc) {
DataSource.belongsTo(Adapter, { foreignKey: 'adapterId', targetKey: 'id' });
Adapter.hasMany(DataSource, { foreignKey: 'adapterId', sourceKey: 'id' });
};

2
web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js

@ -24,7 +24,7 @@ function DataSourceModal(props) {
onFinish={onFinish}
stepProps={2}
currentChange={c => { setCurrent(c) }}
stepOneInitValue={{ ...editData, ...editData?.adapterInfo, description: editData?.description }}
stepOneInitValue={{ ...editData, ...editData?.adapter, description: editData?.description }}
stepTwoInitValue={{ ...editData?.config }}
{...props}
/>

20
web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js

@ -13,9 +13,9 @@ import { BellOutlined } from '@ant-design/icons'
import '../../style.less';
function StepThree(props) {
const { prev, next, } = props;
const { prev, next, dataSourceFilter, editData } = props;
const formRef = React.createRef();
const initialValues = {
const initialValues = editData ? editData : {
}
const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 16 } };
@ -33,7 +33,7 @@ function StepThree(props) {
onCancel: () => { },
}}
onFinish={async (values) => {
next()
next(values)
// return true;
}}
style={{ marginTop: 20 }}
@ -44,6 +44,20 @@ function StepThree(props) {
}}
>
{dataSourceFilter && < ProFormSelect
width={'md'}
rules={[{ required: true, message: '请选择数据源' }]}
options={dataSourceFilter?.map(s => {
return { label: s?.name, value: s?.id, disabled: s?.disabled }
})}
disabled={editData}
name="dataSourceId"
label="数据源"
fieldProps={{
showSearch: true
}}
/>
}
<ProFormText
width={'md'}
rules={[{ required: true, message: '请输入数据源名称' },

3
web/client/src/sections/metadataAcquisition/components/taskModal.js

@ -5,6 +5,7 @@ import { STEP_CONFIG } from './steps/index'
function DataSourceModal(props) {
const { visible, editData, onFinish, onCancel,
type = 'postgre',//当前卡片的key (目前只有postgre,支持后续扩展)
dataSourceFilter,
} = props;
const { StepThree } = STEP_CONFIG[type];
// const onFinish = () => { }
@ -17,7 +18,7 @@ function DataSourceModal(props) {
width={1200}
destroyOnClose={true}
>
<StepThree next={onFinish} />
<StepThree next={onFinish} dataSourceFilter={dataSourceFilter} editData={editData} />
</Modal>
</>
}

134
web/client/src/sections/metadataAcquisition/containers/acquisitionTask.js

@ -16,8 +16,8 @@ function AcquisitionTask(props) {
const [editData, setEditData] = useState(null);//模态框编辑数据
const queryData = (search) => {
const query = {
limit: search ? 10 : pageSize || 10,
page: search ? 1 : currentPage || 1,
// limit: search ? 10 : pageSize || 10,
// page: search ? 1 : currentPage || 1,
taskName: searchValue
}
dispatch(actions.metadataAcquisition.getTasks(query));
@ -30,29 +30,28 @@ function AcquisitionTask(props) {
}, [pageSize, currentPage]);
const handleDelete = (id) => {
dispatch(actions.metadataAcquisition.deleteDataSource(id)).then(() => {
dispatch(actions.metadataAcquisition.deleteTask(id)).then(() => {
queryData();
});
};
const columns = [
{
title: '数据源名称',
title: '任务名称',
dataIndex: 'taskName',
},
{
title: '数据源名称',
dataIndex: 'name',
},
{
title: '挂载点',
dataIndex: 'mountPath',
dataIndex: 'dataSourceName',
render: (text, record) => {
return record?.dataSource?.name
}
},
{
title: '适配器类型',
dataIndex: 'adapter',
render: (text, record) => {
const adapterInfo = adapters?.find(s => s.id == record?.adapter)
const adapterInfo = record?.dataSource?.adapter
return adapterInfo?.adapterName
}
},
@ -60,29 +59,23 @@ function AcquisitionTask(props) {
title: '采集方式',
dataIndex: 'control',
render: (text, record) => {
const adapterInfo = adapters?.find(s => s.id == record?.adapter)
const adapterInfo = record?.dataSource?.adapter
return adapterInfo?.mode
}
},
{
title: '工具版本',
dataIndex: 'length',
render: (text, record) => {
const adapterInfo = adapters?.find(s => s.id == record?.adapter)
return adapterInfo?.adapterVersion
}
title: '执行周期',
dataIndex: 'dataSourceName',
},
{
title: '修改时间',
dataIndex: 'time',
render: (text, record) => moment(record?.time).format('YYYY-MM-DD HH:mm:ss')
title: '重复次数',
dataIndex: 'retryCount',
},
{
title: '描述',
dataIndex: 'description',
ellipsis: true,
search: false,
title: '时间间隔',
dataIndex: 'retryTime',
},
{
title: '操作',
width: 160,
@ -115,36 +108,35 @@ function AcquisitionTask(props) {
];
const onFinish = (values) => {
const { stepOneValues, stepTwoValues } = values;
const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName)
if (adapterInfo) {
const dataToSave = {
name: stepOneValues?.name,
audited: true,
adapter: adapterInfo?.id,
mountPath: 1,
description: stepOneValues?.description,
config: stepTwoValues,
time: moment()
}
if (editData) {
dispatch(actions.metadataAcquisition.modifyTask(editData?.id, dataToSave)).then(res => {
if (res.success) {
setVisible(false);
setEditData(null);
queryData();
}
})
} else {
dispatch(actions.metadataAcquisition.addTask(dataToSave)).then(res => {
if (res.success) {
setVisible(false);
setEditData(null);
queryData();
}
})
}
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}>
@ -169,22 +161,22 @@ function AcquisitionTask(props) {
total: tasks?.count,
showSizeChanger: true,
// showQuickJumper: true,
current: currentPage,
pageSize: pageSize || 10,
pageSizeOptions: [10, 20, 50],
showTotal: (total) => {
return <span style={{ fontSize: 15 }}>{`${Math.ceil(total / pageSize)}页,${total}`}</span>
},
onShowSizeChange: (currentPage, pageSize) => {
setCurrentPage(currentPage);
setPageSize(pageSize);
},
onChange: (page, pageSize) => {
setCurrentPage(page);
setPageSize(pageSize);
}
// current: currentPage,
// pageSize: pageSize || 10,
// pageSizeOptions: [10, 20, 50],
// showTotal: (total) => {
// return <span style={{ fontSize: 15 }}>{`共${Math.ceil(total / pageSize)}页,${total}项`}</span>
// },
// onShowSizeChange: (currentPage, pageSize) => {
// setCurrentPage(currentPage);
// setPageSize(pageSize);
// },
// onChange: (page, pageSize) => {
// setCurrentPage(page);
// setPageSize(pageSize);
// }
}}
dataSource={tasks?.rows || []}
options={false}
@ -201,6 +193,10 @@ function AcquisitionTask(props) {
editData={editData}
visible={visible}
onFinish={onFinish}
dataSourceFilter={dataSources?.rows?.map(s => {
s.disabled = !!tasks?.rows?.find(x => x.dataSourceId == s.id);
return s;
})}
{...props}
/>
}

11
web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js

@ -87,9 +87,7 @@ function DataSourceManagement(props) {
render: (text, record) => {
const options = [];
options.push(<a onClick={() => {
const adapterInfo = adapters?.find(x => x.id == record?.adapter)
setVisible(true)
record.adapterInfo = adapterInfo
setEditData(record)
}} style={{ marginRight: 8 }}>编辑</a>)
options.push(
@ -103,7 +101,6 @@ function DataSourceManagement(props) {
>
<a>删除</a>
</Popconfirm>)
return options;
},
@ -117,7 +114,7 @@ function DataSourceManagement(props) {
const dataToSave = {
name: stepOneValues?.name,
audited: true,
adapter: adapterInfo?.id,
adapterId: adapterInfo?.id,
mountPath: 1,
description: stepOneValues?.description,
config: stepTwoValues,
@ -148,7 +145,11 @@ function DataSourceManagement(props) {
<Col span={12}><Button type='primary' onClick={() => { setVisible(true) }}>新建</Button></Col>
<Col span={12} style={{ textAlign: 'right' }}><Input
value={searchValue} onChange={e => { setSearchValue(e.target.value) }}
style={{ width: 220, marginRight: 15 }} placeholder="数据源名称" /><Button onClick={() => { queryData() }} type='primary'>查询</Button></Col>
style={{ width: 220, marginRight: 15 }} placeholder="数据源名称" /><Button onClick={() => {
setCurrentPage(1)
setPageSize(10)
queryData(true)
}} type='primary'>查询</Button></Col>
</Row>
<ProTable
columns={columns}

Loading…
Cancel
Save