diff --git a/api/app/lib/controllers/metadataAcquisition/dataSource.js b/api/app/lib/controllers/metadataAcquisition/dataSource.js
index 004e619..5fdfac0 100644
--- a/api/app/lib/controllers/metadataAcquisition/dataSource.js
+++ b/api/app/lib/controllers/metadataAcquisition/dataSource.js
@@ -20,15 +20,36 @@ function addDataSource(opts) {
function getDataSource(opts) {
return async function (ctx, next) {
+
const models = ctx.fs.dc.models;
+ const { page, limit, name } = ctx.query;
let errMsg = { message: '获取数据源失败' }
+ const Op = ctx.fs.dc.ORM.Op;
try {
+ let searchWhere = {}
let option = {
- where: {},
+ where: searchWhere,
order: [["id", "desc"]],
}
- const res = await models.DataSource.findAll(option);
+ if (name) {
+ searchWhere.name = {
+ // 模糊查询
+ [Op.like]: '%' + name + '%',
+ };
+ }
+
+ option.where = searchWhere
+
+ let limit_ = limit || 10;
+ let page_ = page || 1;
+ let offset = (page_ - 1) * limit_;
+ if (limit && page) {
+ option.limit = limit_
+ option.offset = offset
+ }
+
+ const res = await models.DataSource.findAndCount(option);
ctx.status = 200;
ctx.body = res;
} catch (error) {
diff --git a/api/app/lib/routes/modelManagement/index.js b/api/app/lib/routes/modelManagement/index.js
index 3edd18b..dcd4223 100644
--- a/api/app/lib/routes/modelManagement/index.js
+++ b/api/app/lib/routes/modelManagement/index.js
@@ -1,6 +1,6 @@
'use strict';
-const model = require('../../controllers/model-management/index');
+const model = require('../../controllers/modelManagement/index');
module.exports = function (app, router, opts, AuthCode) {
diff --git a/web/client/src/sections/metadataAcquisition/actions/dataSource.js b/web/client/src/sections/metadataAcquisition/actions/dataSource.js
index 54a4900..a4639b0 100644
--- a/web/client/src/sections/metadataAcquisition/actions/dataSource.js
+++ b/web/client/src/sections/metadataAcquisition/actions/dataSource.js
@@ -16,3 +16,16 @@ export function addDataSource(params, msg) {
});
}
+export function getDataSources(query) {
+ return dispatch => basicAction({
+ type: 'get',
+ dispatch: dispatch,
+ query: query || {},
+ actionType: 'GET_ACQ_DATASOURCES',
+ url: `${ApiTable.getDataSources}`,
+ msg: { error: '获取适配器列表失败' },
+ reducer: { name: 'datasources' }
+ });
+}
+
+
diff --git a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js
index e738349..930e8dd 100644
--- a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js
+++ b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js
@@ -79,7 +79,7 @@ function StepTwo(props) {
];
const checkNext = () => {
- if (!(params?.user || params?.host || params?.database || params?.password || params?.port)) {
+ if (!(params?.user && params?.host && params?.database && params?.password && params?.port)) {
message.warning('请填写完整的参数值!')
return false;
} else {
diff --git a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
index 65c985b..e8497eb 100644
--- a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
+++ b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
@@ -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(编辑)
+ options.push(编辑)
options.push(
-
+ { setSearchValue(e.target.value) }}
+ style={{ width: 220, marginRight: 15 }} placeholder="数据源名称" />
@@ -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 || []
};
}
diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js
index d3dcd1d..e382760 100644
--- a/web/client/src/utils/webapi.js
+++ b/web/client/src/utils/webapi.js
@@ -22,6 +22,7 @@ export const ApiTable = {
pgCheckConnect: 'adapter/check/connect',
addDataSource: 'meta/acq/dataSource',
getAdapters: 'meta/acq/adapters',
+ getDataSources: 'meta/acq/dataSources',
};
export const RouteTable = {