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
6faa43bb
Commit
6faa43bb
authored
Jul 23, 2021
by
godkaikai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysql
parent
fe14f1dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
91 deletions
+130
-91
DBForm.tsx
dlink-web/src/pages/DataBase/components/DBForm.tsx
+19
-9
MySqlForm.tsx
dlink-web/src/pages/DataBase/components/MySqlForm.tsx
+101
-70
data.d.ts
dlink-web/src/pages/DataBase/data.d.ts
+0
-2
index.tsx
dlink-web/src/pages/DataBase/index.tsx
+10
-10
No files found.
dlink-web/src/pages/DataBase/components/
ChooseDB
.tsx
→
dlink-web/src/pages/DataBase/components/
DBForm
.tsx
View file @
6faa43bb
...
@@ -6,6 +6,7 @@ import {connect} from "umi";
...
@@ -6,6 +6,7 @@ import {connect} from "umi";
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
getDBImage
}
from
"@/pages/DataBase/DB"
;
import
{
getDBImage
}
from
"@/pages/DataBase/DB"
;
import
MysqlForm
from
"@/pages/DataBase/components/MySqlForm"
;
import
MysqlForm
from
"@/pages/DataBase/components/MySqlForm"
;
import
{
handleAddOrUpdate
}
from
"@/components/Common/crud"
;
export
type
UpdateFormProps
=
{
export
type
UpdateFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
...
@@ -29,12 +30,13 @@ const data = [
...
@@ -29,12 +30,13 @@ const data = [
},
},
];
];
const
ChooseDB
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
DBForm
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
{
const
{
//
onSubmit: handleUpdate,
onSubmit
:
handleUpdate
,
onCancel
:
handleChooseDBModalVisible
,
onCancel
:
handleChooseDBModalVisible
,
modalVisible
,
modalVisible
,
values
}
=
props
;
}
=
props
;
const
[
dbType
,
setDbType
]
=
useState
<
string
>
();
const
[
dbType
,
setDbType
]
=
useState
<
string
>
();
...
@@ -51,12 +53,13 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
...
@@ -51,12 +53,13 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
<
Modal
<
Modal
width=
{
800
}
width=
{
800
}
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
title=
{
'
选择数据源类型
'
}
title=
{
'
创建数据源
'
}
visible=
{
modalVisible
}
visible=
{
modalVisible
}
onCancel=
{
()
=>
handleChooseDBModalVisible
()
}
onCancel=
{
()
=>
handleChooseDBModalVisible
()
}
maskClosable
=
{
false
}
footer=
{
null
}
footer=
{
null
}
>
>
{
<
List
!
dbType
&&
(
<
List
grid=
{
{
grid=
{
{
gutter
:
16
,
gutter
:
16
,
xs
:
1
,
xs
:
1
,
...
@@ -79,13 +82,20 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
...
@@ -79,13 +82,20 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
</
Card
>
</
Card
>
</
List
.
Item
>
</
List
.
Item
>
)
}
)
}
/>
/>)
}
<
MysqlForm
<
MysqlForm
onCancel=
{
()
=>
setDbType
(
undefined
)
}
onCancel=
{
()
=>
setDbType
(
undefined
)
}
modalVisible=
{
dbType
==
'MySql'
}
modalVisible=
{
dbType
==
'MySql'
}
values=
{
{}
}
values=
{
{}
}
onSubmit=
{
()
=>
{
onSubmit=
{
async
(
value
)
=>
{
setDbType
(
undefined
)
console
.
log
(
value
);
const
success
=
await
handleAddOrUpdate
(
'/api/database'
,
value
);
if
(
success
)
{
handleChooseDBModalVisible
();
setDbType
(
undefined
);
handleUpdate
(
value
);
}
}
}
}
}
/>
/>
</
Modal
>
</
Modal
>
...
@@ -94,4 +104,4 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
...
@@ -94,4 +104,4 @@ const ChooseDB: React.FC<UpdateFormProps> = (props) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
cluster
:
Studio
.
cluster
,
cluster
:
Studio
.
cluster
,
}))(
ChooseDB
);
}))(
DBForm
);
dlink-web/src/pages/DataBase/components/MySqlForm.tsx
View file @
6faa43bb
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Button
,
Input
,
Modal
,
Select
}
from
'antd'
;
import
{
Form
,
Button
,
Input
,
Space
,
Select
}
from
'antd'
;
import
Switch
from
"antd/es/switch"
;
import
Switch
from
"antd/es/switch"
;
import
TextArea
from
"antd/es/input/TextArea"
;
import
TextArea
from
"antd/es/input/TextArea"
;
import
{
DataBaseItem
}
from
"@/pages/DataBase/data"
;
import
{
DataBaseItem
}
from
"@/pages/DataBase/data"
;
export
type
MysqlFormProps
=
{
export
type
MysqlFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
onSubmit
:
(
values
:
Partial
<
DataBaseItem
>
)
=>
void
;
onSubmit
:
(
values
:
Partial
<
DataBaseItem
>
)
=>
void
;
modalVisible
:
boolean
;
modalVisible
:
boolean
;
values
:
Partial
<
DataBaseItem
>
;
values
:
Partial
<
DataBaseItem
>
;
};
};
const
FormItem
=
Form
.
Item
;
const
Option
=
Select
.
Option
;
const
formLayout
=
{
const
formLayout
=
{
labelCol
:
{
span
:
7
},
labelCol
:
{
span
:
7
},
wrapperCol
:
{
span
:
13
},
wrapperCol
:
{
span
:
13
},
};
};
const
MysqlForm
:
React
.
FC
<
MysqlFormProps
>
=
(
props
)
=>
{
const
MysqlForm
:
React
.
FC
<
MysqlFormProps
>
=
(
props
)
=>
{
...
@@ -23,110 +24,140 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
...
@@ -23,110 +24,140 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
id
:
props
.
values
.
id
,
id
:
props
.
values
.
id
,
name
:
props
.
values
.
name
,
name
:
props
.
values
.
name
,
alias
:
props
.
values
.
alias
,
alias
:
props
.
values
.
alias
,
type
:
props
.
values
.
type
,
type
:
"Mysql"
,
groupName
:
props
.
values
.
groupName
,
url
:
props
.
values
.
url
,
username
:
props
.
values
.
username
,
password
:
props
.
values
.
password
,
dbVersion
:
props
.
values
.
dbVersion
,
note
:
props
.
values
.
note
,
note
:
props
.
values
.
note
,
enabled
:
props
.
values
.
enabled
,
enabled
:
props
.
values
.
enabled
,
});
});
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
{
const
{
onSubmit
:
handleUpdate
,
onSubmit
:
handleUpdate
,
onCancel
:
handle
Update
ModalVisible
,
onCancel
:
handleModalVisible
,
modalVisible
,
modalVisible
,
values
,
values
,
}
=
props
;
}
=
props
;
const
submitForm
=
async
()
=>
{
const
submitForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
({
...
formVals
,
...
fieldsValue
});
setFormVals
({...
formVals
,
...
fieldsValue
});
handleUpdate
({
...
formVals
,
...
fieldsValue
});
handleUpdate
({...
formVals
,
...
fieldsValue
});
};
const
onReset
=
()
=>
{
form
.
resetFields
();
};
};
const
renderContent
=
(
formVals
)
=>
{
const
renderContent
=
(
formVals
)
=>
{
return
(
return
(
<>
<>
<
FormItem
<
Form
.
Item
name=
"name"
name=
"name"
label=
"名称"
label=
"名称"
rules=
{
[{
required
:
true
,
message
:
'请输入名称!'
}]
}
>
rules=
{
[{
required
:
true
,
message
:
'请输入名称!'
}]
}
>
<
Input
placeholder=
"请输入
"
/>
<
Input
placeholder=
"请输入
唯一英文标识"
/>
</
FormItem
>
</
Form
.
Item
>
<
FormItem
<
Form
.
Item
name=
"alias"
name=
"alias"
label=
"别名"
label=
"别名"
>
>
<
Input
placeholder=
"请输入
"
/>
<
Input
placeholder=
"请输入
别名"
/>
</
FormItem
>
</
Form
.
Item
>
<
FormItem
<
Form
.
Item
name=
"
typ
e"
name=
"
groupNam
e"
label=
"类型"
label=
"
分组
类型"
>
>
<
Select
defaultValue=
"Yarn"
allowClear
>
<
Select
defaultValue=
"其他"
>
<
Option
value=
"Standalone"
>
Standalone
</
Option
>
<
Option
value=
"来源"
>
来源
</
Option
>
<
Option
value=
"Yarn"
>
Yarn
</
Option
>
<
Option
value=
"数仓"
>
数仓
</
Option
>
<
Option
value=
"Others"
>
Others
</
Option
>
<
Option
value=
"应用"
>
应用
</
Option
>
<
Option
value=
"备份"
>
备份
</
Option
>
<
Option
value=
"其他"
>
其他
</
Option
>
</
Select
>
</
Select
>
</
FormItem
>
</
Form
.
Item
>
<
FormItem
<
Form
.
Item
name=
"hosts"
name=
"url"
label=
"Hosts"
label=
"url"
>
<
TextArea
placeholder=
"jdbc:mysql://{host}:{port}/{database}"
allowClear
autoSize=
{
{
minRows
:
3
,
maxRows
:
10
}
}
/>
</
Form
.
Item
>
<
Form
.
Item
name=
"username"
label=
"用户名"
>
<
Input
/>
</
Form
.
Item
>
<
Form
.
Item
name=
"password"
label=
"密码"
>
>
<
TextArea
placeholder=
"添加 Flink Hosts...例如:127.0.0.1:8081,127.0.0.1:8091"
allowClear
autoSize=
{
{
minRows
:
3
,
maxRows
:
10
}
}
/>
<
Input
.
Password
/>
</
FormItem
>
</
Form
.
Item
>
<
FormItem
<
Form
.
Item
name=
"note"
name=
"note"
label=
"注释"
label=
"注释"
>
>
<
Input
placeholder=
"请输入"
/>
<
Input
placeholder=
"请输入"
/>
</
FormItem
>
</
Form
.
Item
>
<
FormItem
<
Form
.
Item
name=
"enabled"
name=
"enabled"
label=
"是否启用"
label=
"是否启用"
rules=
{
[{
required
:
true
,
message
:
'请输入是否启用!'
}]
}
>
>
<
Switch
checkedChildren=
"启用"
unCheckedChildren=
"禁用"
<
Switch
checkedChildren=
"启用"
unCheckedChildren=
"禁用"
defaultChecked=
{
formVals
.
enabled
}
/>
defaultChecked=
{
formVals
.
enabled
}
/>
</
FormItem
>
</
Form
.
Item
>
</>
);
};
const
renderFooter
=
()
=>
{
return
(
<>
<
Button
onClick=
{
()
=>
handleUpdateModalVisible
(
false
,
values
)
}
>
取消
</
Button
>
<
Button
type=
"primary"
onClick=
{
()
=>
submitForm
()
}
>
完成
</
Button
>
</>
</>
);
);
};
};
return
(
return
(
<
Modal
<>
{
width=
{
640
}
modalVisible
&&
(
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
<>
destroyOnClose
<
Form
title=
{
formVals
.
id
?
'编辑'
:
'创建 MySql 数据源'
}
{
...
formLayout
}
visible=
{
modalVisible
}
form=
{
form
}
footer=
{
renderFooter
()
}
initialValues=
{
{
onCancel=
{
()
=>
handleUpdateModalVisible
()
}
id
:
formVals
.
id
,
>
name
:
formVals
.
name
,
<
Form
alias
:
formVals
.
alias
,
{
...
formLayout
}
type
:
formVals
.
type
,
form=
{
form
}
groupName
:
formVals
.
groupName
,
initialValues=
{
{
url
:
formVals
.
url
,
id
:
formVals
.
id
,
username
:
formVals
.
username
,
name
:
formVals
.
name
,
password
:
formVals
.
password
,
alias
:
formVals
.
alias
,
note
:
formVals
.
note
,
type
:
formVals
.
type
,
enabled
:
formVals
.
enabled
,
note
:
formVals
.
note
,
}
}
enabled
:
formVals
.
enabled
,
>
}
}
{
renderContent
(
formVals
)
}
>
<
Form
.
Item
wrapperCol=
{
{
offset
:
8
,
span
:
16
}
}
>
{
renderContent
(
formVals
)
}
<
Space
>
</
Form
>
<
Button
htmlType=
"button"
onClick=
{
()
=>
{
</
Modal
>
handleModalVisible
(
false
)
}
}
>
返回
</
Button
>
<
Button
htmlType=
"button"
onClick=
{
onReset
}
>
重置
</
Button
>
<
Button
htmlType=
"button"
>
测试
</
Button
>
<
Button
type=
"primary"
htmlType=
"button"
onClick=
{
()
=>
submitForm
()
}
>
保存
</
Button
>
</
Space
>
</
Form
.
Item
>
</
Form
>
</>
)
}
</>
);
);
};
};
...
...
dlink-web/src/pages/DataBase/data.d.ts
View file @
6faa43bb
...
@@ -4,8 +4,6 @@ export type DataBaseItem = {
...
@@ -4,8 +4,6 @@ export type DataBaseItem = {
alias
:
string
,
alias
:
string
,
groupName
:
string
,
groupName
:
string
,
type
:
string
,
type
:
string
,
ip
:
string
,
port
:
number
,
url
:
string
,
url
:
string
,
username
:
string
,
username
:
string
,
password
:
string
,
password
:
string
,
...
...
dlink-web/src/pages/DataBase/index.tsx
View file @
6faa43bb
import
React
,
{
useState
}
from
"react"
;
import
React
,
{
use
Ref
,
use
State
}
from
"react"
;
import
{
PageContainer
,
FooterToolbar
}
from
'@ant-design/pro-layout'
;
import
{
PageContainer
,
FooterToolbar
}
from
'@ant-design/pro-layout'
;
import
{
DownOutlined
,
HeartOutlined
,
PlusOutlined
,
UserOutlined
}
from
'@ant-design/icons'
;
import
{
DownOutlined
,
HeartOutlined
,
PlusOutlined
,
UserOutlined
}
from
'@ant-design/icons'
;
import
{
Progress
,
Tag
,
Button
,
Space
,
Badge
,
Typography
,
Image
,
Row
,
Col
}
from
'antd'
;
import
{
Progress
,
Tag
,
Button
,
Space
,
Badge
,
Typography
,
Image
,
Row
,
Col
}
from
'antd'
;
import
ProList
from
'@ant-design/pro-list'
;
import
ProList
from
'@ant-design/pro-list'
;
import
{
queryData
}
from
"@/components/Common/crud"
;
import
{
queryData
}
from
"@/components/Common/crud"
;
import
{
getDBImage
}
from
"@/pages/DataBase/DB"
;
import
{
getDBImage
}
from
"@/pages/DataBase/DB"
;
import
ChooseDB
from
"./components/ChooseDB"
;
import
DBForm
from
"./components/DBForm"
;
import
{
ActionType
}
from
"@ant-design/pro-table"
;
const
{
Text
}
=
Typography
;
const
{
Text
}
=
Typography
;
...
@@ -13,18 +14,15 @@ const url = '/api/database';
...
@@ -13,18 +14,15 @@ const url = '/api/database';
const
DataBaseTableList
:
React
.
FC
<
{}
>
=
(
props
:
any
)
=>
{
const
DataBaseTableList
:
React
.
FC
<
{}
>
=
(
props
:
any
)
=>
{
const
[
chooseDBModalVisible
,
handleChooseDBModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
chooseDBModalVisible
,
handleDBFormModalVisible
]
=
useState
<
boolean
>
(
false
);
const
actionRef
=
useRef
<
ActionType
>
();
const
chooseDB
=
()
=>
{
};
return
(
return
(
<
PageContainer
>
<
PageContainer
>
<
ProList
<
ProList
actionRef=
{
actionRef
}
toolBarRender=
{
()
=>
{
toolBarRender=
{
()
=>
{
return
[
return
[
<
Button
type=
"primary"
onClick=
{
()
=>
handle
ChooseDB
ModalVisible
(
true
)
}
>
<
Button
type=
"primary"
onClick=
{
()
=>
handle
DBForm
ModalVisible
(
true
)
}
>
<
PlusOutlined
/>
新建
<
PlusOutlined
/>
新建
</
Button
>,
</
Button
>,
];
];
...
@@ -79,7 +77,9 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
...
@@ -79,7 +77,9 @@ const DataBaseTableList: React.FC<{}> = (props: any) => {
}
}
}
}
headerTitle=
"数据源"
headerTitle=
"数据源"
/>
/>
<
ChooseDB
onCancel=
{
()
=>
handleChooseDBModalVisible
(
false
)
}
modalVisible=
{
chooseDBModalVisible
}
/>
<
DBForm
onCancel=
{
()
=>
handleDBFormModalVisible
(
false
)
}
modalVisible=
{
chooseDBModalVisible
}
onSubmit=
{
()
=>
{
actionRef
.
current
?.
reloadAndRest
?.();}
}
/>
</
PageContainer
>
</
PageContainer
>
);
);
};
};
...
...
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