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
0f7563ce
Commit
0f7563ce
authored
Dec 13, 2021
by
godkaikai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增数据源的Sql校验
parent
f5742858
Changes
27
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
387 additions
and
25 deletions
+387
-25
pom.xml
dlink-admin/pom.xml
+14
-0
CatalogueTaskDTO.java
...k-admin/src/main/java/com/dlink/dto/CatalogueTaskDTO.java
+2
-0
StudioExecuteDTO.java
...k-admin/src/main/java/com/dlink/dto/StudioExecuteDTO.java
+2
-0
Task.java
dlink-admin/src/main/java/com/dlink/model/Task.java
+4
-0
CatalogueServiceImpl.java
...ain/java/com/dlink/service/impl/CatalogueServiceImpl.java
+3
-0
StudioServiceImpl.java
...c/main/java/com/dlink/service/impl/StudioServiceImpl.java
+27
-0
TaskMapper.xml
dlink-admin/src/main/resources/mapper/TaskMapper.xml
+3
-1
SqlExplainResult.java
...mmon/src/main/java/com/dlink/result/SqlExplainResult.java
+23
-0
Dialect.java
dlink-core/src/main/java/com/dlink/config/Dialect.java
+40
-0
dlink.sql
dlink-doc/sql/dlink.sql
+2
-0
dlink_history.sql
dlink-doc/sql/dlink_history.sql
+8
-0
SavePointType.java
...src/main/java/com/dlink/gateway/config/SavePointType.java
+1
-1
AbstractJdbcDriver.java
...in/java/com/dlink/metadata/driver/AbstractJdbcDriver.java
+27
-0
Driver.java
...-base/src/main/java/com/dlink/metadata/driver/Driver.java
+3
-0
ExplainResult.java
...rc/main/java/com/dlink/metadata/result/ExplainResult.java
+11
-0
ClickHouseDriver.java
...main/java/com/dlink/metadata/driver/ClickHouseDriver.java
+31
-0
index.tsx
...components/Studio/StudioRightTool/StudioSetting/index.tsx
+1
-3
index.less
...ponents/Studio/StudioRightTool/StudioSqlConfig/index.less
+9
-0
index.tsx
...mponents/Studio/StudioRightTool/StudioSqlConfig/index.tsx
+104
-0
index.tsx
dlink-web/src/components/Studio/StudioRightTool/index.tsx
+23
-7
SimpleTaskForm.tsx
...omponents/Studio/StudioTree/components/SimpleTaskForm.tsx
+21
-9
data.d.ts
dlink-web/src/components/Studio/StudioTree/data.d.ts
+1
-0
index.tsx
dlink-web/src/components/Studio/StudioTree/index.tsx
+2
-2
conf.ts
dlink-web/src/components/Studio/conf.ts
+6
-0
model.ts
dlink-web/src/pages/FlinkSqlStudio/model.ts
+11
-2
data.d.ts
dlink-web/src/pages/Task/data.d.ts
+5
-0
Welcome.tsx
dlink-web/src/pages/Welcome.tsx
+3
-0
No files found.
dlink-admin/pom.xml
View file @
0f7563ce
...
...
@@ -130,6 +130,20 @@
<groupId>
com.dlink
</groupId>
<artifactId>
dlink-gateway
</artifactId>
</dependency>
<!--<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-metadata-clickhouse</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-metadata-mysql</artifactId>
<version>0.5.0-SNAPSHOT</version>
</dependency>-->
</dependencies>
<build>
<plugins>
...
...
dlink-admin/src/main/java/com/dlink/dto/CatalogueTaskDTO.java
View file @
0f7563ce
package
com
.
dlink
.
dto
;
import
com.dlink.config.Dialect
;
import
lombok.Getter
;
import
lombok.Setter
;
...
...
@@ -17,4 +18,5 @@ public class CatalogueTaskDTO {
private
boolean
isLeaf
;
private
String
name
;
private
String
alias
;
private
String
dialect
=
Dialect
.
DEFAULT
.
getValue
();
}
dlink-admin/src/main/java/com/dlink/dto/StudioExecuteDTO.java
View file @
0f7563ce
...
...
@@ -22,6 +22,7 @@ import java.util.Map;
public
class
StudioExecuteDTO
{
// RUN_MODE
private
String
type
;
private
String
dialect
;
private
boolean
useResult
;
private
boolean
statementSet
;
private
boolean
useSession
;
...
...
@@ -29,6 +30,7 @@ public class StudioExecuteDTO {
private
boolean
useRemote
;
private
Integer
clusterId
;
private
Integer
clusterConfigurationId
;
private
Integer
databaseId
;
private
Integer
jarId
;
private
boolean
fragment
;
private
String
statement
;
...
...
dlink-admin/src/main/java/com/dlink/model/Task.java
View file @
0f7563ce
...
...
@@ -32,6 +32,8 @@ public class Task extends SuperEntity{
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
String
alias
;
private
String
dialect
;
private
String
type
;
private
Integer
checkPoint
;
...
...
@@ -50,6 +52,8 @@ public class Task extends SuperEntity{
private
Integer
clusterConfigurationId
;
private
Integer
databaseId
;
private
Integer
jarId
;
private
String
configJson
;
...
...
dlink-admin/src/main/java/com/dlink/service/impl/CatalogueServiceImpl.java
View file @
0f7563ce
package
com
.
dlink
.
service
.
impl
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.db.service.impl.SuperServiceImpl
;
import
com.dlink.dto.CatalogueTaskDTO
;
import
com.dlink.mapper.CatalogueMapper
;
...
...
@@ -40,11 +41,13 @@ public class CatalogueServiceImpl extends SuperServiceImpl<CatalogueMapper, Cata
Task
task
=
new
Task
();
task
.
setName
(
catalogueTaskDTO
.
getName
());
task
.
setAlias
(
catalogueTaskDTO
.
getAlias
());
task
.
setDialect
(
catalogueTaskDTO
.
getDialect
());
taskService
.
saveOrUpdateTask
(
task
);
Catalogue
catalogue
=
new
Catalogue
();
catalogue
.
setName
(
catalogueTaskDTO
.
getAlias
());
catalogue
.
setIsLeaf
(
true
);
catalogue
.
setTaskId
(
task
.
getId
());
catalogue
.
setType
(
catalogueTaskDTO
.
getDialect
());
catalogue
.
setParentId
(
catalogueTaskDTO
.
getParentId
());
this
.
save
(
catalogue
);
return
catalogue
;
...
...
dlink-admin/src/main/java/com/dlink/service/impl/StudioServiceImpl.java
View file @
0f7563ce
package
com
.
dlink
.
service
.
impl
;
import
com.dlink.api.FlinkAPI
;
import
com.dlink.assertion.Assert
;
import
com.dlink.assertion.Asserts
;
import
com.dlink.config.Dialect
;
import
com.dlink.dto.SessionDTO
;
import
com.dlink.dto.StudioDDLDTO
;
import
com.dlink.dto.StudioExecuteDTO
;
...
...
@@ -14,7 +16,9 @@ import com.dlink.gateway.result.SavePointResult;
import
com.dlink.job.JobConfig
;
import
com.dlink.job.JobManager
;
import
com.dlink.job.JobResult
;
import
com.dlink.metadata.driver.Driver
;
import
com.dlink.model.Cluster
;
import
com.dlink.model.DataBase
;
import
com.dlink.model.Savepoints
;
import
com.dlink.model.SystemConfiguration
;
import
com.dlink.result.IResult
;
...
...
@@ -22,6 +26,7 @@ import com.dlink.result.SelectResult;
import
com.dlink.result.SqlExplainResult
;
import
com.dlink.service.ClusterConfigurationService
;
import
com.dlink.service.ClusterService
;
import
com.dlink.service.DataBaseService
;
import
com.dlink.service.SavepointsService
;
import
com.dlink.service.StudioService
;
import
com.dlink.session.SessionConfig
;
...
...
@@ -59,6 +64,8 @@ public class StudioServiceImpl implements StudioService {
private
ClusterConfigurationService
clusterConfigurationService
;
@Autowired
private
SavepointsService
savepointsService
;
@Autowired
private
DataBaseService
dataBaseService
;
@Override
public
JobResult
executeSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
...
...
@@ -85,6 +92,14 @@ public class StudioServiceImpl implements StudioService {
@Override
public
List
<
SqlExplainResult
>
explainSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
if
(
Dialect
.
SQL
.
equalsVal
(
studioExecuteDTO
.
getDialect
())){
return
explainCommonSql
(
studioExecuteDTO
);
}
else
{
return
explainFlinkSql
(
studioExecuteDTO
);
}
}
private
List
<
SqlExplainResult
>
explainFlinkSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
if
(!
config
.
isUseSession
())
{
config
.
setAddress
(
clusterService
.
buildEnvironmentAddress
(
config
.
isUseRemote
(),
studioExecuteDTO
.
getClusterId
()));
...
...
@@ -93,6 +108,18 @@ public class StudioServiceImpl implements StudioService {
return
jobManager
.
explainSql
(
studioExecuteDTO
.
getStatement
()).
getSqlExplainResults
();
}
private
List
<
SqlExplainResult
>
explainCommonSql
(
StudioExecuteDTO
studioExecuteDTO
)
{
if
(
Asserts
.
isNull
(
studioExecuteDTO
.
getDatabaseId
())){
return
new
ArrayList
<>();
}
else
{
DataBase
dataBase
=
dataBaseService
.
getById
(
studioExecuteDTO
.
getDatabaseId
());
SqlExplainResult
explainResult
=
Driver
.
build
(
dataBase
.
getDriverConfig
()).
connect
().
explain
(
studioExecuteDTO
.
getStatement
());
return
new
ArrayList
<
SqlExplainResult
>(){{
add
(
explainResult
);
}};
}
}
@Override
public
ObjectNode
getStreamGraph
(
StudioExecuteDTO
studioExecuteDTO
)
{
JobConfig
config
=
studioExecuteDTO
.
getJobConfig
();
...
...
dlink-admin/src/main/resources/mapper/TaskMapper.xml
View file @
0f7563ce
...
...
@@ -7,6 +7,7 @@
<id
column=
"id"
property=
"id"
/>
<result
column=
"name"
property=
"name"
/>
<result
column=
"alias"
property=
"alias"
/>
<result
column=
"dialect"
property=
"dialect"
/>
<result
column=
"type"
property=
"type"
/>
<result
column=
"check_point"
property=
"checkPoint"
/>
<result
column=
"save_point_strategy"
property=
"savePointStrategy"
/>
...
...
@@ -16,6 +17,7 @@
<result
column=
"statement_set"
property=
"statementSet"
/>
<result
column=
"cluster_id"
property=
"clusterId"
/>
<result
column=
"cluster_configuration_id"
property=
"clusterConfigurationId"
/>
<result
column=
"database_id"
property=
"databaseId"
/>
<result
column=
"jar_id"
property=
"jarId"
/>
<result
column=
"config_json"
property=
"configJson"
/>
<result
column=
"note"
property=
"note"
/>
...
...
@@ -26,7 +28,7 @@
<!-- 通用查询结果列 -->
<sql
id=
"Base_Column_List"
>
id, name, alias,
type,check_point,save_point_strategy,save_point_path, parallelism,fragment,statement_set,cluster_id,cluster_configuration
_id,jar_id,config_json,note, enabled, create_time, update_time
id, name, alias,
dialect, type,check_point,save_point_strategy,save_point_path, parallelism,fragment,statement_set,cluster_id,cluster_configuration_id,database
_id,jar_id,config_json,note, enabled, create_time, update_time
</sql>
...
...
dlink-common/src/main/java/com/dlink/result/SqlExplainResult.java
View file @
0f7563ce
...
...
@@ -20,6 +20,29 @@ public class SqlExplainResult {
private
boolean
explainTrue
;
private
LocalDateTime
explainTime
;
public
SqlExplainResult
()
{
}
public
SqlExplainResult
(
Integer
index
,
String
type
,
String
sql
,
String
parse
,
String
explain
,
String
error
,
boolean
parseTrue
,
boolean
explainTrue
,
LocalDateTime
explainTime
)
{
this
.
index
=
index
;
this
.
type
=
type
;
this
.
sql
=
sql
;
this
.
parse
=
parse
;
this
.
explain
=
explain
;
this
.
error
=
error
;
this
.
parseTrue
=
parseTrue
;
this
.
explainTrue
=
explainTrue
;
this
.
explainTime
=
explainTime
;
}
public
static
SqlExplainResult
success
(
String
type
,
String
sql
,
String
explain
){
return
new
SqlExplainResult
(
1
,
type
,
sql
,
null
,
explain
,
null
,
true
,
true
,
LocalDateTime
.
now
());
}
public
static
SqlExplainResult
fail
(
String
sql
,
String
error
){
return
new
SqlExplainResult
(
1
,
null
,
sql
,
null
,
null
,
error
,
false
,
false
,
LocalDateTime
.
now
());
}
public
Integer
getIndex
()
{
return
index
;
}
...
...
dlink-core/src/main/java/com/dlink/config/Dialect.java
0 → 100644
View file @
0f7563ce
package
com
.
dlink
.
config
;
import
com.dlink.assertion.Asserts
;
/**
* Dialect
*
* @author wenmo
* @since 2021/12/13
**/
public
enum
Dialect
{
FLINKSQL
(
"FlinkSql"
),
SQL
(
"Sql"
),
JAVA
(
"Java"
);
private
String
value
;
public
static
final
Dialect
DEFAULT
=
Dialect
.
FLINKSQL
;
Dialect
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getValue
()
{
return
value
;
}
public
boolean
equalsVal
(
String
valueText
){
return
Asserts
.
isEqualsIgnoreCase
(
value
,
valueText
);
}
public
static
Dialect
get
(
String
value
){
for
(
Dialect
type
:
Dialect
.
values
())
{
if
(
Asserts
.
isEqualsIgnoreCase
(
type
.
getValue
(),
value
)){
return
type
;
}
}
return
Dialect
.
FLINKSQL
;
}
}
dlink-doc/sql/dlink.sql
View file @
0f7563ce
...
...
@@ -221,6 +221,7 @@ CREATE TABLE `dlink_task` (
`id`
int
(
11
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'ID'
,
`name`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NOT
NULL
COMMENT
'名称'
,
`alias`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'别名'
,
`dialect`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'方言'
,
`type`
varchar
(
50
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'类型'
,
`check_point`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'CheckPoint '
,
`save_point_strategy`
int
(
1
)
UNSIGNED
ZEROFILL
NULL
DEFAULT
NULL
COMMENT
'SavePoint策略'
,
...
...
@@ -230,6 +231,7 @@ CREATE TABLE `dlink_task` (
`statement_set`
tinyint
(
1
)
NULL
DEFAULT
NULL
COMMENT
'启用语句集'
,
`cluster_id`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'Flink集群ID'
,
`cluster_configuration_id`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'集群配置ID'
,
`database_id`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'数据源ID'
,
`jar_id`
int
(
11
)
NULL
DEFAULT
NULL
COMMENT
'jarID'
,
`config_json`
text
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
COMMENT
'配置JSON'
,
`note`
varchar
(
255
)
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
DEFAULT
NULL
COMMENT
'注释'
,
...
...
dlink-doc/sql/dlink_history.sql
View file @
0f7563ce
...
...
@@ -471,4 +471,12 @@ INSERT INTO `dlink_user`(`id`, `username`, `password`, `nickname`, `worknum`, `a
ALTER
TABLE
`dlink_task`
CHANGE
COLUMN
`config`
`config_json`
text
CHARACTER
SET
utf8
COLLATE
utf8_general_ci
NULL
COMMENT
'配置JSON'
AFTER
`jar_id`
;
-- ----------------------------
-- 0.5.0-SNAPSHOT 2021-12-13
-- ----------------------------
ALTER
TABLE
`dlink_task`
ADD
COLUMN
`dialect`
varchar
(
50
)
NULL
COMMENT
'方言'
AFTER
`alias`
;
ALTER
TABLE
`dlink_task`
ADD
COLUMN
`database_id`
int
(
11
)
NULL
COMMENT
'数据源ID'
AFTER
`cluster_configuration_id`
;
SET
FOREIGN_KEY_CHECKS
=
1
;
dlink-gateway/src/main/java/com/dlink/gateway/config/SavePointType.java
View file @
0f7563ce
...
...
@@ -23,7 +23,7 @@ public enum SavePointType{
public
static
SavePointType
get
(
String
value
){
for
(
SavePointType
type
:
SavePointType
.
values
())
{
if
(
Asserts
.
isEquals
(
type
.
getValue
(),
value
)){
if
(
Asserts
.
isEquals
IgnoreCase
(
type
.
getValue
(),
value
)){
return
type
;
}
}
...
...
dlink-metadata/dlink-metadata-base/src/main/java/com/dlink/metadata/driver/AbstractJdbcDriver.java
View file @
0f7563ce
...
...
@@ -5,6 +5,7 @@ import com.dlink.constant.CommonConstant;
import
com.dlink.model.Column
;
import
com.dlink.model.Schema
;
import
com.dlink.model.Table
;
import
com.dlink.result.SqlExplainResult
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -270,4 +271,30 @@ public abstract class AbstractJdbcDriver extends AbstractDriver {
}
return
datas
;
}
@Override
public
SqlExplainResult
explain
(
String
sql
){
boolean
correct
=
true
;
String
error
=
null
;
PreparedStatement
preparedStatement
=
null
;
ResultSet
results
=
null
;
try
{
preparedStatement
=
conn
.
prepareStatement
(
"explain "
+
sql
);
results
=
preparedStatement
.
executeQuery
();
if
(!
results
.
next
()){
correct
=
false
;
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
correct
=
false
;
error
=
e
.
getMessage
();
}
finally
{
close
(
preparedStatement
,
results
);
}
if
(
correct
)
{
return
SqlExplainResult
.
success
(
null
,
sql
,
null
);
}
else
{
return
SqlExplainResult
.
fail
(
sql
,
error
);
}
}
}
dlink-metadata/dlink-metadata-base/src/main/java/com/dlink/metadata/driver/Driver.java
View file @
0f7563ce
...
...
@@ -6,6 +6,7 @@ import com.dlink.metadata.result.SelectResult;
import
com.dlink.model.Column
;
import
com.dlink.model.Schema
;
import
com.dlink.model.Table
;
import
com.dlink.result.SqlExplainResult
;
import
com.fasterxml.jackson.databind.JsonNode
;
import
sun.misc.Service
;
...
...
@@ -91,4 +92,6 @@ public interface Driver {
List
query
(
String
sql
);
SqlExplainResult
explain
(
String
sql
);
}
dlink-metadata/dlink-metadata-base/src/main/java/com/dlink/metadata/result/ExplainResult.java
0 → 100644
View file @
0f7563ce
package
com
.
dlink
.
metadata
.
result
;
/**
* ExplainResult
*
* @author qiwenkai
* @since 2021/12/13 19:14
**/
public
class
ExplainResult
{
private
String
sql
;
}
dlink-metadata/dlink-metadata-clickhouse/src/main/java/com/dlink/metadata/driver/ClickHouseDriver.java
View file @
0f7563ce
...
...
@@ -5,6 +5,11 @@ import com.dlink.metadata.convert.ITypeConvert;
import
com.dlink.metadata.query.ClickHouseQuery
;
import
com.dlink.metadata.query.IDBQuery
;
import
com.dlink.model.Table
;
import
com.dlink.result.SqlExplainResult
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
/**
* ClickHouseDriver
...
...
@@ -42,4 +47,30 @@ public class ClickHouseDriver extends AbstractJdbcDriver {
public
String
getCreateTableSql
(
Table
table
)
{
return
null
;
}
@Override
public
SqlExplainResult
explain
(
String
sql
){
boolean
correct
=
true
;
String
error
=
null
;
StringBuilder
explain
=
new
StringBuilder
();
PreparedStatement
preparedStatement
=
null
;
ResultSet
results
=
null
;
try
{
preparedStatement
=
conn
.
prepareStatement
(
"explain "
+
sql
);
results
=
preparedStatement
.
executeQuery
();
while
(
results
.
next
()){
explain
.
append
(
getTypeConvert
().
convertValue
(
results
,
"explain"
,
"string"
)+
"\r\n"
);
}
}
catch
(
SQLException
e
)
{
correct
=
false
;
error
=
e
.
getMessage
();
}
finally
{
close
(
preparedStatement
,
results
);
}
if
(
correct
)
{
return
SqlExplainResult
.
success
(
"ClickHouseSql"
,
sql
,
explain
.
toString
());
}
else
{
return
SqlExplainResult
.
fail
(
sql
,
error
);
}
}
}
dlink-web/src/components/Studio/StudioRightTool/StudioSetting/index.tsx
View file @
0f7563ce
...
...
@@ -7,7 +7,7 @@ import {useEffect} from "react";
import
{
showTables
}
from
"@/components/Studio/StudioEvent/DDL"
;
import
{
JarStateType
}
from
"@/pages/Jar/model"
;
import
{
Scrollbars
}
from
"react-custom-scrollbars"
;
import
{
RUN_MODE
}
from
"@/components/Studio/
StudioRightTool/StudioSetting/
conf"
;
import
{
RUN_MODE
}
from
"@/components/Studio/conf"
;
const
{
Option
}
=
Select
;
const
{
Text
}
=
Typography
;
...
...
@@ -124,7 +124,6 @@ const StudioSetting = (props: any) => {
)
:
(<
Select
style=
{
{
width
:
'100%'
}
}
placeholder=
"选择Flink集群"
defaultValue=
{
0
}
optionLabelProp=
"label"
onChange=
{
onChangeClusterSession
}
>
...
...
@@ -143,7 +142,6 @@ const StudioSetting = (props: any) => {
<
Select
style=
{
{
width
:
'100%'
}
}
placeholder=
"选择Flink集群配置"
defaultValue=
{
0
}
optionLabelProp=
"label"
>
{
getClusterConfigurationOptions
()
}
...
...
dlink-web/src/components/Studio/StudioRightTool/StudioSqlConfig/index.less
0 → 100644
View file @
0f7563ce
@import '~antd/es/style/themes/default.less';
.form_setting{
padding-left: 10px;
}
.form_item{
margin-bottom: 5px;
}
dlink-web/src/components/Studio/StudioRightTool/StudioSqlConfig/index.tsx
0 → 100644
View file @
0f7563ce
import
{
connect
}
from
"umi"
;
import
{
StateType
}
from
"@/pages/FlinkSqlStudio/model"
;
import
{
Form
,
InputNumber
,
Select
,
Tag
,
Row
,
Col
,
Tooltip
,
Button
,
}
from
"antd"
;
import
{
MinusSquareOutlined
}
from
"@ant-design/icons"
;
import
styles
from
"./index.less"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
const
{
Option
}
=
Select
;
const
StudioSqlConfig
=
(
props
:
any
)
=>
{
const
{
current
,
form
,
dispatch
,
tabs
,
database
,
toolHeight
}
=
props
;
form
.
setFieldsValue
(
current
.
task
);
const
onValuesChange
=
(
change
:
any
,
all
:
any
)
=>
{
let
newTabs
=
tabs
;
for
(
let
i
=
0
;
i
<
newTabs
.
panes
.
length
;
i
++
){
if
(
newTabs
.
panes
[
i
].
key
==
newTabs
.
activeKey
){
for
(
let
key
in
change
){
newTabs
.
panes
[
i
].
task
[
key
]
=
change
[
key
];
}
break
;
}
}
dispatch
&&
dispatch
({
type
:
"Studio/saveTabs"
,
payload
:
newTabs
,
});
};
const
getDataBaseOptions
=
()
=>
{
const
itemList
=
[];
for
(
const
item
of
database
)
{
const
tag
=
(<><
Tag
color=
{
item
.
enabled
?
"processing"
:
"error"
}
>
{
item
.
type
}
</
Tag
>
{
item
.
alias
}
</>);
itemList
.
push
(<
Option
key=
{
item
.
id
}
value=
{
item
.
id
}
label=
{
tag
}
>
{
tag
}
</
Option
>)
}
return
itemList
;
};
return
(
<>
<
Row
>
<
Col
span=
{
24
}
>
<
div
style=
{
{
float
:
"right"
}
}
>
<
Tooltip
title=
"最小化"
>
<
Button
type=
"text"
icon=
{
<
MinusSquareOutlined
/>
}
/>
</
Tooltip
>
</
div
>
</
Col
>
</
Row
>
<
Scrollbars
style=
{
{
height
:(
toolHeight
-
32
)}
}
>
<
Form
form=
{
form
}
layout=
"vertical"
className=
{
styles
.
form_setting
}
onValuesChange=
{
onValuesChange
}
>
<
Row
>
<
Col
span=
{
24
}
>
<
Form
.
Item
label=
"数据源"
tooltip=
{
`选择 Sql 语句执行的数据源`
}
name=
"databaseId"
className=
{
styles
.
form_item
}
>
<
Select
style=
{
{
width
:
'100%'
}
}
placeholder=
"选择数据源"
optionLabelProp=
"label"
>
{
getDataBaseOptions
()
}
</
Select
>
</
Form
.
Item
>
</
Col
>
<
Col
span=
{
24
}
>
<
Form
.
Item
label=
"最大行数"
className=
{
styles
.
form_item
}
name=
"maxRowNum"
tooltip=
'预览数据的最大行数'
>
<
InputNumber
min=
{
1
}
max=
{
9999
}
defaultValue=
{
100
}
/>
</
Form
.
Item
>
</
Col
>
</
Row
>
</
Form
>
</
Scrollbars
>
</>
);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
database
:
Studio
.
database
,
current
:
Studio
.
current
,
tabs
:
Studio
.
tabs
,
toolHeight
:
Studio
.
toolHeight
,
}))(
StudioSqlConfig
);
dlink-web/src/components/Studio/StudioRightTool/index.tsx
View file @
0f7563ce
...
...
@@ -6,17 +6,27 @@ import styles from "./index.less";
import
StudioConfig
from
"./StudioConfig"
;
import
StudioSetting
from
"./StudioSetting"
;
import
StudioSavePoint
from
"./StudioSavePoint"
;
import
StudioSqlConfig
from
"./StudioSqlConfig"
;
import
{
DIALECT
}
from
"@/components/Studio/conf"
;
const
{
TabPane
}
=
Tabs
;
const
StudioRightTool
=
(
props
:
any
)
=>
{
// const [form] = Form.useForm();
const
{
form
,
toolHeight
}
=
props
;
return
(
<
Tabs
defaultActiveKey=
"1"
size=
"small"
tabPosition=
"right"
style=
{
{
height
:
toolHeight
}
}
>
<
TabPane
tab=
{
<
span
><
SettingOutlined
/>
作业配置
</
span
>
}
key=
"StudioSetting"
>
const
{
current
,
form
,
toolHeight
}
=
props
;
const
renderSqlContent
=
()
=>
{
return
(<>
<
TabPane
tab=
{
<
span
><
ScheduleOutlined
/>
执行配置
</
span
>
}
key=
"StudioConfig"
>
<
StudioSqlConfig
form=
{
form
}
/>
</
TabPane
>
</>)
};
const
renderFlinkSqlContent
=
()
=>
{
return
(<><
TabPane
tab=
{
<
span
><
SettingOutlined
/>
作业配置
</
span
>
}
key=
"StudioSetting"
>
<
StudioSetting
form=
{
form
}
/>
</
TabPane
>
<
TabPane
tab=
{
<
span
><
ScheduleOutlined
/>
执行配置
</
span
>
}
key=
"StudioConfig"
>
...
...
@@ -27,7 +37,12 @@ const StudioRightTool = (props:any) => {
</
TabPane
>
<
TabPane
tab=
{
<
span
><
AuditOutlined
/>
审计
</
span
>
}
key=
"4"
>
<
Empty
image=
{
Empty
.
PRESENTED_IMAGE_SIMPLE
}
/>
</
TabPane
>
</
TabPane
></>)
};
return
(
<
Tabs
defaultActiveKey=
"1"
size=
"small"
tabPosition=
"right"
style=
{
{
height
:
toolHeight
}
}
>
{
current
.
task
.
dialect
===
DIALECT
.
SQL
?
renderSqlContent
():
renderFlinkSqlContent
()
}
</
Tabs
>
);
};
...
...
@@ -35,4 +50,5 @@ const StudioRightTool = (props:any) => {
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
sql
:
Studio
.
sql
,
toolHeight
:
Studio
.
toolHeight
,
current
:
Studio
.
current
,
}))(
StudioRightTool
);
dlink-web/src/components/Studio/StudioTree/components/
Updat
eTaskForm.tsx
→
dlink-web/src/components/Studio/StudioTree/components/
Simpl
eTaskForm.tsx
View file @
0f7563ce
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Form
,
Button
,
Input
,
Modal
}
from
'antd'
;
import
{
Form
,
Button
,
Input
,
Modal
,
Select
}
from
'antd'
;
import
type
{
TaskTableListItem
}
from
'../data.d'
;
import
{
DIALECT
}
from
"@/components/Studio/conf"
;
const
{
Option
}
=
Select
;
export
type
UpdateFormProps
=
{
onCancel
:
(
flag
?:
boolean
,
formVals
?:
Partial
<
TaskTableListItem
>
)
=>
void
;
...
...
@@ -11,14 +14,12 @@ export type UpdateFormProps = {
values
:
Partial
<
TaskTableListItem
>
;
};
const
FormItem
=
Form
.
Item
;
const
formLayout
=
{
labelCol
:
{
span
:
7
},
wrapperCol
:
{
span
:
13
},
};
const
Updat
eTaskForm
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
Simpl
eTaskForm
:
React
.
FC
<
UpdateFormProps
>
=
(
props
)
=>
{
const
[
formVals
,
setFormVals
]
=
useState
<
Partial
<
TaskTableListItem
>>
({
id
:
props
.
values
.
id
,
name
:
props
.
values
.
name
,
...
...
@@ -45,18 +46,28 @@ const UpdateTaskForm: React.FC<UpdateFormProps> = (props) => {
const
renderContent
=
()
=>
{
return
(
<>
<
FormItem
{
isCreate
?(<
Form
.
Item
label=
"作业类型"
name=
"dialect"
tooltip=
'指定作业类型,默认为 FlinkSql'
>
<
Select
defaultValue=
{
DIALECT
.
FLINKSQL
}
value=
{
DIALECT
.
FLINKSQL
}
>
<
Option
value=
{
DIALECT
.
FLINKSQL
}
>
FlinkSql
</
Option
>
<
Option
value=
{
DIALECT
.
SQL
}
>
Sql
</
Option
>
<
Option
value=
{
DIALECT
.
JAVA
}
>
Java
</
Option
>
</
Select
>
</
Form
.
Item
>):
undefined
}
<
Form
.
Item
name=
"name"
label=
"名称"
rules=
{
[{
required
:
true
,
message
:
'请输入唯一名称!'
}]
}
>
<
Input
placeholder=
"请输入"
/>
</
FormItem
>
<
FormItem
</
Form
.
Item
>
<
Form
.
Item
name=
"alias"
label=
"别名"
rules=
{
[{
required
:
true
,
message
:
'请输入别名!'
}]
}
>
<
Input
placeholder=
"请输入"
/>
</
FormItem
>
</
Form
.
Item
>
</>
);
};
...
...
@@ -89,6 +100,7 @@ const UpdateTaskForm: React.FC<UpdateFormProps> = (props) => {
id
:
formVals
.
id
,
name
:
formVals
.
name
,
alias
:
formVals
.
alias
,
dialect
:
formVals
.
dialect
,
parentId
:
formVals
.
parentId
,
}
}
>
...
...
@@ -98,4 +110,4 @@ const UpdateTaskForm: React.FC<UpdateFormProps> = (props) => {
);
};
export
default
Updat
eTaskForm
;
export
default
Simpl
eTaskForm
;
dlink-web/src/components/Studio/StudioTree/data.d.ts
View file @
0f7563ce
...
...
@@ -9,5 +9,6 @@ export type TaskTableListItem = {
id
:
number
,
name
:
string
,
alias
:
string
,
dialect
:
string
,
parentId
:
number
,
};
dlink-web/src/components/Studio/StudioTree/index.tsx
View file @
0f7563ce
...
...
@@ -12,7 +12,7 @@ import {
}
from
"@/components/Common/crud"
;
import
UpdateCatalogueForm
from
'./components/UpdateCatalogueForm'
;
import
{
ActionType
}
from
"@ant-design/pro-table"
;
import
UpdateTaskForm
from
"@/components/Studio/StudioTree/components/Updat
eTaskForm"
;
import
SimpleTaskForm
from
"@/components/Studio/StudioTree/components/Simpl
eTaskForm"
;
import
{
Scrollbars
}
from
'react-custom-scrollbars'
;
const
{
DirectoryTree
}
=
Tree
;
const
{
Search
}
=
Input
;
...
...
@@ -392,7 +392,7 @@ const StudioTree: React.FC<StudioTreeProps> = (props) => {
/>
)
:
null
}
{
updateTaskModalVisible
?
(
<
Updat
eTaskForm
<
Simpl
eTaskForm
onSubmit=
{
async
(
value
)
=>
{
const
datas
=
await
handleAddOrUpdateWithResult
(
'/api/catalogue/createTask'
,
value
);
if
(
datas
)
{
...
...
dlink-web/src/components/Studio/
StudioRightTool/StudioSetting/
conf.ts
→
dlink-web/src/components/Studio/conf.ts
View file @
0f7563ce
...
...
@@ -5,3 +5,9 @@ export const RUN_MODE = {
YARN_PER_JOB
:
'yarn-per-job'
,
YARN_APPLICATION
:
'yarn-application'
,
};
export
const
DIALECT
=
{
FLINKSQL
:
'FlinkSql'
,
SQL
:
'Sql'
,
JAVA
:
'Java'
,
};
dlink-web/src/pages/FlinkSqlStudio/model.ts
View file @
0f7563ce
...
...
@@ -55,6 +55,7 @@ export type TaskType = {
catalogueId
?:
number
,
name
?:
string
,
alias
?:
string
,
dialect
?:
string
,
type
?:
string
,
checkPoint
?:
number
,
savePointStrategy
?:
number
,
...
...
@@ -67,6 +68,8 @@ export type TaskType = {
clusterName
?:
string
,
clusterConfigurationId
?:
number
,
clusterConfigurationName
?:
string
,
databaseId
?:
number
,
databaseName
?:
string
,
jarId
?:
number
,
note
?:
string
,
enabled
?:
boolean
,
...
...
@@ -194,7 +197,7 @@ const Model: ModelType = {
isModified
:
false
,
task
:
{
jobName
:
'草稿'
,
// type: 'standalone
',
type
:
'local
'
,
checkPoint
:
0
,
savePointStrategy
:
0
,
savePointPath
:
''
,
...
...
@@ -205,11 +208,14 @@ const Model: ModelType = {
clusterName
:
"本地环境"
,
clusterConfigurationId
:
undefined
,
clusterConfigurationName
:
undefined
,
databaseId
:
undefined
,
databaseName
:
undefined
,
jarId
:
undefined
,
maxRowNum
:
100
,
config
:
[],
session
:
''
,
alias
:
'草稿'
,
dialect
:
'FlinkSql'
,
useResult
:
true
,
useSession
:
false
,
useRemote
:
false
,
...
...
@@ -234,7 +240,7 @@ const Model: ModelType = {
path
:
[
'草稿'
],
task
:
{
jobName
:
'草稿'
,
// type: 'standalone
',
type
:
'local
'
,
checkPoint
:
0
,
savePointStrategy
:
0
,
savePointPath
:
''
,
...
...
@@ -245,11 +251,14 @@ const Model: ModelType = {
clusterName
:
"本地环境"
,
clusterConfigurationId
:
undefined
,
clusterConfigurationName
:
undefined
,
databaseId
:
undefined
,
databaseName
:
undefined
,
jarId
:
undefined
,
session
:
''
,
config
:
[],
maxRowNum
:
100
,
alias
:
'草稿'
,
dialect
:
'FlinkSql'
,
useResult
:
true
,
useSession
:
false
,
useRemote
:
false
,
...
...
dlink-web/src/pages/Task/data.d.ts
View file @
0f7563ce
...
...
@@ -2,6 +2,7 @@ export type TaskTableListItem = {
id
:
number
,
name
:
string
,
alias
:
string
,
dialect
:
string
,
type
:
string
,
checkPoint
:
number
,
savePointPath
:
string
,
...
...
@@ -9,6 +10,10 @@ export type TaskTableListItem = {
fragment
:
boolean
,
clusterId
:
number
,
clusterName
:
string
,
clusterConfigurationId
:
number
,
clusterConfigurationName
:
string
,
databaseId
:
number
,
databaseName
:
string
,
note
:
string
,
enabled
:
boolean
,
createTime
:
Date
,
...
...
dlink-web/src/pages/Welcome.tsx
View file @
0f7563ce
...
...
@@ -478,6 +478,9 @@ export default (): React.ReactNode => {
<
li
>
<
Link
>
新增 OpenAPI 的执行Jar、停止、SavePoint接口
</
Link
>
</
li
>
<
li
>
<
Link
>
新增数据源的 Sql 作业语法校验
</
Link
>
</
li
>
</
ul
>
</
Paragraph
>
</
Timeline
.
Item
>
...
...
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