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
7aa316d7
Commit
7aa316d7
authored
Jul 08, 2021
by
godkaikai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
集群下拉框优化
parent
4b6db6d8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
77 deletions
+99
-77
DDL.ts
dlink-web/src/components/Studio/StudioEvent/DDL.ts
+35
-25
SessionForm.tsx
...StudioLeftTool/StudioConnector/components/SessionForm.tsx
+18
-2
index.tsx
...components/Studio/StudioRightTool/StudioSetting/index.tsx
+14
-23
index.tsx
dlink-web/src/components/Studio/index.tsx
+3
-0
model.ts
dlink-web/src/pages/FlinkSqlStudio/model.ts
+29
-27
No files found.
dlink-web/src/components/Studio/StudioEvent/DDL.ts
View file @
7aa316d7
...
@@ -2,22 +2,22 @@ import {executeDDL} from "@/pages/FlinkSqlStudio/service";
...
@@ -2,22 +2,22 @@ import {executeDDL} from "@/pages/FlinkSqlStudio/service";
import
FlinkSQL
from
"./FlinkSQL"
;
import
FlinkSQL
from
"./FlinkSQL"
;
import
{
TaskType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
TaskType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
Modal
}
from
"antd"
;
import
{
Modal
}
from
"antd"
;
import
{
handleRemove
}
from
"@/components/Common/crud"
;
import
{
getData
,
handleRemove
}
from
"@/components/Common/crud"
;
export
function
showTables
(
task
:
TaskType
,
dispatch
:
any
)
{
export
function
showTables
(
task
:
TaskType
,
dispatch
:
any
)
{
const
res
=
executeDDL
({
const
res
=
executeDDL
({
statement
:
FlinkSQL
.
SHOW_TABLES
,
statement
:
FlinkSQL
.
SHOW_TABLES
,
clusterId
:
task
.
clusterId
,
clusterId
:
task
.
clusterId
,
session
:
task
.
session
,
session
:
task
.
session
,
useSession
:
task
.
useSession
,
useSession
:
task
.
useSession
,
useResult
:
true
,
useResult
:
true
,
});
});
res
.
then
((
result
)
=>
{
res
.
then
((
result
)
=>
{
let
tableData
=
[];
let
tableData
=
[];
if
(
result
.
datas
.
rowData
.
length
>
0
)
{
if
(
result
.
datas
.
rowData
.
length
>
0
)
{
tableData
=
result
.
datas
.
rowData
;
tableData
=
result
.
datas
.
rowData
;
}
}
dispatch
&&
dispatch
({
dispatch
&&
dispatch
({
type
:
"Studio/refreshCurrentSessionCluster"
,
type
:
"Studio/refreshCurrentSessionCluster"
,
payload
:
{
payload
:
{
session
:
task
.
session
,
session
:
task
.
session
,
...
@@ -29,39 +29,49 @@ export function showTables(task:TaskType,dispatch:any) {
...
@@ -29,39 +29,49 @@ export function showTables(task:TaskType,dispatch:any) {
});
});
}
}
export
function
removeTable
(
tablename
:
string
,
task
:
TaskType
,
dispatch
:
any
)
{
export
function
removeTable
(
tablename
:
string
,
task
:
TaskType
,
dispatch
:
any
)
{
Modal
.
confirm
({
Modal
.
confirm
({
title
:
'确定删除表【'
+
tablename
+
'】吗?'
,
title
:
'确定删除表【'
+
tablename
+
'】吗?'
,
okText
:
'确认'
,
okText
:
'确认'
,
cancelText
:
'取消'
,
cancelText
:
'取消'
,
onOk
:
async
()
=>
{
onOk
:
async
()
=>
{
const
res
=
executeDDL
({
const
res
=
executeDDL
({
statement
:
"drop table "
+
tablename
,
statement
:
"drop table "
+
tablename
,
clusterId
:
task
.
clusterId
,
clusterId
:
task
.
clusterId
,
session
:
task
.
session
,
session
:
task
.
session
,
useSession
:
task
.
useSession
,
useSession
:
task
.
useSession
,
useResult
:
true
,
useResult
:
true
,
});
});
res
.
then
((
result
)
=>
{
res
.
then
((
result
)
=>
{
showTables
(
task
,
dispatch
);
showTables
(
task
,
dispatch
);
});
});
}
}
});
});
}
}
export
function
clearSession
(
session
:
string
,
task
:
TaskType
,
dispatch
:
any
)
{
export
function
clearSession
(
session
:
string
,
task
:
TaskType
,
dispatch
:
any
)
{
Modal
.
confirm
({
Modal
.
confirm
({
title
:
'确认清空会话【'
+
session
+
'】?'
,
title
:
'确认清空会话【'
+
session
+
'】?'
,
okText
:
'确认'
,
okText
:
'确认'
,
cancelText
:
'取消'
,
cancelText
:
'取消'
,
onOk
:
async
()
=>
{
onOk
:
async
()
=>
{
let
para
=
{
let
para
=
{
id
:
session
,
id
:
session
,
};
};
const
res
=
handleRemove
(
'/api/studio/clearSession'
,[
para
]);
const
res
=
handleRemove
(
'/api/studio/clearSession'
,
[
para
]);
res
.
then
((
result
)
=>
{
res
.
then
((
result
)
=>
{
showTables
(
task
,
dispatch
);
showTables
(
task
,
dispatch
);
});
});
}
}
});
});
}
}
export
function
showCluster
(
dispatch
:
any
)
{
const
res
=
getData
(
'api/cluster/listEnabledAll'
);
res
.
then
((
result
)
=>
{
result
.
datas
&&
dispatch
&&
dispatch
({
type
:
"Studio/saveCluster"
,
payload
:
result
.
datas
,
});
});
}
dlink-web/src/components/Studio/StudioLeftTool/StudioConnector/components/SessionForm.tsx
View file @
7aa316d7
import
React
,
{
useState
}
from
'react'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Form
,
Button
,
Input
,
Modal
,
Select
,
Switch
}
from
'antd'
;
import
{
Form
,
Button
,
Input
,
Modal
,
Select
,
Tag
,
Switch
}
from
'antd'
;
import
{
SessionItem
}
from
'../data.d'
;
import
{
SessionItem
}
from
'../data.d'
;
import
{
connect
}
from
"umi"
;
import
{
connect
}
from
"umi"
;
...
@@ -32,6 +32,8 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -32,6 +32,8 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
createTime
:
props
.
values
.
createTime
,
createTime
:
props
.
values
.
createTime
,
});
});
const
{
cluster
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
{
const
{
...
@@ -47,6 +49,20 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -47,6 +49,20 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
handleUpdate
({...
formVals
,
...
fieldsValue
});
handleUpdate
({...
formVals
,
...
fieldsValue
});
};
};
const
getClusterOptions
=
()
=>
{
let
itemList
=
[(<
Option
value=
{
0
}
label=
{
(<><
Tag
color=
"default"
>
Local
</
Tag
>
本地环境
</>)
}
>
<
Tag
color=
"default"
>
Local
</
Tag
>
本地环境
</
Option
>)];
for
(
let
item
of
cluster
){
let
tag
=
(<><
Tag
color=
{
item
.
enabled
?
"processing"
:
"error"
}
>
{
item
.
type
}
</
Tag
>
{
item
.
alias
}
</>);
itemList
.
push
(<
Option
value=
{
item
.
id
}
label=
{
tag
}
>
{
tag
}
</
Option
>)
}
return
itemList
;
};
const
renderContent
=
()
=>
{
const
renderContent
=
()
=>
{
return
(
return
(
<>
<>
...
@@ -82,7 +98,7 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -82,7 +98,7 @@ const SessionForm: React.FC<UpdateFormProps> = (props) => {
defaultValue=
{
0
}
defaultValue=
{
0
}
optionLabelProp=
"label"
optionLabelProp=
"label"
>
>
{
getClusterOptions
()
}
</
Select
>
</
Select
>
</
Item
>
</
Item
>
</>
</>
...
...
dlink-web/src/components/Studio/StudioRightTool/StudioSetting/index.tsx
View file @
7aa316d7
...
@@ -4,35 +4,30 @@ import {Form, InputNumber,Input,Switch,Select,Tag,Row,Col,Divider,Tooltip,Button
...
@@ -4,35 +4,30 @@ import {Form, InputNumber,Input,Switch,Select,Tag,Row,Col,Divider,Tooltip,Button
import
{
InfoCircleOutlined
,
PlusOutlined
,
MinusSquareOutlined
}
from
"@ant-design/icons"
;
import
{
InfoCircleOutlined
,
PlusOutlined
,
MinusSquareOutlined
}
from
"@ant-design/icons"
;
import
styles
from
"./index.less"
;
import
styles
from
"./index.less"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
showTables
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
show
Cluster
,
show
Tables
}
from
"@/components/Studio/StudioEvent/DDL"
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
StudioSetting
=
(
props
:
any
)
=>
{
const
StudioSetting
=
(
props
:
any
)
=>
{
const
{
cluster
,
current
,
form
,
dispatch
,
tabs
}
=
props
;
const
{
cluster
,
current
,
form
,
dispatch
,
tabs
}
=
props
;
const
[
clusterOption
,
setClusterOption
]
=
useState
<
[]
>
();
const
getClusterOptions
=
()
=>
{
const
getCluster
=
()
=>
{
let
itemList
=
[(<
Option
value=
{
0
}
label=
{
(<><
Tag
color=
"default"
>
Local
</
Tag
>
本地环境
</>)
}
>
cluster
&&
cluster
.
then
(
value
=>
{
<
Tag
color=
"default"
>
Local
</
Tag
>
let
itemList
=
[];
本地环境
for
(
let
item
of
value
){
</
Option
>)];
for
(
let
item
of
cluster
){
let
tag
=
(<><
Tag
color=
{
item
.
enabled
?
"processing"
:
"error"
}
>
{
item
.
type
}
</
Tag
>
{
item
.
alias
}
</>);
let
tag
=
(<><
Tag
color=
{
item
.
enabled
?
"processing"
:
"error"
}
>
{
item
.
type
}
</
Tag
>
{
item
.
alias
}
</>);
itemList
.
push
(<
Option
value=
{
item
.
id
}
label=
{
tag
}
>
itemList
.
push
(<
Option
value=
{
item
.
id
}
label=
{
tag
}
>
{
tag
}
{
tag
}
</
Option
>)
</
Option
>)
}
}
setClusterOption
(
itemList
);
return
itemList
;
});
};
};
form
.
setFieldsValue
(
current
.
task
);
form
.
setFieldsValue
(
current
.
task
);
useEffect
(()
=>
{
getCluster
();
},
[]);
const
onValuesChange
=
(
change
:
any
,
all
:
any
)
=>
{
const
onValuesChange
=
(
change
:
any
,
all
:
any
)
=>
{
let
newTabs
=
tabs
;
let
newTabs
=
tabs
;
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
){
...
@@ -123,11 +118,7 @@ const StudioSetting = (props: any) => {
...
@@ -123,11 +118,7 @@ const StudioSetting = (props: any) => {
optionLabelProp=
"label"
optionLabelProp=
"label"
onChange=
{
onChangeClusterSession
}
onChange=
{
onChangeClusterSession
}
>
>
<
Option
value=
{
0
}
label=
{
(<><
Tag
color=
"default"
>
Local
</
Tag
>
本地环境
</>)
}
>
{
getClusterOptions
()
}
<
Tag
color=
"default"
>
Local
</
Tag
>
本地环境
</
Option
>
{
clusterOption
}
</
Select
>
</
Select
>
</
Form
.
Item
>
</
Form
.
Item
>
</
Col
>
</
Col
>
...
...
dlink-web/src/components/Studio/index.tsx
View file @
7aa316d7
...
@@ -11,6 +11,7 @@ import {StateType} from "@/pages/FlinkSqlStudio/model";
...
@@ -11,6 +11,7 @@ import {StateType} from "@/pages/FlinkSqlStudio/model";
import
StudioConsole
from
"./StudioConsole"
;
import
StudioConsole
from
"./StudioConsole"
;
import
StudioLeftTool
from
"./StudioLeftTool"
;
import
StudioLeftTool
from
"./StudioLeftTool"
;
import
StudioRightTool
from
"./StudioRightTool"
;
import
StudioRightTool
from
"./StudioRightTool"
;
import
{
showCluster
}
from
"@/components/Studio/StudioEvent/DDL"
;
type
StudioProps
=
{
type
StudioProps
=
{
rightClickMenu
:
StateType
[
'rightClickMenu'
];
rightClickMenu
:
StateType
[
'rightClickMenu'
];
...
@@ -22,6 +23,8 @@ const Studio: React.FC<StudioProps> = (props) => {
...
@@ -22,6 +23,8 @@ const Studio: React.FC<StudioProps> = (props) => {
const
{
rightClickMenu
,
dispatch
}
=
props
;
const
{
rightClickMenu
,
dispatch
}
=
props
;
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
showCluster
(
dispatch
);
const
onClick
=
()
=>
{
const
onClick
=
()
=>
{
if
(
rightClickMenu
){
if
(
rightClickMenu
){
dispatch
&&
dispatch
({
dispatch
&&
dispatch
({
...
...
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
7aa316d7
...
@@ -85,16 +85,16 @@ export type SessionType = {
...
@@ -85,16 +85,16 @@ export type SessionType = {
}
}
export
type
StateType
=
{
export
type
StateType
=
{
cluster
?:
ClusterType
[];
cluster
?:
ClusterType
[];
currentSessionCluster
:
SessionType
;
currentSessionCluster
?
:
SessionType
;
current
:
TabsItemType
;
current
?
:
TabsItemType
;
sql
?:
string
;
sql
?:
string
;
monaco
?:
any
;
monaco
?:
any
;
currentPath
?:
string
[];
currentPath
?:
string
[];
tabs
:
TabsType
;
tabs
?
:
TabsType
;
session
:
SessionType
[];
session
?
:
SessionType
[];
result
:{};
result
?
:{};
rightClickMenu
?:
boolean
;
rightClickMenu
?:
boolean
;
refs
:{
refs
?
:{
history
:
any
;
history
:
any
;
};
};
};
};
...
@@ -116,24 +116,14 @@ export type ModelType = {
...
@@ -116,24 +116,14 @@ export type ModelType = {
showRightClickMenu
:
Reducer
<
StateType
>
;
showRightClickMenu
:
Reducer
<
StateType
>
;
refreshCurrentSessionCluster
:
Reducer
<
StateType
>
;
refreshCurrentSessionCluster
:
Reducer
<
StateType
>
;
saveResult
:
Reducer
<
StateType
>
;
saveResult
:
Reducer
<
StateType
>
;
saveCluster
:
Reducer
<
StateType
>
;
};
};
};
};
const
getClusters
=
async
()
=>
{
try
{
const
{
datas
}
=
await
getData
(
'api/cluster/listEnabledAll'
);
return
datas
;
}
catch
(
error
)
{
console
.
error
(
'获取Flink集群失败'
);
return
[];
}
};
const
Model
:
ModelType
=
{
const
Model
:
ModelType
=
{
namespace
:
'Studio'
,
namespace
:
'Studio'
,
state
:
{
state
:
{
cluster
:
getClusters
()
,
cluster
:
[]
,
currentSessionCluster
:
{
currentSessionCluster
:
{
connectors
:
[],
connectors
:
[],
},
},
...
@@ -322,7 +312,8 @@ const Model: ModelType = {
...
@@ -322,7 +312,8 @@ const Model: ModelType = {
};
};
},
},
saveSession
(
state
,
{
payload
})
{
saveSession
(
state
,
{
payload
})
{
let
newSession
=
state
.
session
;
let
newSession
=
state
?.
session
;
if
(
newSession
)
{
for
(
let
i
=
0
;
i
<
newSession
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
newSession
.
length
;
i
++
)
{
if
(
newSession
[
i
].
key
==
payload
)
{
if
(
newSession
[
i
].
key
==
payload
)
{
return
{};
return
{};
...
@@ -333,6 +324,11 @@ const Model: ModelType = {
...
@@ -333,6 +324,11 @@ const Model: ModelType = {
...
state
,
...
state
,
session
:
newSession
,
session
:
newSession
,
};
};
}
else
{
return
{
...
state
};
}
},
},
showRightClickMenu
(
state
,
{
payload
})
{
showRightClickMenu
(
state
,
{
payload
})
{
return
{
return
{
...
@@ -356,6 +352,12 @@ const Model: ModelType = {
...
@@ -356,6 +352,12 @@ const Model: ModelType = {
},
},
};
};
},
},
saveCluster
(
state
,
{
payload
})
{
return
{
...
state
,
cluster
:
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