Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
46da724a
Commit
46da724a
authored
Mar 11, 2024
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
元数据新增数据源
parent
9a607502
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
21 deletions
+62
-21
metadata-update-datasource.jsx
src/view/Feign/metadata-update-datasource.jsx
+52
-21
index.jsx
src/view/Manage/DatasourceManage/index.jsx
+10
-0
No files found.
src/view/Feign/metadata-update-datasource.jsx
View file @
46da724a
...
@@ -17,6 +17,11 @@ const FC = (props) => {
...
@@ -17,6 +17,11 @@ const FC = (props) => {
const
[
loadingSupportedTargetTypes
,
setLoadingSupportedTargetTypes
]
=
React
.
useState
(
false
)
const
[
loadingSupportedTargetTypes
,
setLoadingSupportedTargetTypes
]
=
React
.
useState
(
false
)
const
[
supportedTargetTypes
,
setSupportedTargetTypes
]
=
React
.
useState
()
const
[
supportedTargetTypes
,
setSupportedTargetTypes
]
=
React
.
useState
()
const
[
loadingSupportedDatasourceTypies
,
setLoadingSupportedDatasourceTypies
]
=
React
.
useState
(
false
)
const
[
supportedDatasourceTypies
,
setSupportedDatasourceTypies
]
=
React
.
useState
()
const
[
selectedTargetType
,
setSelectedTargetType
]
=
React
.
useState
()
const
[
currentDatasourceType
,
setDatasourceType
]
=
React
.
useState
()
const
basicRef
=
React
.
useRef
()
const
basicRef
=
React
.
useRef
()
const
credentialRef
=
React
.
useRef
()
const
credentialRef
=
React
.
useRef
()
...
@@ -26,9 +31,17 @@ const FC = (props) => {
...
@@ -26,9 +31,17 @@ const FC = (props) => {
if
(
metadataId
)
{
if
(
metadataId
)
{
getDatasource
()
getDatasource
()
getSupportedTargetTypes
()
getSupportedTargetTypes
()
getSupportedDatasourceTypies
()
}
}
},
[
metadataId
])
},
[
metadataId
])
React
.
useEffect
(()
=>
{
const
index
=
(
supportedDatasourceTypies
??[]).
findIndex
(
item
=>
item
.
type
===
selectedTargetType
)
if
(
index
!==
-
1
)
{
setDatasourceType
(
supportedDatasourceTypies
[
index
])
}
},
[
selectedTargetType
,
supportedDatasourceTypies
])
const
getDatasource
=
()
=>
{
const
getDatasource
=
()
=>
{
setLoading
(
false
)
setLoading
(
false
)
dispatch
({
dispatch
({
...
@@ -42,18 +55,8 @@ const FC = (props) => {
...
@@ -42,18 +55,8 @@ const FC = (props) => {
databaseType
,
databaseType
,
},
},
callback
:
data
=>
{
callback
:
data
=>
{
function
compare
(
val1
,
val2
)
{
setDatasource
(
data
)
var
a
=
val1
.
seq
;
setSelectedTargetType
(
data
?.
type
)
var
b
=
val2
.
seq
;
return
(
a
-
b
);
}
const
newData
=
produce
(
data
??{},
(
draft
)
=>
{
(
draft
.
credential
?.
credentialParameters
??[]).
sort
(
compare
);
(
draft
.
targetParameters
??[]).
sort
(
compare
);
})
setDatasource
(
newData
)
}
}
})
})
}
}
...
@@ -72,6 +75,32 @@ const FC = (props) => {
...
@@ -72,6 +75,32 @@ const FC = (props) => {
})
})
}
}
const
getSupportedDatasourceTypies
=
()
=>
{
setLoadingSupportedDatasourceTypies
(
true
)
dispatch
({
type
:
'datasource.getAllSupportedDatasourceTypies'
,
callback
:
data
=>
{
setLoadingSupportedDatasourceTypies
(
false
);
function
compare
(
val1
,
val2
)
{
var
a
=
val1
.
seq
;
var
b
=
val2
.
seq
;
return
(
a
-
b
);
}
(
data
||
[]).
forEach
(
item
=>
{
item
.
credential
&&
(
item
.
credential
.
credentialParameters
||
[]).
sort
(
compare
);
(
item
.
targetParameters
||
[]).
sort
(
compare
);
});
setSupportedDatasourceTypies
(
data
);
},
error
:
()
=>
{
setLoadingSupportedDatasourceTypies
(
false
)
}
})
}
const
close
=
(
refresh
=
false
)
=>
{
const
close
=
(
refresh
=
false
)
=>
{
setWaiting
(
false
)
setWaiting
(
false
)
setTestWaiting
(
false
)
setTestWaiting
(
false
)
...
@@ -178,15 +207,17 @@ const FC = (props) => {
...
@@ -178,15 +207,17 @@ const FC = (props) => {
centered
destroyOnClose
centered
destroyOnClose
onCancel=
{
()
=>
{
close
()
}
}
onCancel=
{
()
=>
{
close
()
}
}
>
>
<
Spin
spinning=
{
loading
||
waiting
}
>
<
Spin
spinning=
{
loading
||
waiting
||
loadingSupportedDatasourceTypies
||
loadingSupportedTargetTypes
}
>
<
div
className=
'flex'
style=
{
{
justifyContent
:
'end'
}
}
>
<
div
className=
'flex'
style=
{
{
justifyContent
:
'end'
}
}
>
<
Space
>
<
Space
>
<
span
>
数据源类型:
</
span
>
<
span
>
数据源类型:
</
span
>
<
Select
<
Select
loading=
{
loadingSupportedTargetTypes
}
loading=
{
loadingSupportedTargetTypes
}
value=
{
datasource
?.
t
ype
}
value=
{
selectedTargetT
ype
}
style=
{
{
width
:
130
}
}
style=
{
{
width
:
130
}
}
disabled=
{
true
}
onChange=
{
(
val
)
=>
{
setSelectedTargetType
(
val
)
}
}
>
>
{
{
(
supportedTargetTypes
??[]).
map
((
item
,
index
)
=>
{
(
supportedTargetTypes
??[]).
map
((
item
,
index
)
=>
{
...
@@ -199,9 +230,9 @@ const FC = (props) => {
...
@@ -199,9 +230,9 @@ const FC = (props) => {
</
Space
>
</
Space
>
</
div
>
</
div
>
<
Divider
>
数据源信息
</
Divider
>
<
Divider
>
数据源信息
</
Divider
>
<
Basic
ref=
{
basicRef
}
datasource=
{
datasource
}
/>
<
Basic
ref=
{
basicRef
}
datasource=
{
datasource
}
datasourceType=
{
currentDatasourceType
}
/>
<
Divider
>
认证信息
</
Divider
>
<
Divider
>
认证信息
</
Divider
>
<
Credential
ref=
{
credentialRef
}
datasource=
{
datasource
}
/>
<
Credential
ref=
{
credentialRef
}
datasource=
{
datasource
}
datasourceType=
{
currentDatasourceType
}
/>
</
Spin
>
</
Spin
>
</
Modal
>
</
Modal
>
)
)
...
@@ -209,7 +240,7 @@ const FC = (props) => {
...
@@ -209,7 +240,7 @@ const FC = (props) => {
export
default
FC
export
default
FC
const
Basic
=
React
.
forwardRef
(
function
({
datasource
},
ref
)
{
const
Basic
=
React
.
forwardRef
(
function
({
datasource
,
datasourceType
},
ref
)
{
const
[
form
]
=
Form
.
useForm
()
const
[
form
]
=
Form
.
useForm
()
React
.
useImperativeHandle
(
ref
,
()
=>
({
React
.
useImperativeHandle
(
ref
,
()
=>
({
...
@@ -243,7 +274,7 @@ const Basic = React.forwardRef(function ({ datasource }, ref) {
...
@@ -243,7 +274,7 @@ const Basic = React.forwardRef(function ({ datasource }, ref) {
return
(
return
(
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
{
{
(
datasource
?.
targetParameters
??[]).
map
((
item
,
index
)
=>
{
(
datasource
Type
?.
targetParameters
??[]).
map
((
item
,
index
)
=>
{
return
(
return
(
<
Form
.
Item
<
Form
.
Item
label=
{
item
.
cnName
||
''
}
label=
{
item
.
cnName
||
''
}
...
@@ -275,7 +306,7 @@ const Basic = React.forwardRef(function ({ datasource }, ref) {
...
@@ -275,7 +306,7 @@ const Basic = React.forwardRef(function ({ datasource }, ref) {
)
)
})
})
const
Credential
=
React
.
forwardRef
(
function
({
datasource
},
ref
)
{
const
Credential
=
React
.
forwardRef
(
function
({
datasource
,
datasourceType
},
ref
)
{
const
[
fileListBindName
,
setFileListBindName
]
=
React
.
useState
([])
const
[
fileListBindName
,
setFileListBindName
]
=
React
.
useState
([])
const
[
form
]
=
Form
.
useForm
()
const
[
form
]
=
Form
.
useForm
()
...
@@ -343,7 +374,7 @@ const Credential = React.forwardRef(function ({ datasource }, ref) {
...
@@ -343,7 +374,7 @@ const Credential = React.forwardRef(function ({ datasource }, ref) {
return
(
return
(
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
{
{
(
datasource
?.
credential
?.
credentialParameters
??[]).
map
((
item
,
index
)
=>
{
(
datasource
Type
?.
credential
?.
credentialParameters
??[]).
map
((
item
,
index
)
=>
{
let
_fileList
=
[];
let
_fileList
=
[];
const
_index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
const
_index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
...
...
src/view/Manage/DatasourceManage/index.jsx
View file @
46da724a
...
@@ -13,6 +13,7 @@ import { dispatch } from '../../../model';
...
@@ -13,6 +13,7 @@ import { dispatch } from '../../../model';
import
{
showMessage
,
getQueryParam
}
from
'../../../util'
;
import
{
showMessage
,
getQueryParam
}
from
'../../../util'
;
import
{
DatasourceContext
}
from
'./Component/ContextManager.js'
;
import
{
DatasourceContext
}
from
'./Component/ContextManager.js'
;
import
{
AppContext
}
from
'../../../App'
;
import
{
AppContext
}
from
'../../../App'
;
import
MetadataUpdateDatasource
from
'../../Feign/metadata-update-datasource'
import
'./index.less'
;
import
'./index.less'
;
...
@@ -497,6 +498,15 @@ const DatasourceManage = (props) => {
...
@@ -497,6 +498,15 @@ const DatasourceManage = (props) => {
setApiConfigModalVisible
(
false
)
setApiConfigModalVisible
(
false
)
}
}
}
}
/>
/>
<
MetadataUpdateDatasource
metadataId=
'Database=1=cc998fa5c3f44da8bbbb1960882223cd'
name=
'7878'
systemId=
'4'
catalogId=
'1'
model=
'Database'
databaseType=
'MySQL'
/>
{
contextHolder
}
{
contextHolder
}
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment