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
a0d8113c
Commit
a0d8113c
authored
Jul 24, 2021
by
wenmo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
编辑数据源
parent
dce6c815
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
149 additions
and
61 deletions
+149
-61
pom.xml
dlink-admin/pom.xml
+2
-1
DataBaseController.java
...rc/main/java/com/dlink/controller/DataBaseController.java
+7
-0
DBForm.tsx
dlink-web/src/pages/DataBase/components/DBForm.tsx
+19
-12
MySqlForm.tsx
dlink-web/src/pages/DataBase/components/MySqlForm.tsx
+10
-2
index.less
dlink-web/src/pages/DataBase/index.less
+4
-0
index.tsx
dlink-web/src/pages/DataBase/index.tsx
+87
-46
service.ts
dlink-web/src/pages/DataBase/service.ts
+20
-0
No files found.
dlink-admin/pom.xml
View file @
a0d8113c
...
@@ -82,6 +82,7 @@
...
@@ -82,6 +82,7 @@
<groupId>
com.dlink
</groupId>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-common
</artifactId>
<artifactId>
dlink-common
</artifactId>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.dlink
</groupId>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-metadata-base
</artifactId>
<artifactId>
dlink-metadata-base
</artifactId>
...
@@ -89,7 +90,7 @@
...
@@ -89,7 +90,7 @@
<dependency>
<dependency>
<groupId>
com.dlink
</groupId>
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-metadata-mysql
</artifactId>
<artifactId>
dlink-metadata-mysql
</artifactId>
<
scope>
provided
</scope
>
<
!--<scope>provided</scope>--
>
</dependency>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
dlink-admin/src/main/java/com/dlink/controller/DataBaseController.java
View file @
a0d8113c
...
@@ -77,4 +77,11 @@ public class DataBaseController {
...
@@ -77,4 +77,11 @@ public class DataBaseController {
return
Result
.
succeed
(
database
,
"获取成功"
);
return
Result
.
succeed
(
database
,
"获取成功"
);
}
}
/**
* 全部心跳监测
*/
@PostMapping
(
"/testConnect"
)
public
Result
testConnect
(
@RequestBody
DataBase
database
)
{
return
Result
.
succeed
(
databaseService
.
checkHeartBeat
(
database
),
"获取成功"
);
}
}
}
\ No newline at end of file
dlink-web/src/pages/DataBase/components/DBForm.tsx
View file @
a0d8113c
...
@@ -6,7 +6,8 @@ import {connect} from "umi";
...
@@ -6,7 +6,8 @@ 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"
;
import
{
handleAddOrUpdate
,
handleOption
,
postAll
}
from
"@/components/Common/crud"
;
import
{
createOrModifyDatabase
,
testDatabaseConnect
}
from
"@/pages/DataBase/service"
;
export
type
UpdateFormProps
=
{
export
type
UpdateFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
DataBaseItem
>
)
=>
void
;
...
@@ -40,18 +41,13 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -40,18 +41,13 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
}
=
props
;
}
=
props
;
const
[
dbType
,
setDbType
]
=
useState
<
string
>
();
const
[
dbType
,
setDbType
]
=
useState
<
string
>
();
const
[
createModalVisible
,
handleModalVisible
]
=
useState
<
boolean
>
(
false
);
const
chooseOne
=
(
item
:
DataBaseItem
)
=>
{
const
chooseOne
=
(
item
:
DataBaseItem
)
=>
{
setDbType
(
item
.
type
);
setDbType
(
item
.
type
);
handleModalVisible
(
true
);
// handleChooseDBModalVisible();
};
};
const
onSubmit
=
async
(
value
:
any
)
=>
{
const
onSubmit
=
async
(
value
:
any
)
=>
{
console
.
log
(
value
);
const
success
=
await
createOrModifyDatabase
(
value
);
const
success
=
await
handleAddOrUpdate
(
'/api/database'
,
value
);
if
(
success
)
{
if
(
success
)
{
handleChooseDBModalVisible
();
handleChooseDBModalVisible
();
setDbType
(
undefined
);
setDbType
(
undefined
);
...
@@ -59,17 +55,25 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -59,17 +55,25 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
}
}
};
};
const
onTest
=
async
(
value
:
any
)
=>
{
await
testDatabaseConnect
(
value
);
};
return
(
return
(
<
Modal
<
Modal
width=
{
800
}
width=
{
800
}
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
bodyStyle=
{
{
padding
:
'32px 40px 48px'
}
}
title=
{
'创建数据源'
}
title=
{
values
.
id
?
'编辑数据源'
:
'创建数据源'
}
visible=
{
modalVisible
}
visible=
{
modalVisible
}
onCancel=
{
()
=>
handleChooseDBModalVisible
()
}
onCancel=
{
()
=>
{
setDbType
(
undefined
);
handleChooseDBModalVisible
();
}
}
maskClosable
=
{
false
}
maskClosable
=
{
false
}
destroyOnClose
=
{
true
}
footer=
{
null
}
footer=
{
null
}
>
{
>
{
!
dbType
&&
(<
List
(
!
dbType
&&!
values
.
id
)
&&
(<
List
grid=
{
{
grid=
{
{
gutter
:
16
,
gutter
:
16
,
xs
:
1
,
xs
:
1
,
...
@@ -96,11 +100,14 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
...
@@ -96,11 +100,14 @@ const DBForm: React.FC<UpdateFormProps> = (props) => {
}
}
<
MysqlForm
<
MysqlForm
onCancel=
{
()
=>
setDbType
(
undefined
)
}
onCancel=
{
()
=>
setDbType
(
undefined
)
}
modalVisible=
{
dbType
==
'MySql'
}
modalVisible=
{
dbType
==
'MySql'
||
values
.
type
==
'MySql'
}
values=
{
{}
}
values=
{
values
}
onSubmit=
{
(
value
)
=>
{
onSubmit=
{
(
value
)
=>
{
onSubmit
(
value
);
onSubmit
(
value
);
}
}
}
}
onTest=
{
(
value
)
=>
{
onTest
(
value
);
}
}
/>
/>
</
Modal
>
</
Modal
>
);
);
...
...
dlink-web/src/pages/DataBase/components/MySqlForm.tsx
View file @
a0d8113c
...
@@ -9,6 +9,7 @@ import {DataBaseItem} from "@/pages/DataBase/data";
...
@@ -9,6 +9,7 @@ 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
;
onTest
:
(
values
:
Partial
<
DataBaseItem
>
)
=>
void
;
modalVisible
:
boolean
;
modalVisible
:
boolean
;
values
:
Partial
<
DataBaseItem
>
;
values
:
Partial
<
DataBaseItem
>
;
};
};
...
@@ -37,6 +38,7 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
...
@@ -37,6 +38,7 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
const
{
const
{
onSubmit
:
handleUpdate
,
onSubmit
:
handleUpdate
,
onTest
:
handleTest
,
onCancel
:
handleModalVisible
,
onCancel
:
handleModalVisible
,
modalVisible
,
modalVisible
,
values
,
values
,
...
@@ -48,6 +50,12 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
...
@@ -48,6 +50,12 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
handleUpdate
({...
formVals
,
...
fieldsValue
});
handleUpdate
({...
formVals
,
...
fieldsValue
});
};
};
const
testForm
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
setFormVals
({...
formVals
,
...
fieldsValue
});
handleTest
({...
formVals
,
...
fieldsValue
});
};
const
onReset
=
()
=>
{
const
onReset
=
()
=>
{
form
.
resetFields
();
form
.
resetFields
();
};
};
...
@@ -146,10 +154,10 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
...
@@ -146,10 +154,10 @@ const MysqlForm: React.FC<MysqlFormProps> = (props) => {
<
Button
htmlType=
"button"
onClick=
{
onReset
}
>
<
Button
htmlType=
"button"
onClick=
{
onReset
}
>
重置
重置
</
Button
>
</
Button
>
<
Button
htmlType=
"button"
>
<
Button
type=
"primary"
htmlType=
"button"
onClick=
{
testForm
}
>
测试
测试
</
Button
>
</
Button
>
<
Button
type=
"primary"
htmlType=
"button"
onClick=
{
()
=>
submitForm
()
}
>
<
Button
type=
"primary"
htmlType=
"button"
onClick=
{
submitForm
}
>
保存
保存
</
Button
>
</
Button
>
</
Space
>
</
Space
>
...
...
dlink-web/src/pages/DataBase/index.less
0 → 100644
View file @
a0d8113c
.cardImage{
height: 120px;
}
dlink-web/src/pages/DataBase/index.tsx
View file @
a0d8113c
This diff is collapsed.
Click to expand it.
dlink-web/src/pages/DataBase/service.ts
0 → 100644
View file @
a0d8113c
import
request
from
"umi-request"
;
import
{
handleAddOrUpdate
,
handleOption
,
postAll
}
from
"@/components/Common/crud"
;
import
{
DataBaseItem
}
from
"@/pages/DataBase/data"
;
import
{
message
}
from
"antd"
;
export
async
function
createOrModifyDatabase
(
databse
:
DataBaseItem
)
{
return
handleAddOrUpdate
(
'/api/database'
,
databse
);
}
export
async
function
testDatabaseConnect
(
databse
:
DataBaseItem
)
{
const
hide
=
message
.
loading
(
'正在测试连接'
);
try
{
const
{
datas
}
=
await
postAll
(
'/api/database/testConnect'
,
databse
);
hide
();
datas
?
message
.
success
(
"数据源连接测试成功!"
):
message
.
error
(
"数据源连接测试失败,请检查连接配置。"
);
}
catch
(
error
)
{
hide
();
message
.
error
(
'请求失败,请重试'
);
}
}
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