Unverified Commit d33d97f6 authored by Zzm0809's avatar Zzm0809 Committed by GitHub

Optimize some judgment logic and alert rule logic (#3591)

parent 1166b336
...@@ -89,9 +89,9 @@ public class AlertRuleController { ...@@ -89,9 +89,9 @@ public class AlertRuleController {
boolean saved = alertRuleService.saveOrUpdate(alertRule); boolean saved = alertRuleService.saveOrUpdate(alertRule);
if (saved) { if (saved) {
JobAlertHandler.getInstance().refreshRulesData(); 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 @DeleteMapping
......
...@@ -19,8 +19,12 @@ ...@@ -19,8 +19,12 @@
package org.dinky.data.model.alert; package org.dinky.data.model.alert;
import org.dinky.data.typehandler.ListTypeHandler;
import org.dinky.mybatis.model.SuperEntity; import org.dinky.mybatis.model.SuperEntity;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
...@@ -38,8 +42,9 @@ import lombok.NoArgsConstructor; ...@@ -38,8 +42,9 @@ import lombok.NoArgsConstructor;
@ApiModel(value = "AlertRule", description = "AlertRule") @ApiModel(value = "AlertRule", description = "AlertRule")
public class AlertRule extends SuperEntity<AlertRule> { public class AlertRule extends SuperEntity<AlertRule> {
@ApiModelProperty(value = "rule", required = true, dataType = "String", example = "rule") @ApiModelProperty(value = "rule", required = true, dataType = "List<AlertTriggerRule>", example = "rule")
String rule; @TableField(typeHandler = ListTypeHandler.class)
List<AlertTriggerRule> rule;
@ApiModelProperty(value = "templateId", required = true, dataType = "int", example = "1") @ApiModelProperty(value = "templateId", required = true, dataType = "int", example = "1")
int templateId; int templateId;
......
/*
*
* 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;
}
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
*/ */
import { import {
assert,
getCurrentData, getCurrentData,
getCurrentTab, getCurrentTab,
isDataStudioTabsItemType, isDataStudioTabsItemType,
...@@ -135,7 +136,7 @@ const Result = (props: any) => { ...@@ -135,7 +136,7 @@ const Result = (props: any) => {
} else if (consoleData.results && !isRefresh) { } else if (consoleData.results && !isRefresh) {
setDataList(consoleData.results); setDataList(consoleData.results);
} else { } else {
if (current?.dialect && current?.dialect?.toLowerCase() == DIALECT.FLINK_SQL) { if (assert(current?.dialect, [DIALECT.FLINK_SQL], true, 'includes')) {
// flink sql // flink sql
// to do: get job data by history id list, not flink jid // to do: get job data by history id list, not flink jid
if (current?.id) { if (current?.id) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import { TabsPageType, TaskDataType } from '@/pages/DataStudio/model'; import { TabsPageType, TaskDataType } from '@/pages/DataStudio/model';
import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants'; import { JOB_LIFE_CYCLE } from '@/pages/DevOps/constants';
import { DIALECT } from '@/services/constants'; import { DIALECT } from '@/services/constants';
import { assert } from '@/pages/DataStudio/function';
/** /**
* @description: 生成面包屑 * @description: 生成面包屑
...@@ -46,15 +47,22 @@ export const isOnline = (data: TaskDataType | undefined) => { ...@@ -46,15 +47,22 @@ export const isOnline = (data: TaskDataType | undefined) => {
export const isCanPushDolphin = (data: TaskDataType | undefined) => { export const isCanPushDolphin = (data: TaskDataType | undefined) => {
return data return data
? JOB_LIFE_CYCLE.PUBLISH === data.step && ? JOB_LIFE_CYCLE.PUBLISH === data.step &&
data?.dialect?.toLowerCase() !== DIALECT.FLINKSQLENV && assert(
data?.dialect?.toLowerCase() !== DIALECT.SCALA && data?.dialect,
data?.dialect?.toLowerCase() !== DIALECT.JAVA && [DIALECT.FLINKSQLENV, DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG],
data?.dialect?.toLowerCase() !== DIALECT.PYTHON_LONG true,
'notIncludes'
)
: false; : 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; return false;
} }
switch (dialect.toLowerCase()) { switch (dialect.toLowerCase()) {
......
...@@ -22,8 +22,10 @@ import { PushpinIcon } from '@/components/Icons/CustomIcons'; ...@@ -22,8 +22,10 @@ import { PushpinIcon } from '@/components/Icons/CustomIcons';
import { FlexCenterDiv } from '@/components/StyledComponents'; import { FlexCenterDiv } from '@/components/StyledComponents';
import { LeftBottomKey } from '@/pages/DataStudio/data.d'; import { LeftBottomKey } from '@/pages/DataStudio/data.d';
import { import {
assert,
getCurrentData, getCurrentData,
getCurrentTab, getCurrentTab,
isNotEmpty,
lockTask, lockTask,
mapDispatchToProps mapDispatchToProps
} from '@/pages/DataStudio/function'; } from '@/pages/DataStudio/function';
...@@ -373,9 +375,8 @@ const HeaderContainer = (props: connect) => { ...@@ -373,9 +375,8 @@ const HeaderContainer = (props: connect) => {
icon: <ApartmentOutlined />, icon: <ApartmentOutlined />,
title: l('button.graph'), title: l('button.graph'),
isShow: isShow:
(projectCommonShow(currentTab?.type) && projectCommonShow(currentTab?.type) &&
currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL) || assert(currentTab?.subType, [DIALECT.FLINK_SQL, DIALECT.FLINKJAR], true, 'includes'),
currentTab?.subType?.toLowerCase() === DIALECT.FLINKJAR,
click: async () => showDagGraph(), click: async () => showDagGraph(),
props: { props: {
disabled: isLockTask disabled: isLockTask
...@@ -391,9 +392,13 @@ const HeaderContainer = (props: connect) => { ...@@ -391,9 +392,13 @@ const HeaderContainer = (props: connect) => {
click: () => showExplain(), click: () => showExplain(),
isShow: isShow:
projectCommonShow(currentTab?.type) && projectCommonShow(currentTab?.type) &&
currentTab?.subType?.toLowerCase() !== DIALECT.JAVA && assert(
currentTab?.subType?.toLowerCase() !== DIALECT.SCALA && currentTab?.subType,
currentTab?.subType?.toLowerCase() !== DIALECT.PYTHON_LONG, [DIALECT.JAVA, DIALECT.SCALA, DIALECT.PYTHON_LONG],
true,
'notIncludes'
) &&
!isSql(currentTab?.subType),
props: { props: {
disabled: isLockTask disabled: isLockTask
} }
...@@ -414,7 +419,7 @@ const HeaderContainer = (props: connect) => { ...@@ -414,7 +419,7 @@ const HeaderContainer = (props: connect) => {
// 发布按钮 // 发布按钮
icon: isOnline(currentData) ? <MergeCellsOutlined /> : <FundOutlined />, icon: isOnline(currentData) ? <MergeCellsOutlined /> : <FundOutlined />,
title: isOnline(currentData) ? l('button.offline') : l('button.publish'), title: isOnline(currentData) ? l('button.offline') : l('button.publish'),
isShow: currentTab?.type == TabsPageType.project, isShow: assert(currentTab?.type, TabsPageType.project, true, 'equal'),
click: () => handleChangeJobLife(), click: () => handleChangeJobLife(),
props: { props: {
disabled: isLockTask disabled: isLockTask
...@@ -425,10 +430,10 @@ const HeaderContainer = (props: connect) => { ...@@ -425,10 +430,10 @@ const HeaderContainer = (props: connect) => {
icon: <RotateRightOutlined />, icon: <RotateRightOutlined />,
title: l('pages.datastudio.to.jobDetail'), title: l('pages.datastudio.to.jobDetail'),
isShow: isShow:
currentTab?.type == TabsPageType.project && isNotEmpty(currentData?.jobInstanceId) &&
currentData?.jobInstanceId && !isSql(currentTab?.subType) &&
(currentTab?.subType?.toLowerCase() == DIALECT.FLINK_SQL || assert(currentTab?.subType, [DIALECT.FLINK_SQL, DIALECT.FLINKJAR], true, 'includes') &&
currentTab?.subType?.toLowerCase() == DIALECT.FLINKJAR), assert(currentTab?.type, TabsPageType.project, true, 'equal'),
props: { props: {
onClick: async () => { onClick: async () => {
const dataByParams = await queryDataByParams<Jobs.JobInstance>( const dataByParams = await queryDataByParams<Jobs.JobInstance>(
...@@ -451,12 +456,14 @@ const HeaderContainer = (props: connect) => { ...@@ -451,12 +456,14 @@ const HeaderContainer = (props: connect) => {
hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F10', hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F10',
hotKeyDesc: 'Shift+F10', hotKeyDesc: 'Shift+F10',
isShow: isShow:
currentTab?.type == TabsPageType.project && assert(currentTab?.type, TabsPageType.project, true, 'equal') &&
isStatusDone(currentData?.status) && isStatusDone(currentData?.status) &&
currentTab?.subType?.toLowerCase() !== DIALECT.JAVA && assert(
currentTab?.subType?.toLowerCase() !== DIALECT.SCALA && currentTab?.subType,
currentTab?.subType?.toLowerCase() !== DIALECT.PYTHON_LONG && [DIALECT.JAVA, DIALECT.SCALA, DIALECT.PYTHON_LONG, DIALECT.FLINKSQLENV],
currentTab?.subType?.toLowerCase() !== DIALECT.FLINKSQLENV, true,
'notIncludes'
),
props: { props: {
style: { background: '#52c41a' }, style: { background: '#52c41a' },
type: 'primary', type: 'primary',
...@@ -471,10 +478,10 @@ const HeaderContainer = (props: connect) => { ...@@ -471,10 +478,10 @@ const HeaderContainer = (props: connect) => {
hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F9', hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F9',
hotKeyDesc: 'Shift+F9', hotKeyDesc: 'Shift+F9',
isShow: isShow:
currentTab?.type == TabsPageType.project && assert(currentTab?.type, TabsPageType.project, true, 'equal') &&
isStatusDone(currentData?.status) && isStatusDone(currentData?.status) &&
(currentTab?.subType?.toLowerCase() === DIALECT.FLINK_SQL || !isSql(currentTab?.subType) &&
isSql(currentTab?.subType?.toLowerCase() ?? '')), assert(currentTab?.subType, [DIALECT.FLINK_SQL], true, 'includes'),
props: { props: {
style: { background: '#52c41a' }, style: { background: '#52c41a' },
type: 'primary', type: 'primary',
...@@ -486,7 +493,9 @@ const HeaderContainer = (props: connect) => { ...@@ -486,7 +493,9 @@ const HeaderContainer = (props: connect) => {
icon: <PauseOutlined />, icon: <PauseOutlined />,
title: l('pages.datastudio.editor.stop'), title: l('pages.datastudio.editor.stop'),
click: handlerStop, 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', hotKey: (e: KeyboardEvent) => e.shiftKey && e.key === 'F10',
hotKeyDesc: 'Shift+F10', hotKeyDesc: 'Shift+F10',
props: { props: {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
*/ */
import { LeftBottomKey, RightMenuKey } from '@/pages/DataStudio/data.d'; 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 { isSql } from '@/pages/DataStudio/HeaderContainer/function';
import { getTabIcon } from '@/pages/DataStudio/MiddleContainer/function'; import { getTabIcon } from '@/pages/DataStudio/MiddleContainer/function';
import { DIALECT } from '@/services/constants'; import { DIALECT } from '@/services/constants';
...@@ -323,15 +323,11 @@ export const buildProjectTree = ( ...@@ -323,15 +323,11 @@ export const buildProjectTree = (
: []; : [];
export const isUDF = (jobType: string): boolean => { export const isUDF = (jobType: string): boolean => {
return ( return assert(jobType, [DIALECT.SCALA, DIALECT.PYTHON_LONG, DIALECT.JAVA], true, 'includes');
jobType.toLowerCase() === DIALECT.SCALA ||
jobType.toLowerCase() === DIALECT.PYTHON_LONG ||
jobType.toLowerCase() === DIALECT.JAVA
);
}; };
export const isFlinkJob = (jobType: string): boolean => { 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 { export function getRightSelectKeyFromNodeClickJobType(jobType: string): string {
......
...@@ -18,14 +18,17 @@ ...@@ -18,14 +18,17 @@
*/ */
import RightContextMenu from '@/components/RightContextMenu'; 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 { useTasksDispatch } from '@/pages/DataStudio/LeftContainer/BtnContext';
import { import {
FOLDER_RIGHT_MENU, FOLDER_RIGHT_MENU,
JOB_RIGHT_MENU JOB_RIGHT_MENU
} from '@/pages/DataStudio/LeftContainer/Project/constants'; } from '@/pages/DataStudio/LeftContainer/Project/constants';
import FolderModal from '@/pages/DataStudio/LeftContainer/Project/FolderModal'; 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 JobModal from '@/pages/DataStudio/LeftContainer/Project/JobModal';
import JobTree from '@/pages/DataStudio/LeftContainer/Project/JobTree'; import JobTree from '@/pages/DataStudio/LeftContainer/Project/JobTree';
import { import {
...@@ -146,6 +149,13 @@ const Project: React.FC = (props: connect) => { ...@@ -146,6 +149,13 @@ const Project: React.FC = (props: connect) => {
type: STUDIO_MODEL.updateSelectRightKey, type: STUDIO_MODEL.updateSelectRightKey,
payload: getRightSelectKeyFromNodeClickJobType(type) 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({ dispatch({
...@@ -213,7 +223,7 @@ const Project: React.FC = (props: connect) => { ...@@ -213,7 +223,7 @@ const Project: React.FC = (props: connect) => {
() => {}, () => {},
() => { () => {
dispatch({ type: STUDIO_MODEL_ASYNC.queryProject, payload: selectCatalogueSortTypeData }); 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 }); dispatch({ type: STUDIO_MODEL_ASYNC.queryEnv });
} }
if (projectState.isEdit) { if (projectState.isEdit) {
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
import FlinkOptionsSelect from '@/components/Flink/OptionsSelect'; import FlinkOptionsSelect from '@/components/Flink/OptionsSelect';
import { SAVE_POINT_TYPE } from '@/pages/DataStudio/constants'; import { SAVE_POINT_TYPE } from '@/pages/DataStudio/constants';
import { import {
assert,
getCurrentData, getCurrentData,
getCurrentTab, getCurrentTab,
isDataStudioTabsItemType, isDataStudioTabsItemType,
...@@ -121,10 +122,12 @@ const JobConfig = (props: any) => { ...@@ -121,10 +122,12 @@ const JobConfig = (props: any) => {
Object.keys(change).forEach((key) => { Object.keys(change).forEach((key) => {
if (key === 'configJson') { if (key === 'configJson') {
if (!pane.params.taskData.configJson) { if (!pane.params.taskData.configJson) {
// @ts-ignore
pane.params.taskData.configJson = {}; pane.params.taskData.configJson = {};
} }
Object.keys(change[key]).forEach((k) => { Object.keys(change[key]).forEach((k) => {
// @ts-ignore
pane.params.taskData[key][k] = all[key][k]; pane.params.taskData[key][k] = all[key][k];
}); });
} else { } else {
...@@ -315,7 +318,7 @@ const JobConfig = (props: any) => { ...@@ -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 <ProFormSelect
name='envId' name='envId'
label={l('pages.datastudio.label.jobConfig.flinksql.env')} label={l('pages.datastudio.label.jobConfig.flinksql.env')}
......
...@@ -211,11 +211,11 @@ export function isProjectTabs(panes: TabsItemType[], activeKey: string): boolean ...@@ -211,11 +211,11 @@ export function isProjectTabs(panes: TabsItemType[], activeKey: string): boolean
} }
export function isShowRightTabsJobConfig(dialect: string): boolean { export function isShowRightTabsJobConfig(dialect: string): boolean {
return ( return assert(
dialect.toLowerCase() === DIALECT.JAVA || dialect,
dialect.toLowerCase() === DIALECT.PYTHON_LONG || [DIALECT.JAVA, DIALECT.PYTHON_LONG, DIALECT.SCALA, DIALECT.FLINKSQLENV],
dialect.toLowerCase() === DIALECT.SCALA || true,
dialect.toLowerCase() === DIALECT.FLINKSQLENV 'includes'
); );
} }
...@@ -331,3 +331,64 @@ export const lockTask = ( ...@@ -331,3 +331,64 @@ export const lockTask = (
return false; 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);
};
...@@ -57,6 +57,7 @@ import { ...@@ -57,6 +57,7 @@ import {
} from '@ant-design/icons'; } from '@ant-design/icons';
import { TabPaneProps } from 'antd'; import { TabPaneProps } from 'antd';
import React, { ReactNode } from 'react'; import React, { ReactNode } from 'react';
import { assert } from '@/pages/DataStudio/function';
export const LeftSide: TabProp[] = [ export const LeftSide: TabProp[] = [
{ {
...@@ -73,13 +74,13 @@ export const LeftSide: TabProp[] = [ ...@@ -73,13 +74,13 @@ export const LeftSide: TabProp[] = [
label: l(LeftMenuKey.CATALOG_KEY), label: l(LeftMenuKey.CATALOG_KEY),
children: <Catalog />, children: <Catalog />,
isShow: (type, subType) => isShow: (type, subType) =>
(type === TabsPageType.project || type === TabsPageType.metadata) && assert(type, [TabsPageType.project, TabsPageType.metadata], true, 'includes') &&
subType?.toLowerCase() !== DIALECT.FLINKJAR && assert(
subType?.toLowerCase() !== DIALECT.FLINKSQLENV && subType,
subType?.toLowerCase() !== DIALECT.SCALA && [DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG, DIALECT.FLINKSQLENV, DIALECT.FLINKJAR],
subType?.toLowerCase() !== DIALECT.PYTHON_LONG && true,
subType?.toLowerCase() !== DIALECT.JAVA && 'notIncludes'
subType?.toLowerCase() !== DIALECT.FLINKSQLENV )
}, },
{ {
auth: PermissionConstants.DATASTUDIO_LEFT_DATASOURCE, auth: PermissionConstants.DATASTUDIO_LEFT_DATASOURCE,
...@@ -95,11 +96,9 @@ export const LeftSide: TabProp[] = [ ...@@ -95,11 +96,9 @@ export const LeftSide: TabProp[] = [
label: l(LeftMenuKey.FRAGMENT_KEY), label: l(LeftMenuKey.FRAGMENT_KEY),
children: <GlobalVariable />, children: <GlobalVariable />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
!isSql(subType ?? '') && !isSql(subType) &&
subType?.toLowerCase() !== DIALECT.SCALA && assert(subType, [DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG], true, 'notIncludes')
subType?.toLowerCase() !== DIALECT.PYTHON_LONG &&
subType?.toLowerCase() !== DIALECT.JAVA
} }
]; ];
...@@ -111,8 +110,8 @@ export const RightSide: TabProp[] = [ ...@@ -111,8 +110,8 @@ export const RightSide: TabProp[] = [
label: l(RightMenuKey.JOB_CONFIG_KEY), label: l(RightMenuKey.JOB_CONFIG_KEY),
children: <JobConfig />, children: <JobConfig />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
(TabsPageSubType.flinkSql === subType || TabsPageSubType.flinkJar === subType) assert(subType, [TabsPageSubType.flinkSql, TabsPageSubType.flinkJar], true, 'includes')
}, },
{ {
auth: PermissionConstants.DATASTUDIO_RIGHT_PREVIEW_CONFIG, auth: PermissionConstants.DATASTUDIO_RIGHT_PREVIEW_CONFIG,
...@@ -121,8 +120,9 @@ export const RightSide: TabProp[] = [ ...@@ -121,8 +120,9 @@ export const RightSide: TabProp[] = [
label: l(RightMenuKey.PREVIEW_CONFIG_KEY), label: l(RightMenuKey.PREVIEW_CONFIG_KEY),
children: <PreViewConfig />, children: <PreViewConfig />,
isShow: (type, subType) => isShow: (type, subType) =>
(type === TabsPageType.project && TabsPageSubType.flinkSql === subType) || (assert(type, TabsPageType.project, true, 'equal') &&
isSql(subType ?? '') assert(subType, [TabsPageSubType.flinkSql], true, 'includes')) ||
isSql(subType)
}, },
{ {
auth: PermissionConstants.DATASTUDIO_RIGHT_SAVE_POINT, auth: PermissionConstants.DATASTUDIO_RIGHT_SAVE_POINT,
...@@ -130,7 +130,9 @@ export const RightSide: TabProp[] = [ ...@@ -130,7 +130,9 @@ export const RightSide: TabProp[] = [
icon: <FolderOutlined />, icon: <FolderOutlined />,
label: l(RightMenuKey.SAVEPOINT_KEY), label: l(RightMenuKey.SAVEPOINT_KEY),
children: <SavePoints />, 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, auth: PermissionConstants.DATASTUDIO_RIGHT_HISTORY_VISION,
...@@ -138,7 +140,9 @@ export const RightSide: TabProp[] = [ ...@@ -138,7 +140,9 @@ export const RightSide: TabProp[] = [
icon: <HistoryOutlined />, icon: <HistoryOutlined />,
label: l(RightMenuKey.HISTORY_VISION_KEY), label: l(RightMenuKey.HISTORY_VISION_KEY),
children: <HistoryVersion />, 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, auth: PermissionConstants.DATASTUDIO_RIGHT_JOB_INFO,
...@@ -146,7 +150,7 @@ export const RightSide: TabProp[] = [ ...@@ -146,7 +150,7 @@ export const RightSide: TabProp[] = [
icon: <InfoCircleOutlined />, icon: <InfoCircleOutlined />,
label: l(RightMenuKey.JOB_INFO_KEY), label: l(RightMenuKey.JOB_INFO_KEY),
children: <JobInfo />, children: <JobInfo />,
isShow: (type) => type === TabsPageType.project isShow: (type) => assert(type, TabsPageType.project, true, 'equal')
} }
]; ];
...@@ -158,11 +162,13 @@ export const LeftBottomSide: TabProp[] = [ ...@@ -158,11 +162,13 @@ export const LeftBottomSide: TabProp[] = [
label: l(LeftBottomKey.CONSOLE_KEY), label: l(LeftBottomKey.CONSOLE_KEY),
children: <Console />, children: <Console />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
subType?.toLowerCase() !== DIALECT.FLINKSQLENV && assert(
subType?.toLowerCase() !== DIALECT.SCALA && subType,
subType?.toLowerCase() !== DIALECT.PYTHON_LONG && [DIALECT.FLINKSQLENV, DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG],
subType?.toLowerCase() !== DIALECT.JAVA true,
'notIncludes'
)
}, },
{ {
auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_RESULT, auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_RESULT,
...@@ -171,12 +177,13 @@ export const LeftBottomSide: TabProp[] = [ ...@@ -171,12 +177,13 @@ export const LeftBottomSide: TabProp[] = [
label: l(LeftBottomKey.RESULT_KEY), label: l(LeftBottomKey.RESULT_KEY),
children: <Result />, children: <Result />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
subType?.toLowerCase() !== DIALECT.FLINKSQLENV && assert(
subType?.toLowerCase() !== DIALECT.FLINKJAR && subType,
subType?.toLowerCase() !== DIALECT.SCALA && [DIALECT.FLINKSQLENV, DIALECT.FLINKJAR, DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG],
subType?.toLowerCase() !== DIALECT.PYTHON_LONG && true,
subType?.toLowerCase() !== DIALECT.JAVA 'notIncludes'
)
}, },
{ {
auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_LINEAGE, auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_LINEAGE,
...@@ -185,12 +192,13 @@ export const LeftBottomSide: TabProp[] = [ ...@@ -185,12 +192,13 @@ export const LeftBottomSide: TabProp[] = [
label: l(LeftBottomKey.LINEAGE_KEY), label: l(LeftBottomKey.LINEAGE_KEY),
children: <Lineage />, children: <Lineage />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
subType?.toLowerCase() !== DIALECT.FLINKSQLENV && assert(
subType?.toLowerCase() !== DIALECT.FLINKJAR && subType,
subType?.toLowerCase() !== DIALECT.SCALA && [DIALECT.FLINKSQLENV, DIALECT.FLINKJAR, DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG],
subType?.toLowerCase() !== DIALECT.PYTHON_LONG && true,
subType?.toLowerCase() !== DIALECT.JAVA 'notIncludes'
)
}, },
{ {
auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_HISTORY, auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_HISTORY,
...@@ -199,13 +207,14 @@ export const LeftBottomSide: TabProp[] = [ ...@@ -199,13 +207,14 @@ export const LeftBottomSide: TabProp[] = [
label: l(LeftBottomKey.HISTORY_KEY), label: l(LeftBottomKey.HISTORY_KEY),
children: <JobExecHistory />, children: <JobExecHistory />,
isShow: (type, subType) => isShow: (type, subType) =>
type === TabsPageType.project && assert(type, TabsPageType.project, true, 'equal') &&
!isSql(subType ?? '') && !isSql(subType) &&
subType?.toLowerCase() !== DIALECT.FLINKSQLENV && assert(
// subType?.toLowerCase() !== DIALECT.FLINKJAR && subType,
subType?.toLowerCase() !== DIALECT.SCALA && [DIALECT.FLINKSQLENV, DIALECT.SCALA, DIALECT.JAVA, DIALECT.PYTHON_LONG],
subType?.toLowerCase() !== DIALECT.PYTHON_LONG && true,
subType?.toLowerCase() !== DIALECT.JAVA 'notIncludes'
)
}, },
{ {
auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_TABLE_DATA, auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_TABLE_DATA,
...@@ -214,7 +223,8 @@ export const LeftBottomSide: TabProp[] = [ ...@@ -214,7 +223,8 @@ export const LeftBottomSide: TabProp[] = [
label: l(LeftBottomKey.TABLE_DATA_KEY), label: l(LeftBottomKey.TABLE_DATA_KEY),
children: <></>, children: <></>,
isShow: (type, subType) => 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, auth: PermissionConstants.DATASTUDIO_LEFT_BOTTOM_TOOL,
......
...@@ -22,6 +22,7 @@ import { ClusterType } from '@/pages/RegCenter/Cluster/constants'; ...@@ -22,6 +22,7 @@ import { ClusterType } from '@/pages/RegCenter/Cluster/constants';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { CheckboxOptionType } from 'antd/es/checkbox/Group'; import { CheckboxOptionType } from 'antd/es/checkbox/Group';
import { DefaultOptionType } from 'antd/es/select'; import { DefaultOptionType } from 'antd/es/select';
import {RUN_MODE} from "@/services/constants";
export enum RuleType { export enum RuleType {
SYSTEM = 'SYSTEM', SYSTEM = 'SYSTEM',
...@@ -40,19 +41,19 @@ export const TriggerType: CheckboxOptionType[] = [ ...@@ -40,19 +41,19 @@ export const TriggerType: CheckboxOptionType[] = [
]; ];
export const AllRuleOperator: DefaultOptionType[] = [ export const AllRuleOperator: DefaultOptionType[] = [
{ label: '>', value: 'GT' }, { label: '>', value: 'GT' , key: 'GT'},
{ label: '<', value: 'LT' }, { label: '<', value: 'LT' , key: 'LT' },
{ label: '=', value: 'EQ' }, { label: '=', value: 'EQ' , key: 'EQ' },
{ label: '!=', value: 'NE' }, { label: '!=', value: 'NE' , key: 'NE' },
{ label: '>=', value: 'GE' }, { label: '>=', value: 'GE' , key: 'GE' },
{ label: '<=', value: 'LE' } { 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[] = [ export const BOOLEAN_VALUE_ENUM: DefaultOptionType[] = [
{ label: 'True', value: 'true' }, { label: 'True', value: 'true' , key: 'true' },
{ label: 'False', value: 'false' } { label: 'False', value: 'false' , key: 'false' }
]; ];
export const AlertRules: any = { export const AlertRules: any = {
...@@ -77,7 +78,7 @@ export const AlertRules: any = { ...@@ -77,7 +78,7 @@ export const AlertRules: any = {
clusterType: { clusterType: {
label: l('sys.alert.rule.label.jobType'), label: l('sys.alert.rule.label.jobType'),
valueType: OperatorType.OPTIONS_SEL, valueType: OperatorType.OPTIONS_SEL,
valueEnum: Object.values(ClusterType).map((t) => `'${t}'`) valueEnum: Object.values(RUN_MODE).map((t) => `'${t}'`)
}, },
checkpointCostTime: { checkpointCostTime: {
label: l('sys.alert.rule.label.checkpointTime'), label: l('sys.alert.rule.label.checkpointTime'),
......
...@@ -33,7 +33,8 @@ export const AlertRulesOption = () => { ...@@ -33,7 +33,8 @@ export const AlertRulesOption = () => {
res.push({ res.push({
// @ts-ignore // @ts-ignore
label: v.label, label: v.label,
value: k value: k,
key: k,
}); });
} }
return res; return res;
...@@ -62,18 +63,22 @@ export const buildValueItem = (key: string, isSystem: boolean) => { ...@@ -62,18 +63,22 @@ export const buildValueItem = (key: string, isSystem: boolean) => {
name={'ruleValue'} name={'ruleValue'}
fieldProps={{ precision: 0 }} fieldProps={{ precision: 0 }}
placeholder={plh} placeholder={plh}
width={'sm'} width={'md'}
/> />
); );
case OperatorType.STR_VALUE: case OperatorType.STR_VALUE:
return ( return (
<ProFormText width={'sm'} disabled={isSystem} name={'ruleValue'} placeholder={plh} /> <ProFormText width={'md'} disabled={isSystem} name={'ruleValue'} placeholder={plh} />
); );
case OperatorType.OPTIONS_SEL: case OperatorType.OPTIONS_SEL:
return ( return (
<ProFormSelect <ProFormSelect
width={'sm'} width={'md'}
disabled={isSystem} disabled={isSystem}
fieldProps={{
defaultActiveFirstOption: true,
showSearch: true,
}}
name='ruleValue' name='ruleValue'
mode={'single'} mode={'single'}
placeholder={plh} placeholder={plh}
......
...@@ -17,23 +17,20 @@ ...@@ -17,23 +17,20 @@
* *
*/ */
import { Authorized } from '@/hooks/useAccess'; import {Authorized} from '@/hooks/useAccess';
import { import {RuleType, TriggerType} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants';
RuleType,
TriggerType
} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/constants';
import { import {
AlertRulesOption, AlertRulesOption,
buildValueItem, buildValueItem,
getOperatorOptions getOperatorOptions
} from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function'; } from '@/pages/RegCenter/Alert/AlertRule/AlertRuleList/RuleEditForm/function';
import { getData } from '@/services/api'; import {getData} from '@/services/api';
import { SWITCH_OPTIONS } from '@/services/constants'; import {SWITCH_OPTIONS} from '@/services/constants';
import { API_CONSTANTS } from '@/services/endpoints'; import {API_CONSTANTS} from '@/services/endpoints';
import { Alert } from '@/types/RegCenter/data'; import {Alert} from '@/types/RegCenter/data';
import { AlertRule } from '@/types/SettingCenter/data'; import {AlertRule, AlertRuleCondition} from '@/types/SettingCenter/data';
import { l } from '@/utils/intl'; import {l} from '@/utils/intl';
import { import {
DrawerForm, DrawerForm,
ProCard, ProCard,
...@@ -46,10 +43,10 @@ import { ...@@ -46,10 +43,10 @@ import {
ProFormText, ProFormText,
ProFormTextArea ProFormTextArea
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { ProFormDependency } from '@ant-design/pro-form'; import {ProFormDependency} from '@ant-design/pro-form';
import { Button, Divider, Form, Space, Typography } from 'antd'; import {Button, Divider, Form, Space, Typography} from 'antd';
const { Link } = Typography; const {Link} = Typography;
type AlertRuleFormProps = { type AlertRuleFormProps = {
onCancel: (flag?: boolean) => void; onCancel: (flag?: boolean) => void;
...@@ -59,7 +56,7 @@ type AlertRuleFormProps = { ...@@ -59,7 +56,7 @@ type AlertRuleFormProps = {
}; };
const RuleEditForm = (props: AlertRuleFormProps) => { const RuleEditForm = (props: AlertRuleFormProps) => {
const { onSubmit: handleSubmit, onCancel: handleModalVisible, modalVisible, values } = props; const {onSubmit: handleSubmit, onCancel: handleModalVisible, modalVisible, values} = props;
// if is system rule disable edit // if is system rule disable edit
const isSystem = values.ruleType == RuleType.SYSTEM; const isSystem = values.ruleType == RuleType.SYSTEM;
...@@ -68,12 +65,12 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -68,12 +65,12 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
const getAlertTemplate = async () => { const getAlertTemplate = async () => {
const template: Alert.AlertTemplate[] = (await getData(API_CONSTANTS.ALERT_TEMPLATE)).data; const template: Alert.AlertTemplate[] = (await getData(API_CONSTANTS.ALERT_TEMPLATE)).data;
return template.map((t) => ({ label: t.name, value: t.id })); return template.map((t) => ({label: t.name, value: t.id}));
}; };
const submit = async () => { const submit = async () => {
const fieldsValue = await form.validateFields(); const fieldsValue = await form.validateFields();
return handleSubmit({ ...fieldsValue, rule: JSON.stringify(fieldsValue.rule) }); return handleSubmit({...values,...fieldsValue});
}; };
const renderTemplateDropDown = (item: any) => { const renderTemplateDropDown = (item: any) => {
...@@ -82,7 +79,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -82,7 +79,7 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
{item} {item}
<Authorized key='create' path='/registration/alert/template/add'> <Authorized key='create' path='/registration/alert/template/add'>
<> <>
<Divider style={{ margin: '8px 0' }} /> <Divider style={{margin: '8px 0'}}/>
<Link href={'#/registration/alert/template'}>+ {l('rc.alert.template.new')}</Link> <Link href={'#/registration/alert/template'}>+ {l('rc.alert.template.new')}</Link>
</> </>
</Authorized> </Authorized>
...@@ -111,8 +108,9 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -111,8 +108,9 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
<DrawerForm <DrawerForm
layout={'vertical'} layout={'vertical'}
form={form} form={form}
width={'40%'}
open={modalVisible} open={modalVisible}
submitter={{ render: () => [...renderFooter()] }} submitter={{render: () => [...renderFooter()]}}
drawerProps={{ drawerProps={{
onClose: () => handleModalVisible(false), onClose: () => handleModalVisible(false),
destroyOnClose: true destroyOnClose: true
...@@ -120,11 +118,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -120,11 +118,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
initialValues={values} initialValues={values}
> >
<ProFormGroup> <ProFormGroup>
<ProFormText name='id' hidden={true} /> <ProFormText name='id' hidden={true}/>
<ProFormText name='ruleType' hidden={true} /> <ProFormText name='ruleType' hidden={true}/>
<ProFormText <ProFormText
disabled={isSystem} disabled={isSystem}
rules={[{ required: true }]} rules={[{required: true}]}
name='name' name='name'
width='md' width='md'
label={l('sys.alert.rule.name')} label={l('sys.alert.rule.name')}
...@@ -137,14 +135,14 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -137,14 +135,14 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
name='templateId' name='templateId'
request={async () => getAlertTemplate()} request={async () => getAlertTemplate()}
placeholder={l('sys.alert.rule.template')} placeholder={l('sys.alert.rule.template')}
rules={[{ required: true, message: l('sys.alert.rule.template') }]} rules={[{required: true, message: l('sys.alert.rule.template')}]}
fieldProps={{ dropdownRender: (item) => renderTemplateDropDown(item) }} fieldProps={{dropdownRender: (item) => renderTemplateDropDown(item)}}
/> />
</ProFormGroup> </ProFormGroup>
<ProFormGroup> <ProFormGroup>
<ProFormTextArea width='md' name='description' label={l('global.table.note')} /> <ProFormTextArea width='md' name='description' label={l('global.table.note')}/>
<ProFormSwitch name='enabled' {...SWITCH_OPTIONS()} label={l('global.table.isEnable')} /> <ProFormSwitch name='enabled' {...SWITCH_OPTIONS()} label={l('global.table.isEnable')}/>
</ProFormGroup> </ProFormGroup>
<Divider orientation={'left'}>{l('sys.alert.rule.trigger')}</Divider> <Divider orientation={'left'}>{l('sys.alert.rule.trigger')}</Divider>
...@@ -153,11 +151,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => { ...@@ -153,11 +151,11 @@ const RuleEditForm = (props: AlertRuleFormProps) => {
disabled={isSystem} disabled={isSystem}
name='triggerConditions' name='triggerConditions'
label={l('sys.alert.rule.triggerConditions')} label={l('sys.alert.rule.triggerConditions')}
rules={[{ required: true }]} rules={[{required: true}]}
options={TriggerType} options={TriggerType}
/> />
<ProFormList <ProFormList<AlertRuleCondition>
name='rule' name='rule'
label={l('sys.alert.rule.triggerRule')} label={l('sys.alert.rule.triggerRule')}
creatorButtonProps={ creatorButtonProps={
......
...@@ -69,16 +69,11 @@ const AlertRuleList: React.FC = () => { ...@@ -69,16 +69,11 @@ const AlertRuleList: React.FC = () => {
} }
const initData = async (params: any, sorter: any, filter: any) => { 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, ...params,
sorter, sorter,
filter filter
}); });
const data = result.data.map((t: AlertRule) => {
t.rule = JSON.parse(t.rule);
return t;
});
return { data: data };
}; };
const columns: ProColumns<AlertRule>[] = [ const columns: ProColumns<AlertRule>[] = [
...@@ -114,7 +109,6 @@ const AlertRuleList: React.FC = () => { ...@@ -114,7 +109,6 @@ const AlertRuleList: React.FC = () => {
disabled={!HasAuthority(PermissionConstants.REGISTRATION_ALERT_RULE_EDIT)} disabled={!HasAuthority(PermissionConstants.REGISTRATION_ALERT_RULE_EDIT)}
onChange={async () => { onChange={async () => {
record.enabled = !record.enabled; record.enabled = !record.enabled;
record.rule = JSON.stringify(record.rule);
await handleSubmit(record); await handleSubmit(record);
}} }}
/> />
......
...@@ -31,6 +31,7 @@ import { ...@@ -31,6 +31,7 @@ import {
StarRocksIcons StarRocksIcons
} from '@/components/Icons/DBIcons'; } from '@/components/Icons/DBIcons';
import { QUERY_KEYWORD } from '@/pages/RegCenter/DataSource/components/constants'; import { QUERY_KEYWORD } from '@/pages/RegCenter/DataSource/components/constants';
import { DIALECT } from '@/services/constants';
/** /**
* render DB icon * render DB icon
...@@ -39,35 +40,34 @@ import { QUERY_KEYWORD } from '@/pages/RegCenter/DataSource/components/constants ...@@ -39,35 +40,34 @@ import { QUERY_KEYWORD } from '@/pages/RegCenter/DataSource/components/constants
*/ */
export const renderDBIcon = (type: string, size?: number) => { export const renderDBIcon = (type: string, size?: number) => {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case 'mysql': case DIALECT.MYSQL:
return <MysqlIcons size={size} />; return <MysqlIcons size={size} />;
case 'oracle': case DIALECT.ORACLE:
return <OracleIcons size={size} />; return <OracleIcons size={size} />;
case 'postgresql': case DIALECT.POSTGRESQL:
return <PostgresqlIcons size={size} />; return <PostgresqlIcons size={size} />;
case 'clickhouse': case DIALECT.CLICKHOUSE:
return <ClickHouseIcons size={size} />; return <ClickHouseIcons size={size} />;
case 'sqlserver': case DIALECT.SQLSERVER:
return <SqlServerIcons size={size} />; return <SqlServerIcons size={size} />;
case 'doris': case DIALECT.DORIS:
return <DorisIcons size={size} />; return <DorisIcons size={size} />;
case 'phoenix': case DIALECT.PHOENIX:
return <PhoenixIcons size={size} />; return <PhoenixIcons size={size} />;
case 'hive': case DIALECT.HIVE:
return <HiveIcons size={size} />; return <HiveIcons size={size} />;
case 'starrocks': case DIALECT.STARROCKS:
return <StarRocksIcons size={size} />; return <StarRocksIcons size={size} />;
case 'presto': case DIALECT.PRESTO:
return <PrestoIcons size={size} />; return <PrestoIcons size={size} />;
default: default:
return <DefaultDBIcons size={size} />; return <DefaultDBIcons size={size} />;
} }
}; };
export const buildColumnsQueryKeyWord = (data: string[]) => { export const buildColumnsQueryKeyWord = (data: string[] = []) => {
const result = data.concat(QUERY_KEYWORD).map((item: string | number) => ({ return data.concat(QUERY_KEYWORD).map((item: string | number) => ({
value: item, value: item,
label: item label: item
})); }));
return result;
}; };
...@@ -55,10 +55,18 @@ export type AlertRule = { ...@@ -55,10 +55,18 @@ export type AlertRule = {
description: string; description: string;
ruleType: string; ruleType: string;
triggerConditions: string; triggerConditions: string;
rule: any; rule: AlertRuleCondition[];
enabled: boolean; enabled: boolean;
}; };
// [{"ruleKey":"jobStatus","ruleOperator":"EQ","ruleValue":"'FAILED'","rulePriority":"1"}]
export type AlertRuleCondition = {
ruleKey: string;
ruleOperator: string;
ruleValue: string;
rulePriority?: number;
}
// ============================ System Settings ============================ // ============================ System Settings ============================
export type Settings = { export type Settings = {
dolphinscheduler: BaseConfigProperties[]; dolphinscheduler: BaseConfigProperties[];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment