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. 34
      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;

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

@ -40,10 +40,22 @@ 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}
@ -141,24 +153,15 @@ function StepOne(props) {
label: 'title', label: 'title',
}, },
}} }}
addonAfter={!editData && <> addonAfter={renderAddonAfter()}
<a onClick={() => {
dispatch(push(`/metadataManagement/latestMetadata`));
}} style={{ marginRight: 8 }}>新建</a>
<a onClick={() => {
formRef?.current?.setFieldsValue({
catalogKey: null
})
refresh()
}}>刷新</a>
</>}
disabled={editData} disabled={editData}
/> : <ProFormSelect /> : <ProFormSelect
width={480}
rules={[{ required: true, message: '请选择' }]} rules={[{ required: true, message: '请选择' }]}
options={[]} options={[]}
name="catalogKey" name="catalogKey"
label="数据源挂载路径" label="数据源挂载路径"
addonAfter={renderAddonAfter()}
placeholder="请选择数据源挂载路径" placeholder="请选择数据源挂载路径"
disabled={editData} disabled={editData}
/>} />}
@ -175,7 +178,6 @@ function StepOne(props) {
</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