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 = {
where: searchWhere,
order: [["id", "desc"]],
include: [{ model: models.Adapter }]
include: [
{ model: models.Adapter },
{ model: models.ResourceCatalog },
]
}
if (name) {

4
api/app/lib/index.js

@ -55,13 +55,15 @@ module.exports.models = function (dc) {
});
const {
DataSource, AcquisitionTask, Adapter, User, MetadataDatabase, MetadataFile, MetadataRestapi, AcquisitionLog
DataSource, AcquisitionTask, Adapter, User, MetadataDatabase, MetadataFile, MetadataRestapi, AcquisitionLog, ResourceCatalog
} = dc.models;
AcquisitionTask.belongsTo(DataSource, { foreignKey: 'dataSourceId', targetKey: 'id' });
DataSource.hasMany(AcquisitionTask, { foreignKey: 'dataSourceId', sourceKey: 'id' });
AcquisitionLog.belongsTo(AcquisitionTask, { foreignKey: 'task', targetKey: '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' });
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
}
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();
return <Spin spinning={loading || treeDataFilter.length == 0}>
<ProForm
formRef={formRef}
title={''}
initialValues={initialValues}
layout="horizontal"
grid={true}
{...formItemLayout}
modalProps={{
destroyOnClose: true,
onCancel: () => { },
}}
onFinish={async (values) => {
values.mountPath = values.catalogKey.split('-')[values.catalogKey.split('-')?.length - 1]
next()
stepOneValuesFinish(values)
return true;
}}
style={{ marginTop: 20 }}
submitter={{
render: (props, defaultDoms) => {
return null;
},
}}
>
return <ProForm
formRef={formRef}
title={''}
initialValues={initialValues}
layout="horizontal"
grid={true}
{...formItemLayout}
modalProps={{
destroyOnClose: true,
onCancel: () => { },
}}
onFinish={async (values) => {
values.mountPath = values.catalogKey.split('-')[values.catalogKey.split('-')?.length - 1]
next()
stepOneValuesFinish(values)
return true;
}}
style={{ marginTop: 20 }}
submitter={{
render: (props, defaultDoms) => {
return null;
},
}}
>
<ProFormText
rules={[
{ required: true, message: '请输入数据源名称' },
{ max: 255, message: '数据源名称长度不能大于255个字符' },
]}
name="name"
label="数据源名称"
/>
<ProFormText
rules={[
{ required: true, message: '请输入数据源名称' },
{ max: 255, message: '数据源名称长度不能大于255个字符' },
]}
name="name"
label="数据源名称"
/>
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: 'PostgreSQL采集适配器', value: 'PostgreSQL采集适配器' },
]}
name="adapterName"
label="适配器"
disabled={readOnly}
/>
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: 'PostgreSQL采集适配器', value: 'PostgreSQL采集适配器' },
]}
name="adapterName"
label="适配器"
disabled={readOnly}
/>
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: '9.x', value: '9.x' },
]}
name="adapterVersion"
label="工具版本"
disabled={readOnly}
/>
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: '数据库连接', value: '数据库连接' },
]}
name="mode"
label="采集模式"
disabled={readOnly}
/>
{/* <ProFormSelect
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: '9.x', value: '9.x' },
]}
name="adapterVersion"
label="工具版本"
disabled={readOnly}
/>
<ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[
{ label: '数据库连接', value: '数据库连接' },
]}
name="mode"
label="采集模式"
disabled={readOnly}
/>
{/* <ProFormSelect
rules={[{ required: true, message: '请选择输入控件' }]}
options={[
{ label: '库表/目录1', value: 1 },
@ -114,68 +126,58 @@ function StepOne(props) {
label="数据源挂载路径"
// disabled={true}
/> */}
{treeDataFilter.length > 0 ? <ProFormTreeSelect
key={JSON.stringify(treeDataFilter)}
// width={'md'}
name="catalogKey"
label="数据源挂载路径"
placeholder="请选择数据源挂载路径"
rules={[{ required: true, message: '请选择数据源挂载路径' }]}
allowClear
width={480}
secondary
request={async () => {
return treeDataFilter || [];
}}
// tree-select args
fieldProps={{
showArrow: false,
filterTreeNode: true,
showSearch: true,
dropdownMatchSelectWidth: false,
labelInValue: false,
autoClearSearchValue: true,
multiple: false,
treeNodeFilterProp: 'title',
fieldNames: {
label: 'title',
},
}}
addonAfter={!editData && <>
<a onClick={() => {
dispatch(push(`/metadataManagement/latestMetadata`));
}} style={{ marginRight: 8 }}>新建</a>
<a onClick={() => {
formRef?.current?.setFieldsValue({
catalogKey: null
})
refresh()
}}>刷新</a>
</>}
disabled={editData}
/> : <ProFormSelect
rules={[{ required: true, message: '请选择' }]}
options={[]}
name="catalogKey"
label="数据源挂载路径"
placeholder="请选择数据源挂载路径"
disabled={editData}
/>}
{treeDataFilter.length > 0 ? <ProFormTreeSelect
key={JSON.stringify(treeDataFilter)}
// width={'md'}
name="catalogKey"
label="数据源挂载路径"
placeholder="请选择数据源挂载路径"
rules={[{ required: true, message: '请选择数据源挂载路径' }]}
allowClear
width={480}
secondary
request={async () => {
return treeDataFilter || [];
}}
// tree-select args
fieldProps={{
showArrow: false,
filterTreeNode: true,
showSearch: true,
dropdownMatchSelectWidth: false,
labelInValue: false,
autoClearSearchValue: true,
multiple: false,
treeNodeFilterProp: 'title',
fieldNames: {
label: 'title',
},
}}
addonAfter={renderAddonAfter()}
disabled={editData}
/> : <ProFormSelect
width={480}
rules={[{ required: true, message: '请选择' }]}
options={[]}
name="catalogKey"
label="数据源挂载路径"
addonAfter={renderAddonAfter()}
placeholder="请选择数据源挂载路径"
disabled={editData}
/>}
<ProFormTextArea
name="description"
label="描述"
rules={[{ max: 255, message: '描述长度不能大于255个字符' }]}
/>
<ProFormTextArea
name="description"
label="描述"
rules={[{ max: 255, message: '描述长度不能大于255个字符' }]}
/>
<div className='step-footer'>
<Button type="primary" htmlType="submit">
下一步
</Button>
</div>
</ProForm>
</Spin >
<div className='step-footer'>
<Button type="primary" htmlType="submit">
下一步
</Button>
</div>
</ProForm>
}
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 { history, actions, dispatch, adapters } = props;
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(() => {
dispatch(actions.metadataAcquisition.getAdapters())
dispatch(actions.metadataAcquisition.getDataSources());
@ -35,6 +41,11 @@ const LatestMetadata = (props) => {
{ label: '关系型数据库', key: '关系型数据库', children: renderRelationalDatabase() },
];
const refresh = () => {
// queryData();
setRefreshTree(refreshTree + 1)
}
const onFinish = (values) => {
const { stepOneValues, stepTwoValues, stepThreeValue } = values;
const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName)
@ -86,6 +97,7 @@ const LatestMetadata = (props) => {
type={isModalOpen} //当前卡片的key (目前只有postgre,支持后续扩展)
onFinish={onFinish}
treeData={treeData}
refresh={refresh}
{...props}
/>
</Modal>

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

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

Loading…
Cancel
Save