diff --git a/api/app/lib/controllers/adapter/index.js b/api/app/lib/controllers/metadataAcquisition/adapter.js similarity index 60% rename from api/app/lib/controllers/adapter/index.js rename to api/app/lib/controllers/metadataAcquisition/adapter.js index a631665..7430cfa 100644 --- a/api/app/lib/controllers/adapter/index.js +++ b/api/app/lib/controllers/metadataAcquisition/adapter.js @@ -26,8 +26,26 @@ function checkConnect(opts) { } } +// 新增适配器 +function addAdapter(opts) { + return async function (ctx, next) { + + const models = ctx.fs.dc.models; + try { + let rslt = ctx.request.body; + await models.Adapter.create(Object.assign({}, rslt)) + ctx.status = 204; + ctx.body = { message: '新建适配器成功' } + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { message: '新建适配器失败' } + } + } +} + module.exports = { checkConnect, - + addAdapter } \ No newline at end of file diff --git a/api/app/lib/controllers/metadataAcquisition/dataSource.js b/api/app/lib/controllers/metadataAcquisition/dataSource.js new file mode 100644 index 0000000..40dabae --- /dev/null +++ b/api/app/lib/controllers/metadataAcquisition/dataSource.js @@ -0,0 +1,24 @@ +'use strict'; + +// 新增数据源 +function addDataSource(opts) { + return async function (ctx, next) { + + const models = ctx.fs.dc.models; + try { + let rslt = ctx.request.body; + await models.DataSource.create(Object.assign({}, rslt)) + ctx.status = 204; + ctx.body = { message: '新建数据源成功' } + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = { message: '新建数据源失败' } + } + } +} + + +module.exports = { + addDataSource, +} \ No newline at end of file diff --git a/api/app/lib/controllers/metadataAcquisition/log.js b/api/app/lib/controllers/metadataAcquisition/log.js new file mode 100644 index 0000000..e69de29 diff --git a/api/app/lib/controllers/metadataAcquisition/plan.js b/api/app/lib/controllers/metadataAcquisition/plan.js new file mode 100644 index 0000000..e69de29 diff --git a/api/app/lib/routes/adapter/index.js b/api/app/lib/routes/adapter/index.js deleted file mode 100644 index a98eac8..0000000 --- a/api/app/lib/routes/adapter/index.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -const model = require('../../controllers/adapter/index'); - -module.exports = function (app, router, opts, AuthCode) { - - app.fs.api.logAttr['POST/adapter/check/connect'] = { content: '增加模型信息', visible: true }; - router.post('/adapter/check/connect', model.checkConnect(opts)) - - - -}; diff --git a/api/app/lib/routes/metadataAcquisition/adapter.js b/api/app/lib/routes/metadataAcquisition/adapter.js new file mode 100644 index 0000000..db3184e --- /dev/null +++ b/api/app/lib/routes/metadataAcquisition/adapter.js @@ -0,0 +1,14 @@ +'use strict'; + +const adapter = require('../../controllers/metadataAcquisition/adapter'); + +module.exports = function (app, router, opts, AuthCode) { + + app.fs.api.logAttr['POST/adapter/check/connect'] = { content: '测试适配器连接', visible: true }; + router.post('/adapter/check/connect', adapter.checkConnect(opts)) + + app.fs.api.logAttr['POST/adapter'] = { content: '增加适配器', visible: true }; + router.post('/adapter', adapter.addAdapter(opts)) + + +}; diff --git a/api/app/lib/routes/metadataAcquisition/dataSource.js b/api/app/lib/routes/metadataAcquisition/dataSource.js new file mode 100644 index 0000000..13d23d2 --- /dev/null +++ b/api/app/lib/routes/metadataAcquisition/dataSource.js @@ -0,0 +1,12 @@ +'use strict'; + +const dataSource = require('../../controllers/metadataAcquisition/dataSource'); + +module.exports = function (app, router, opts, AuthCode) { + + app.fs.api.logAttr['POST/meta/acq/dataSource'] = { content: '增加模型信息', visible: true }; + router.post('/meta/acq/dataSource', dataSource.addDataSource(opts)) + + + +}; diff --git a/web/client/src/sections/metadataAcquisition/components/adapterStep.js b/web/client/src/sections/metadataAcquisition/components/adapterStep.js index 39142b8..2bf67a5 100644 --- a/web/client/src/sections/metadataAcquisition/components/adapterStep.js +++ b/web/client/src/sections/metadataAcquisition/components/adapterStep.js @@ -6,7 +6,8 @@ import { STEP_CONFIG } from './steps/index'; const AdapterStep = (props) => { const { type } = props; const [current, setCurrent] = useState(0); - const [stepOneValues, setStepOneValues] = useState(0); + const [stepOneValues, setStepOneValues] = useState(); + const [stepTwoValues, setStepTwoValues] = useState({}); const { StepOne, StepTwo, StepThree } = STEP_CONFIG[type]; //记录第一页表单数据用于切换步骤时展示上一次填写的值 const next = () => { @@ -19,6 +20,9 @@ const AdapterStep = (props) => { const stepOneValuesFinish = (values) => { setStepOneValues(values) } + const stepTwoValuesFinish = (values) => { + setStepTwoValues(values) + } const steps = [ { @@ -27,7 +31,7 @@ const AdapterStep = (props) => { }, { title: '数据源参数配置', - content: , + content: , }, { title: '配置计划任务', diff --git a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js index fb87e29..ac9a91f 100644 --- a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js +++ b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js @@ -1,17 +1,96 @@ import React, { useEffect, useState } from 'react' -import { Button } from 'antd'; -import '../../style.less'; +import { Button, Form, Input, Row, Col } from 'antd'; +import { + ProForm, + ProFormSelect, + ProFormTextArea, + ProFormText, + ProFormDigit +} from '@ant-design/pro-form'; +import '../../style.less'; function StepThree(props) { - const { prev, next } = props; + const { prev, next, stepOneValues, stepOneValuesFinish } = props; + const formRef = React.createRef(); + const initialValues = stepOneValues ? stepOneValues : { + + } + const formItemLayout = { labelCol: { span: 4 }, wrapperCol: { span: 10 } }; return <> -
- - -
+ { }, + }} + onFinish={async (values) => { + next() + stepOneValuesFinish(values) + return true; + }} + style={{ marginTop: 20 }} + submitter={{ + render: (props, defaultDoms) => { + return null; + }, + }} + > + + + + + + + + + + + +
+ + +
+
} -export default StepThree; \ No newline at end of file +export default StepThree + 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 0da4e96..e738349 100644 --- a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js +++ b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js @@ -4,24 +4,13 @@ import '../../style.less'; import { Func, useMockRequest, useFsRequest, ApiTable } from '$utils'; function StepTwo(props) { - const { prev, next, dispatch, actions } = props; + const { prev, next, dispatch, actions, stepTwoValues, stepTwoValuesFinish } = props; const [params, setParams] = useState({}) const [connect, setConnet] = useState('') const [loading, setLoading] = useState(false); - // const { data: connect = {} } = useFsRequest({ - // url: ApiTable.pgCheckConnect, - // method: 'post', - // body: { - // "user": params?.user, - // "host": params?.host, - // "database": params?.database, - // "password": params?.password, - // "port": params?.port - // }, - // ready: !!(params?.user && params?.host && params?.database && params?.password && params?.port), - // }); - - + useEffect(() => { + setParams(stepTwoValues) + }, []) const dataSource = [ { param: 'host', @@ -77,12 +66,14 @@ function StepTwo(props) { dataIndex: 'value', key: 'value', render: (text, record) => { - return { - const obj = {}; - obj[text] = e.target.value; - const paramToSet = Object.assign(params, obj, {}) - setParams(paramToSet) - }} /> + return { + const obj = {}; + obj[text] = e.target.value; + const paramToSet = Object.assign(params, obj, {}) + setParams(paramToSet) + }} /> } }, ]; @@ -124,7 +115,10 @@ function StepTwo(props) {