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
d33d97f6
Unverified
Commit
d33d97f6
authored
Jun 13, 2024
by
Zzm0809
Committed by
GitHub
Jun 13, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize some judgment logic and alert rule logic (#3591)
Signed-off-by:
Zzm0809
<
934230207@qq.com
>
Co-authored-by:
Zzm0809
<
Zzm0809@users.noreply.github.com
>
parent
1166b336
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
380 additions
and
238 deletions
+380
-238
AlertRuleController.java
...c/main/java/org/dinky/controller/AlertRuleController.java
+2
-2
AlertRule.java
...n/src/main/java/org/dinky/data/model/alert/AlertRule.java
+7
-2
AlertTriggerRule.java
...ain/java/org/dinky/data/model/alert/AlertTriggerRule.java
+33
-0
index.tsx
...web/src/pages/DataStudio/BottomContainer/Result/index.tsx
+2
-1
function.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx
+14
-6
index.tsx
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
+29
-20
function.tsx
...b/src/pages/DataStudio/LeftContainer/Project/function.tsx
+3
-7
index.tsx
...-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
+13
-3
index.tsx
...b/src/pages/DataStudio/RightContainer/JobConfig/index.tsx
+4
-1
function.tsx
dinky-web/src/pages/DataStudio/function.tsx
+66
-5
route.tsx
dinky-web/src/pages/DataStudio/route.tsx
+54
-44
constants.ts
...r/Alert/AlertRule/AlertRuleList/RuleEditForm/constants.ts
+11
-10
function.tsx
...r/Alert/AlertRule/AlertRuleList/RuleEditForm/function.tsx
+9
-4
index.tsx
...nter/Alert/AlertRule/AlertRuleList/RuleEditForm/index.tsx
+110
-112
index.tsx
...c/pages/RegCenter/Alert/AlertRule/AlertRuleList/index.tsx
+1
-7
function.tsx
...eb/src/pages/RegCenter/DataSource/components/function.tsx
+13
-13
data.d.ts
dinky-web/src/types/SettingCenter/data.d.ts
+9
-1
No files found.
dinky-admin/src/main/java/org/dinky/controller/AlertRuleController.java
View file @
d33d97f6
...
...
@@ -89,9 +89,9 @@ public class AlertRuleController {
boolean
saved
=
alertRuleService
.
saveOrUpdate
(
alertRule
);
if
(
saved
)
{
JobAlertHandler
.
getInstance
().
refreshRulesData
();
return
Result
.
succeed
(
Status
.
MODIFY
_SUCCESS
);
return
Result
.
succeed
(
Status
.
SAVE
_SUCCESS
);
}
return
Result
.
failed
(
Status
.
MODIFY
_FAILED
);
return
Result
.
failed
(
Status
.
SAVE
_FAILED
);
}
@DeleteMapping
...
...
dinky-admin/src/main/java/org/dinky/data/model/alert/AlertRule.java
View file @
d33d97f6
...
...
@@ -19,8 +19,12 @@
package
org
.
dinky
.
data
.
model
.
alert
;
import
org.dinky.data.typehandler.ListTypeHandler
;
import
org.dinky.mybatis.model.SuperEntity
;
import
java.util.List
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
...
...
@@ -38,8 +42,9 @@ import lombok.NoArgsConstructor;
@ApiModel
(
value
=
"AlertRule"
,
description
=
"AlertRule"
)
public
class
AlertRule
extends
SuperEntity
<
AlertRule
>
{
@ApiModelProperty
(
value
=
"rule"
,
required
=
true
,
dataType
=
"String"
,
example
=
"rule"
)
String
rule
;
@ApiModelProperty
(
value
=
"rule"
,
required
=
true
,
dataType
=
"List<AlertTriggerRule>"
,
example
=
"rule"
)
@TableField
(
typeHandler
=
ListTypeHandler
.
class
)
List
<
AlertTriggerRule
>
rule
;
@ApiModelProperty
(
value
=
"templateId"
,
required
=
true
,
dataType
=
"int"
,
example
=
"1"
)
int
templateId
;
...
...
dinky-admin/src/main/java/org/dinky/data/model/alert/AlertTriggerRule.java
0 → 100644
View file @
d33d97f6
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package
org
.
dinky
.
data
.
model
.
alert
;
import
lombok.Data
;
/**
* alert triggering rules
*/
@Data
public
class
AlertTriggerRule
{
private
String
ruleKey
;
private
String
ruleOperator
;
private
String
ruleValue
;
private
Integer
rulePriority
;
}
dinky-web/src/pages/DataStudio/BottomContainer/Result/index.tsx
View file @
d33d97f6
...
...
@@ -18,6 +18,7 @@
*/
import
{
assert
,
getCurrentData
,
getCurrentTab
,
isDataStudioTabsItemType
,
...
...
@@ -135,7 +136,7 @@ const Result = (props: any) => {
}
else
if
(
consoleData
.
results
&&
!
isRefresh
)
{
setDataList
(
consoleData
.
results
);
}
else
{
if
(
current
?.
dialect
&&
current
?.
dialect
?.
toLowerCase
()
==
DIALECT
.
FLINK_SQL
)
{
if
(
assert
(
current
?.
dialect
,
[
DIALECT
.
FLINK_SQL
],
true
,
'includes'
)
)
{
// flink sql
// to do: get job data by history id list, not flink jid
if
(
current
?.
id
)
{
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/function.tsx
View file @
d33d97f6
...
...
@@ -20,6 +20,7 @@
import
{
TabsPageType
,
TaskDataType
}
from
'@/pages/DataStudio/model'
;
import
{
JOB_LIFE_CYCLE
}
from
'@/pages/DevOps/constants'
;
import
{
DIALECT
}
from
'@/services/constants'
;
import
{
assert
}
from
'@/pages/DataStudio/function'
;
/**
* @description: 生成面包屑
...
...
@@ -46,15 +47,22 @@ export const isOnline = (data: TaskDataType | undefined) => {
export
const
isCanPushDolphin
=
(
data
:
TaskDataType
|
undefined
)
=>
{
return
data
?
JOB_LIFE_CYCLE
.
PUBLISH
===
data
.
step
&&
data
?.
dialect
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
data
?.
dialect
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
data
?.
dialect
?.
toLowerCase
()
!==
DIALECT
.
JAVA
&&
data
?.
dialect
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
assert
(
data
?.
dialect
,
[
DIALECT
.
FLINKSQLENV
,
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
:
false
;
};
export
const
isSql
=
(
dialect
:
string
,
includedFlinkSQL
:
boolean
=
false
)
=>
{
if
(
!
dialect
)
{
/**
* @description: 判断是否为 SQL 方言 | assert is sql dialect
* @param dialect
* @param includedFlinkSQL
*/
export
const
isSql
=
(
dialect
:
string
=
''
,
includedFlinkSQL
:
boolean
=
false
)
=>
{
if
(
!
dialect
||
dialect
===
''
)
{
return
false
;
}
switch
(
dialect
.
toLowerCase
())
{
...
...
dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
View file @
d33d97f6
...
...
@@ -22,8 +22,10 @@ import { PushpinIcon } from '@/components/Icons/CustomIcons';
import
{
FlexCenterDiv
}
from
'@/components/StyledComponents'
;
import
{
LeftBottomKey
}
from
'@/pages/DataStudio/data.d'
;
import
{
assert
,
getCurrentData
,
getCurrentTab
,
isNotEmpty
,
lockTask
,
mapDispatchToProps
}
from
'@/pages/DataStudio/function'
;
...
...
@@ -373,9 +375,8 @@ const HeaderContainer = (props: connect) => {
icon
:
<
ApartmentOutlined
/>,
title
:
l
(
'button.graph'
),
isShow
:
(
projectCommonShow
(
currentTab
?.
type
)
&&
currentTab
?.
subType
?.
toLowerCase
()
===
DIALECT
.
FLINK_SQL
)
||
currentTab
?.
subType
?.
toLowerCase
()
===
DIALECT
.
FLINKJAR
,
projectCommonShow
(
currentTab
?.
type
)
&&
assert
(
currentTab
?.
subType
,
[
DIALECT
.
FLINK_SQL
,
DIALECT
.
FLINKJAR
],
true
,
'includes'
),
click
:
async
()
=>
showDagGraph
(),
props
:
{
disabled
:
isLockTask
...
...
@@ -391,9 +392,13 @@ const HeaderContainer = (props: connect) => {
click
:
()
=>
showExplain
(),
isShow
:
projectCommonShow
(
currentTab
?.
type
)
&&
currentTab
?.
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
&&
currentTab
?.
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
currentTab
?.
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
,
assert
(
currentTab
?.
subType
,
[
DIALECT
.
JAVA
,
DIALECT
.
SCALA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
&&
!
isSql
(
currentTab
?.
subType
),
props
:
{
disabled
:
isLockTask
}
...
...
@@ -414,7 +419,7 @@ const HeaderContainer = (props: connect) => {
// 发布按钮
icon
:
isOnline
(
currentData
)
?
<
MergeCellsOutlined
/>
:
<
FundOutlined
/>,
title
:
isOnline
(
currentData
)
?
l
(
'button.offline'
)
:
l
(
'button.publish'
),
isShow
:
currentTab
?.
type
==
TabsPageType
.
project
,
isShow
:
assert
(
currentTab
?.
type
,
TabsPageType
.
project
,
true
,
'equal'
)
,
click
:
()
=>
handleChangeJobLife
(),
props
:
{
disabled
:
isLockTask
...
...
@@ -425,10 +430,10 @@ const HeaderContainer = (props: connect) => {
icon
:
<
RotateRightOutlined
/>,
title
:
l
(
'pages.datastudio.to.jobDetail'
),
isShow
:
currentTab
?.
type
==
TabsPageType
.
project
&&
currentData
?.
jobInstanceId
&&
(
currentTab
?.
subType
?.
toLowerCase
()
==
DIALECT
.
FLINK_SQL
||
currentTab
?.
subType
?.
toLowerCase
()
==
DIALECT
.
FLINKJAR
),
isNotEmpty
(
currentData
?.
jobInstanceId
)
&&
!
isSql
(
currentTab
?.
subType
)
&&
assert
(
currentTab
?.
subType
,
[
DIALECT
.
FLINK_SQL
,
DIALECT
.
FLINKJAR
],
true
,
'includes'
)
&&
assert
(
currentTab
?.
type
,
TabsPageType
.
project
,
true
,
'equal'
),
props
:
{
onClick
:
async
()
=>
{
const
dataByParams
=
await
queryDataByParams
<
Jobs
.
JobInstance
>
(
...
...
@@ -451,12 +456,14 @@ const HeaderContainer = (props: connect) => {
hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F10',
hotKeyDesc: 'Shift+F10',
isShow:
currentTab?.type == TabsPageType.project
&&
assert(currentTab?.type, TabsPageType.project, true, 'equal')
&&
isStatusDone(currentData?.status) &&
currentTab?.subType?.toLowerCase() !== DIALECT.JAVA &&
currentTab?.subType?.toLowerCase() !== DIALECT.SCALA &&
currentTab?.subType?.toLowerCase() !== DIALECT.PYTHON_LONG &&
currentTab?.subType?.toLowerCase() !== DIALECT.FLINKSQLENV,
assert(
currentTab?.subType,
[DIALECT.JAVA, DIALECT.SCALA, DIALECT.PYTHON_LONG, DIALECT.FLINKSQLENV],
true,
'notIncludes'
),
props: {
style: { background: '#52c41a' },
type: 'primary',
...
...
@@ -471,10 +478,10 @@ const HeaderContainer = (props: connect) => {
hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F9',
hotKeyDesc: 'Shift+F9',
isShow:
currentTab?.type == TabsPageType.project
&&
assert(currentTab?.type, TabsPageType.project, true, 'equal')
&&
isStatusDone(currentData?.status) &&
(currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL ||
isSql(currentTab?.subType?.toLowerCase() ?? '')
),
!isSql(currentTab?.subType) &&
assert(currentTab?.subType, [DIALECT.FLINK_SQL], true, 'includes'
),
props: {
style: { background: '#52c41a' },
type: 'primary',
...
...
@@ -486,7 +493,9 @@ const HeaderContainer = (props: connect) => {
icon: <PauseOutlined />,
title: l('pages.datastudio.editor.stop'),
click: handlerStop,
isShow: currentTab?.type == TabsPageType.project && !isStatusDone(currentData?.status),
isShow:
assert(currentTab?.type, TabsPageType.project, true, 'equal') &&
!isStatusDone(currentData?.status),
hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F10',
hotKeyDesc: 'Shift+F10',
props: {
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/function.tsx
View file @
d33d97f6
...
...
@@ -18,7 +18,7 @@
*/
import
{
LeftBottomKey
,
RightMenuKey
}
from
'@/pages/DataStudio/data.d'
;
import
{
lockTask
,
showAllOwners
}
from
'@/pages/DataStudio/function'
;
import
{
assert
,
lockTask
,
showAllOwners
}
from
'@/pages/DataStudio/function'
;
import
{
isSql
}
from
'@/pages/DataStudio/HeaderContainer/function'
;
import
{
getTabIcon
}
from
'@/pages/DataStudio/MiddleContainer/function'
;
import
{
DIALECT
}
from
'@/services/constants'
;
...
...
@@ -323,15 +323,11 @@ export const buildProjectTree = (
:
[];
export
const
isUDF
=
(
jobType
:
string
):
boolean
=>
{
return
(
jobType
.
toLowerCase
()
===
DIALECT
.
SCALA
||
jobType
.
toLowerCase
()
===
DIALECT
.
PYTHON_LONG
||
jobType
.
toLowerCase
()
===
DIALECT
.
JAVA
);
return
assert
(
jobType
,
[
DIALECT
.
SCALA
,
DIALECT
.
PYTHON_LONG
,
DIALECT
.
JAVA
],
true
,
'includes'
);
};
export
const
isFlinkJob
=
(
jobType
:
string
):
boolean
=>
{
return
jobType
.
toLowerCase
()
===
DIALECT
.
FLINK_SQL
||
jobType
.
toLowerCase
()
===
DIALECT
.
FLINKJAR
;
return
assert
(
jobType
,
[
DIALECT
.
FLINK_SQL
,
DIALECT
.
FLINKJAR
],
true
,
'includes'
)
;
};
export
function
getRightSelectKeyFromNodeClickJobType
(
jobType
:
string
):
string
{
...
...
dinky-web/src/pages/DataStudio/LeftContainer/Project/index.tsx
View file @
d33d97f6
...
...
@@ -18,14 +18,17 @@
*/
import
RightContextMenu
from
'@/components/RightContextMenu'
;
import
{
getTabByTaskId
}
from
'@/pages/DataStudio/function'
;
import
{
assert
,
getTabByTaskId
}
from
'@/pages/DataStudio/function'
;
import
{
useTasksDispatch
}
from
'@/pages/DataStudio/LeftContainer/BtnContext'
;
import
{
FOLDER_RIGHT_MENU
,
JOB_RIGHT_MENU
}
from
'@/pages/DataStudio/LeftContainer/Project/constants'
;
import
FolderModal
from
'@/pages/DataStudio/LeftContainer/Project/FolderModal'
;
import
{
getRightSelectKeyFromNodeClickJobType
}
from
'@/pages/DataStudio/LeftContainer/Project/function'
;
import
{
getRightSelectKeyFromNodeClickJobType
,
isUDF
}
from
'@/pages/DataStudio/LeftContainer/Project/function'
;
import
JobModal
from
'@/pages/DataStudio/LeftContainer/Project/JobModal'
;
import
JobTree
from
'@/pages/DataStudio/LeftContainer/Project/JobTree'
;
import
{
...
...
@@ -146,6 +149,13 @@ const Project: React.FC = (props: connect) => {
type
:
STUDIO_MODEL
.
updateSelectRightKey
,
payload
:
getRightSelectKeyFromNodeClickJobType
(
type
)
});
// 如果是 udf 或者 是env 则需要更新 bottom key 为空|| if is udf or is env then update bottom key to empty
if
(
isUDF
(
type
)
||
assert
(
type
,
[
DIALECT
.
FLINKSQLENV
],
true
,
'includes'
))
{
dispatch
({
type
:
STUDIO_MODEL
.
updateSelectBottomKey
,
payload
:
''
});
}
}
dispatch
({
...
...
@@ -213,7 +223,7 @@ const Project: React.FC = (props: connect) => {
()
=>
{},
()
=>
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryProject
,
payload
:
selectCatalogueSortTypeData
});
if
(
values
.
type
&&
values
.
type
.
toLowerCase
()
===
DIALECT
.
FLINKSQLENV
)
{
if
(
assert
(
values
.
type
,
[
DIALECT
.
FLINKSQLENV
],
true
,
'includes'
)
)
{
dispatch
({
type
:
STUDIO_MODEL_ASYNC
.
queryEnv
});
}
if
(
projectState
.
isEdit
)
{
...
...
dinky-web/src/pages/DataStudio/RightContainer/JobConfig/index.tsx
View file @
d33d97f6
...
...
@@ -20,6 +20,7 @@
import
FlinkOptionsSelect
from
'@/components/Flink/OptionsSelect'
;
import
{
SAVE_POINT_TYPE
}
from
'@/pages/DataStudio/constants'
;
import
{
assert
,
getCurrentData
,
getCurrentTab
,
isDataStudioTabsItemType
,
...
...
@@ -121,10 +122,12 @@ const JobConfig = (props: any) => {
Object
.
keys
(
change
).
forEach
((
key
)
=>
{
if
(
key
===
'configJson'
)
{
if
(
!
pane
.
params
.
taskData
.
configJson
)
{
// @ts-ignore
pane
.
params
.
taskData
.
configJson
=
{};
}
Object
.
keys
(
change
[
key
]).
forEach
((
k
)
=>
{
// @ts-ignore
pane
.
params
.
taskData
[
key
][
k
]
=
all
[
key
][
k
];
});
}
else
{
...
...
@@ -315,7 +318,7 @@ const JobConfig = (props: any) => {
</>
)
}
{
current
?.
dialect
&&
current
?.
dialect
?.
toLowerCase
()
===
DIALECT
.
FLINK_SQL
&&
(
{
assert
(
current
?.
dialect
,
[
DIALECT
.
FLINK_SQL
],
true
,
'includes'
)
&&
(
<
ProFormSelect
name=
'envId'
label=
{
l
(
'pages.datastudio.label.jobConfig.flinksql.env'
)
}
...
...
dinky-web/src/pages/DataStudio/function.tsx
View file @
d33d97f6
...
...
@@ -211,11 +211,11 @@ export function isProjectTabs(panes: TabsItemType[], activeKey: string): boolean
}
export
function
isShowRightTabsJobConfig
(
dialect
:
string
):
boolean
{
return
(
dialect
.
toLowerCase
()
===
DIALECT
.
JAVA
||
dialect
.
toLowerCase
()
===
DIALECT
.
PYTHON_LONG
||
dialect
.
toLowerCase
()
===
DIALECT
.
SCALA
||
dialect
.
toLowerCase
()
===
DIALECT
.
FLINKSQLENV
return
assert
(
dialect
,
[
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
,
DIALECT
.
SCALA
,
DIALECT
.
FLINKSQLENV
],
true
,
'includes'
);
}
...
...
@@ -331,3 +331,64 @@ export const lockTask = (
return
false
;
}
};
/**
* 断言 断言类型值是否在断言类型值列表中 | assert whether the assertion type value is in the assertion type value list
* @param needAssertTypeValue
* @param assertTypeValueList
* @param needAssertTypeValueLowerCase
* @param assertType
*/
export
const
assert
=
(
needAssertTypeValue
:
string
=
''
,
assertTypeValueList
:
string
[]
|
string
=
[],
needAssertTypeValueLowerCase
=
false
,
assertType
:
'notIncludes'
|
'includes'
|
'notEqual'
|
'equal'
=
'includes'
):
boolean
=>
{
// 如果 needAssertTypeValue 为空, 则直接返回 false 不需要断言 | if needAssertTypeValue is empty, return false directly
if
(
isEmpty
(
needAssertTypeValue
))
{
return
false
;
}
// 判断 assertTypeValueList 是字符串还是数组 | judge whether assertTypeValueList is a string or an array
if
(
!
Array
.
isArray
(
assertTypeValueList
))
{
assertTypeValueList
=
[
assertTypeValueList
];
}
// 如果是 assertType 是 notEqual 或 equal, 则 assertTypeValueList 只能有一个值 | if assertType is notEqual or equal, assertTypeValueList can only have one value
if
(
assertType
===
'notEqual'
||
assertType
===
'equal'
)
{
assertTypeValueList
=
assertTypeValueList
.
slice
(
0
,
1
);
}
// 判断需要断言的值是否需要转小写 | determine whether the value to be asserted needs to be converted to lowercase
if
(
needAssertTypeValueLowerCase
)
{
needAssertTypeValue
=
needAssertTypeValue
.
toLowerCase
();
assertTypeValueList
=
assertTypeValueList
.
map
((
item
)
=>
item
.
toLowerCase
());
}
if
(
assertType
===
'notIncludes'
)
{
return
!
assertTypeValueList
.
includes
(
needAssertTypeValue
);
}
if
(
assertType
===
'includes'
)
{
return
assertTypeValueList
.
includes
(
needAssertTypeValue
);
}
if
(
assertType
===
'notEqual'
)
{
return
assertTypeValueList
.
every
((
item
)
=>
item
!==
needAssertTypeValue
);
}
if
(
assertType
===
'equal'
)
{
return
assertTypeValueList
.
every
((
item
)
=>
item
===
needAssertTypeValue
);
}
return
false
;
};
/**
* 判断 不为空或者不为 undefined | determine whether it is not empty or not undefined
* @param value
*/
export
const
isNotEmpty
=
(
value
:
any
):
boolean
=>
{
return
value
!==
''
&&
value
!==
undefined
&&
value
!==
null
;
};
/**
* 判断为空或者为 undefined | determine whether it is empty or undefined
* @param value
*/
export
const
isEmpty
=
(
value
:
any
):
boolean
=>
{
return
!
isNotEmpty
(
value
);
};
dinky-web/src/pages/DataStudio/route.tsx
View file @
d33d97f6
...
...
@@ -57,6 +57,7 @@ import {
}
from
'@ant-design/icons'
;
import
{
TabPaneProps
}
from
'antd'
;
import
React
,
{
ReactNode
}
from
'react'
;
import
{
assert
}
from
'@/pages/DataStudio/function'
;
export
const
LeftSide
:
TabProp
[]
=
[
{
...
...
@@ -73,13 +74,13 @@ export const LeftSide: TabProp[] = [
label
:
l
(
LeftMenuKey
.
CATALOG_KEY
),
children
:
<
Catalog
/>,
isShow
:
(
type
,
subType
)
=>
(
type
===
TabsPageType
.
project
||
type
===
TabsPageType
.
metadata
)
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKJAR
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
assert
(
type
,
[
TabsPageType
.
project
,
TabsPageType
.
metadata
],
true
,
'includes'
)
&&
assert
(
subType
,
[
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
,
DIALECT
.
FLINKSQLENV
,
DIALECT
.
FLINKJAR
],
true
,
'notIncludes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_DATASOURCE
,
...
...
@@ -95,11 +96,9 @@ export const LeftSide: TabProp[] = [
label
:
l
(
LeftMenuKey
.
FRAGMENT_KEY
),
children
:
<
GlobalVariable
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
!
isSql
(
subType
??
''
)
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
!
isSql
(
subType
)
&&
assert
(
subType
,
[
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
}
];
...
...
@@ -111,8 +110,8 @@ export const RightSide: TabProp[] = [
label
:
l
(
RightMenuKey
.
JOB_CONFIG_KEY
),
children
:
<
JobConfig
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
(
TabsPageSubType
.
flinkSql
===
subType
||
TabsPageSubType
.
flinkJar
===
subType
)
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
TabsPageSubType
.
flinkSql
,
TabsPageSubType
.
flinkJar
],
true
,
'includes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_RIGHT_PREVIEW_CONFIG
,
...
...
@@ -121,8 +120,9 @@ export const RightSide: TabProp[] = [
label
:
l
(
RightMenuKey
.
PREVIEW_CONFIG_KEY
),
children
:
<
PreViewConfig
/>,
isShow
:
(
type
,
subType
)
=>
(
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
)
||
isSql
(
subType
??
''
)
(
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
TabsPageSubType
.
flinkSql
],
true
,
'includes'
))
||
isSql
(
subType
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_RIGHT_SAVE_POINT
,
...
...
@@ -130,7 +130,9 @@ export const RightSide: TabProp[] = [
icon
:
<
FolderOutlined
/>,
label
:
l
(
RightMenuKey
.
SAVEPOINT_KEY
),
children
:
<
SavePoints
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
isShow
:
(
type
,
subType
)
=>
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
TabsPageSubType
.
flinkSql
,
true
,
'equal'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_RIGHT_HISTORY_VISION
,
...
...
@@ -138,7 +140,9 @@ export const RightSide: TabProp[] = [
icon
:
<
HistoryOutlined
/>,
label
:
l
(
RightMenuKey
.
HISTORY_VISION_KEY
),
children
:
<
HistoryVersion
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
TabsPageSubType
.
flinkSql
===
subType
isShow
:
(
type
,
subType
)
=>
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
TabsPageSubType
.
flinkSql
,
true
,
'equal'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_RIGHT_JOB_INFO
,
...
...
@@ -146,7 +150,7 @@ export const RightSide: TabProp[] = [
icon
:
<
InfoCircleOutlined
/>,
label
:
l
(
RightMenuKey
.
JOB_INFO_KEY
),
children
:
<
JobInfo
/>,
isShow
:
(
type
)
=>
type
===
TabsPageType
.
project
isShow
:
(
type
)
=>
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
}
];
...
...
@@ -158,11 +162,13 @@ export const LeftBottomSide: TabProp[] = [
label
:
l
(
LeftBottomKey
.
CONSOLE_KEY
),
children
:
<
Console
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
DIALECT
.
FLINKSQLENV
,
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_BOTTOM_RESULT
,
...
...
@@ -171,12 +177,13 @@ export const LeftBottomSide: TabProp[] = [
label
:
l
(
LeftBottomKey
.
RESULT_KEY
),
children
:
<
Result
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKJAR
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
DIALECT
.
FLINKSQLENV
,
DIALECT
.
FLINKJAR
,
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_BOTTOM_LINEAGE
,
...
...
@@ -185,12 +192,13 @@ export const LeftBottomSide: TabProp[] = [
label
:
l
(
LeftBottomKey
.
LINEAGE_KEY
),
children
:
<
Lineage
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKJAR
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
DIALECT
.
FLINKSQLENV
,
DIALECT
.
FLINKJAR
,
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_BOTTOM_HISTORY
,
...
...
@@ -199,13 +207,14 @@ export const LeftBottomSide: TabProp[] = [
label
:
l
(
LeftBottomKey
.
HISTORY_KEY
),
children
:
<
JobExecHistory
/>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
!
isSql
(
subType
??
''
)
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
FLINKSQLENV
&&
// subType?.toLowerCase() !== DIALECT.FLINKJAR &&
subType
?.
toLowerCase
()
!==
DIALECT
.
SCALA
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
PYTHON_LONG
&&
subType
?.
toLowerCase
()
!==
DIALECT
.
JAVA
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
!
isSql
(
subType
)
&&
assert
(
subType
,
[
DIALECT
.
FLINKSQLENV
,
DIALECT
.
SCALA
,
DIALECT
.
JAVA
,
DIALECT
.
PYTHON_LONG
],
true
,
'notIncludes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_BOTTOM_TABLE_DATA
,
...
...
@@ -214,7 +223,8 @@ export const LeftBottomSide: TabProp[] = [
label
:
l
(
LeftBottomKey
.
TABLE_DATA_KEY
),
children
:
<></>,
isShow
:
(
type
,
subType
)
=>
type
===
TabsPageType
.
project
&&
subType
?.
toLowerCase
()
===
DIALECT
.
FLINK_SQL
assert
(
type
,
TabsPageType
.
project
,
true
,
'equal'
)
&&
assert
(
subType
,
[
DIALECT
.
FLINK_SQL
],
true
,
'includes'
)
},
{
auth
:
PermissionConstants
.
DATASTUDIO_LEFT_BOTTOM_TOOL
,
...
...
dinky-web/src/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants.ts
View file @
d33d97f6
...
...
@@ -22,6 +22,7 @@ import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import
{
l
}
from
'@/utils/intl'
;
import
{
CheckboxOptionType
}
from
'antd/es/checkbox/Group'
;
import
{
DefaultOptionType
}
from
'antd/es/select'
;
import
{
RUN_MODE
}
from
"@/services/constants"
;
export
enum
RuleType
{
SYSTEM
=
'SYSTEM'
,
...
...
@@ -40,19 +41,19 @@ export const TriggerType: CheckboxOptionType[] = [
];
export
const
AllRuleOperator
:
DefaultOptionType
[]
=
[
{
label
:
'>'
,
value
:
'GT'
},
{
label
:
'<'
,
value
:
'LT'
},
{
label
:
'='
,
value
:
'EQ'
},
{
label
:
'!='
,
value
:
'NE'
},
{
label
:
'>='
,
value
:
'GE'
},
{
label
:
'<='
,
value
:
'LE'
}
{
label
:
'>'
,
value
:
'GT'
,
key
:
'GT'
},
{
label
:
'<'
,
value
:
'LT'
,
key
:
'LT'
},
{
label
:
'='
,
value
:
'EQ'
,
key
:
'EQ'
},
{
label
:
'!='
,
value
:
'NE'
,
key
:
'NE'
},
{
label
:
'>='
,
value
:
'GE'
,
key
:
'GE'
},
{
label
:
'<='
,
value
:
'LE'
,
key
:
'LE'
}
];
export
const
EqRuleOperator
:
DefaultOptionType
[]
=
[{
label
:
'='
,
value
:
'EQ'
}];
export
const
EqRuleOperator
:
DefaultOptionType
[]
=
[{
label
:
'='
,
value
:
'EQ'
,
key
:
'EQ'
}];
export
const
BOOLEAN_VALUE_ENUM
:
DefaultOptionType
[]
=
[
{
label
:
'True'
,
value
:
'true'
},
{
label
:
'False'
,
value
:
'false'
}
{
label
:
'True'
,
value
:
'true'
,
key
:
'true'
},
{
label
:
'False'
,
value
:
'false'
,
key
:
'false'
}
];
export
const
AlertRules
:
any
=
{
...
...
@@ -77,7 +78,7 @@ export const AlertRules: any = {
clusterType
:
{
label
:
l
(
'sys.alert.rule.label.jobType'
),
valueType
:
OperatorType
.
OPTIONS_SEL
,
valueEnum
:
Object
.
values
(
ClusterType
).
map
((
t
)
=>
`'
${
t
}
'`
)
valueEnum
:
Object
.
values
(
RUN_MODE
).
map
((
t
)
=>
`'
${
t
}
'`
)
},
checkpointCostTime
:
{
label
:
l
(
'sys.alert.rule.label.checkpointTime'
),
...
...
dinky-web/src/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function.tsx
View file @
d33d97f6
...
...
@@ -33,7 +33,8 @@ export const AlertRulesOption = () => {
res
.
push
({
// @ts-ignore
label
:
v
.
label
,
value
:
k
value
:
k
,
key
:
k
,
});
}
return
res
;
...
...
@@ -62,18 +63,22 @@ export const buildValueItem = (key: string, isSystem: boolean) => {
name=
{
'ruleValue'
}
fieldProps=
{
{
precision
:
0
}
}
placeholder=
{
plh
}
width=
{
'
sm
'
}
width=
{
'
md
'
}
/>
);
case
OperatorType
.
STR_VALUE
:
return
(
<
ProFormText
width=
{
'
sm
'
}
disabled=
{
isSystem
}
name=
{
'ruleValue'
}
placeholder=
{
plh
}
/>
<
ProFormText
width=
{
'
md
'
}
disabled=
{
isSystem
}
name=
{
'ruleValue'
}
placeholder=
{
plh
}
/>
);
case
OperatorType
.
OPTIONS_SEL
:
return
(
<
ProFormSelect
width=
{
'
sm
'
}
width=
{
'
md
'
}
disabled=
{
isSystem
}
fieldProps=
{
{
defaultActiveFirstOption
:
true
,
showSearch
:
true
,
}
}
name=
'ruleValue'
mode=
{
'single'
}
placeholder=
{
plh
}
...
...
dinky-web/src/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/index.tsx
View file @
d33d97f6
...
...
@@ -17,23 +17,20 @@
*
*/
import
{
Authorized
}
from
'@/hooks/useAccess'
;
import
{
Authorized
}
from
'@/hooks/useAccess'
;
import
{
RuleType
,
TriggerType
}
from
'@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants'
;
import
{
RuleType
,
TriggerType
}
from
'@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants'
;
import
{
AlertRulesOption
,
buildValueItem
,
getOperatorOptions
}
from
'@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function'
;
import
{
getData
}
from
'@/services/api'
;
import
{
SWITCH_OPTIONS
}
from
'@/services/constants'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
Alert
}
from
'@/types/RegCenter/data'
;
import
{
AlertRule
}
from
'@/types/SettingCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
getData
}
from
'@/services/api'
;
import
{
SWITCH_OPTIONS
}
from
'@/services/constants'
;
import
{
API_CONSTANTS
}
from
'@/services/endpoints'
;
import
{
Alert
}
from
'@/types/RegCenter/data'
;
import
{
AlertRule
,
AlertRuleCondition
}
from
'@/types/SettingCenter/data'
;
import
{
l
}
from
'@/utils/intl'
;
import
{
DrawerForm
,
ProCard
,
...
...
@@ -46,10 +43,10 @@ import {
ProFormText
,
ProFormTextArea
}
from
'@ant-design/pro-components'
;
import
{
ProFormDependency
}
from
'@ant-design/pro-form'
;
import
{
Button
,
Divider
,
Form
,
Space
,
Typography
}
from
'antd'
;
import
{
ProFormDependency
}
from
'@ant-design/pro-form'
;
import
{
Button
,
Divider
,
Form
,
Space
,
Typography
}
from
'antd'
;
const
{
Link
}
=
Typography
;
const
{
Link
}
=
Typography
;
type
AlertRuleFormProps
=
{
onCancel
:
(
flag
?:
boolean
)
=>
void
;
...
...
@@ -59,111 +56,112 @@ type AlertRuleFormProps = {
};
const
RuleEditForm
=
(
props
:
AlertRuleFormProps
)
=>
{
const
{
onSubmit
:
handleSubmit
,
onCancel
:
handleModalVisible
,
modalVisible
,
values
}
=
props
;
// if is system rule disable edit
const
isSystem
=
values
.
ruleType
==
RuleType
.
SYSTEM
;
const
{
onSubmit
:
handleSubmit
,
onCancel
:
handleModalVisible
,
modalVisible
,
values
}
=
props
;
// if is system rule disable edit
const
isSystem
=
values
.
ruleType
==
RuleType
.
SYSTEM
;
const
[
form
]
=
Form
.
useForm
<
AlertRule
>
();
const
getAlertTemplate
=
async
()
=>
{
const
template
:
Alert
.
AlertTemplate
[]
=
(
await
getData
(
API_CONSTANTS
.
ALERT_TEMPLATE
)).
data
;
return
template
.
map
((
t
)
=>
({
label
:
t
.
name
,
value
:
t
.
id
}));
};
const
submit
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
return
handleSubmit
({...
values
,...
fieldsValue
});
};
const
renderTemplateDropDown
=
(
item
:
any
)
=>
{
return
(
<>
{
item
}
<
Authorized
key=
'create'
path=
'/registration/alert/template/add'
>
<>
<
Divider
style=
{
{
margin
:
'8px 0'
}
}
/>
<
Link
href=
{
'#/registration/alert/template'
}
>
+
{
l
(
'rc.alert.template.new'
)
}
</
Link
>
</>
</
Authorized
>
</>
);
};
const
renderFooter
=
()
=>
{
return
[
<
Button
key=
{
'RuleCancel'
}
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
{
l
(
'button.cancel'
)
}
</
Button
>,
<
Button
key=
{
'RuleFinish'
}
type=
'primary'
htmlType=
{
'submit'
}
autoFocus
onClick=
{
()
=>
submit
()
}
>
{
l
(
'button.finish'
)
}
</
Button
>
];
};
const
[
form
]
=
Form
.
useForm
<
AlertRule
>
();
return
(
<
DrawerForm
layout=
{
'vertical'
}
form=
{
form
}
width=
{
'40%'
}
open=
{
modalVisible
}
submitter=
{
{
render
:
()
=>
[...
renderFooter
()]}
}
drawerProps=
{
{
onClose
:
()
=>
handleModalVisible
(
false
),
destroyOnClose
:
true
}
}
initialValues=
{
values
}
>
<
ProFormGroup
>
<
ProFormText
name=
'id'
hidden=
{
true
}
/>
<
ProFormText
name=
'ruleType'
hidden=
{
true
}
/>
<
ProFormText
disabled=
{
isSystem
}
rules=
{
[{
required
:
true
}]
}
name=
'name'
width=
'md'
label=
{
l
(
'sys.alert.rule.name'
)
}
placeholder=
{
l
(
'sys.alert.rule.name'
)
}
/>
<
ProFormSelect
label=
{
l
(
'sys.alert.rule.template'
)
}
width=
'md'
name=
'templateId'
request=
{
async
()
=>
getAlertTemplate
()
}
placeholder=
{
l
(
'sys.alert.rule.template'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'sys.alert.rule.template'
)}]
}
fieldProps=
{
{
dropdownRender
:
(
item
)
=>
renderTemplateDropDown
(
item
)}
}
/>
</
ProFormGroup
>
const
getAlertTemplate
=
async
()
=>
{
const
template
:
Alert
.
AlertTemplate
[]
=
(
await
getData
(
API_CONSTANTS
.
ALERT_TEMPLATE
)).
data
;
return
template
.
map
((
t
)
=>
({
label
:
t
.
name
,
value
:
t
.
id
}));
};
<
ProFormGroup
>
<
ProFormTextArea
width=
'md'
name=
'description'
label=
{
l
(
'global.table.note'
)
}
/>
<
ProFormSwitch
name=
'enabled'
{
...
SWITCH_OPTIONS
()}
label=
{
l
(
'global.table.isEnable'
)
}
/>
</
ProFormGroup
>
const
submit
=
async
()
=>
{
const
fieldsValue
=
await
form
.
validateFields
();
return
handleSubmit
({
...
fieldsValue
,
rule
:
JSON
.
stringify
(
fieldsValue
.
rule
)
});
};
<
Divider
orientation=
{
'left'
}
>
{
l
(
'sys.alert.rule.trigger'
)
}
</
Divider
>
const
renderTemplateDropDown
=
(
item
:
any
)
=>
{
return
(
<>
{
item
}
<
Authorized
key=
'create'
path=
'/registration/alert/template/add'
>
<>
<
Divider
style=
{
{
margin
:
'8px 0'
}
}
/>
<
Link
href=
{
'#/registration/alert/template'
}
>
+
{
l
(
'rc.alert.template.new'
)
}
</
Link
>
</>
</
Authorized
>
</>
);
};
const
renderFooter
=
()
=>
{
return
[
<
Button
key=
{
'RuleCancel'
}
onClick=
{
()
=>
handleModalVisible
(
false
)
}
>
{
l
(
'button.cancel'
)
}
</
Button
>,
<
Button
key=
{
'RuleFinish'
}
type=
'primary'
htmlType=
{
'submit'
}
autoFocus
onClick=
{
()
=>
submit
()
}
>
{
l
(
'button.finish'
)
}
</
Button
>
];
};
return
(
<
DrawerForm
layout=
{
'vertical'
}
form=
{
form
}
open=
{
modalVisible
}
submitter=
{
{
render
:
()
=>
[...
renderFooter
()]
}
}
drawerProps=
{
{
onClose
:
()
=>
handleModalVisible
(
false
),
destroyOnClose
:
true
}
}
initialValues=
{
values
}
>
<
ProFormGroup
>
<
ProFormText
name=
'id'
hidden=
{
true
}
/>
<
ProFormText
name=
'ruleType'
hidden=
{
true
}
/>
<
ProFormText
<
ProFormRadio
.
Group
disabled=
{
isSystem
}
rules=
{
[{
required
:
true
}]
}
name=
'name'
width=
'md'
label=
{
l
(
'sys.alert.rule.name'
)
}
placeholder=
{
l
(
'sys.alert.rule.name'
)
}
name=
'triggerConditions'
label=
{
l
(
'sys.alert.rule.triggerConditions'
)
}
rules=
{
[{
required
:
true
}]
}
options=
{
TriggerType
}
/>
<
ProFormSelect
label=
{
l
(
'sys.alert.rule.template'
)
}
width=
'md'
name=
'templateId'
request=
{
async
()
=>
getAlertTemplate
()
}
placeholder=
{
l
(
'sys.alert.rule.template'
)
}
rules=
{
[{
required
:
true
,
message
:
l
(
'sys.alert.rule.template'
)
}]
}
fieldProps=
{
{
dropdownRender
:
(
item
)
=>
renderTemplateDropDown
(
item
)
}
}
/>
</
ProFormGroup
>
<
ProFormGroup
>
<
ProFormTextArea
width=
'md'
name=
'description'
label=
{
l
(
'global.table.note'
)
}
/>
<
ProFormSwitch
name=
'enabled'
{
...
SWITCH_OPTIONS
()}
label=
{
l
(
'global.table.isEnable'
)
}
/>
</
ProFormGroup
>
<
Divider
orientation=
{
'left'
}
>
{
l
(
'sys.alert.rule.trigger'
)
}
</
Divider
>
<
ProFormRadio
.
Group
disabled=
{
isSystem
}
name=
'triggerConditions'
label=
{
l
(
'sys.alert.rule.triggerConditions'
)
}
rules=
{
[{
required
:
true
}]
}
options=
{
TriggerType
}
/>
<
ProFormList
name=
'rule'
label=
{
l
(
'sys.alert.rule.triggerRule'
)
}
creatorButtonProps=
{
isSystem
?
false
:
{
<
ProFormList
<
AlertRuleCondition
>
name='rule'
label=
{
l
(
'sys.alert.rule.triggerRule'
)
}
creatorButtonProps=
{
isSystem
?
false
:
{
creatorButtonText
:
l
(
'sys.alert.rule.addRule'
)
}
}
...
...
dinky-web/src/pages/RegCenter/Alert/AlertRule/AlertRuleList/index.tsx
View file @
d33d97f6
...
...
@@ -69,16 +69,11 @@ const AlertRuleList: React.FC = () => {
}
const
initData
=
async
(
params
:
any
,
sorter
:
any
,
filter
:
any
)
=>
{
const
result
=
await
queryList
(
API_CONSTANTS
.
ALERT_RULE_LIST
,
{
return
await
queryList
(
API_CONSTANTS
.
ALERT_RULE_LIST
,
{
...
params
,
sorter
,
filter
});
const
data
=
result
.
data
.
map
((
t
:
AlertRule
)
=>
{
t
.
rule
=
JSON
.
parse
(
t
.
rule
);
return
t
;
});
return
{
data
:
data
};
};
const
columns
:
ProColumns
<
AlertRule
>
[]
=
[
...
...
@@ -114,7 +109,6 @@ const AlertRuleList: React.FC = () => {
disabled=
{
!
HasAuthority
(
PermissionConstants
.
REGISTRATION_ALERT_RULE_EDIT
)
}
onChange=
{
async
()
=>
{
record
.
enabled
=
!
record
.
enabled
;
record
.
rule
=
JSON
.
stringify
(
record
.
rule
);
await
handleSubmit
(
record
);
}
}
/>
...
...
dinky-web/src/pages/RegCenter/DataSource/components/function.tsx
View file @
d33d97f6
...
...
@@ -31,6 +31,7 @@ import {
StarRocksIcons
}
from
'@/components/Icons/DBIcons'
;
import
{
QUERY_KEYWORD
}
from
'@/pages/RegCenter/DataSource/components/constants'
;
import
{
DIALECT
}
from
'@/services/constants'
;
/**
* render DB icon
...
...
@@ -39,35 +40,34 @@ import { QUERY_KEYWORD } from '@/pages/RegCenter/DataSource/components/constants
*/
export
const
renderDBIcon
=
(
type
:
string
,
size
?:
number
)
=>
{
switch
(
type
.
toLowerCase
())
{
case
'mysql'
:
case
DIALECT
.
MYSQL
:
return
<
MysqlIcons
size=
{
size
}
/>;
case
'oracle'
:
case
DIALECT
.
ORACLE
:
return
<
OracleIcons
size=
{
size
}
/>;
case
'postgresql'
:
case
DIALECT
.
POSTGRESQL
:
return
<
PostgresqlIcons
size=
{
size
}
/>;
case
'clickhouse'
:
case
DIALECT
.
CLICKHOUSE
:
return
<
ClickHouseIcons
size=
{
size
}
/>;
case
'sqlserver'
:
case
DIALECT
.
SQLSERVER
:
return
<
SqlServerIcons
size=
{
size
}
/>;
case
'doris'
:
case
DIALECT
.
DORIS
:
return
<
DorisIcons
size=
{
size
}
/>;
case
'phoenix'
:
case
DIALECT
.
PHOENIX
:
return
<
PhoenixIcons
size=
{
size
}
/>;
case
'hive'
:
case
DIALECT
.
HIVE
:
return
<
HiveIcons
size=
{
size
}
/>;
case
'starrocks'
:
case
DIALECT
.
STARROCKS
:
return
<
StarRocksIcons
size=
{
size
}
/>;
case
'presto'
:
case
DIALECT
.
PRESTO
:
return
<
PrestoIcons
size=
{
size
}
/>;
default
:
return
<
DefaultDBIcons
size=
{
size
}
/>;
}
};
export
const
buildColumnsQueryKeyWord
=
(
data
:
string
[])
=>
{
const
result
=
data
.
concat
(
QUERY_KEYWORD
).
map
((
item
:
string
|
number
)
=>
({
export
const
buildColumnsQueryKeyWord
=
(
data
:
string
[]
=
[]
)
=>
{
return
data
.
concat
(
QUERY_KEYWORD
).
map
((
item
:
string
|
number
)
=>
({
value
:
item
,
label
:
item
}));
return
result
;
};
dinky-web/src/types/SettingCenter/data.d.ts
View file @
d33d97f6
...
...
@@ -55,10 +55,18 @@ export type AlertRule = {
description
:
string
;
ruleType
:
string
;
triggerConditions
:
string
;
rule
:
any
;
rule
:
AlertRuleCondition
[]
;
enabled
:
boolean
;
};
// [{"ruleKey":"jobStatus","ruleOperator":"EQ","ruleValue":"'FAILED'","rulePriority":"1"}]
export
type
AlertRuleCondition
=
{
ruleKey
:
string
;
ruleOperator
:
string
;
ruleValue
:
string
;
rulePriority
?:
number
;
}
// ============================ System Settings ============================
export
type
Settings
=
{
dolphinscheduler
:
BaseConfigProperties
[];
...
...
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