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
Hide 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
useDraggable
from
'../../hooks/useDraggable'
;
import
styles
from
'./DraggleLayout.less'
;
import
styles
from
'./DraggleLayout.less'
;
import
{
connect
}
from
"umi"
;
import
{
connect
}
from
"umi"
;
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
function
DraggleLayout
({
function
DraggleLayout
({
children
,
// 两列布局
children
,
// 两列布局
min
=
400
,
// 左侧最小宽度
min
=
400
,
// 左侧最小宽度
max
=
Infinity
,
// 左侧最大宽度
max
=
Infinity
,
// 左侧最大宽度
containerWidth
=
0
,
// 容器宽度
containerWidth
=
0
,
// 容器宽度
containerHeight
=
0
,
// 容器高度
containerHeight
=
0
,
// 容器高度
initLeftWidth
=
0
,
// 初始左侧容器宽度
initLeftWidth
=
0
,
// 初始左侧容器宽度
handler
=
null
,
// 拖拽器
handler
=
null
,
// 拖拽器
onWidthChange
=
width
=>
width
,
// 左侧容器高度变化
isLeft
=
true
,
// 拖拽器
toolWidth
,
onWidthChange
=
width
=>
width
,
// 左侧容器高度变化
dispatch
dispatch
,
})
{
})
{
const
ref
=
useRef
(
null
);
const
ref
=
useRef
(
null
);
const
[
position
,
setPosition
]
=
useState
({
x
:
initLeftWidth
,
y
:
0
});
const
[
position
,
setPosition
]
=
useState
({
x
:
initLeftWidth
,
y
:
0
});
const
[
props
]
=
useDraggable
(
const
[
props
]
=
useDraggable
(
ref
,
ref
,
{
{
onMouseMove
:
({
x
,
y
})
=>
{
onMouseMove
:
({
x
,
y
})
=>
{
let
_x
=
x
;
let
_x
=
x
;
if
(
_x
<
min
)
_x
=
min
;
if
(
_x
<
min
)
_x
=
min
;
if
(
_x
>
max
)
_x
=
max
;
if
(
_x
>
max
)
_x
=
max
;
if
(
onWidthChange
)
onWidthChange
(
_x
);
if
(
onWidthChange
)
onWidthChange
(
_x
);
setPosition
({
x
:
_x
,
y
});
setPosition
({
x
:
_x
,
y
});
dispatch
&&
dispatch
({
if
(
isLeft
)
{
type
:
"Studio/saveToolWidth"
,
dispatch
&&
dispatch
({
payload
:
_x
,
type
:
"Studio/saveToolLeftWidth"
,
});
payload
:
_x
,
});
}
else
{
dispatch
&&
dispatch
({
type
:
"Studio/saveToolRightWidth"
,
payload
:
(
containerWidth
-
_x
),
});
}
},
},
},
},
{
overbound
:
false
},
{
overbound
:
false
},
);
);
const
_handler
=
handler
?
(
const
_handler
=
handler
?
(
React
.
cloneElement
(
handler
,
{
React
.
cloneElement
(
handler
,
{
...
@@ -46,16 +53,16 @@ function DraggleLayout({
...
@@ -46,16 +53,16 @@ function DraggleLayout({
},
},
})
})
)
:
(
)
:
(
<
span
style=
{
{
fontSize
:
18
,
pointerEvents
:
'none'
}
}
>
》
</
span
>
<
span
style=
{
{
fontSize
:
18
,
pointerEvents
:
'none'
}
}
>
》
</
span
>
);
);
return
(
return
(
<
div
<
div
ref=
{
ref
}
ref=
{
ref
}
className=
{
styles
.
root
}
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
]
}
{
children
[
0
]
}
<
div
className=
{
styles
.
handler
}
{
...
props
}
>
<
div
className=
{
styles
.
handler
}
{
...
props
}
>
...
@@ -64,7 +71,7 @@ function DraggleLayout({
...
@@ -64,7 +71,7 @@ function DraggleLayout({
</
div
>
</
div
>
<
div
<
div
className=
{
styles
.
right
}
className=
{
styles
.
right
}
style=
{
{
width
:
containerWidth
-
position
.
x
}
}
style=
{
{
width
:
containerWidth
-
position
.
x
}
}
>
>
{
children
[
1
]
}
{
children
[
1
]
}
</
div
>
</
div
>
...
@@ -73,5 +80,4 @@ function DraggleLayout({
...
@@ -73,5 +80,4 @@ function DraggleLayout({
}
}
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
toolWidth
:
Studio
.
toolWidth
,
}))(
DraggleLayout
);
}))(
DraggleLayout
);
dlink-web/src/components/Studio/StudioLeftTool/StudioCluster/index.tsx
View file @
51728178
...
@@ -205,15 +205,13 @@ const StudioCluster = (props: any) => {
...
@@ -205,15 +205,13 @@ const StudioCluster = (props: any) => {
onClick=
{
onCreateCluster
}
onClick=
{
onCreateCluster
}
/>
/>
</
Tooltip
>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新 Flink 集群"
>
<
Tooltip
title=
"刷新 Flink 集群"
>
<
Button
<
Button
type=
"text"
type=
"text"
icon=
{
<
ReloadOutlined
/>
}
icon=
{
<
ReloadOutlined
/>
}
onClick=
{
onRefreshCluster
}
onClick=
{
onRefreshCluster
}
/>
/>
</
Tooltip
>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
cluster
.
length
>
0
?
(
{
cluster
.
length
>
0
?
(
<
Table
dataSource=
{
cluster
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
<
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) => {
...
@@ -261,7 +261,6 @@ const StudioConnector = (props: any) => {
onClick=
{
createSessions
}
onClick=
{
createSessions
}
/>
/>
</
Tooltip
>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
{
session
.
length
>
0
?
(
{
session
.
length
>
0
?
(
<
Tooltip
title=
"切换会话"
>
<
Tooltip
title=
"切换会话"
>
<
Button
<
Button
...
@@ -295,7 +294,6 @@ const StudioConnector = (props: any) => {
...
@@ -295,7 +294,6 @@ const StudioConnector = (props: any) => {
/>
/>
</
Tooltip
>
</
Tooltip
>
</>)
}
</>)
}
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
currentSession
.
connectors
&&
currentSession
.
connectors
.
length
>
0
?
(
{
currentSession
.
connectors
&&
currentSession
.
connectors
.
length
>
0
?
(
<
Table
dataSource=
{
currentSession
.
connectors
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
<
Table
dataSource=
{
currentSession
.
connectors
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioDataBase/index.tsx
View file @
51728178
...
@@ -68,15 +68,13 @@ const StudioDataBase = (props: any) => {
...
@@ -68,15 +68,13 @@ const StudioDataBase = (props: any) => {
onClick=
{
onCreateDataBase
}
onClick=
{
onCreateDataBase
}
/>
/>
</
Tooltip
>
</
Tooltip
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新数据源"
>
<
Tooltip
title=
"刷新数据源"
>
<
Button
<
Button
type=
"text"
type=
"text"
icon=
{
<
ReloadOutlined
/>
}
icon=
{
<
ReloadOutlined
/>
}
onClick=
{
onRefreshDataBase
}
onClick=
{
onRefreshDataBase
}
/>
/>
</
Tooltip
>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
{
database
.
length
>
0
?
(
{
database
.
length
>
0
?
(
<
Table
dataSource=
{
database
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
<
Table
dataSource=
{
database
}
columns=
{
getColumns
()
}
size=
"small"
/>)
:
(
...
...
dlink-web/src/components/Studio/StudioLeftTool/StudioMetaData/index.tsx
View file @
51728178
...
@@ -68,15 +68,13 @@ const StudioMetaData = (props: any) => {
...
@@ -68,15 +68,13 @@ const StudioMetaData = (props: any) => {
>
>
{
getDataBaseOptions
()
}
{
getDataBaseOptions
()
}
</
Select
>
</
Select
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"刷新元数据表"
>
<
Tooltip
title=
"刷新元数据表"
>
<
Button
<
Button
type=
"text"
type=
"text"
icon=
{
<
ReloadOutlined
/>
}
icon=
{
<
ReloadOutlined
/>
}
onClick=
{
onRefreshTreeData
}
onClick=
{
onRefreshTreeData
}
/>
/>
</
Tooltip
>
</
Tooltip
>
</
div
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
Scrollbars
style=
{
{
height
:
(
toolHeight
-
32
)}
}
>
<
DirectoryTree
<
DirectoryTree
multiple
multiple
...
...
dlink-web/src/components/Studio/StudioTree/index.tsx
View file @
51728178
...
@@ -345,7 +345,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -345,7 +345,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
<
div
className=
{
style
.
tree_div
}
>
<
div
className=
{
style
.
tree_div
}
>
<
Row
>
<
Row
>
<
Col
span=
{
24
}
>
<
Col
span=
{
24
}
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"创建根目录"
>
<
Tooltip
title=
"创建根目录"
>
<
Button
<
Button
type=
"text"
type=
"text"
...
@@ -360,7 +359,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
...
@@ -360,7 +359,6 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
onClick=
{
offExpandAll
}
onClick=
{
offExpandAll
}
/>
/>
</
Tooltip
>
</
Tooltip
>
</
div
>
</
Col
>
</
Col
>
</
Row
>
</
Row
>
<
Scrollbars
style=
{
{
height
:(
toolHeight
-
32
)}
}
>
<
Scrollbars
style=
{
{
height
:(
toolHeight
-
32
)}
}
>
...
...
dlink-web/src/components/Studio/index.tsx
View file @
51728178
...
@@ -24,14 +24,16 @@ type StudioProps = {
...
@@ -24,14 +24,16 @@ type StudioProps = {
const
Studio
:
React
.
FC
<
StudioProps
>
=
(
props
)
=>
{
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
[
form
]
=
Form
.
useForm
();
const
VIEW
=
{
const
VIEW
=
{
rightToolWidth
:
300
,
leftToolWidth
:
300
,
leftToolWidth
:
300
,
marginTop
:
116
,
marginTop
:
116
,
topHeight
:
35.6
,
topHeight
:
35.6
,
bottomHeight
:
153.6
,
bottomHeight
:
153.6
,
rightMargin
:
32
,
leftMargin
:
36
,
midMargin
:
46
,
};
};
const
[
size
,
setSize
]
=
useState
({
const
[
size
,
setSize
]
=
useState
({
width
:
document
.
documentElement
.
clientWidth
-
1
,
width
:
document
.
documentElement
.
clientWidth
-
1
,
...
@@ -92,11 +94,12 @@ const Studio: React.FC<StudioProps> = (props) => {
...
@@ -92,11 +94,12 @@ const Studio: React.FC<StudioProps> = (props) => {
>
>
<
Row
>
<
Row
>
<
DraggleLayout
<
DraggleLayout
containerWidth=
{
size
.
width
-
VIEW
.
rightToolWidth
}
containerWidth=
{
size
.
width
}
containerHeight=
{
toolHeight
}
containerHeight=
{
toolHeight
}
min=
{
VIEW
.
leftToolWidth
}
min=
{
VIEW
.
leftMargin
+
VIEW
.
midMargin
}
max=
{
size
.
width
*
(
1
/
2
)
}
max=
{
size
.
width
-
VIEW
.
rightMargin
}
initLeftWidth=
{
VIEW
.
leftToolWidth
}
initLeftWidth=
{
size
.
width
-
toolRightWidth
}
isLeft=
{
false
}
handler=
{
handler=
{
<
div
<
div
style=
{
{
style=
{
{
...
@@ -107,20 +110,38 @@ const Studio: React.FC<StudioProps> = (props) => {
...
@@ -107,20 +110,38 @@ const Studio: React.FC<StudioProps> = (props) => {
/>
/>
}
}
>
>
<
Col
className=
{
styles
[
"vertical-tabs"
]
}
>
<
DraggleLayout
<
StudioLeftTool
style=
{
{
containerWidth=
{
size
.
width
-
toolRightWidth
}
display
:
'flex'
,
containerHeight=
{
toolHeight
}
alignItems
:
'center'
,
min=
{
VIEW
.
leftMargin
}
justifyContent
:
'center'
,
max=
{
size
.
width
-
VIEW
.
rightMargin
-
VIEW
.
midMargin
}
}
}
/>
initLeftWidth=
{
toolLeftWidth
}
</
Col
>
isLeft=
{
true
}
<
Col
>
handler=
{
<
StudioTabs
width=
{
size
.
width
-
VIEW
.
rightToolWidth
-
toolWidth
}
/>
<
div
style=
{
{
width
:
4
,
height
:
'100%'
,
background
:
'rgb(240, 240, 240)'
,
}
}
/>
}
>
<
Col
className=
{
styles
[
"vertical-tabs"
]
}
>
<
StudioLeftTool
style=
{
{
display
:
'flex'
,
alignItems
:
'center'
,
justifyContent
:
'center'
,
}
}
/>
</
Col
>
<
Col
>
<
StudioTabs
width=
{
size
.
width
-
toolRightWidth
-
toolLeftWidth
}
/>
</
Col
>
</
DraggleLayout
>
<
Col
id=
'StudioRightTool'
className=
{
styles
[
"vertical-tabs"
]
}
>
<
StudioRightTool
form=
{
form
}
/>
</
Col
>
</
Col
>
</
DraggleLayout
>
</
DraggleLayout
>
<
Col
id=
'StudioRightTool'
style=
{
{
width
:
VIEW
.
rightToolWidth
}
}
className=
{
styles
[
"vertical-tabs"
]
}
>
<
StudioRightTool
form=
{
form
}
/>
</
Col
>
</
Row
>
</
Row
>
<
Row
>
<
Row
>
<
Col
span=
{
24
}
>
<
Col
span=
{
24
}
>
...
@@ -137,5 +158,6 @@ const Studio: React.FC<StudioProps> = (props) => {
...
@@ -137,5 +158,6 @@ const Studio: React.FC<StudioProps> = (props) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
rightClickMenu
:
Studio
.
rightClickMenu
,
rightClickMenu
:
Studio
.
rightClickMenu
,
toolHeight
:
Studio
.
toolHeight
,
toolHeight
:
Studio
.
toolHeight
,
toolWidth
:
Studio
.
toolWidth
,
toolLeftWidth
:
Studio
.
toolLeftWidth
,
toolRightWidth
:
Studio
.
toolRightWidth
,
}))(
Studio
);
}))(
Studio
);
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
51728178
...
@@ -123,7 +123,8 @@ export type SessionType = {
...
@@ -123,7 +123,8 @@ export type SessionType = {
export
type
StateType
=
{
export
type
StateType
=
{
toolHeight
?:
number
;
toolHeight
?:
number
;
toolWidth
?:
number
;
toolRightWidth
?:
number
;
toolLeftWidth
?:
number
;
cluster
?:
ClusterType
[];
cluster
?:
ClusterType
[];
sessionCluster
?:
ClusterType
[];
sessionCluster
?:
ClusterType
[];
clusterConfiguration
?:
ClusterConfigurationType
[];
clusterConfiguration
?:
ClusterConfigurationType
[];
...
@@ -150,7 +151,8 @@ export type ModelType = {
...
@@ -150,7 +151,8 @@ export type ModelType = {
};
};
reducers
:
{
reducers
:
{
saveToolHeight
:
Reducer
<
StateType
>
;
saveToolHeight
:
Reducer
<
StateType
>
;
saveToolWidth
:
Reducer
<
StateType
>
;
saveToolRightWidth
:
Reducer
<
StateType
>
;
saveToolLeftWidth
:
Reducer
<
StateType
>
;
saveSql
:
Reducer
<
StateType
>
;
saveSql
:
Reducer
<
StateType
>
;
saveCurrentPath
:
Reducer
<
StateType
>
;
saveCurrentPath
:
Reducer
<
StateType
>
;
saveMonaco
:
Reducer
<
StateType
>
;
saveMonaco
:
Reducer
<
StateType
>
;
...
@@ -174,7 +176,8 @@ const Model: ModelType = {
...
@@ -174,7 +176,8 @@ const Model: ModelType = {
namespace
:
'Studio'
,
namespace
:
'Studio'
,
state
:
{
state
:
{
toolHeight
:
400
,
toolHeight
:
400
,
toolWidth
:
300
,
toolRightWidth
:
300
,
toolLeftWidth
:
300
,
cluster
:
[],
cluster
:
[],
sessionCluster
:
[],
sessionCluster
:
[],
clusterConfiguration
:
[],
clusterConfiguration
:
[],
...
@@ -282,10 +285,15 @@ const Model: ModelType = {
...
@@ -282,10 +285,15 @@ const Model: ModelType = {
...
state
,
...
state
,
toolHeight
:
payload
,
toolHeight
:
payload
,
};
};
},
saveToolWidth
(
state
,
{
payload
})
{
},
saveTool
Right
Width
(
state
,
{
payload
})
{
return
{
return
{
...
state
,
...
state
,
toolWidth
:
payload
,
toolRightWidth
:
payload
,
};
},
saveToolLeftWidth
(
state
,
{
payload
})
{
return
{
...
state
,
toolLeftWidth
:
payload
,
};
};
},
},
saveSql
(
state
,
{
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