Browse Source

(*)元数据采集自测完善

master
peng.peng 2 years ago
parent
commit
8b1f32c268
  1. 5
      api/app/lib/controllers/metadataAcquisition/dataSource.js
  2. 4
      api/app/lib/index.js
  3. 1
      scripts/0.0.3/schema/04_update_t_adapter.sql
  4. 246
      web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js
  5. 14
      web/client/src/sections/metadataAcquisition/containers/adapter.js
  6. 1
      web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js

5
api/app/lib/controllers/metadataAcquisition/dataSource.js

@ -42,7 +42,10 @@ function getDataSource(opts) {
let option = { let option = {
where: searchWhere, where: searchWhere,
order: [["id", "desc"]], order: [["id", "desc"]],
include: [{ model: models.Adapter }] include: [
{ model: models.Adapter },
{ model: models.ResourceCatalog },
]
} }
if (name) { if (name) {

4
api/app/lib/index.js

@ -55,13 +55,15 @@ module.exports.models = function (dc) {
}); });
const { const {
DataSource, AcquisitionTask, Adapter, User, MetadataDatabase, MetadataFile, MetadataRestapi, AcquisitionLog DataSource, AcquisitionTask, Adapter, User, MetadataDatabase, MetadataFile, MetadataRestapi, AcquisitionLog, ResourceCatalog
} = dc.models; } = dc.models;
AcquisitionTask.belongsTo(DataSource, { foreignKey: 'dataSourceId', targetKey: 'id' }); AcquisitionTask.belongsTo(DataSource, { foreignKey: 'dataSourceId', targetKey: 'id' });
DataSource.hasMany(AcquisitionTask, { foreignKey: 'dataSourceId', sourceKey: 'id' }); DataSource.hasMany(AcquisitionTask, { foreignKey: 'dataSourceId', sourceKey: 'id' });
AcquisitionLog.belongsTo(AcquisitionTask, { foreignKey: 'task', targetKey: 'id' }); AcquisitionLog.belongsTo(AcquisitionTask, { foreignKey: 'task', targetKey: 'id' });
AcquisitionTask.hasMany(AcquisitionLog, { foreignKey: 'task', sourceKey: 'id' }); AcquisitionTask.hasMany(AcquisitionLog, { foreignKey: 'task', sourceKey: 'id' });
DataSource.belongsTo(ResourceCatalog, { foreignKey: 'mountPath', targetKey: 'id' });
ResourceCatalog.hasMany(DataSource, { foreignKey: 'mountPath', sourceKey: 'id' });
DataSource.belongsTo(Adapter, { foreignKey: 'adapterId', targetKey: 'id' }); DataSource.belongsTo(Adapter, { foreignKey: 'adapterId', targetKey: 'id' });
Adapter.hasMany(DataSource, { foreignKey: 'adapterId', sourceKey: 'id' }); Adapter.hasMany(DataSource, { foreignKey: 'adapterId', sourceKey: 'id' });

1
scripts/0.0.3/schema/04_update_t_adapter.sql

@ -0,0 +1 @@
update t_adapter set mode = '数据库连接' where id = 1;

246
web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js

@ -40,72 +40,84 @@ function StepOne(props) {
} }
return treeData return treeData
} }
const treeDataFilter = treeData && dataSources?.rows?.length > 0 ? getTreeNodeData(treeData, null, 'rc') : [] const renderAddonAfter = () => {
return !editData && <>
<a onClick={() => {
dispatch(push(`/metadataManagement/latestMetadata`));
}} style={{ marginRight: 8 }}>新建</a>
<a onClick={() => {
formRef?.current?.setFieldsValue({
catalogKey: null
})
refresh && refresh()
}}>刷新</a>
</>
}
const treeDataFilter = treeData ? getTreeNodeData(treeData, null, 'rc') : []
const formRef = useRef(); const formRef = useRef();
return <Spin spinning={loading || treeDataFilter.length == 0}> return <ProForm
<ProForm formRef={formRef}
formRef={formRef} title={''}
title={''} initialValues={initialValues}
initialValues={initialValues} layout="horizontal"
layout="horizontal" grid={true}
grid={true} {...formItemLayout}
{...formItemLayout} modalProps={{
modalProps={{ destroyOnClose: true,
destroyOnClose: true, onCancel: () => { },
onCancel: () => { }, }}
}} onFinish={async (values) => {
onFinish={async (values) => { values.mountPath = values.catalogKey.split('-')[values.catalogKey.split('-')?.length - 1]
values.mountPath = values.catalogKey.split('-')[values.catalogKey.split('-')?.length - 1] next()
next() stepOneValuesFinish(values)
stepOneValuesFinish(values) return true;
return true; }}
}} style={{ marginTop: 20 }}
style={{ marginTop: 20 }} submitter={{
submitter={{ render: (props, defaultDoms) => {
render: (props, defaultDoms) => { return null;
return null; },
}, }}
}} >
>
<ProFormText <ProFormText
rules={[ rules={[
{ required: true, message: '请输入数据源名称' }, { required: true, message: '请输入数据源名称' },
{ max: 255, message: '数据源名称长度不能大于255个字符' }, { max: 255, message: '数据源名称长度不能大于255个字符' },
]} ]}
name="name" name="name"
label="数据源名称" label="数据源名称"
/> />
<ProFormSelect <ProFormSelect
rules={[{ required: true, message: '请选择' }]} rules={[{ required: true, message: '请选择' }]}
options={[ options={[
{ label: 'PostgreSQL采集适配器', value: 'PostgreSQL采集适配器' }, { label: 'PostgreSQL采集适配器', value: 'PostgreSQL采集适配器' },
]} ]}
name="adapterName" name="adapterName"
label="适配器" label="适配器"
disabled={readOnly} disabled={readOnly}
/> />
<ProFormSelect <ProFormSelect
rules={[{ required: true, message: '请选择' }]} rules={[{ required: true, message: '请选择' }]}
options={[ options={[
{ label: '9.x', value: '9.x' }, { label: '9.x', value: '9.x' },
]} ]}
name="adapterVersion" name="adapterVersion"
label="工具版本" label="工具版本"
disabled={readOnly} disabled={readOnly}
/> />
<ProFormSelect <ProFormSelect
rules={[{ required: true, message: '请选择' }]} rules={[{ required: true, message: '请选择' }]}
options={[ options={[
{ label: '数据库连接', value: '数据库连接' }, { label: '数据库连接', value: '数据库连接' },
]} ]}
name="mode" name="mode"
label="采集模式" label="采集模式"
disabled={readOnly} disabled={readOnly}
/> />
{/* <ProFormSelect {/* <ProFormSelect
rules={[{ required: true, message: '请选择输入控件' }]} rules={[{ required: true, message: '请选择输入控件' }]}
options={[ options={[
{ label: '库表/目录1', value: 1 }, { label: '库表/目录1', value: 1 },
@ -114,68 +126,58 @@ function StepOne(props) {
label="数据源挂载路径" label="数据源挂载路径"
// disabled={true} // disabled={true}
/> */} /> */}
{treeDataFilter.length > 0 ? <ProFormTreeSelect {treeDataFilter.length > 0 ? <ProFormTreeSelect
key={JSON.stringify(treeDataFilter)} key={JSON.stringify(treeDataFilter)}
// width={'md'} // width={'md'}
name="catalogKey" name="catalogKey"
label="数据源挂载路径" label="数据源挂载路径"
placeholder="请选择数据源挂载路径" placeholder="请选择数据源挂载路径"
rules={[{ required: true, message: '请选择数据源挂载路径' }]} rules={[{ required: true, message: '请选择数据源挂载路径' }]}
allowClear allowClear
width={480} width={480}
secondary secondary
request={async () => { request={async () => {
return treeDataFilter || []; return treeDataFilter || [];
}} }}
// tree-select args // tree-select args
fieldProps={{ fieldProps={{
showArrow: false, showArrow: false,
filterTreeNode: true, filterTreeNode: true,
showSearch: true, showSearch: true,
dropdownMatchSelectWidth: false, dropdownMatchSelectWidth: false,
labelInValue: false, labelInValue: false,
autoClearSearchValue: true, autoClearSearchValue: true,
multiple: false, multiple: false,
treeNodeFilterProp: 'title', treeNodeFilterProp: 'title',
fieldNames: { fieldNames: {
label: 'title', label: 'title',
}, },
}} }}
addonAfter={!editData && <> addonAfter={renderAddonAfter()}
<a onClick={() => { disabled={editData}
dispatch(push(`/metadataManagement/latestMetadata`)); /> : <ProFormSelect
}} style={{ marginRight: 8 }}>新建</a> width={480}
<a onClick={() => { rules={[{ required: true, message: '请选择' }]}
formRef?.current?.setFieldsValue({ options={[]}
catalogKey: null name="catalogKey"
}) label="数据源挂载路径"
refresh() addonAfter={renderAddonAfter()}
}}>刷新</a> placeholder="请选择数据源挂载路径"
</>} disabled={editData}
disabled={editData} />}
/> : <ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[]}
name="catalogKey"
label="数据源挂载路径"
placeholder="请选择数据源挂载路径"
disabled={editData}
/>}
<ProFormTextArea <ProFormTextArea
name="description" name="description"
label="描述" label="描述"
rules={[{ max: 255, message: '描述长度不能大于255个字符' }]} rules={[{ max: 255, message: '描述长度不能大于255个字符' }]}
/> />
<div className='step-footer'> <div className='step-footer'>
<Button type="primary" htmlType="submit"> <Button type="primary" htmlType="submit">
下一步 下一步
</Button> </Button>
</div> </div>
</ProForm> </ProForm>
</Spin >
} }
export default StepOne export default StepOne

14
web/client/src/sections/metadataAcquisition/containers/adapter.js

@ -10,7 +10,13 @@ import { useFsRequest, ApiTable } from '$utils';
const LatestMetadata = (props) => { const LatestMetadata = (props) => {
const { history, actions, dispatch, adapters } = props; const { history, actions, dispatch, adapters } = props;
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const { data: treeData = [] } = useFsRequest({ url: ApiTable.getResourceCatalog }); const [refreshTree, setRefreshTree] = useState(1);
const { data: treeData = [] } = useFsRequest({
url: ApiTable.getResourceCatalog,
refreshDeps: [refreshTree]
});
useEffect(() => { useEffect(() => {
dispatch(actions.metadataAcquisition.getAdapters()) dispatch(actions.metadataAcquisition.getAdapters())
dispatch(actions.metadataAcquisition.getDataSources()); dispatch(actions.metadataAcquisition.getDataSources());
@ -35,6 +41,11 @@ const LatestMetadata = (props) => {
{ label: '关系型数据库', key: '关系型数据库', children: renderRelationalDatabase() }, { label: '关系型数据库', key: '关系型数据库', children: renderRelationalDatabase() },
]; ];
const refresh = () => {
// queryData();
setRefreshTree(refreshTree + 1)
}
const onFinish = (values) => { const onFinish = (values) => {
const { stepOneValues, stepTwoValues, stepThreeValue } = values; const { stepOneValues, stepTwoValues, stepThreeValue } = values;
const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName) const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName)
@ -86,6 +97,7 @@ const LatestMetadata = (props) => {
type={isModalOpen} //当前卡片的key (目前只有postgre,支持后续扩展) type={isModalOpen} //当前卡片的key (目前只有postgre,支持后续扩展)
onFinish={onFinish} onFinish={onFinish}
treeData={treeData} treeData={treeData}
refresh={refresh}
{...props} {...props}
/> />
</Modal> </Modal>

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

@ -47,6 +47,7 @@ function DataSourceManagement(props) {
{ {
title: '挂载点', title: '挂载点',
dataIndex: 'mountPath', dataIndex: 'mountPath',
render: (text, record) => record?.resourceCatalog?.name
}, },
{ {
title: '适配器类型', title: '适配器类型',

Loading…
Cancel
Save