Browse Source

(*)适配器管理功能提交

master
peng.peng 2 years ago
parent
commit
c3842df050
  1. 20
      api/app/lib/controllers/metadataAcquisition/adapter.js
  2. 24
      api/app/lib/controllers/metadataAcquisition/dataSource.js
  3. 0
      api/app/lib/controllers/metadataAcquisition/log.js
  4. 0
      api/app/lib/controllers/metadataAcquisition/plan.js
  5. 12
      api/app/lib/routes/adapter/index.js
  6. 14
      api/app/lib/routes/metadataAcquisition/adapter.js
  7. 12
      api/app/lib/routes/metadataAcquisition/dataSource.js
  8. 8
      web/client/src/sections/metadataAcquisition/components/adapterStep.js
  9. 89
      web/client/src/sections/metadataAcquisition/components/steps/postgre/stepThree.js
  10. 28
      web/client/src/sections/metadataAcquisition/components/steps/postgre/stepTwo.js

20
api/app/lib/controllers/adapter/index.js → 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
}

24
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,
}

0
api/app/lib/controllers/metadataAcquisition/log.js

0
api/app/lib/controllers/metadataAcquisition/plan.js

12
api/app/lib/routes/adapter/index.js

@ -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))
};

14
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))
};

12
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))
};

8
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: <StepTwo prev={prev} next={next} {...props} />,
content: <StepTwo stepTwoValues={stepTwoValues} prev={prev} next={next} stepTwoValuesFinish={stepTwoValuesFinish} {...props} />,
},
{
title: '配置计划任务',

89
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 <>
<ProForm
title={''}
initialValues={initialValues}
layout="horizontal"
grid={true}
{...formItemLayout}
modalProps={{
destroyOnClose: true,
onCancel: () => { },
}}
onFinish={async (values) => {
next()
stepOneValuesFinish(values)
return true;
}}
style={{ marginTop: 20 }}
submitter={{
render: (props, defaultDoms) => {
return null;
},
}}
>
<ProForm.Group title="请输入该计划任务执行时间">
<ProFormText
rules={[{ required: true, message: '请输入数据源名称' },
{ max: 255, message: '数据源名称长度不能大于255个字符' },
]}
name="name"
label="名称"
style={{
minWidth: 140,
}}
/>
<ProFormText
rules={[{ required: true, message: '请输入cron表达式' },
{ max: 255, message: 'cron表达式长度不能大于255个字符' },
]}
name="name"
label="请输入cron表达式"
style={{
minWidth: 140,
}}
/>
<ProFormDigit
rules={[{ required: true, message: '请输入重试次数' },
{ max: 10, message: '重试次数不能大于10个字符' },
]}
name="name"
label="重试次数"
fieldProps={{ precision: 0, max: 10, }}
/>
<ProFormText
rules={[{ required: true, message: '请输入时间间隔' },
{ max: 255, message: '时间间隔长度不能大于255个字符' },
]}
name="name"
label="时间间隔"
addonAfter={'分钟'}
/>
</ProForm.Group>
<div className='step-footer'>
<Button style={{ margin: '0 8px', }} onClick={() => prev()}>上一步</Button>
<Button type="primary" onClick={() => {next()}}>
<Button type="primary" htmlType="submit">
完成
</Button>
</div>
</ProForm>
</>
}
export default StepThree;
export default StepThree

28
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,7 +66,9 @@ function StepTwo(props) {
dataIndex: 'value',
key: 'value',
render: (text, record) => {
return <Input onChange={(e) => {
return <Input
defaultValue={stepTwoValues ? stepTwoValues[text] : ''}
onChange={(e) => {
const obj = {};
obj[text] = e.target.value;
const paramToSet = Object.assign(params, obj, {})
@ -124,7 +115,10 @@ function StepTwo(props) {
<div className='step-footer'>
<Button style={{ margin: '0 8px', }} onClick={() => prev()}>上一步</Button>
<Button type="primary" onClick={() => {
if (checkNext() === true) { next() }
if (checkNext() === true) {
stepTwoValuesFinish(params)
next()
}
}}>
下一步
</Button>

Loading…
Cancel
Save