diff --git a/web/client/src/sections/metadataAcquisition/components/adapterStep.js b/web/client/src/sections/metadataAcquisition/components/adapterStep.js
index eb2a4a4..85d3597 100644
--- a/web/client/src/sections/metadataAcquisition/components/adapterStep.js
+++ b/web/client/src/sections/metadataAcquisition/components/adapterStep.js
@@ -7,15 +7,18 @@ const AdapterStep = (props) => {
const {
type = 'postgre',
stepProps = 3,//步骤配置 适配器显示3步 数据源显示2步
- currentChange
+ currentChange,
+ editData,
+ stepOneInitValue,
+ stepTwoInitValue
} = props;
const [current, setCurrent] = useState(0);
- const [stepOneValues, setStepOneValues] = useState();
- const [stepTwoValues, setStepTwoValues] = useState({});
+ const [stepOneValues, setStepOneValues] = useState(editData ? stepOneInitValue : null);
+ const [stepTwoValues, setStepTwoValues] = useState(editData ? stepTwoInitValue : null);
const { StepOne, StepTwo, StepThree } = STEP_CONFIG[type]; //记录第一页表单数据用于切换步骤时展示上一次填写的值
useEffect(() => {
- currentChange(current)
+ currentChange && currentChange(current)
}, [current]);
const next = () => {
@@ -35,19 +38,20 @@ const AdapterStep = (props) => {
const stepOneValuesFinish = (values) => {
setStepOneValues(values)
}
+
const stepTwoValuesFinish = (values) => {
- stepProps == 2 ? onFinish() : setStepTwoValues(values)
+ setStepTwoValues(values)
+ if (stepProps == 2) onFinish()
}
-
const steps = [
{
title: '配置数据源基本信息',
- content: ,
+ content: ,
},
{
title: '数据源参数配置',
- content: ,
+ content: ,
},
{
title: '配置计划任务',
diff --git a/web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js b/web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js
index c820f25..079d6ae 100644
--- a/web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js
+++ b/web/client/src/sections/metadataAcquisition/components/dataSourceManagementModal.js
@@ -4,7 +4,7 @@ import AdapterStep from './adapterStep';
import { BellOutlined } from '@ant-design/icons'
function DataSourceModal(props) {
- const { visible, editData, onFinish, onCancel } = props;
+ const { visible, editData, onFinish, onCancel, adapterInfo } = props;
const [current, setCurrent] = useState(0);
// const onFinish = () => { }
return <>
@@ -16,12 +16,14 @@ function DataSourceModal(props) {
width={1200}
destroyOnClose={true}
>
-
数据源基本信息
+ {current == 0 ? '数据源基本信息' : '数据源参数配置'}
{ setCurrent(c) }}
+ stepOneInitValue={{ ...editData, ...editData?.adapterInfo }}
+ stepTwoInitValue={{ ...editData?.config }}
{...props}
/>
diff --git a/web/client/src/sections/metadataAcquisition/components/steps/index.js b/web/client/src/sections/metadataAcquisition/components/steps/index.js
index 2355053..3c5f815 100644
--- a/web/client/src/sections/metadataAcquisition/components/steps/index.js
+++ b/web/client/src/sections/metadataAcquisition/components/steps/index.js
@@ -1,9 +1,9 @@
import * as postgre from './postgre/index';
-
+// 配置适配器步骤 目前只有potgres配置类型,后续支持扩展 目前其他类型配置步骤不确定
export const STEP_CONFIG = {
'postgre': {
StepOne: postgre.stepOne,
StepTwo: postgre.stepTwo,
StepThree: postgre.stepThree
- }
+ },
}
\ No newline at end of file
diff --git a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js
index 5e81339..6c96444 100644
--- a/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js
+++ b/web/client/src/sections/metadataAcquisition/components/steps/postgre/stepOne.js
@@ -9,14 +9,24 @@ import {
import '../../style.less';
function StepOne(props) {
- const { next, stepOneValues, stepOneValuesFinish } = props;
+ const { next, stepOneValues, stepOneValuesFinish, readOnly, dataSources, stepOneInitValue } = props;
const formRef = React.createRef();
const initialValues = stepOneValues ? stepOneValues : {
- adapter: 'PostgreSQL采集适配器',
- version: '9.x',
+ adapterName: 'PostgreSQL采集适配器',
+ adapterVersion: '9.x',
mode: '数据库连接',
- source: '库表/目录1',
+ mountPath: 1,
}
+
+ const checkName = async (rule, value) => {
+ let filter = dataSources?.rows?.find(s => s?.name == value && value !== stepOneInitValue?.name)
+ if (filter) {
+ return Promise.reject(new Error('已存该数据源名称!'));
+ }
+ return Promise.resolve();
+ }
+
+
const formItemLayout = { labelCol: { span: 3 }, wrapperCol: { span: 10 } };
return <>
-
+
{
- setParams(stepTwoValues)
+ stepTwoValues && setParams(stepTwoValues)
}, [])
+
const dataSource = [
{
param: 'host',
@@ -67,6 +68,7 @@ function StepTwo(props) {
key: 'value',
render: (text, record) => {
return {
const obj = {};
@@ -114,13 +116,13 @@ function StepTwo(props) {
-
diff --git a/web/client/src/sections/metadataAcquisition/containers/adapter.js b/web/client/src/sections/metadataAcquisition/containers/adapter.js
index 8747b3f..c422fd2 100644
--- a/web/client/src/sections/metadataAcquisition/containers/adapter.js
+++ b/web/client/src/sections/metadataAcquisition/containers/adapter.js
@@ -35,7 +35,7 @@ const LatestMetadata = (props) => {
const onFinish = (values) => {
const { stepOneValues, stepTwoValues } = values;
- const adapterInfo = adapters?.find(x => x.adapterName == x.name == stepOneValues?.adapter)
+ const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName)
if (adapterInfo) {
dispatch(actions.metadataAcquisition.addDataSource({
name: stepOneValues?.name,
diff --git a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
index a75c617..3b46e9b 100644
--- a/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
+++ b/web/client/src/sections/metadataAcquisition/containers/dataSourceManagement.js
@@ -86,7 +86,12 @@ function DataSourceManagement(props) {
valueType: 'option',
render: (text, record) => {
const options = [];
- options.push(编辑)
+ options.push( {
+ const adapterInfo = adapters?.find(x => x.id == record?.adapter)
+ setVisible(true)
+ record.adapterInfo = adapterInfo
+ setEditData(record)
+ }} style={{ marginRight: 8 }}>编辑)
options.push(
{
const { stepOneValues, stepTwoValues } = values;
- const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapter)
+ const adapterInfo = adapters?.find(x => x.adapterName == stepOneValues?.adapterName)
if (adapterInfo) {
- dispatch(actions.metadataAcquisition.addDataSource({
+ const dataToSave = {
name: stepOneValues?.name,
audited: true,
adapter: adapterInfo?.id,
@@ -117,10 +122,18 @@ function DataSourceManagement(props) {
description: stepOneValues?.description,
config: stepTwoValues,
time: moment()
- })).then(res => {
- setVisible(false)
- queryData();
- })
+ }
+ if (editData) {
+ dispatch(actions.metadataAcquisition.modifyDataSource(editData?.id, dataToSave)).then(res => {
+ setVisible(false)
+ queryData();
+ })
+ } else {
+ dispatch(actions.metadataAcquisition.addDataSource(dataToSave)).then(res => {
+ setVisible(false)
+ queryData();
+ })
+ }
}
}
diff --git a/web/client/src/sections/metadataManagement/components/modelModal.js b/web/client/src/sections/metadataManagement/components/modelModal.js
index a6a9f63..ef37ca1 100644
--- a/web/client/src/sections/metadataManagement/components/modelModal.js
+++ b/web/client/src/sections/metadataManagement/components/modelModal.js
@@ -16,7 +16,7 @@ export default (props) => {
} : {};
const checkName = async (rule, value) => {
- let filter = models?.find(s => s?.attributeName == value)
+ let filter = models?.find(s => s?.attributeName == value && value !== editData?.attributeName)
if (filter) {
return Promise.reject(new Error('已存该属性名称!'));
}
@@ -24,7 +24,7 @@ export default (props) => {
}
const checkCode = async (rule, value) => {
- let filter = models?.find(s => s?.attributeCode == value)
+ let filter = models?.find(s => s?.attributeCode == value && value !== editData?.attributeCode)
if (filter) {
return Promise.reject(new Error('已存该属性代码!'));
}