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
34d7202d
Commit
34d7202d
authored
Jul 22, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
系统调整
parent
ea4d698a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
57 deletions
+74
-57
App.js
src/App.js
+8
-3
index.js
src/index.js
+1
-1
index.jsx
src/view/Manage/DatasourceManage/index.jsx
+65
-53
No files found.
src/App.js
View file @
34d7202d
...
@@ -17,7 +17,9 @@ import DatasourceManage from './view/Manage/DatasourceManage';
...
@@ -17,7 +17,9 @@ import DatasourceManage from './view/Manage/DatasourceManage';
import
AssetDetail
from
'./view/Manage/AssetManage/Component/AssetDetail'
;
import
AssetDetail
from
'./view/Manage/AssetManage/Component/AssetDetail'
;
import
ImportAction
from
'./view/Manage/Model/Component/ImportAction'
;
import
ImportAction
from
'./view/Manage/Model/Component/ImportAction'
;
export
default
class
App
extends
React
.
Component
{
export
const
AppContext
=
React
.
createContext
();
export
class
App
extends
React
.
Component
{
render
()
{
render
()
{
const
{
params
}
=
this
.
props
;
const
{
params
}
=
this
.
props
;
...
@@ -52,7 +54,9 @@ export default class App extends React.Component {
...
@@ -52,7 +54,9 @@ export default class App extends React.Component {
}
}
return
(
return
(
<
React
.
Fragment
>
<
AppContext
.
Provider
value
=
{{
env
:
params
?.
env
}}
>
<
Router
basename
=
{
window
.
__POWERED_BY_QIANKUN__
?
'/data-govern'
:
'/'
}
>
<
Router
basename
=
{
window
.
__POWERED_BY_QIANKUN__
?
'/data-govern'
:
'/'
}
>
<
Switch
>
<
Switch
>
<
Route
path
=
{
`
${
ContextPath
}
/login`
}
component
=
{
Signin
}
exact
/>
<
Route
path
=
{
`
${
ContextPath
}
/login`
}
component
=
{
Signin
}
exact
/>
...
@@ -73,7 +77,7 @@ export default class App extends React.Component {
...
@@ -73,7 +77,7 @@ export default class App extends React.Component {
<
Route
path
=
{
'/center-home/menu/asset-recycle'
}
component
=
{
AssetRecycle
}
exact
/>
<
Route
path
=
{
'/center-home/menu/asset-recycle'
}
component
=
{
AssetRecycle
}
exact
/>
<
/Switch
>
<
/Switch
>
<
/Router
>
<
/Router
>
<
/
React.Fragment
>
<
/
AppContext.Provider
>
);
);
}
}
}
}
\ No newline at end of file
src/index.js
View file @
34d7202d
...
@@ -7,7 +7,7 @@ import { ConfigProvider } from 'antd';
...
@@ -7,7 +7,7 @@ import { ConfigProvider } from 'antd';
import
zh_CN
from
'antd/es/locale-provider/zh_CN'
;
import
zh_CN
from
'antd/es/locale-provider/zh_CN'
;
import
{
Provider
}
from
"react-redux"
;
import
{
Provider
}
from
"react-redux"
;
import
{
store
}
from
'./model'
;
import
{
store
}
from
'./model'
;
import
App
from
'./App'
import
{
App
}
from
'./App'
import
'./index.less'
;
import
'./index.less'
;
...
...
src/view/Manage/DatasourceManage/index.jsx
View file @
34d7202d
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
,
useContext
}
from
'react'
;
import
{
Space
,
Select
,
Button
,
Modal
,
Cascader
}
from
'antd'
;
import
{
Space
,
Select
,
Button
,
Modal
,
Cascader
,
TreeSelect
}
from
'antd'
;
import
DatasourceList
from
'./Component/DatasourceList'
;
import
DatasourceList
from
'./Component/DatasourceList'
;
import
UpdateDatasourceModal
from
'./Component/UpdateDatasourceModal'
;
import
UpdateDatasourceModal
from
'./Component/UpdateDatasourceModal'
;
...
@@ -10,6 +10,7 @@ import UpdateTaskModal from './Component/UpdateTaskModal';
...
@@ -10,6 +10,7 @@ import UpdateTaskModal from './Component/UpdateTaskModal';
import
{
dispatch
}
from
'../../../model'
;
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
'./index.less'
;
import
'./index.less'
;
...
@@ -17,10 +18,15 @@ const { Option } = Select;
...
@@ -17,10 +18,15 @@ const { Option } = Select;
const
DatasourceManage
=
(
props
)
=>
{
const
DatasourceManage
=
(
props
)
=>
{
const
{
env
}
=
useContext
(
AppContext
);
const
domainId
=
getQueryParam
(
'domainId'
,
props
.
location
.
search
);
const
domainId
=
getQueryParam
(
'domainId'
,
props
.
location
.
search
);
const
catalogId
=
getQueryParam
(
'catalogId'
,
props
.
location
.
search
);
const
catalogId
=
getQueryParam
(
'catalogId'
,
props
.
location
.
search
);
const
scopeId
=
getQueryParam
(
'scopeId'
,
props
.
location
.
search
);
const
scopeId
=
getQueryParam
(
'scopeId'
,
props
.
location
.
search
);
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
treeValue
,
setTreeValue
]
=
useState
(
''
);
const
[
treeExpandKeys
,
setTreeExpandKeys
]
=
useState
([]);
const
[
scopes
,
setScopes
]
=
useState
([]);
const
[
scopes
,
setScopes
]
=
useState
([]);
const
[
selectedScope
,
setSelectedScope
]
=
useState
([]);
const
[
selectedScope
,
setSelectedScope
]
=
useState
([]);
const
[
rawSupportDatabases
,
setRawSupportDatabases
]
=
useState
([]);
const
[
rawSupportDatabases
,
setRawSupportDatabases
]
=
useState
([]);
...
@@ -58,6 +64,38 @@ const DatasourceManage = (props) => {
...
@@ -58,6 +64,38 @@ const DatasourceManage = (props) => {
},
[])
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
env
&&
env
.
children
)
{
setTreeData
(
env
.
children
);
const
defaultDomain
=
(
env
?.
children
||
[]).
length
>
0
?
env
.
children
[
0
]:
null
;
if
(
defaultDomain
)
{
const
defaultSystem
=
(
defaultDomain
?.
children
||
[]).
length
>
0
?
defaultDomain
.
children
[
0
]:
null
;
if
(
defaultSystem
)
{
if
(
env
?.
value
===
domainId
)
{
setTreeValue
(
Number
(
scopeId
));
setSelectedScope
([
Number
(
domainId
),
Number
(
catalogId
),
Number
(
scopeId
)]);
}
else
{
setTreeValue
(
defaultSystem
.
value
);
setSelectedScope
([
env
?.
value
,
defaultDomain
.
value
,
defaultSystem
.
value
]);
}
let
_expandKeys
=
[];
(
env
.
children
||
[]).
forEach
(
item
=>
{
_expandKeys
.
push
(
item
.
key
);
})
setTreeExpandKeys
(
_expandKeys
);
}
}
}
},
[
env
])
useEffect
(()
=>
{
if
((
selectedScope
||
[]).
length
>
0
)
{
if
((
selectedScope
||
[]).
length
>
0
)
{
getAllDatasources
();
getAllDatasources
();
}
}
...
@@ -71,7 +109,7 @@ const DatasourceManage = (props) => {
...
@@ -71,7 +109,7 @@ const DatasourceManage = (props) => {
type
:
'datasource.getScopesAndSupportedTargetTypes'
,
type
:
'datasource.getScopesAndSupportedTargetTypes'
,
callback
:
data
=>
{
callback
:
data
=>
{
setLoadingDatabases
(
false
);
setLoadingDatabases
(
false
);
conver
tScopes
(
data
.
scopes
||
[]);
se
tScopes
(
data
.
scopes
||
[]);
setRawSupportDatabases
(
data
.
typies
||
[]);
setRawSupportDatabases
(
data
.
typies
||
[]);
setSupportDatabases
([{
targetType
:
'all'
,
targetName
:
'全部类型'
},
...(
data
.
typies
||
[])]);
setSupportDatabases
([{
targetType
:
'all'
,
targetName
:
'全部类型'
},
...(
data
.
typies
||
[])]);
setSelectedDatabaseKey
(
'all'
);
setSelectedDatabaseKey
(
'all'
);
...
@@ -82,50 +120,6 @@ const DatasourceManage = (props) => {
...
@@ -82,50 +120,6 @@ const DatasourceManage = (props) => {
})
})
}
}
const
convertScopes
=
(
data
)
=>
{
const
newScopes
=
[...(
data
||
[])];
const
defaultScope
=
[];
newScopes
.
forEach
((
item
,
index
)
=>
{
item
.
value
=
item
.
domainId
;
item
.
label
=
item
.
domainName
||
''
;
item
.
children
=
[];
if
(
index
===
0
)
{
defaultScope
.
push
(
item
.
domainId
);
}
(
item
.
catalogs
||
[]).
forEach
((
catalog
,
_index
)
=>
{
if
(
_index
===
0
)
{
item
.
children
.
push
({
value
:
''
,
label
:
'领域'
,
disabled
:
true
});
}
if
(
index
===
0
&&
_index
===
0
)
{
defaultScope
.
push
(
catalog
.
catalogId
);
}
const
children
=
[];
(
catalog
.
scopes
||
[]).
forEach
((
scope
,
__index
)
=>
{
if
(
__index
===
0
)
{
children
.
push
({
value
:
''
,
label
:
'系统'
,
disabled
:
true
});
}
if
(
index
===
0
&&
_index
===
0
&&
__index
===
0
)
{
defaultScope
.
push
(
scope
.
scopeId
);
}
children
.
push
({
value
:
scope
.
scopeId
,
label
:
scope
.
scopeName
||
''
});
})
item
.
children
.
push
({
value
:
catalog
.
catalogId
,
label
:
catalog
.
catalogName
||
''
,
children
});
})
})
setScopes
([{
value
:
''
,
label
:
'环境'
,
disabled
:
true
},
...
newScopes
]);
setSelectedScope
(
domainId
&&
catalogId
&&
scopeId
?[
Number
(
domainId
),
Number
(
catalogId
),
Number
(
scopeId
)]:
defaultScope
);
}
const
getAllDatasources
=
()
=>
{
const
getAllDatasources
=
()
=>
{
setLoadingDatasources
(
true
);
setLoadingDatasources
(
true
);
dispatch
({
dispatch
({
...
@@ -155,7 +149,19 @@ const DatasourceManage = (props) => {
...
@@ -155,7 +149,19 @@ const DatasourceManage = (props) => {
}
}
const
onScopeChange
=
(
value
)
=>
{
const
onScopeChange
=
(
value
)
=>
{
setSelectedScope
(
value
);
let
domainId
=
''
;
(
treeData
||
[]).
forEach
(
domain
=>
{
(
domain
.
children
||
[]).
forEach
(
system
=>
{
if
(
system
.
value
===
value
)
{
domainId
=
domain
.
value
}
})
})
setTreeValue
(
value
);
setSelectedScope
([
env
?.
value
,
domainId
,
value
]);
}
}
const
onDatabaseChange
=
(
value
)
=>
{
const
onDatabaseChange
=
(
value
)
=>
{
...
@@ -318,12 +324,18 @@ const DatasourceManage = (props) => {
...
@@ -318,12 +324,18 @@ const DatasourceManage = (props) => {
>
>
<
Space
>
<
Space
>
<
span
>
系统:
</
span
>
<
span
>
系统:
</
span
>
<
Cascader
<
TreeSelect
options=
{
scopes
}
style=
{
{
width
:
170
}
}
expandTrigger=
"hover"
dropdownMatchSelectWidth=
{
210
}
listHeight=
{
450
}
value=
{
treeValue
}
treeData=
{
treeData
}
placeholder=
"请选择系统"
treeExpandedKeys=
{
treeExpandKeys
}
onTreeExpand=
{
(
keys
)
=>
{
setTreeExpandKeys
(
keys
);
}
}
onChange=
{
onScopeChange
}
onChange=
{
onScopeChange
}
value=
{
selectedScope
}
allowClear=
{
false
}
/>
/>
<
span
>
数据源类型:
</
span
>
<
span
>
数据源类型:
</
span
>
<
Select
<
Select
...
...
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