|
|
@ -5,20 +5,22 @@ import ProTable from '@ant-design/pro-table'; |
|
|
|
|
|
|
|
const TreeNode = Tree.TreeNode; |
|
|
|
function DataSourceManagement(props) { |
|
|
|
const { loading, clientHeight, actions, dispatch, metaModel } = props; |
|
|
|
const { loading, clientHeight, actions, dispatch, dataSources, adapters } = props; |
|
|
|
const [pageSize, setPageSize] = useState(10); |
|
|
|
const [currentPage, setCurrentPage] = useState(1); |
|
|
|
|
|
|
|
const [searchValue, setSearchValue] = useState('') |
|
|
|
const queryData = (search) => { |
|
|
|
const query = { |
|
|
|
limit: search ? 10 : pageSize || 10, |
|
|
|
page: search ? 1 : currentPage || 1, |
|
|
|
name: searchValue |
|
|
|
} |
|
|
|
|
|
|
|
dispatch(actions.metadataManagement.getMetaModelList(query)); |
|
|
|
dispatch(actions.metadataAcquisition.getDataSources(query)); |
|
|
|
} |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
dispatch(actions.metadataAcquisition.getAdapters()) |
|
|
|
queryData(); |
|
|
|
}, [pageSize, currentPage]); |
|
|
|
|
|
|
@ -28,73 +30,46 @@ function DataSourceManagement(props) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const onFinish = async (values, editData) => { |
|
|
|
if (editData) { |
|
|
|
const dataToSave = { ...values } |
|
|
|
return dispatch( |
|
|
|
actions.metadataManagement.modifyMetaModel(editData.id, dataToSave, values?.msg || ''), |
|
|
|
).then(() => { |
|
|
|
queryData(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
return dispatch(actions.metadataManagement.addMetaModel({ |
|
|
|
...values, |
|
|
|
})).then(() => { |
|
|
|
queryData(); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
title: '属性名称', |
|
|
|
dataIndex: 'attributeName', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
title: '数据源名称', |
|
|
|
dataIndex: 'name', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '属性代码', |
|
|
|
dataIndex: 'attributeCode', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
title: '挂载点', |
|
|
|
dataIndex: 'mountPath', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '数据类型', |
|
|
|
dataIndex: 'dataType', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
title: '适配器类型', |
|
|
|
dataIndex: 'adapter', |
|
|
|
render: (text, record) => { |
|
|
|
const adapterInfo = adapters?.find(s => s.id == record?.adapter) |
|
|
|
return adapterInfo?.adapterName |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '输入控件', |
|
|
|
title: '采集方式', |
|
|
|
dataIndex: 'control', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
render: (text, record) => { |
|
|
|
const adapterInfo = adapters?.find(s => s.id == record?.adapter) |
|
|
|
return adapterInfo?.toolName |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '长度', |
|
|
|
title: '工具版本', |
|
|
|
dataIndex: 'length', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
render: (text, record) => { |
|
|
|
const adapterInfo = adapters?.find(s => s.id == record?.adapter) |
|
|
|
return adapterInfo?.adapterVersion |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '允许为空', |
|
|
|
title: '修改时间', |
|
|
|
dataIndex: 'nullable', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
render: (text, record) => record?.nullable ? '是' : '否' |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '是否只读', |
|
|
|
dataIndex: 'readOnly', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
render: (text, record) => record?.readOnly ? '是' : '否' |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '描述', |
|
|
|
dataIndex: 'description', |
|
|
|
ellipsis: true, |
|
|
|
search: false, |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '操作', |
|
|
@ -103,7 +78,7 @@ function DataSourceManagement(props) { |
|
|
|
valueType: 'option', |
|
|
|
render: (text, record) => { |
|
|
|
const options = []; |
|
|
|
options.push(<a>编辑</a>) |
|
|
|
options.push(<a style={{ marginRight: 8 }}>编辑</a>) |
|
|
|
options.push( |
|
|
|
<Popconfirm |
|
|
|
key="del" |
|
|
@ -124,7 +99,9 @@ function DataSourceManagement(props) { |
|
|
|
return <Spin spinning={loading}> |
|
|
|
<Row style={{ marginBottom: 16 }}> |
|
|
|
<Col span={12}><Button type='primary'>新建</Button></Col> |
|
|
|
<Col span={12} style={{ textAlign: 'right' }}><Input style={{ width: 220, marginRight: 15 }} placeholder="数据源名称" /><Button type='primary'>查询</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> |
|
|
|
</Row> |
|
|
|
<Table |
|
|
|
columns={columns} |
|
|
@ -138,7 +115,7 @@ function DataSourceManagement(props) { |
|
|
|
} |
|
|
|
pagination={{ |
|
|
|
size: 'large', |
|
|
|
total: metaModel?.count, |
|
|
|
total: dataSources?.count, |
|
|
|
showSizeChanger: true, |
|
|
|
// showQuickJumper: true,
|
|
|
|
current: currentPage, |
|
|
@ -158,7 +135,7 @@ function DataSourceManagement(props) { |
|
|
|
|
|
|
|
} |
|
|
|
}} |
|
|
|
dataSource={metaModel?.rows || []} |
|
|
|
dataSource={dataSources?.rows || []} |
|
|
|
options={false} |
|
|
|
/> |
|
|
|
</Spin> |
|
|
@ -167,13 +144,14 @@ function DataSourceManagement(props) { |
|
|
|
|
|
|
|
function mapStateToProps(state) { |
|
|
|
const { |
|
|
|
auth, global, metaModel |
|
|
|
auth, global, datasources, adapters |
|
|
|
} = state; |
|
|
|
return { |
|
|
|
loading: metaModel.isRequesting, |
|
|
|
loading: datasources.isRequesting || adapters?.isRequesting, |
|
|
|
clientHeight: global.clientHeight, |
|
|
|
actions: global.actions, |
|
|
|
metaModel: metaModel?.data || {} |
|
|
|
dataSources: datasources?.data || {}, |
|
|
|
adapters: adapters?.data || [] |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|