Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
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
wangpeng
dinky
Commits
cd7470a3
Unverified
Commit
cd7470a3
authored
Oct 17, 2023
by
ZackYoung
Committed by
GitHub
Oct 17, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize-same-web-code (#2393)
parent
dc81815b
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
712 additions
and
673 deletions
+712
-673
JobDataDto.java
dinky-admin/src/main/java/org/dinky/data/dto/JobDataDto.java
+15
-12
index.tsx
...web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
+205
-183
route.tsx
dinky-web/src/pages/DataStudio/route.tsx
+251
-239
index.tsx
...Center/Cluster/Instance/components/InstanceList/index.tsx
+2
-3
contants.tsx
.../pages/RegCenter/Cluster/Instance/components/contants.tsx
+10
-0
function.tsx
.../pages/RegCenter/Cluster/Instance/components/function.tsx
+38
-41
constants.ts
dinky-web/src/pages/RegCenter/Cluster/constants.ts
+3
-1
index.tsx
.../RegCenter/DataSource/components/DataSourceList/index.tsx
+17
-40
index.tsx
...ce/components/DataSourceModal/DataSourceProForm/index.tsx
+144
-152
index.tsx
...RegCenter/DataSource/components/DataSourceModal/index.tsx
+6
-2
service.tsx
dinky-web/src/pages/RegCenter/DataSource/service.tsx
+21
-0
No files found.
dinky-admin/src/main/java/org/dinky/data/dto/JobDataDto.java
View file @
cd7470a3
...
...
@@ -33,6 +33,7 @@ import java.time.LocalDateTime;
import
com.fasterxml.jackson.databind.JsonNode
;
import
cn.hutool.core.lang.Opt
;
import
cn.hutool.json.JSONUtil
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
...
...
@@ -115,17 +116,19 @@ public class JobDataDto {
}
public
static
JobDataDto
fromJobHistory
(
JobHistory
jobHistory
)
{
return
JobDataDto
.
builder
()
.
id
(
jobHistory
.
getId
())
.
tenantId
(
jobHistory
.
getTenantId
())
.
job
(
jobHistory
.
getJobJson
())
.
exceptions
(
jobHistory
.
getExceptionsJson
())
.
checkpoints
(
jobHistory
.
getCheckpointsJson
())
.
checkpointsConfig
(
jobHistory
.
getCheckpointsConfigJson
())
.
config
(
jobHistory
.
getConfigJson
())
.
jar
(
JsonUtils
.
parseToJsonNode
(
jobHistory
.
getJarJson
()))
.
cluster
(
jobHistory
.
getClusterJson
())
.
clusterConfiguration
(
jobHistory
.
getClusterConfigurationJson
())
.
build
();
return
Opt
.
ofNullable
(
jobHistory
)
.
map
(
x
->
JobDataDto
.
builder
()
.
id
(
jobHistory
.
getId
())
.
tenantId
(
jobHistory
.
getTenantId
())
.
job
(
jobHistory
.
getJobJson
())
.
exceptions
(
jobHistory
.
getExceptionsJson
())
.
checkpoints
(
jobHistory
.
getCheckpointsJson
())
.
checkpointsConfig
(
jobHistory
.
getCheckpointsConfigJson
())
.
config
(
jobHistory
.
getConfigJson
())
.
jar
(
JsonUtils
.
parseToJsonNode
(
jobHistory
.
getJarJson
()))
.
cluster
(
jobHistory
.
getClusterJson
())
.
clusterConfiguration
(
jobHistory
.
getClusterConfigurationJson
())
.
build
())
.
orElse
(
null
);
}
}
dinky-web/src/pages/DataStudio/LeftContainer/MetaData/index.tsx
View file @
cd7470a3
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
{
TagAlignLeft
}
from
'@/components/StyledComponents'
;
import
{
BtnRoute
}
from
'@/pages/DataStudio/route'
;
import
SchemaTree
from
'@/pages/RegCenter/DataSource/components/DataSourceDetail/SchemaTree'
;
import
{
DataSources
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
{
useEffect
,
useState
}
from
'react'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
clearMetaDataTable
,
showMetaDataTable
}
from
'./service'
;
import
{
DataSources
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DatabaseOutlined
,
TableOutlined
}
from
'@ant-design/icons'
;
import
{
Key
,
ProForm
,
ProFormSelect
}
from
'@ant-design/pro-components'
;
import
{
connect
}
from
'@umijs/max'
;
import
{
Spin
,
Tag
}
from
'antd'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
StateType
,
STUDIO_MODEL
}
from
'../../model'
;
import
{
clearMetaDataTable
,
getDataBase
,
showMetaDataTable
}
from
'./service'
;
import
DataSourceModal
from
"@/pages/RegCenter/DataSource/components/DataSourceModal"
;
import
{
handleTest
,
saveOrUpdateHandle
}
from
"@/pages/RegCenter/DataSource/service"
;
const
MetaData
=
(
props
:
any
)
=>
{
const
{
dispatch
,
toolContentHeight
,
database
:
{
dbData
,
selectDatabaseId
,
expandKeys
,
selectKeys
}
}
=
props
;
const
[
treeData
,
setTreeData
]
=
useState
<
[]
>
([]);
const
[
isLoadingDatabase
,
setIsLoadingDatabase
]
=
useState
(
false
);
const
selectDb
=
(
dbData
as
DataSources
.
DataSource
[]).
filter
((
x
)
=>
x
.
id
===
selectDatabaseId
)[
0
];
/**
* @description: 刷新树数据
* @param {number} databaseId
*/
const
onRefreshTreeData
=
async
(
databaseId
:
number
)
=>
{
if
(
!
databaseId
)
{
setIsLoadingDatabase
(
false
);
return
;
}
setIsLoadingDatabase
(
true
);
const
tables
=
(
await
showMetaDataTable
(
databaseId
))
??
[];
setIsLoadingDatabase
(
false
);
for
(
let
table
of
tables
)
{
table
.
title
=
table
.
name
;
table
.
key
=
table
.
name
;
table
.
icon
=
<
DatabaseOutlined
/>;
table
.
children
=
table
.
tables
;
for
(
let
child
of
table
.
children
)
{
child
.
title
=
child
.
name
;
child
.
key
=
table
.
name
+
'.'
+
child
.
name
;
child
.
icon
=
<
TableOutlined
/>;
child
.
isLeaf
=
true
;
child
.
schema
=
table
.
name
;
child
.
table
=
child
.
name
;
}
}
setTreeData
(
tables
);
};
useEffect
(()
=>
{
if
(
selectDatabaseId
)
{
onRefreshTreeData
(
selectDatabaseId
);
}
},
[]);
/**
* 数据库选择改变时间时 刷新树数据
* @param {number} value
*/
const
onChangeDataBase
=
(
value
:
number
)
=>
{
onRefreshTreeData
(
value
);
};
BtnRoute
[
'menu.datastudio.metadata'
][
0
].
onClick
=
()
=>
{
if
(
!
selectDatabaseId
)
return
;
setIsLoadingDatabase
(
true
);
clearMetaDataTable
(
selectDatabaseId
).
then
(()
=>
{
onChangeDataBase
(
selectDatabaseId
);
});
};
/**
* 构建数据库列表 下拉框
*/
const
getDataBaseOptions
=
()
=>
{
return
dbData
.
map
(({
id
,
name
,
type
,
enabled
,
status
}:
DataSources
.
DataSource
)
=>
({
key
:
id
,
value
:
id
,
label
:
(
<
TagAlignLeft
>
<
Tag
key=
{
id
}
color=
{
enabled
?
'processing'
:
'error'
}
>
{
type
}
</
Tag
>
{
name
}
</
TagAlignLeft
>
),
disabled
:
!
enabled
||
!
status
}));
};
/**
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
*/
const
handleTreeNodeClick
=
async
(
keys
:
Key
[],
info
:
any
)
=>
{
// 选中的key
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
payload
:
keys
});
const
{
node
:
{
isLeaf
,
parentId
:
schemaName
,
name
:
tableName
,
fullInfo
}
}
=
info
;
if
(
!
isLeaf
)
{
return
;
}
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
selectDb
.
type
,
id
:
selectDatabaseId
+
schemaName
+
tableName
,
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
'/'
),
label
:
schemaName
+
'.'
+
tableName
,
params
:
{
queryParams
:
queryParams
,
tableInfo
:
fullInfo
},
type
:
'metadata'
}
});
};
/**
* 数据库选择改变事件
* @param {number} databaseId
*/
const
handleSelectDataBaseId
=
(
databaseId
:
number
)
=>
{
dispatch
({
type
:
STUDIO_MODEL
.
updateSelectDatabaseId
,
payload
:
databaseId
});
onChangeDataBase
(
databaseId
);
};
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const
handleTreeExpand
=
(
expandedKeys
:
Key
[])
=>
{
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseExpandKey
,
payload
:
expandedKeys
});
};
return
(
<
Spin
spinning=
{
isLoadingDatabase
}
delay=
{
500
}
>
<
ProForm
style=
{
{
height
:
40
}
}
initialValues=
{
{
selectDb
:
selectDatabaseId
}
}
submitter=
{
false
}
>
<
ProFormSelect
style=
{
{
paddingInline
:
6
}
}
// width={leftContainer.width }
width=
{
'xl'
}
// addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear=
{
false
}
name=
{
'selectDb'
}
placeholder=
{
l
(
'pages.metadata.selectDatabase'
)
}
options=
{
getDataBaseOptions
()
}
fieldProps=
{
{
onSelect
:
(
selectId
)
=>
handleSelectDataBaseId
(
selectId
as
number
)
}
}
/>
</
ProForm
>
<
SchemaTree
selectKeys=
{
selectKeys
}
expandKeys=
{
expandKeys
}
style=
{
{
height
:
toolContentHeight
-
64
-
20
}
}
onNodeClick=
{
handleTreeNodeClick
}
treeData=
{
treeData
}
onExpand=
{
handleTreeExpand
}
/>
</
Spin
>
);
dispatch
,
toolContentHeight
,
database
:
{
dbData
,
selectDatabaseId
,
expandKeys
,
selectKeys
}
}
=
props
;
const
[
treeData
,
setTreeData
]
=
useState
<
[]
>
([]);
const
[
isLoadingDatabase
,
setIsLoadingDatabase
]
=
useState
(
false
);
const
[
showCreate
,
setShowCreate
]
=
useState
(
false
);
const
selectDb
=
(
dbData
as
DataSources
.
DataSource
[]).
filter
((
x
)
=>
x
.
id
===
selectDatabaseId
)[
0
];
/**
* @description: 刷新树数据
* @param {number} databaseId
*/
const
onRefreshTreeData
=
async
(
databaseId
:
number
)
=>
{
if
(
!
databaseId
)
{
setIsLoadingDatabase
(
false
);
return
;
}
setIsLoadingDatabase
(
true
);
const
tables
=
(
await
showMetaDataTable
(
databaseId
))
??
[];
setIsLoadingDatabase
(
false
);
for
(
let
table
of
tables
)
{
table
.
title
=
table
.
name
;
table
.
key
=
table
.
name
;
table
.
icon
=
<
DatabaseOutlined
/>;
table
.
children
=
table
.
tables
;
for
(
let
child
of
table
.
children
)
{
child
.
title
=
child
.
name
;
child
.
key
=
table
.
name
+
'.'
+
child
.
name
;
child
.
icon
=
<
TableOutlined
/>;
child
.
isLeaf
=
true
;
child
.
schema
=
table
.
name
;
child
.
table
=
child
.
name
;
}
}
setTreeData
(
tables
);
};
useEffect
(()
=>
{
if
(
selectDatabaseId
)
{
onRefreshTreeData
(
selectDatabaseId
);
}
},
[]);
/**
* 数据库选择改变时间时 刷新树数据
* @param {number} value
*/
const
onChangeDataBase
=
(
value
:
number
)
=>
{
onRefreshTreeData
(
value
);
};
BtnRoute
[
'menu.datastudio.metadata'
][
0
].
onClick
=
()
=>
{
setShowCreate
(
true
)
};
BtnRoute
[
'menu.datastudio.metadata'
][
1
].
onClick
=
()
=>
{
if
(
!
selectDatabaseId
)
return
;
setIsLoadingDatabase
(
true
);
clearMetaDataTable
(
selectDatabaseId
).
then
(()
=>
{
onChangeDataBase
(
selectDatabaseId
);
});
};
/**
* 构建数据库列表 下拉框
*/
const
getDataBaseOptions
=
()
=>
{
return
dbData
.
map
(({
id
,
name
,
type
,
enabled
,
status
}:
DataSources
.
DataSource
)
=>
({
key
:
id
,
value
:
id
,
label
:
(
<
TagAlignLeft
>
<
Tag
key=
{
id
}
color=
{
enabled
?
'processing'
:
'error'
}
>
{
type
}
</
Tag
>
{
name
}
</
TagAlignLeft
>
),
disabled
:
!
enabled
||
!
status
}));
};
/**
* 树节点点击事件 添加tab页 并传递参数
* @param keys
* @param info
*/
const
handleTreeNodeClick
=
async
(
keys
:
Key
[],
info
:
any
)
=>
{
// 选中的key
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseSelectKey
,
payload
:
keys
});
const
{
node
:
{
isLeaf
,
parentId
:
schemaName
,
name
:
tableName
,
fullInfo
}
}
=
info
;
if
(
!
isLeaf
)
{
return
;
}
const
queryParams
=
{
id
:
selectDatabaseId
,
schemaName
,
tableName
};
dispatch
({
type
:
STUDIO_MODEL
.
addTab
,
payload
:
{
icon
:
selectDb
.
type
,
id
:
selectDatabaseId
+
schemaName
+
tableName
,
breadcrumbLabel
:
[
selectDb
.
type
,
selectDb
.
name
].
join
(
'/'
),
label
:
schemaName
+
'.'
+
tableName
,
params
:
{
queryParams
:
queryParams
,
tableInfo
:
fullInfo
},
type
:
'metadata'
}
});
};
/**
* 数据库选择改变事件
* @param {number} databaseId
*/
const
handleSelectDataBaseId
=
(
databaseId
:
number
)
=>
{
dispatch
({
type
:
STUDIO_MODEL
.
updateSelectDatabaseId
,
payload
:
databaseId
});
onChangeDataBase
(
databaseId
);
};
/**
* 树节点展开事件
* @param {Key[]} expandedKeys
*/
const
handleTreeExpand
=
(
expandedKeys
:
Key
[])
=>
{
dispatch
({
type
:
STUDIO_MODEL
.
updateDatabaseExpandKey
,
payload
:
expandedKeys
});
};
return
(
<
Spin
spinning=
{
isLoadingDatabase
}
delay=
{
500
}
>
<
DataSourceModal
values=
{
{}
}
visible=
{
showCreate
}
onCancel=
{
()
=>
setShowCreate
(
false
)
}
onTest=
{
(
value
)
=>
handleTest
(
value
)
}
onSubmit=
{
async
(
value
)
=>
{
await
saveOrUpdateHandle
(
value
);
const
data
=
await
getDataBase
();
dispatch
({
type
:
STUDIO_MODEL
.
saveDataBase
,
payload
:
data
});
}
}
/>
<
ProForm
style=
{
{
height
:
40
}
}
initialValues=
{
{
selectDb
:
selectDatabaseId
}
}
submitter=
{
false
}
>
<
ProFormSelect
style=
{
{
paddingInline
:
6
}
}
// width={leftContainer.width }
width=
{
'xl'
}
// addonAfter={<ReloadOutlined spin={isLoadingDatabase} title={l('button.refresh')} onClick={() => refreshDataBase()} />}
allowClear=
{
false
}
name=
{
'selectDb'
}
placeholder=
{
l
(
'pages.metadata.selectDatabase'
)
}
options=
{
getDataBaseOptions
()
}
fieldProps=
{
{
onSelect
:
(
selectId
)
=>
handleSelectDataBaseId
(
selectId
as
number
)
}
}
/>
</
ProForm
>
<
SchemaTree
selectKeys=
{
selectKeys
}
expandKeys=
{
expandKeys
}
style=
{
{
height
:
toolContentHeight
-
64
-
20
}
}
onNodeClick=
{
handleTreeNodeClick
}
treeData=
{
treeData
}
onExpand=
{
handleTreeExpand
}
/>
</
Spin
>
);
};
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
toolContentHeight
:
Studio
.
toolContentHeight
,
leftContainer
:
Studio
.
leftContainer
,
database
:
Studio
.
database
export
default
connect
(({
Studio
}:
{
Studio
:
StateType
})
=>
({
toolContentHeight
:
Studio
.
toolContentHeight
,
leftContainer
:
Studio
.
leftContainer
,
database
:
Studio
.
database
}))(
MetaData
);
dinky-web/src/pages/DataStudio/route.tsx
View file @
cd7470a3
...
...
@@ -17,282 +17,294 @@
*
*/
import
{
CircleDataStudioButtonProps
}
from
'@/components/CallBackButton/CircleBtn'
;
import
{
CircleDataStudioButtonProps
}
from
'@/components/CallBackButton/CircleBtn'
;
import
Console
from
'@/pages/DataStudio/BottomContainer/Console'
;
import
Lineage
from
'@/pages/DataStudio/BottomContainer/Lineage'
;
import
Result
from
'@/pages/DataStudio/BottomContainer/Result'
;
import
TableData
from
'@/pages/DataStudio/BottomContainer/TableData'
;
import
{
Catalog
}
from
'@/pages/DataStudio/LeftContainer/Catalog'
;
import
{
Catalog
}
from
'@/pages/DataStudio/LeftContainer/Catalog'
;
import
MetaData
from
'@/pages/DataStudio/LeftContainer/MetaData'
;
import
Project
from
'@/pages/DataStudio/LeftContainer/Project'
;
import
{
TabsPageSubType
,
TabsPageType
}
from
'@/pages/DataStudio/model'
;
import
{
TabsPageSubType
,
TabsPageType
}
from
'@/pages/DataStudio/model'
;
import
ExecuteConfig
from
'@/pages/DataStudio/RightContainer/ExecuteConfig'
;
import
HistoryVersion
from
'@/pages/DataStudio/RightContainer/HistoryVersion'
;
import
JobConfig
from
'@/pages/DataStudio/RightContainer/JobConfig'
;
import
JobInfo
from
'@/pages/DataStudio/RightContainer/JobInfo'
;
import
SavePoints
from
'@/pages/DataStudio/RightContainer/SavePoints'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
ApartmentOutlined
,
ArrowsAltOutlined
,
BarChartOutlined
,
CalendarOutlined
,
ConsoleSqlOutlined
,
DatabaseOutlined
,
DesktopOutlined
,
EnvironmentOutlined
,
FolderOutlined
,
HistoryOutlined
,
InfoCircleOutlined
,
MonitorOutlined
,
PlayCircleOutlined
,
PlusCircle
Outlined
,
ReloadOutlined
,
RightSquareOutlined
,
SettingOutlined
,
ShrinkOutlined
,
TableOutlined
,
ToolOutlined
ApartmentOutlined
,
ArrowsAltOutlined
,
BarChartOutlined
,
CalendarOutlined
,
ConsoleSqlOutlined
,
DatabaseOutlined
,
DesktopOutlined
,
EnvironmentOutlined
,
FolderOutlined
,
HistoryOutlined
,
InfoCircleOutlined
,
MonitorOutlined
,
PlayCircleOutlined
,
PlusCircleOutlined
,
Plus
Outlined
,
ReloadOutlined
,
RightSquareOutlined
,
SettingOutlined
,
ShrinkOutlined
,
TableOutlined
,
ToolOutlined
}
from
'@ant-design/icons'
;
import
{
DiffEditor
}
from
'@monaco-editor/react'
;
import
{
ReactNode
}
from
'react'
;
import
{
DiffEditor
}
from
'@monaco-editor/react'
;
import
{
ReactNode
}
from
'react'
;
export
const
LeftSide
=
[
{
auth
:
'/datastudio/left/project'
,
key
:
'menu.datastudio.project'
,
icon
:
<
ConsoleSqlOutlined
/>,
label
:
l
(
'menu.datastudio.project'
),
children
:
<
Project
/>
},
{
auth
:
'/datastudio/left/catalog'
,
key
:
'menu.datastudio.catalog'
,
icon
:
<
TableOutlined
/>,
label
:
l
(
'menu.datastudio.catalog'
),
children
:
<
Catalog
/>
},
{
auth
:
'/datastudio/left/metadata'
,
key
:
'menu.datastudio.metadata'
,
icon
:
<
DatabaseOutlined
/>,
label
:
l
(
'menu.datastudio.metadata'
),
children
:
<
MetaData
/>
}
{
auth
:
'/datastudio/left/project'
,
key
:
'menu.datastudio.project'
,
icon
:
<
ConsoleSqlOutlined
/>,
label
:
l
(
'menu.datastudio.project'
),
children
:
<
Project
/>
},
{
auth
:
'/datastudio/left/catalog'
,
key
:
'menu.datastudio.catalog'
,
icon
:
<
TableOutlined
/>,
label
:
l
(
'menu.datastudio.catalog'
),
children
:
<
Catalog
/>
},
{
auth
:
'/datastudio/left/metadata'
,
key
:
'menu.datastudio.metadata'
,
icon
:
<
DatabaseOutlined
/>,
label
:
l
(
'menu.datastudio.metadata'
),
children
:
<
MetaData
/>
}
];
export
const
RightSide
:
TabProp
[]
=
[
{
auth
:
'/datastudio/right/jobConfig'
,
key
:
'menu.datastudio.jobConfig'
,
icon
:
<
SettingOutlined
/>,
label
:
l
(
'menu.datastudio.jobConfig'
),
children
:
<
JobConfig
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
auth
:
'/datastudio/right/executeConfig'
,
key
:
'menu.datastudio.executeConfig'
,
icon
:
<
PlayCircleOutlined
/>,
label
:
l
(
'menu.datastudio.executeConfig'
),
children
:
<
ExecuteConfig
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
auth
:
'/datastudio/right/savePoint'
,
key
:
'menu.datastudio.savePoint'
,
icon
:
<
FolderOutlined
/>,
label
:
l
(
'menu.datastudio.savePoint'
),
children
:
<
SavePoints
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
auth
:
'/datastudio/right/historyVision'
,
key
:
'menu.datastudio.historyVision'
,
icon
:
<
HistoryOutlined
/>,
label
:
l
(
'menu.datastudio.historyVision'
),
children
:
<
HistoryVersion
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
auth
:
'/datastudio/right/jobInfo'
,
key
:
'menu.datastudio.jobInfo'
,
icon
:
<
InfoCircleOutlined
/>,
label
:
l
(
'menu.datastudio.jobInfo'
),
children
:
<
JobInfo
/>,
isShow
:
(
type
)
=>
type
!==
TabsPageType
.
None
}
];
export
const
LeftBottomSide
=
[
{
auth
:
'/datastudio/bottom/console'
,
key
:
'menu.datastudio.console'
,
icon
:
<
RightSquareOutlined
/>,
label
:
l
(
'menu.datastudio.console'
),
children
:
<
Console
/>
},
{
auth
:
'/datastudio/bottom/result'
,
key
:
'menu.datastudio.result'
,
icon
:
<
MonitorOutlined
/>,
label
:
l
(
'menu.datastudio.result'
),
children
:
<
Result
/>
},
{
auth
:
'/datastudio/bottom/bi'
,
key
:
'menu.datastudio.bi'
,
icon
:
<
BarChartOutlined
/>,
label
:
l
(
'menu.datastudio.bi'
)
},
{
auth
:
'/datastudio/bottom/lineage'
,
key
:
'menu.datastudio.lineage'
,
icon
:
<
ApartmentOutlined
/>,
label
:
l
(
'menu.datastudio.lineage'
),
children
:
<
Lineage
/>
},
{
auth
:
'/datastudio/bottom/process'
,
key
:
'menu.datastudio.process'
,
icon
:
<
DesktopOutlined
/>,
label
:
l
(
'menu.datastudio.process'
)
},
{
auth
:
'/datastudio/bottom/history'
,
key
:
'menu.datastudio.history'
,
icon
:
<
CalendarOutlined
/>,
label
:
l
(
'menu.datastudio.history'
)
},
{
auth
:
'/datastudio/bottom/table-data'
,
key
:
'menu.datastudio.table-data'
,
icon
:
<
TableOutlined
/>,
label
:
l
(
'menu.datastudio.table-data'
),
children
:
<
TableData
/>
},
{
auth
:
'/datastudio/bottom/tool'
,
key
:
'menu.datastudio.tool'
,
icon
:
<
ToolOutlined
/>,
label
:
l
(
'menu.datastudio.tool'
)
}
];
export
const
LeftBottomMoreTabs
:
{
[
c
:
string
]:
TabProp
[]
}
=
{
'menu.datastudio.tool'
:
[
{
key
:
'menu.datastudio.tool.text-comparison'
,
icon
:
<
ToolOutlined
/>,
label
:
l
(
'menu.datastudio.tool.text-comparison'
),
children
:
(
<
DiffEditor
height=
{
'100%'
}
options=
{
{
readOnly
:
false
,
originalEditable
:
true
,
selectOnLineNumbers
:
true
,
lineDecorationsWidth
:
20
,
mouseWheelZoom
:
true
,
automaticLayout
:
true
,
scrollBeyondLastLine
:
false
,
scrollbar
:
{
useShadows
:
false
,
verticalScrollbarSize
:
8
,
horizontalScrollbarSize
:
8
,
arrowSize
:
30
}
}
}
language=
{
'text'
}
/>
)
auth
:
'/datastudio/right/jobConfig'
,
key
:
'menu.datastudio.jobConfig'
,
icon
:
<
SettingOutlined
/>,
label
:
l
(
'menu.datastudio.jobConfig'
),
children
:
<
JobConfig
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
key
:
'menu.datastudio.tool.datax2'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.datax2'
,
children
:
<
div
>
datax2
</
div
>
}
],
'menu.datastudio.tool2'
:
[
auth
:
'/datastudio/right/executeConfig'
,
key
:
'menu.datastudio.executeConfig'
,
icon
:
<
PlayCircleOutlined
/>,
label
:
l
(
'menu.datastudio.executeConfig'
),
children
:
<
ExecuteConfig
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
auth
:
'/datastudio/right/savePoint'
,
key
:
'menu.datastudio.savePoint'
,
icon
:
<
FolderOutlined
/>,
label
:
l
(
'menu.datastudio.savePoint'
),
children
:
<
SavePoints
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
key
:
'menu.datastudio.tool.text-comparison'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.text-comparison'
,
children
:
(
<
DiffEditor
height=
{
'95%'
}
options=
{
{
readOnly
:
true
,
selectOnLineNumbers
:
true
,
lineDecorationsWidth
:
20
,
mouseWheelZoom
:
true
,
automaticLayout
:
true
}
}
language=
{
'sql'
}
original=
{
''
}
modified=
{
''
}
/>
)
auth
:
'/datastudio/right/historyVision'
,
key
:
'menu.datastudio.historyVision'
,
icon
:
<
HistoryOutlined
/>,
label
:
l
(
'menu.datastudio.historyVision'
),
children
:
<
HistoryVersion
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
},
{
key
:
'menu.datastudio.tool.datax2'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.datax2'
,
children
:
<
div
>
datax2
</
div
>
auth
:
'/datastudio/right/jobInfo'
,
key
:
'menu.datastudio.jobInfo'
,
icon
:
<
InfoCircleOutlined
/>,
label
:
l
(
'menu.datastudio.jobInfo'
),
children
:
<
JobInfo
/>,
isShow
:
(
type
)
=>
type
!==
TabsPageType
.
None
}
]
};
];
// btn route
export
const
BtnRoute
:
{
[
c
:
string
]:
CircleDataStudioButtonProps
[]
}
=
{
'menu.datastudio.metadata'
:
[
export
const
LeftBottomSide
=
[
{
icon
:
<
ReloadOutlined
/>
,
title
:
l
(
'button.refresh'
)
,
onClick
:
()
=>
{}
}
],
'menu.datastudio.catalog'
:
[
auth
:
'/datastudio/bottom/console'
,
key
:
'menu.datastudio.console'
,
icon
:
<
RightSquareOutlined
/>,
label
:
l
(
'menu.datastudio.console'
),
children
:
<
Console
/>
},
{
icon
:
<
ReloadOutlined
/>,
title
:
l
(
'button.refresh'
),
onClick
:
()
=>
{}
}
],
'menu.datastudio.project'
:
[
auth
:
'/datastudio/bottom/result'
,
key
:
'menu.datastudio.result'
,
icon
:
<
MonitorOutlined
/>,
label
:
l
(
'menu.datastudio.result'
),
children
:
<
Result
/>
},
{
auth
:
'/datastudio/bottom/bi'
,
key
:
'menu.datastudio.bi'
,
icon
:
<
BarChartOutlined
/>,
label
:
l
(
'menu.datastudio.bi'
)
},
{
icon
:
<
PlusCircleOutlined
/>,
title
:
l
(
'right.menu.createRoot'
),
key
:
'right.menu.createRoot'
,
onClick
:
()
=>
{}
auth
:
'/datastudio/bottom/lineage'
,
key
:
'menu.datastudio.lineage'
,
icon
:
<
ApartmentOutlined
/>,
label
:
l
(
'menu.datastudio.lineage'
),
children
:
<
Lineage
/>
},
{
icon
:
<
ArrowsAltOutlined
/>
,
title
:
l
(
'button.expand-all'
)
,
key
:
'button.expand-all'
,
onClick
:
()
=>
{}
auth
:
'/datastudio/bottom/process'
,
key
:
'menu.datastudio.process'
,
icon
:
<
DesktopOutlined
/>
,
label
:
l
(
'menu.datastudio.process'
)
},
{
icon
:
<
ShrinkOutlined
/>
,
title
:
l
(
'button.collapse-all'
)
,
key
:
'button.collapse-all'
,
onClick
:
()
=>
{}
auth
:
'/datastudio/bottom/history'
,
key
:
'menu.datastudio.history'
,
icon
:
<
CalendarOutlined
/>
,
label
:
l
(
'menu.datastudio.history'
)
},
{
icon
:
<
EnvironmentOutlined
/>,
title
:
l
(
'button.position'
),
key
:
'button.position'
,
onClick
:
()
=>
{}
auth
:
'/datastudio/bottom/table-data'
,
key
:
'menu.datastudio.table-data'
,
icon
:
<
TableOutlined
/>,
label
:
l
(
'menu.datastudio.table-data'
),
children
:
<
TableData
/>
},
{
auth
:
'/datastudio/bottom/tool'
,
key
:
'menu.datastudio.tool'
,
icon
:
<
ToolOutlined
/>,
label
:
l
(
'menu.datastudio.tool'
)
}
]
];
export
const
LeftBottomMoreTabs
:
{
[
c
:
string
]:
TabProp
[]
}
=
{
'menu.datastudio.tool'
:
[
{
key
:
'menu.datastudio.tool.text-comparison'
,
icon
:
<
ToolOutlined
/>,
label
:
l
(
'menu.datastudio.tool.text-comparison'
),
children
:
(
<
DiffEditor
height=
{
'100%'
}
options=
{
{
readOnly
:
false
,
originalEditable
:
true
,
selectOnLineNumbers
:
true
,
lineDecorationsWidth
:
20
,
mouseWheelZoom
:
true
,
automaticLayout
:
true
,
scrollBeyondLastLine
:
false
,
scrollbar
:
{
useShadows
:
false
,
verticalScrollbarSize
:
8
,
horizontalScrollbarSize
:
8
,
arrowSize
:
30
}
}
}
language=
{
'text'
}
/>
)
},
{
key
:
'menu.datastudio.tool.datax2'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.datax2'
,
children
:
<
div
>
datax2
</
div
>
}
],
'menu.datastudio.tool2'
:
[
{
key
:
'menu.datastudio.tool.text-comparison'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.text-comparison'
,
children
:
(
<
DiffEditor
height=
{
'95%'
}
options=
{
{
readOnly
:
true
,
selectOnLineNumbers
:
true
,
lineDecorationsWidth
:
20
,
mouseWheelZoom
:
true
,
automaticLayout
:
true
}
}
language=
{
'sql'
}
original=
{
''
}
modified=
{
''
}
/>
)
},
{
key
:
'menu.datastudio.tool.datax2'
,
icon
:
<
ToolOutlined
/>,
label
:
'menu.datastudio.tool.datax2'
,
children
:
<
div
>
datax2
</
div
>
}
]
};
// btn route
export
const
BtnRoute
:
{
[
c
:
string
]:
CircleDataStudioButtonProps
[]
}
=
{
'menu.datastudio.metadata'
:
[
{
icon
:
<
PlusOutlined
/>,
title
:
l
(
'button.create'
),
onClick
:
()
=>
{
}
},
{
icon
:
<
ReloadOutlined
/>,
title
:
l
(
'button.refresh'
),
onClick
:
()
=>
{
}
}
],
'menu.datastudio.catalog'
:
[
{
icon
:
<
ReloadOutlined
/>,
title
:
l
(
'button.refresh'
),
onClick
:
()
=>
{
}
}
],
'menu.datastudio.project'
:
[
{
icon
:
<
PlusCircleOutlined
/>,
title
:
l
(
'right.menu.createRoot'
),
key
:
'right.menu.createRoot'
,
onClick
:
()
=>
{
}
},
{
icon
:
<
ArrowsAltOutlined
/>,
title
:
l
(
'button.expand-all'
),
key
:
'button.expand-all'
,
onClick
:
()
=>
{
}
},
{
icon
:
<
ShrinkOutlined
/>,
title
:
l
(
'button.collapse-all'
),
key
:
'button.collapse-all'
,
onClick
:
()
=>
{
}
},
{
icon
:
<
EnvironmentOutlined
/>,
title
:
l
(
'button.position'
),
key
:
'button.position'
,
onClick
:
()
=>
{
}
}
]
};
export
type
TabProp
=
{
key
:
string
;
icon
:
ReactNode
;
label
:
string
;
children
:
ReactNode
;
isShow
?:
(
type
:
TabsPageType
,
subType
?:
TabsPageSubType
)
=>
boolean
;
auth
?:
string
;
key
:
string
;
icon
:
ReactNode
;
label
:
string
;
children
:
ReactNode
;
isShow
?:
(
type
:
TabsPageType
,
subType
?:
TabsPageSubType
)
=>
boolean
;
auth
?:
string
;
};
dinky-web/src/pages/RegCenter/Cluster/Instance/components/InstanceList/index.tsx
View file @
cd7470a3
...
...
@@ -186,7 +186,6 @@ export default () => {
description=
{
l
(
'rc.ci.deleteConfirm'
)
}
/>
</
Authorized
>
{
renderWebUiRedirect
(
record
)
}
</
Space
>
);
...
...
@@ -201,7 +200,7 @@ export default () => {
<
Col
flex=
'85%'
>
<
Paragraph
>
<
blockquote
>
{
l
(
'rc.ci.jma'
)
}
:
<
Link
>
{
item
.
jobManagerHost
}
</
Link
>
{
l
(
'rc.ci.jma'
)
}
:
{
renderWebUiRedirect
(
item
)
}
</
blockquote
>
<
blockquote
>
{
l
(
'rc.ci.version'
)
}
:
<
Link
>
{
item
.
version
}
</
Link
>
...
...
@@ -306,7 +305,7 @@ export default () => {
<
Badge
.
Ribbon
className=
{
'card-list-item-wrapper'
}
color=
{
item
.
autoRegisters
?
'green'
:
'yellow'
}
text=
{
item
.
autoRegisters
?
l
(
'rc.ci.ar'
)
:
l
(
'rc.ci.mr'
)
}
text=
{
item
.
autoRegisters
?
l
(
'rc.ci.ar'
)
:
<
span
style=
{
{
color
:
"crimson"
}
}
>
{
l
(
'rc.ci.mr'
)
}
</
span
>
}
>
<
Card
headStyle=
{
{
minHeight
:
'10px'
}
}
...
...
dinky-web/src/pages/RegCenter/Cluster/Instance/components/contants.tsx
View file @
cd7470a3
...
...
@@ -38,6 +38,16 @@ export const CLUSTER_INSTANCE_TYPE: DefaultOptionType[] = [
value
:
ClusterType
.
KUBERNETES_SESSION
,
label
:
'Kubernetes Session'
,
key
:
ClusterType
.
KUBERNETES_SESSION
},
{
value
:
ClusterType
.
YARN_APPLICATION
,
label
:
'Yarn Application'
,
key
:
ClusterType
.
YARN_APPLICATION
},
{
value
:
ClusterType
.
LOACL
,
label
:
'Local'
,
key
:
ClusterType
.
LOACL
}
];
...
...
dinky-web/src/pages/RegCenter/Cluster/Instance/components/function.tsx
View file @
cd7470a3
...
...
@@ -17,12 +17,14 @@
*
*/
import
{
WebIcon
}
from
'@/components/Icons/CustomIcons'
;
import
{
RUN_MODE
}
from
'@/services/constants'
;
import
{
Cluster
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
Button
}
from
'antd'
;
import
{
RuleObject
}
from
'rc-field-form/es/interface'
;
import
{
WebIcon
}
from
'@/components/Icons/CustomIcons'
;
import
{
RUN_MODE
}
from
'@/services/constants'
;
import
{
Cluster
}
from
'@/types/RegCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
Button
,
Typography
}
from
'antd'
;
import
{
RuleObject
}
from
'rc-field-form/es/interface'
;
const
{
Text
,
Paragraph
,
Link
}
=
Typography
;
/**
* validatorJMHAAdderess
...
...
@@ -30,21 +32,21 @@ import { RuleObject } from 'rc-field-form/es/interface';
* @param value
*/
export
const
validatorJMHAAdderess
=
(
rule
:
RuleObject
,
value
=
''
)
=>
{
let
hostArray
=
[];
if
(
value
.
trim
().
length
===
0
)
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmhaPlaceholder'
)));
}
else
{
hostArray
=
value
.
split
(
','
);
for
(
let
i
=
0
;
i
<
hostArray
.
length
;
i
++
)
{
if
(
hostArray
[
i
].
includes
(
'/'
))
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmha.validate.slash'
)));
}
if
(
parseInt
(
hostArray
[
i
].
split
(
':'
)[
1
])
>=
65535
)
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmha.validate.port'
)));
}
let
hostArray
=
[];
if
(
value
.
trim
().
length
===
0
)
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmhaPlaceholder'
)));
}
else
{
hostArray
=
value
.
split
(
','
);
for
(
let
i
=
0
;
i
<
hostArray
.
length
;
i
++
)
{
if
(
hostArray
[
i
].
includes
(
'/'
))
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmha.validate.slash'
)));
}
if
(
parseInt
(
hostArray
[
i
].
split
(
':'
)[
1
])
>=
65535
)
{
return
Promise
.
reject
(
new
Error
(
l
(
'rc.ci.jmha.validate.port'
)));
}
}
return
Promise
.
resolve
();
}
return
Promise
.
resolve
();
}
};
/**
...
...
@@ -52,25 +54,20 @@ export const validatorJMHAAdderess = (rule: RuleObject, value = '') => {
* @param record
*/
export
const
renderWebUiRedirect
=
(
record
:
Cluster
.
Instance
)
=>
{
if
(
record
.
status
&&
(
record
.
type
===
RUN_MODE
.
YARN_SESSION
||
record
.
type
===
RUN_MODE
.
STANDALONE
||
record
.
type
===
RUN_MODE
.
YARN_APPLICATION
||
record
.
type
===
RUN_MODE
.
YARN_PER_JOB
)
)
{
return
(
<>
<
Button
icon=
{
<
WebIcon
/>
}
key=
{
`${record.id}_webui`
}
type=
'link'
title=
{
`http://${record.jobManagerHost}/#/overview`
}
href=
{
`http://${record.jobManagerHost}/#/overview`
}
target=
'_blank'
/>
</>
);
}
return
undefined
;
if
(
record
.
status
&&
(
record
.
type
===
RUN_MODE
.
YARN_SESSION
||
record
.
type
===
RUN_MODE
.
STANDALONE
||
record
.
type
===
RUN_MODE
.
YARN_APPLICATION
||
record
.
type
===
RUN_MODE
.
YARN_PER_JOB
)
)
{
return
(
<
Link
href=
{
`/api/flink/${record.jobManagerHost}/#/overview`
}
key=
{
`${record.id}_webui`
}
target=
'_blank'
>
{
record
.
jobManagerHost
}
</
Link
>
);
}
return
<
Link
>
{
record
.
hosts
}
</
Link
>;
};
dinky-web/src/pages/RegCenter/Cluster/constants.ts
View file @
cd7470a3
...
...
@@ -23,5 +23,7 @@ export const enum ClusterType {
YARN_SESSION
=
'yarn-session'
,
KUBERNETES_SESSION
=
'kubernetes-session'
,
KUBERNETES_NATIVE
=
'kubernetes-application'
,
KUBERNETES_OPERATOR
=
'kubernetes-application-operator'
KUBERNETES_OPERATOR
=
'kubernetes-application-operator'
,
YARN_APPLICATION
=
'yarn-application'
,
LOACL
=
'local'
,
}
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceList/index.tsx
View file @
cd7470a3
...
...
@@ -37,7 +37,7 @@ import { API_CONSTANTS } from '@/services/endpoints';
import
{
DataSources
}
from
'@/types/RegCenter/data.d'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
WarningMessage
}
from
'@/utils/messages'
;
import
{
useNavigate
}
from
'@@/exports'
;
import
{
useNavigate
}
from
'@@/exports'
;
import
{
CheckCircleOutlined
,
CopyTwoTone
,
...
...
@@ -50,22 +50,28 @@ import DescriptionsItem from 'antd/es/descriptions/Item';
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
connect
}
from
'umi'
;
import
DataSourceModal
from
'../DataSourceModal'
;
import
{
handleTest
,
saveOrUpdateHandle
}
from
"@/pages/RegCenter/DataSource/service"
;
const
DataSourceTable
:
React
.
FC
<
connect
&
StateType
>
=
(
props
)
=>
{
const
navigate
=
useNavigate
();
const
{
dispatch
}
=
props
;
const
navigate
=
useNavigate
();
/**
* state
*/
const
actionRef
=
React
.
useRef
<
ActionType
>
();
const
[
loading
,
setLoading
]
=
React
.
useState
<
boolean
>
(
false
);
const
[
modalVisible
,
setModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
detailPage
,
setDetailPage
]
=
useState
<
boolean
>
(
false
);
const
[
updateModalVisible
,
setUpdateModalVisible
]
=
useState
<
boolean
>
(
false
);
const
[
dataSource
,
setDataSource
]
=
useState
<
DataSources
.
DataSource
[]
>
([]);
const
[
formValues
,
setFormValues
]
=
useState
<
Partial
<
DataSources
.
DataSource
>>
({});
const
actionRef
=
React
.
useRef
<
ActionType
>
();
/**
* query list
*/
useEffect
(()
=>
{
queryDataSourceList
();
},
[]);
/**
* execute query list
...
...
@@ -80,21 +86,13 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
* extra callback
* @param callback
*/
const
executeAndCallbackRefresh
=
async
(
callback
:
()
=>
void
)
=>
{
const
executeAndCallbackRefresh
=
async
(
callback
:
()
=>
Promise
<
any
>
)
=>
{
setLoading
(
true
);
await
callback
();
await
queryDataSourceList
();
setLoading
(
false
);
};
/**
* handle add or update
* @param item
*/
const
saveOrUpdateHandle
=
async
(
item
:
Partial
<
DataSources
.
DataSource
>
)
=>
{
await
executeAndCallbackRefresh
(
async
()
=>
handleAddOrUpdate
(
API_CONSTANTS
.
DATASOURCE
,
item
));
};
/**
* handle delete
* @param id
...
...
@@ -120,13 +118,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
);
};
/**
* handle test
* @param item
*/
const
handleTest
=
async
(
item
:
Partial
<
DataSources
.
DataSource
>
)
=>
{
await
handleOption
(
API_CONSTANTS
.
DATASOURCE_TEST
,
l
(
'button.test'
),
item
);
};
/**
* handle check heart
...
...
@@ -146,12 +138,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
);
};
/**
* query list
*/
useEffect
(()
=>
{
queryDataSourceList
();
},
[]);
/**
* render sub title
...
...
@@ -175,7 +162,7 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
*/
const
editClick
=
(
item
:
DataSources
.
DataSource
)
=>
{
setFormValues
(
item
);
set
Update
ModalVisible
(
!
modalVisible
);
setModalVisible
(
!
modalVisible
);
};
/**
...
...
@@ -272,7 +259,6 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
*/
const
cancelAll
=
()
=>
{
setModalVisible
(
false
);
setUpdateModalVisible
(
false
);
setFormValues
({});
};
...
...
@@ -299,21 +285,12 @@ const DataSourceTable: React.FC<connect & StateType> = (props) => {
/
>
{
/* added */
}
<
DataSourceModal
values=
{
{}
}
visible=
{
modalVisible
}
onCancel=
{
cancelAll
}
onTest=
{
(
value
)
=>
handleTest
(
value
)
}
onSubmit=
{
(
value
)
=>
saveOrUpdateHandle
(
value
)
}
/>
{
/* modify*/
}
<
DataSourceModal
values=
{
formValues
}
visible=
{
updateM
odalVisible
}
visible=
{
m
odalVisible
}
onCancel=
{
cancelAll
}
onTest=
{
(
value
)
=>
handleTest
(
value
)
}
onSubmit=
{
(
value
)
=>
saveOrUpdateHandle
(
value
)
}
onSubmit=
{
(
value
)
=>
executeAndCallbackRefresh
(
async
()
=>
saveOrUpdateHandle
(
value
)
)
}
/>
</>
) : (
...
...
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceModal/DataSourceProForm/index.tsx
View file @
cd7470a3
...
...
@@ -17,176 +17,168 @@
import
CodeEdit
from
'@/components/CustomEditor/CodeEdit'
;
import
{
AUTO_COMPLETE_TYPE
,
DATA_SOURCE_TYPE_OPTIONS
,
GROUP_TYPE
AUTO_COMPLETE_TYPE
,
DATA_SOURCE_TYPE_OPTIONS
,
GROUP_TYPE
}
from
'@/pages/RegCenter/DataSource/components/constants'
;
import
{
DataSources
}
from
'@/types/RegCenter/data.d'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DataSources
}
from
'@/types/RegCenter/data.d'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
ProForm
,
ProFormGroup
,
ProFormSelect
,
ProFormText
,
ProFormTextArea
ProForm
,
ProFormGroup
,
ProFormSelect
,
ProFormText
}
from
'@ant-design/pro-components'
;
import
{
AutoComplete
}
from
'antd'
;
import
{
FormInstance
}
from
'antd/es/form/hooks/useForm'
;
import
{
Values
}
from
'async-validator'
;
import
React
,
{
useState
}
from
'react'
;
import
{
AutoComplete
,
Form
}
from
'antd'
;
import
{
FormInstance
}
from
'antd/es/form/hooks/useForm'
;
import
{
Values
}
from
'async-validator'
;
import
React
,
{
useState
}
from
'react'
;
import
TextArea
from
"antd/es/input/TextArea"
;
type
DataSourceProFormProps
=
{
values
:
Partial
<
DataSources
.
DataSource
>
;
form
:
FormInstance
<
Values
>
;
flinkConfigChange
:
(
value
:
string
)
=>
void
;
flinkTemplateChange
:
(
value
:
string
)
=>
void
;
values
:
Partial
<
DataSources
.
DataSource
>
;
form
:
FormInstance
<
Values
>
;
flinkConfigChange
:
(
value
:
string
)
=>
void
;
flinkTemplateChange
:
(
value
:
string
)
=>
void
;
};
const
CodeEditProps
=
{
height
:
'30vh'
,
width
:
'22vw'
,
lineNumbers
:
'off'
,
language
:
'sql'
height
:
'30vh'
,
width
:
'22vw'
,
lineNumbers
:
'off'
,
language
:
'sql'
};
const
DataSourceProForm
:
React
.
FC
<
DataSourceProFormProps
>
=
(
props
)
=>
{
const
{
values
,
form
,
flinkTemplateChange
,
flinkConfigChange
}
=
props
;
const
[
excludeFormItem
,
setExcludeFormItem
]
=
useState
<
boolean
>
(
false
);
const
{
values
,
form
,
flinkTemplateChange
,
flinkConfigChange
}
=
props
;
const
[
excludeFormItem
,
setExcludeFormItem
]
=
useState
<
boolean
>
(
false
);
const
[
dbType
,
setDbType
]
=
useState
<
string
>
(
values
.
type
??
'MySQL'
);
const
[
dbType
,
setDbType
]
=
useState
<
string
>
(
values
.
type
??
'MySQL'
);
const
handleTypeChange
=
(
value
:
any
)
=>
{
if
(
value
.
type
)
setDbType
(
value
.
type
);
if
(
value
.
type
===
'Hive'
||
value
.
type
===
'Presto'
)
{
setExcludeFormItem
(
true
);
}
else
{
setExcludeFormItem
(
false
);
}
};
const
handleTypeChange
=
(
value
:
any
)
=>
{
if
(
value
.
type
)
setDbType
(
value
.
type
);
if
(
value
.
type
===
'Hive'
||
value
.
type
===
'Presto'
)
{
setExcludeFormItem
(
true
);
}
else
{
setExcludeFormItem
(
false
);
}
};
const
renderDataSourceForm
=
()
=>
{
return
(
<>
<
ProForm
.
Group
>
<
ProFormText
name=
'name'
width=
{
'md'
}
label=
{
l
(
'rc.ds.name'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.namePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.namePlaceholder'
)
}
/>
<
ProFormSelect
name=
'groupName'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.groupName'
)
}
options=
{
GROUP_TYPE
}
placeholder=
{
l
(
'rc.ds.groupNamePlaceholder'
)
}
/>
<
ProFormSelect
name=
'type'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.type'
)
}
showSearch
initialValue=
{
dbType
}
options=
{
DATA_SOURCE_TYPE_OPTIONS
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.typePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.typePlaceholder'
)
}
/>
const
renderDataSourceForm
=
()
=>
{
return
(
<>
<
ProForm
.
Group
>
<
ProFormText
name=
'name'
width=
{
'md'
}
label=
{
l
(
'rc.ds.name'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.namePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.namePlaceholder'
)
}
/>
<
ProFormSelect
name=
'groupName'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.groupName'
)
}
options=
{
GROUP_TYPE
}
placeholder=
{
l
(
'rc.ds.groupNamePlaceholder'
)
}
/>
<
ProFormSelect
name=
'type'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.type'
)
}
showSearch
initialValue=
{
dbType
}
options=
{
DATA_SOURCE_TYPE_OPTIONS
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.typePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.typePlaceholder'
)
}
/>
<
ProFormText
name=
'username'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.username'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.usernamePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.usernamePlaceholder'
)
}
/>
<
ProFormText
.
Password
name=
'password'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.password'
)
}
rules=
{
[
{
required
:
dbType
!==
'Doris'
,
message
:
l
(
'rc.ds.passwordPlaceholder'
)
}
]
}
placeholder=
{
l
(
'rc.ds.passwordPlaceholder'
)
}
/>
<
ProFormText
name=
'note'
width=
{
'md'
}
label=
{
l
(
'global.table.note'
)
}
placeholder=
{
l
(
'global.table.notePlaceholder'
)
}
/>
</
ProForm
.
Group
>
<
ProFormText
name=
'username'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.username'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.usernamePlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.usernamePlaceholder'
)
}
/>
<
ProFormText
.
Password
name=
'password'
width=
{
'sm'
}
label=
{
l
(
'rc.ds.password'
)
}
rules=
{
[
{
required
:
dbType
!==
'Doris'
,
message
:
l
(
'rc.ds.passwordPlaceholder'
)
}
]
}
placeholder=
{
l
(
'rc.ds.passwordPlaceholder'
)
}
/>
<
ProFormText
name=
'note'
width=
{
'md'
}
label=
{
l
(
'global.table.note'
)
}
placeholder=
{
l
(
'global.table.notePlaceholder'
)
}
/>
</
ProForm
.
Group
>
<
ProForm
.
Group
>
<
AutoComplete
virtual
size=
{
'small'
}
placement=
{
'topLeft'
}
autoClearSearchValue
options=
{
AUTO_COMPLETE_TYPE
}
style=
{
{
width
:
parent
.
innerWidth
/
2
-
80
,
minHeight
:
parent
.
innerHeight
/
4
-
110
,
marginBottom
:
0
}
}
filterOption
onSelect=
{
(
value
)
=>
form
&&
form
.
setFieldsValue
({
url
:
value
})
}
>
<
ProFormTextArea
name=
'url'
width=
{
parent
.
innerWidth
/
2
-
80
}
label=
{
l
(
'rc.ds.url'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.urlPlaceholder'
)
}]
}
placeholder=
{
l
(
'rc.ds.urlPlaceholder'
)
}
/>
</
AutoComplete
>
</
ProForm
.
Group
>
<
ProForm
.
Group
>
<
Form
.
Item
name=
"url"
label=
{
l
(
'rc.ds.url'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'rc.ds.urlPlaceholder'
)}]
}
>
{
!
excludeFormItem
&&
(
<
ProFormGroup
>
<
ProForm
.
Item
name=
'flinkConfig'
label=
{
l
(
'rc.ds.flinkConfig'
)
}
tooltip=
{
l
(
'rc.ds.flinkConfigTooltip'
)
}
>
<
CodeEdit
{
...
CodeEditProps
}
onChange=
{
(
value
)
=>
flinkConfigChange
(
value
??
''
)
}
code=
{
values
.
flinkConfig
||
''
}
/>
</
ProForm
.
Item
>
<
AutoComplete
virtual
placement=
{
'topLeft'
}
autoClearSearchValue
options=
{
AUTO_COMPLETE_TYPE
}
style=
{
{
width
:
parent
.
innerWidth
/
2
-
80
}
}
filterOption
onSelect=
{
(
value
)
=>
form
&&
form
.
setFieldsValue
({
url
:
value
})
}
>
<
TextArea
placeholder=
{
l
(
'rc.ds.urlPlaceholder'
)
}
/>
{
/*<ProFormTextArea*/
}
{
/* name='url'*/
}
{
/* width={parent.innerWidth / 2 - 80}*/
}
{
/* label={l('rc.ds.url')}*/
}
{
/* rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}*/
}
{
/* placeholder={l('rc.ds.urlPlaceholder')}*/
}
{
/*/>*/
}
</
AutoComplete
>
</
Form
.
Item
>
<
ProForm
.
Item
name=
'flinkTemplate'
label=
{
l
(
'rc.ds.flinkTemplate'
)
}
tooltip=
{
l
(
'rc.ds.flinkTemplateTooltip'
)
}
>
<
CodeEdit
{
...
CodeEditProps
}
onChange=
{
(
value
)
=>
flinkTemplateChange
(
value
??
''
)
}
code=
{
values
.
flinkTemplate
||
''
}
/>
</
ProForm
.
Item
>
</
ProFormGroup
>
)
}
</>
);
};
</
ProForm
.
Group
>
return
(
<>
<
ProForm
initialValues=
{
values
}
form=
{
form
}
onValuesChange=
{
(
changedValues
,
values
)
=>
handleTypeChange
(
values
)
}
submitter=
{
false
}
>
{
renderDataSourceForm
()
}
</
ProForm
>
</>
);
{
!
excludeFormItem
&&
(
<
ProFormGroup
>
<
ProForm
.
Item
name=
'flinkConfig'
label=
{
l
(
'rc.ds.flinkConfig'
)
}
tooltip=
{
l
(
'rc.ds.flinkConfigTooltip'
)
}
>
<
CodeEdit
{
...
CodeEditProps
}
onChange=
{
(
value
)
=>
flinkConfigChange
(
value
??
''
)
}
code=
{
values
.
flinkConfig
||
''
}
/>
</
ProForm
.
Item
>
<
ProForm
.
Item
name=
'flinkTemplate'
label=
{
l
(
'rc.ds.flinkTemplate'
)
}
tooltip=
{
l
(
'rc.ds.flinkTemplateTooltip'
)
}
>
<
CodeEdit
{
...
CodeEditProps
}
onChange=
{
(
value
)
=>
flinkTemplateChange
(
value
??
''
)
}
code=
{
values
.
flinkTemplate
||
''
}
/>
</
ProForm
.
Item
>
</
ProFormGroup
>
)
}
</>
);
};
return
renderDataSourceForm
();
};
export
default
DataSourceProForm
;
dinky-web/src/pages/RegCenter/DataSource/components/DataSourceModal/index.tsx
View file @
cd7470a3
...
...
@@ -57,8 +57,12 @@ const DataSourceModal: React.FC<DataSourceModalProps> = (props) => {
* when modalVisible or values changed, set form values
*/
useEffect
(()
=>
{
form
.
setFieldsValue
(
values
);
},
[
visible
,
values
,
form
]);
if
(
!
visible
)
{
form
.
resetFields
();
}
else
{
form
.
setFieldsValue
(
values
);
}
},
[
visible
,
values
]);
/**
* handle cancel
...
...
dinky-web/src/pages/RegCenter/DataSource/service.tsx
0 → 100644
View file @
cd7470a3
import
{
DataSources
}
from
"@/types/RegCenter/data"
;
import
{
API_CONSTANTS
}
from
"@/services/endpoints"
;
import
{
handleAddOrUpdate
,
handleOption
}
from
"@/services/BusinessCrud"
;
import
{
l
}
from
"@/utils/intl"
;
/**
* handle test
* @param item
*/
export
const
handleTest
=
async
(
item
:
Partial
<
DataSources
.
DataSource
>
)
=>
{
await
handleOption
(
API_CONSTANTS
.
DATASOURCE_TEST
,
l
(
'button.test'
),
item
);
};
/**
* handle add or update
* @param item
*/
export
const
saveOrUpdateHandle
=
async
(
item
:
Partial
<
DataSources
.
DataSource
>
)
=>
{
await
handleAddOrUpdate
(
API_CONSTANTS
.
DATASOURCE
,
item
);
};
\ No newline at end of file
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