From 6052633cbfa22a1ac3e8e902f86ad129854fe7fe Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Fri, 17 Mar 2023 15:49:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA=E5=AE=8C=E5=96=84=20?= =?UTF-8?q?=E9=80=82=E9=85=8D=E5=99=A8=E5=A2=9E=E5=8A=A0=E9=87=87=E9=9B=86?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=AD=97=E6=AE=B5=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/models/adapter.js | 11 +++++++- api/app/lib/models/data_source.js | 9 +++++++ .../0.0.3/schema/01_alter_t_data_source.sql | 2 ++ scripts/0.0.3/schema/02_alter_t_adapter.sql | 2 ++ .../metadataAcquisition/containers/adapter.js | 25 ++++++++++++------- .../containers/dataSourceManagement.js | 16 +++++++----- .../metadataAcquisition/containers/style.less | 5 ++++ 7 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 scripts/0.0.3/schema/01_alter_t_data_source.sql create mode 100644 scripts/0.0.3/schema/02_alter_t_adapter.sql create mode 100644 web/client/src/sections/metadataAcquisition/containers/style.less diff --git a/api/app/lib/models/adapter.js b/api/app/lib/models/adapter.js index a1614bf..96e1810 100644 --- a/api/app/lib/models/adapter.js +++ b/api/app/lib/models/adapter.js @@ -60,7 +60,16 @@ module.exports = dc => { primaryKey: false, field: "config", autoIncrement: false - } + }, + mode: { + type: DataTypes.STRING, + allowNull: false, + defaultValue: null, + comment: "采集模式", + primaryKey: false, + field: "mode", + autoIncrement: false + }, }, { tableName: "t_adapter", comment: "", diff --git a/api/app/lib/models/data_source.js b/api/app/lib/models/data_source.js index 6ce8b21..17fdab5 100644 --- a/api/app/lib/models/data_source.js +++ b/api/app/lib/models/data_source.js @@ -77,6 +77,15 @@ module.exports = dc => { primaryKey: false, field: "config", autoIncrement: false + }, + time: { + type: DataTypes.DATE, + allowNull: true, + defaultValue: null, + comment: "修改时间", + primaryKey: false, + field: "time", + autoIncrement: false } }, { tableName: "t_data_source", diff --git a/scripts/0.0.3/schema/01_alter_t_data_source.sql b/scripts/0.0.3/schema/01_alter_t_data_source.sql new file mode 100644 index 0000000..c8902c6 --- /dev/null +++ b/scripts/0.0.3/schema/01_alter_t_data_source.sql @@ -0,0 +1,2 @@ +alter table t_data_source + add time timestamp(6) with time zone; diff --git a/scripts/0.0.3/schema/02_alter_t_adapter.sql b/scripts/0.0.3/schema/02_alter_t_adapter.sql new file mode 100644 index 0000000..4980e1a --- /dev/null +++ b/scripts/0.0.3/schema/02_alter_t_adapter.sql @@ -0,0 +1,2 @@ +alter table t_adapter + add mode varchar(255); \ No newline at end of file diff --git a/web/client/src/sections/metadataAcquisition/containers/adapter.js b/web/client/src/sections/metadataAcquisition/containers/adapter.js index 453ff5c..93d58a8 100644 --- a/web/client/src/sections/metadataAcquisition/containers/adapter.js +++ b/web/client/src/sections/metadataAcquisition/containers/adapter.js @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import { Tabs, Card, Modal } from 'antd' import { DatabaseOutlined } from '@ant-design/icons' import AdapterStep from '../components/adapterStep'; - +import moment from 'moment'; //关系型数据库卡片配置 const RELATION_DATABASE_TOOL_CONFIG = [{ key: 'postgre', // key与详情配置(adapterDetail)中的key需一直否则无法查看详情页 @@ -39,14 +39,21 @@ const LatestMetadata = (props) => { const onFinish = (values) => { const { stepOneValues, stepTwoValues } = values; - dispatch(actions.metadataAcquisition.addDataSource({ - name: stepOneValues?.name, - audited: true, - adapter: 1, - mountPath: 1, - description: stepOneValues?.description, - config: stepTwoValues - })) + const adapterName = RELATION_DATABASE_TOOL_CONFIG?.find(x => x.key == isModalOpen)?.name; + const adapterInfo = adapters?.find(x => x.adapterName == adapterName) + if (adapterInfo) { + dispatch(actions.metadataAcquisition.addDataSource({ + name: stepOneValues?.name, + audited: true, + adapter: adapterInfo?.id, + mountPath: 1, + description: stepOneValues?.description, + config: stepTwoValues, + time: moment() + })).then(res => { + setIsModalOpen(false) + }) + } } return <> diff --git a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js index e8497eb..a82ff6b 100644 --- a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js +++ b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js @@ -2,8 +2,8 @@ import React, { useEffect, useState } from 'react' import { Spin, Popconfirm, Tree, Row, Col, Button, Input, Table } from 'antd'; import { connect } from 'react-redux'; import ProTable from '@ant-design/pro-table'; - -const TreeNode = Tree.TreeNode; +import moment from 'moment'; +import './style.less'; function DataSourceManagement(props) { const { loading, clientHeight, actions, dispatch, dataSources, adapters } = props; const [pageSize, setPageSize] = useState(10); @@ -52,7 +52,7 @@ function DataSourceManagement(props) { dataIndex: 'control', render: (text, record) => { const adapterInfo = adapters?.find(s => s.id == record?.adapter) - return adapterInfo?.toolName + return adapterInfo?.mode } }, { @@ -65,11 +65,14 @@ function DataSourceManagement(props) { }, { title: '修改时间', - dataIndex: 'nullable', + dataIndex: 'time', + render: (text, record) => moment(record?.time).format('YYYY-MM-DD HH:mm:ss') }, { title: '描述', dataIndex: 'description', + ellipsis: true, + search: false, }, { title: '操作', @@ -96,14 +99,15 @@ function DataSourceManagement(props) { }, }, ]; + return - + { setSearchValue(e.target.value) }} style={{ width: 220, marginRight: 15 }} placeholder="数据源名称" /> -