Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dlink
Project
Project
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
zhaowei
dlink
Commits
51728178
Commit
51728178
authored
Nov 26, 2021
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
三级拖拽实现
parent
5e8f3caf
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
80 deletions
+106
-80
DraggleLayout.tsx
dlink-web/src/components/DraggleLayout/DraggleLayout.tsx
+31
-25
index.tsx
.../components/Studio/StudioLeftTool/StudioCluster/index.tsx
+7
-9
index.tsx
...omponents/Studio/StudioLeftTool/StudioConnector/index.tsx
+0
-2
index.tsx
...components/Studio/StudioLeftTool/StudioDataBase/index.tsx
+7
-9
index.tsx
...components/Studio/StudioLeftTool/StudioMetaData/index.tsx
+7
-9
index.tsx
dlink-web/src/components/Studio/StudioTree/index.tsx
+0
-2
index.tsx
dlink-web/src/components/Studio/index.tsx
+41
-19
model.ts
dlink-web/src/pages/FlinkSqlStudio/model.ts
+13
-5
No files found.
dlink-web/src/components/DraggleLayout/DraggleLayout.tsx
View file @
51728178
import
React
,
{
useRef
,
useState
}
from
'react'
;
import
React
,
{
useRef
,
useState
}
from
'react'
;
import
useDraggable
from
'../../hooks/useDraggable'
;
import
styles
from
'./DraggleLayout.less'
;
import
{
connect
}
from
"umi"
;
...
...
@@ -12,30 +12,37 @@ function DraggleLayout({
containerHeight
=
0
,
// 容器高度
initLeftWidth
=
0
,
// 初始左侧容器宽度
handler
=
null
,
// 拖拽器
isLeft
=
true
,
// 拖拽器
onWidthChange
=
width
=>
width
,
// 左侧容器高度变化
toolWidth
,
dispatch
dispatch
,
})
{
const
ref
=
useRef
(
null
);
const
[
position
,
setPosition
]
=
useState
({
x
:
initLeftWidth
,
y
:
0
});
const
[
position
,
setPosition
]
=
useState
({
x
:
initLeftWidth
,
y
:
0
});
const
[
props
]
=
useDraggable
(
ref
,
{
onMouseMove
:
({
x
,
y
})
=>
{
onMouseMove
:
({
x
,
y
})
=>
{
let
_x
=
x
;
if
(
_x
<
min
)
_x
=
min
;
if
(
_x
>
max
)
_x
=
max
;
if
(
onWidthChange
)
onWidthChange
(
_x
);
setPosition
({
x
:
_x
,
y
});
dispatch
&&
dispatch
({
type
:
"Studio/saveToolWidth"
,
setPosition
({
x
:
_x
,
y
});
if
(
isLeft
)
{
dispatch
&&
dispatch
({
type
:
"Studio/saveToolLeftWidth"
,
payload
:
_x
,
});
}
else
{
dispatch
&&
dispatch
({
type
:
"Studio/saveToolRightWidth"
,
payload
:
(
containerWidth
-
_x
),
});
}
},
},
{
overbound
:
false
},
{
overbound
:
false
},
);
const
_handler
=
handler
?
(
React
.
cloneElement
(
handler
,
{
...
...
@@ -46,16 +53,16 @@ function DraggleLayout({
},
})
)
:
(
<
span
style=
{
{
fontSize
:
18
,
pointerEvents
:
'none'
}
}
>
》
</
span
>
<
span
style=
{
{
fontSize
:
18
,
pointerEvents
:
'none'
}
}
>
》
</
span
>
);
return
(
<
div
ref=
{
ref
}
className=
{
styles
.
root
}
style=
{
{
width
:
containerWidth
,
height
:
containerHeight
}
}
style=
{
{
width
:
containerWidth
,
height
:
containerHeight
}
}
>
<
div
className=
{
styles
.
left
}
style=
{
{
width
:
position
.
x
}
}
>
<
div
className=
{
styles
.
left
}
style=
{
{
width
:
position
.
x
}
}
>
{
children
[
0
]
}
<
div
className=
{
styles
.
handler
}
{
...
props
}
>
...
...
@@ -64,7 +71,7 @@ function DraggleLayout({
</
div
>
<
div
className=
{
styles
.
right
}
style=
{
{
width
:
containerWidth
-
position
.
x
}
}
style=
{
{
width
:
containerWidth
-
position
.
x
}
}
>
{
children
[
1
]
}
</
div
>
...
...
@@ -73,5 +80,4 @@ function DraggleLayout({
}
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
toolWidth
:
Studio
.
toolWidth
,
}))(
DraggleLayout
);
dlink-web/src/components/Studio/StudioLeftTool/StudioCluster/index.tsx
View file @
51728178
...
...
@@ -205,7 +205,6 @@ const StudioCluster = (props: any) => {
onClick=
{
onCreateCluster
}
/>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新 Flink 集群"
>
<
Button
type=
"text"
...
...
@@ -213,7 +212,6 @@ const StudioCluster = (props: any) => {
onClick=
{
onRefreshCluster
}
/>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
cluster
.
length
>
0
?
(
<
Table
dataSource=
{
cluster
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/index.tsx
View file @
51728178
...
...
@@ -261,7 +261,6 @@ const StudioConnector = (props: any) => {
onClick=
{
createSessions
}
/>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
{
session
.
length
>
0
?
(
<
Tooltip
title=
"切换会话"
>
<
Button
...
...
@@ -295,7 +294,6 @@ const StudioConnector = (props: any) => {
/>
</
Tooltip
>
</>)
}
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
currentSession
.
connectors
&&
currentSession
.
connectors
.
length
>
0
?
(
<
Table
dataSource=
{
currentSession
.
connectors
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioDataBase/index.tsx
View file @
51728178
...
...
@@ -68,7 +68,6 @@ const StudioDataBase = (props: any) => {
onClick=
{
onCreateDataBase
}
/>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新数据源"
>
<
Button
type=
"text"
...
...
@@ -76,7 +75,6 @@ const StudioDataBase = (props: any) => {
onClick=
{
onRefreshDataBase
}
/>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
database
.
length
>
0
?
(
<
Table
dataSource=
{
database
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioMetaData/index.tsx
View file @
51728178
...
...
@@ -68,7 +68,6 @@ const StudioMetaData = (props: any) => {
>
{
getDataBaseOptions
()
}
</
Select
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新元数据表"
>
<
Button
type=
"text"
...
...
@@ -76,7 +75,6 @@ const StudioMetaData = (props: any) => {
onClick=
{
onRefreshTreeData
}
/>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
DirectoryTree
multiple
...
...
dlink-web/src/components/Studio/StudioTree/index.tsx
View file @
51728178
...
...
@@ -345,7 +345,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
<
div
className=
{
style
.
tree_div
}
>
<
Row
>
<
Col
span=
{
24
}
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"创建根目录"
>
<
Button
type=
"text"
...
...
@@ -360,7 +359,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
onClick=
{
offExpandAll
}
/>
</
Tooltip
>
</
div
>
</
Col
>
</
Row
>
<
Scrollbars
style=
{
{
height
:(
toolHeight
-
32
)}
}
>
...
...
dlink-web/src/components/Studio/index.tsx
View file @
51728178
...
...
@@ -24,14 +24,16 @@ type StudioProps = {
const
Studio
:
React
.
FC
<
StudioProps
>
=
(
props
)
=>
{
const
{
rightClickMenu
,
toolHeight
,
toolWidth
,
dispatch
}
=
props
;
const
{
rightClickMenu
,
toolHeight
,
tool
LeftWidth
,
toolRight
Width
,
dispatch
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
VIEW
=
{
rightToolWidth
:
300
,
leftToolWidth
:
300
,
marginTop
:
116
,
topHeight
:
35.6
,
bottomHeight
:
153.6
,
rightMargin
:
32
,
leftMargin
:
36
,
midMargin
:
46
,
};
const
[
size
,
setSize
]
=
useState
({
width
:
document
.
documentElement
.
clientWidth
-
1
,
...
...
@@ -92,11 +94,29 @@ const Studio: React.FC<StudioProps> = (props) => {
>
<
Row
>
<
DraggleLayout
containerWidth=
{
size
.
width
-
VIEW
.
rightToolWidth
}
containerWidth=
{
size
.
width
}
containerHeight=
{
toolHeight
}
min=
{
VIEW
.
leftMargin
+
VIEW
.
midMargin
}
max=
{
size
.
width
-
VIEW
.
rightMargin
}
initLeftWidth=
{
size
.
width
-
toolRightWidth
}
isLeft=
{
false
}
handler=
{
<
div
style=
{
{
width
:
4
,
height
:
'100%'
,
background
:
'rgb(240, 240, 240)'
,
}
}
/>
}
>
<
DraggleLayout
containerWidth=
{
size
.
width
-
toolRightWidth
}
containerHeight=
{
toolHeight
}
min=
{
VIEW
.
leftToolWidth
}
max=
{
size
.
width
*
(
1
/
2
)
}
initLeftWidth=
{
VIEW
.
leftToolWidth
}
min=
{
VIEW
.
leftMargin
}
max=
{
size
.
width
-
VIEW
.
rightMargin
-
VIEW
.
midMargin
}
initLeftWidth=
{
toolLeftWidth
}
isLeft=
{
true
}
handler=
{
<
div
style=
{
{
...
...
@@ -115,12 +135,13 @@ const Studio: React.FC<StudioProps> = (props) => {
}
}
/>
</
Col
>
<
Col
>
<
StudioTabs
width=
{
size
.
width
-
VIEW
.
rightToolWidth
-
tool
Width
}
/>
<
StudioTabs
width=
{
size
.
width
-
toolRightWidth
-
toolLeft
Width
}
/>
</
Col
>
</
DraggleLayout
>
<
Col
id=
'StudioRightTool'
style=
{
{
width
:
VIEW
.
rightToolWidth
}
}
className=
{
styles
[
"vertical-tabs"
]
}
>
<
Col
id=
'StudioRightTool'
className=
{
styles
[
"vertical-tabs"
]
}
>
<
StudioRightTool
form=
{
form
}
/>
</
Col
>
</
DraggleLayout
>
</
Row
>
<
Row
>
<
Col
span=
{
24
}
>
...
...
@@ -137,5 +158,6 @@ const Studio: React.FC<StudioProps> = (props) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
rightClickMenu
:
Studio
.
rightClickMenu
,
toolHeight
:
Studio
.
toolHeight
,
toolWidth
:
Studio
.
toolWidth
,
toolLeftWidth
:
Studio
.
toolLeftWidth
,
toolRightWidth
:
Studio
.
toolRightWidth
,
}))(
Studio
);
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
51728178
...
...
@@ -123,7 +123,8 @@ export type SessionType = {
export
type
StateType
=
{
toolHeight
?:
number
;
toolWidth
?:
number
;
toolRightWidth
?:
number
;
toolLeftWidth
?:
number
;
cluster
?:
ClusterType
[];
sessionCluster
?:
ClusterType
[];
clusterConfiguration
?:
ClusterConfigurationType
[];
...
...
@@ -150,7 +151,8 @@ export type ModelType = {
};
reducers
:
{
saveToolHeight
:
Reducer
<
StateType
>
;
saveToolWidth
:
Reducer
<
StateType
>
;
saveToolRightWidth
:
Reducer
<
StateType
>
;
saveToolLeftWidth
:
Reducer
<
StateType
>
;
saveSql
:
Reducer
<
StateType
>
;
saveCurrentPath
:
Reducer
<
StateType
>
;
saveMonaco
:
Reducer
<
StateType
>
;
...
...
@@ -174,7 +176,8 @@ const Model: ModelType = {
namespace
:
'Studio'
,
state
:
{
toolHeight
:
400
,
toolWidth
:
300
,
toolRightWidth
:
300
,
toolLeftWidth
:
300
,
cluster
:
[],
sessionCluster
:
[],
clusterConfiguration
:
[],
...
...
@@ -282,10 +285,15 @@ const Model: ModelType = {
...
state
,
toolHeight
:
payload
,
};
},
saveToolWidth
(
state
,
{
payload
})
{
},
saveTool
Right
Width
(
state
,
{
payload
})
{
return
{
...
state
,
toolWidth
:
payload
,
toolRightWidth
:
payload
,
};
},
saveToolLeftWidth
(
state
,
{
payload
})
{
return
{
...
state
,
toolLeftWidth
:
payload
,
};
},
saveSql
(
state
,
{
payload
})
{
...
...
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