Unverified Commit 566be090 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor][admin,web] refactor alert group (#1895)

* refactor alert group * added delete alert group and cascade delete alert history * modify note * modify some code
parent e9a68005
......@@ -25,6 +25,7 @@ import org.dinky.model.AlertGroup;
import org.dinky.model.AlertHistory;
import org.dinky.service.AlertGroupService;
import org.dinky.service.AlertHistoryService;
import org.dinky.utils.MessageResolverUtils;
import java.util.ArrayList;
import java.util.List;
......@@ -35,6 +36,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -42,11 +44,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/**
* AlertGroupController
*
* @since 2022/2/24 20:02
*/
/** AlertGroupController */
@Slf4j
@RestController
@RequestMapping("/api/alertGroup")
......@@ -56,23 +54,40 @@ public class AlertGroupController {
private final AlertGroupService alertGroupService;
private final AlertHistoryService alertHistoryService;
/** 新增或者更新 */
/**
* save or update alert Group
*
* @param alertGroup {@link AlertGroup}
* @return {@link Result} with {@link Void}
* @throws Exception {@link Exception}
*/
@PutMapping
public Result<Void> saveOrUpdate(@RequestBody AlertGroup alertGroup) throws Exception {
if (alertGroupService.saveOrUpdate(alertGroup)) {
return Result.succeed("新增成功");
return Result.succeed(MessageResolverUtils.getMessage("save.success"));
} else {
return Result.failed("新增失败");
return Result.failed(MessageResolverUtils.getMessage("save.failed"));
}
}
/** 动态查询列表 */
/**
* list alert groups
*
* @param para {@link JsonNode}
* @return {@link ProTableResult} with {@link AlertGroup}
*/
@PostMapping
public ProTableResult<AlertGroup> listAlertGroups(@RequestBody JsonNode para) {
return alertGroupService.selectForProTable(para);
}
/** 批量删除 */
/**
* batch Delete alert group , this method is {@link Deprecated} in the future , please use
* {@link #deleteGroupById(Integer)} instead
*
* @param para {@link JsonNode}
* @return {@link Result} with {@link Void}
*/
@DeleteMapping
public Result<Void> deleteMul(@RequestBody JsonNode para) {
if (para.size() > 0) {
......@@ -93,20 +108,66 @@ public class AlertGroupController {
}
}
/** 获取指定ID的信息 */
/**
* get alert group by id
*
* @param alertGroup
* @return
* @throws Exception
*/
@PostMapping("/getOneById")
public Result<AlertGroup> getOneById(@RequestBody AlertGroup alertGroup) throws Exception {
alertGroup = alertGroupService.getById(alertGroup.getId());
return Result.succeed(alertGroup, "获取成功");
return Result.succeed(alertGroup, MessageResolverUtils.getMessage("response.get.success"));
}
/** 获取可用的报警组 */
/**
* get all enabled alert group
*
* @return {@link Result} with {@link List} of {@link AlertGroup}
*/
@GetMapping("/listEnabledAll")
public Result<List<AlertGroup>> listEnabledAll() {
return Result.succeed(alertGroupService.listEnabledAll(), "获取成功");
return Result.succeed(
alertGroupService.listEnabledAll(),
MessageResolverUtils.getMessage("response.get.success"));
}
/**
* enable or disable alert group
*
* @return {@link Result} with {@link List} of {@link AlertGroup}
*/
@PutMapping("/enable")
public Result<List<AlertGroup>> enable(@RequestParam("id") Integer id) {
if (alertGroupService.enable(id)) {
return Result.succeed(MessageResolverUtils.getMessage("modify.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("modify.failed"));
}
}
/**
* delete alert group by id
*
* @param id {@link Integer}
* @return {@link Result} of {@link Void}
*/
@DeleteMapping("/delete")
public Result<Void> deleteGroupById(@RequestParam("id") Integer id) {
if (alertGroupService.deleteGroupById(id)) {
return Result.succeed(MessageResolverUtils.getMessage("delete.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("delete.failed"));
}
}
/** 动态查询列表 */
/**
* list alert history
*
* @param para {@link JsonNode}
* @return {@link ProTableResult} with {@link AlertHistory}
*/
@PostMapping("/history")
public ProTableResult<AlertHistory> listAlertHistory(@RequestBody JsonNode para) {
return alertHistoryService.selectForProTable(para);
......
......@@ -81,7 +81,7 @@ public class AlertInstanceController {
}
/**
* bactchDelete AlertInstance, this method is {@link Deprecated} and will be removed in the
* batch Delete AlertInstance, this method is {@link Deprecated} and will be removed in the
* future, please use {@link #deleteInstanceById(Integer)} instead.
*
* @param para
......@@ -101,7 +101,7 @@ public class AlertInstanceController {
*/
@DeleteMapping("/delete")
public Result<Void> deleteInstanceById(@RequestParam("id") Integer id) {
if (alertInstanceService.removeById(id)) {
if (alertInstanceService.deleteAlertInstance(id)) {
return Result.succeed(MessageResolverUtils.getMessage("delete.success"));
} else {
return Result.failed(MessageResolverUtils.getMessage("delete.failed"));
......
......@@ -24,14 +24,37 @@ import org.dinky.model.AlertGroup;
import java.util.List;
/**
* AlertGroupService
*
* @since 2022/2/24 20:00
*/
/** AlertGroupService */
public interface AlertGroupService extends ISuperService<AlertGroup> {
/**
* list all enabled alert group
*
* @return {@link List<AlertGroup>}
*/
List<AlertGroup> listEnabledAll();
/**
* get alert group info by id
*
* @param id {@link Integer}
* @return {@link AlertGroup}
*/
AlertGroup getAlertGroupInfo(Integer id);
/**
* alert group enable or disable by id
*
* @param id
* @return
*/
Boolean enable(Integer id);
/**
* delete alert group by id and cascade delete alert history
*
* @param id {@link Integer}
* @return {@link Boolean}
*/
Boolean deleteGroupById(Integer id);
}
......@@ -22,9 +22,14 @@ package org.dinky.service;
import org.dinky.db.service.ISuperService;
import org.dinky.model.AlertHistory;
/**
* AlertHistoryService
*
* @since 2022/2/24 20:42
*/
public interface AlertHistoryService extends ISuperService<AlertHistory> {}
/** AlertHistoryService */
public interface AlertHistoryService extends ISuperService<AlertHistory> {
/**
* delete alert history by alert group id
*
* @param alertGroupId {@link Integer}
* @return {@link Boolean}
*/
Boolean deleteByAlertGroupId(Integer alertGroupId);
}
......@@ -58,6 +58,14 @@ public interface AlertInstanceService extends ISuperService<AlertInstance> {
@Deprecated
Result<Void> deleteAlertInstance(JsonNode para);
/**
* delete alert instance
*
* @param id {@link Integer}
* @return {@link Result<Void>}
*/
Boolean deleteAlertInstance(Integer id);
/**
* enable or disable alert instance
*
......
......@@ -25,6 +25,7 @@ import org.dinky.mapper.AlertGroupMapper;
import org.dinky.model.AlertGroup;
import org.dinky.model.AlertInstance;
import org.dinky.service.AlertGroupService;
import org.dinky.service.AlertHistoryService;
import org.dinky.service.AlertInstanceService;
import java.util.ArrayList;
......@@ -34,23 +35,24 @@ import javax.annotation.Resource;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
* AlertGroupServiceImpl
*
* @since 2022/2/24 20:01
*/
import cn.hutool.core.util.StrUtil;
/** AlertGroupServiceImpl */
@Service
public class AlertGroupServiceImpl extends SuperServiceImpl<AlertGroupMapper, AlertGroup>
implements AlertGroupService {
@Lazy @Resource private AlertInstanceService alertInstanceService;
@Lazy @Resource private AlertHistoryService alertHistoryService;
@Override
public List<AlertGroup> listEnabledAll() {
return list(new QueryWrapper<AlertGroup>().eq("enabled", 1));
return list(new LambdaQueryWrapper<AlertGroup>().eq(AlertGroup::getEnabled, 1));
}
@Override
......@@ -59,7 +61,7 @@ public class AlertGroupServiceImpl extends SuperServiceImpl<AlertGroupMapper, Al
if (Asserts.isNull(alertGroup) || Asserts.isNullString(alertGroup.getAlertInstanceIds())) {
return alertGroup;
}
String[] alertInstanceIds = alertGroup.getAlertInstanceIds().split(",");
String[] alertInstanceIds = alertGroup.getAlertInstanceIds().split(StrUtil.COMMA);
List<AlertInstance> alertInstanceList = new ArrayList<>();
for (String alertInstanceId : alertInstanceIds) {
if (Asserts.isNullString(alertInstanceId) || "0".equals(alertInstanceId)) {
......@@ -70,4 +72,27 @@ public class AlertGroupServiceImpl extends SuperServiceImpl<AlertGroupMapper, Al
alertGroup.setInstances(alertInstanceList);
return alertGroup;
}
@Override
public Boolean enable(Integer id) {
AlertGroup alertGroup = getById(id);
alertGroup.setEnabled(!alertGroup.getEnabled());
return updateById(alertGroup);
}
/**
* delete alert group by id and cascade delete alert history
*
* @param id {@link Integer}
* @return {@link Boolean}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteGroupById(Integer id) {
if (removeById(id)) {
alertHistoryService.deleteByAlertGroupId(id);
return true;
}
return false;
}
}
......@@ -24,13 +24,31 @@ import org.dinky.mapper.AlertHistoryMapper;
import org.dinky.model.AlertHistory;
import org.dinky.service.AlertHistoryService;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* AlertHistoryServiceImpl
*
* @since 2022/2/24 20:42
*/
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/** AlertHistoryServiceImpl */
@Service
public class AlertHistoryServiceImpl extends SuperServiceImpl<AlertHistoryMapper, AlertHistory>
implements AlertHistoryService {}
implements AlertHistoryService {
/**
* delete alert history by alert group id
*
* @param alertGroupId {@link Integer}
* @return {@link Boolean}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteByAlertGroupId(Integer alertGroupId) {
List<AlertHistory> alertHistoryList =
getBaseMapper()
.selectList(
new LambdaQueryWrapper<AlertHistory>()
.eq(AlertHistory::getAlertGroupId, alertGroupId));
return baseMapper.deleteBatchIds(alertHistoryList) > 0;
}
}
......@@ -51,6 +51,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.JsonNode;
......@@ -80,38 +81,47 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
JSONUtil.toMap(alertInstance.getParams()));
Alert alert = Alert.buildTest(alertConfig);
AlertMsg alertMsg = getAlertMsg(alertInstance);
String title = "任务【" + alertMsg.getJobName() + "】:" + alertMsg.getJobStatus() + "!";
return alert.send(title, alertMsg.toString());
}
private static AlertMsg getAlertMsg(AlertInstance alertInstance) {
String currentDateTime =
LocalDateTime.now()
.format(DateTimeFormatter.ofPattern(BaseConstant.YYYY_MM_DD_HH_MM_SS));
String uuid = UUID.randomUUID().toString();
AlertMsg alertMsg = new AlertMsg();
alertMsg.setAlertType("实时告警监控");
alertMsg.setAlertTime(currentDateTime);
alertMsg.setJobID(uuid);
alertMsg.setJobName("测试任务");
alertMsg.setJobType("SQL");
alertMsg.setJobStatus("FAILED");
alertMsg.setJobStartTime(currentDateTime);
alertMsg.setJobEndTime(currentDateTime);
alertMsg.setJobDuration("1 Seconds");
AlertMsg.AlertMsgBuilder alertMsgBuilder =
AlertMsg.builder()
.alertType("实时告警监控")
.alertTime(currentDateTime)
.jobID(uuid)
.jobName("测试任务")
.jobType("SQL")
.jobStatus("FAILED")
.jobStartTime(currentDateTime)
.jobEndTime(currentDateTime)
.jobDuration("1 Seconds");
String linkUrl = "http://cdh1:8081/#/job/" + uuid + "/overview";
String exceptionUrl = "http://cdh1:8081/#/job/" + uuid + "/exceptions";
Map<String, String> map = JSONUtil.toMap(alertInstance.getParams());
if (map.get("msgtype").equals(ShowType.MARKDOWN.getValue())) {
alertMsg.setLinkUrl("[跳转至该任务的 FlinkWeb](" + linkUrl + ")");
alertMsg.setExceptionUrl("[点击查看该任务的异常日志](" + exceptionUrl + ")");
alertMsgBuilder.linkUrl("[跳转至该任务的 FlinkWeb](" + linkUrl + ")");
alertMsgBuilder.exceptionUrl("[点击查看该任务的异常日志](" + exceptionUrl + ")");
} else {
alertMsg.setLinkUrl(linkUrl);
alertMsg.setExceptionUrl(exceptionUrl);
alertMsgBuilder.linkUrl(linkUrl);
alertMsgBuilder.exceptionUrl(exceptionUrl);
}
String title = "任务【" + alertMsg.getJobName() + "】:" + alertMsg.getJobStatus() + "!";
return alert.send(title, alertMsg.toString());
AlertMsg alertMsg = alertMsgBuilder.build();
return alertMsg;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Void> deleteAlertInstance(JsonNode para) {
if (para.size() > 0) {
final Map<Integer, Set<Integer>> alertGroupInformation = getAlertGroupInformation();
......@@ -134,7 +144,26 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
}
}
/**
* delete alert instance
*
* @param id {@link Integer}
* @return {@link Result<Void>}
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean deleteAlertInstance(Integer id) {
final Map<Integer, Set<Integer>> alertGroupInformation = getAlertGroupInformation();
if (!this.removeById(id)) {
return false;
}
alertGroupInformation.remove(id);
writeBackGroupInformation(alertGroupInformation);
return true;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean enable(Integer id) {
AlertInstance alertInstance = getById(id);
alertInstance.setEnabled(!alertInstance.getEnabled());
......@@ -175,7 +204,6 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
final String groupIds = result.get(groupId);
alertGroup.setAlertInstanceIds(
groupIds == null ? "" : groupIds);
alertGroup.setUpdateTime(now);
return alertGroup;
})
.collect(Collectors.toList());
......
......@@ -1483,26 +1483,31 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
if (Asserts.isNotNull(task.getAlertGroupId())) {
AlertGroup alertGroup = alertGroupService.getAlertGroupInfo(task.getAlertGroupId());
if (Asserts.isNotNull(alertGroup)) {
AlertMsg alertMsg = new AlertMsg();
alertMsg.setAlertType("Flink 实时监控");
alertMsg.setAlertTime(dateFormat.format(new Date()));
alertMsg.setJobID(jobInstance.getJid());
alertMsg.setJobName(task.getName());
alertMsg.setJobType(task.getDialect());
alertMsg.setJobStatus(jobInstance.getStatus());
alertMsg.setJobStartTime(startTime);
alertMsg.setJobEndTime(endTime);
alertMsg.setJobDuration(duration);
// build alert msg of flink job link url
String linkUrl =
String.format(
"http://%s/#/job/%s/overview",
jobManagerHost, jobInstance.getJid());
// build alert msg of flink job exception url
String exceptionUrl =
String.format(
"http://%s/#/job/%s/exceptions",
jobManagerHost, jobInstance.getJid());
AlertMsg.AlertMsgBuilder alertMsgBuilder =
AlertMsg.builder()
.alertType("Flink 实时监控")
.alertTime(dateFormat.format(new Date()))
.jobID(jobInstance.getJid())
.jobName(task.getName())
.jobType(task.getDialect())
.jobStatus(jobInstance.getStatus())
.jobStartTime(startTime)
.jobEndTime(endTime)
.jobDuration(duration);
for (AlertInstance alertInstance : alertGroup.getInstances()) {
if (alertInstance == null
|| (Asserts.isNotNull(alertInstance.getEnabled())
......@@ -1511,12 +1516,14 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
}
Map<String, String> map = JSONUtil.toMap(alertInstance.getParams());
if (map.get("msgtype").equals(ShowType.MARKDOWN.getValue())) {
alertMsg.setLinkUrl("[跳转至该任务的 FlinkWeb](" + linkUrl + ")");
alertMsg.setExceptionUrl("[点击查看该任务的异常日志](" + exceptionUrl + ")");
alertMsgBuilder
.linkUrl("[跳转至该任务的 FlinkWeb](" + linkUrl + ")")
.exceptionUrl("[点击查看该任务的异常日志](" + exceptionUrl + ")");
} else {
alertMsg.setLinkUrl(linkUrl);
alertMsg.setExceptionUrl(exceptionUrl);
alertMsgBuilder.linkUrl(linkUrl).exceptionUrl(exceptionUrl);
}
AlertMsg alertMsg = alertMsgBuilder.build();
sendAlert(alertInstance, jobInstance, task, alertMsg);
}
}
......
......@@ -19,6 +19,7 @@
package org.dinky.alert;
import lombok.Builder;
import lombok.Data;
/**
......@@ -27,6 +28,7 @@ import lombok.Data;
* @since 2022/3/7 18:30
*/
@Data
@Builder
public class AlertMsg {
private String alertType;
......
......@@ -133,7 +133,7 @@ export default [
{
path: '/registration/alert/group',
name: 'group',
// component: './RegistrationCenter/Alert/AlertGroup',
component: './RegCenter/Alert/AlertGroup',
},
],
},
......
......@@ -66,8 +66,7 @@
"react-dom": "^18.0.0",
"react-draggable": "^4.4.5",
"react-helmet-async": "^1.3.0",
"screenfull": "^6.0.2",
"rc-resize-observer": "1.3.1"
"screenfull": "^6.0.2"
},
"devDependencies": {
"@ant-design/pro-cli": "^3.0.1",
......
......@@ -117,6 +117,39 @@ export const EmailSvg = (props: any) => {
};
/**
* random rgb color
*/
function randomRgbColor() {
let r = Math.floor(Math.random() * 256); //random generate r value less than 256
let g = Math.floor(Math.random() * 256); //random generate g value less than 256
let b = Math.floor(Math.random() * 256); //random generate b value less than 256
return `rgb(${r},${g},${b})`; //return rgb(r,g,b) format color
}
export const AlertGroupSvg = (props: any) => {
const size = props.size || defaultSvgSize;
return <>
<Icon style={style} component={
() => (
<svg className="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
width={size} height={size}>
<path
d="M754.176 732.032H684.16V512a200 200 0 0 0-400 0v220.032H214.208a9.984 9.984 0 0 0-10.048 9.984v40c0 5.504 4.48 9.984 10.048 9.984h539.968c5.504 0 9.984-4.48 9.984-9.984v-40a9.984 9.984 0 0 0-9.984-9.984zM454.208 192h59.968v80h-59.968zM298.24 249.92l51.968-30.08 40 69.312-51.968 30.08zM192 377.984l30.016-51.968 69.248 40-29.952 51.968zM677.12 365.952l69.248-40 30.016 51.968-69.312 40zM578.176 289.088l40-69.248 51.904 30.016-40 69.248-51.904-30.016z"
fill={randomRgbColor()}></path>
<path
d="M563.392 502.016H499.84l11.904-83.136a4.992 4.992 0 0 0-8.704-3.84L401.216 533.76a4.992 4.992 0 0 0 3.776 8.192h63.488l-11.904 83.072a4.992 4.992 0 0 0 8.704 3.904l101.888-118.784a4.992 4.992 0 0 0-3.84-8.192z"
fill="#FFFFFF"></path>
</svg>
)
}/>
</>;
};
export const DefaultSvg = (props: any) => {
const size = props.size || defaultSvgSize;
......
......@@ -46,8 +46,8 @@ export default {
'menu.registration.jar': 'Jar',
'menu.registration.database': 'Data Source',
'menu.registration.alert': 'Alarm',
'menu.registration.alert.instance': 'Alarm Instance',
'menu.registration.alert.group': 'Alarm Group',
'menu.registration.alert.instance': 'Alert Instance',
'menu.registration.alert.group': 'Alert Group',
'menu.registration.document': 'Document',
'menu.registration.fragment': 'Global Variable',
'menu.auth': 'Auth Center',
......
......@@ -103,7 +103,7 @@ export default {
'datastudio.editor.push.ds': 'Push to dolphin scheduler',
'datastudio.editor.push.ds.query.error': 'Failed to get dolphin task definition set, reason:\n{msg}',
'datastudio.editor.push.ds.timeout.strategy': 'Timeout strategy',
'datastudio.editor.push.ds.timeout.alarm': 'Timeout warning',
'datastudio.editor.push.ds.timeout.Alert': 'Timeout warning',
'datastudio.editor.push.ds.timeout.error': 'Timeout failed',
'datastudio.editor.push.ds.timeout.strategy.tip': 'A timeout strategy must be selected',
'datastudio.editor.push.ds.add.job.error': 'Failed to create job, reason:\n{msg}',
......@@ -113,12 +113,12 @@ export default {
'datastudio.editor.push.ds.errortry.count': 'Number of failed retries',
'datastudio.editor.push.ds.errortry.min': 'Failure retry interval (minutes)',
'datastudio.editor.push.ds.delayed.time': 'Delayed execution time (minutes)',
'datastudio.editor.push.ds.timeout.min': 'Timeout alarm duration (minutes)',
'datastudio.editor.push.ds.timeout.min': 'Timeout Alert duration (minutes)',
'datastudio.editor.push.ds.running.tag': 'running flag',
'datastudio.editor.stop': 'Stop',
'datastudio.editor.release': 'Release, will not be able to modify after release',
'datastudio.editor.edit': 'Maintenance, click to enter the editing state',
'datastudio.editor.online': 'Online, automatic recovery, alarms, etc. will take effect after online',
'datastudio.editor.online': 'Online, automatic recovery, Alerts, etc. will take effect after online',
'datastudio.editor.offline': 'Offline, will enter the latest release status',
'datastudio.editor.delete': 'Logout, will enter the recycle bin',
'datastudio.editor.recovery': 'Recovery, will enter maintenance mode',
......@@ -333,7 +333,7 @@ export default {
'datastudio.label.jobConfig.savePointpath': 'SavePointpath',
'datastudio.label.jobConfig.savePointpath.tip1': 'Restore Flink task from SavePointPath',
'datastudio.label.jobConfig.savePointpath.tip2': 'hdfs://...',
'datastudio.label.jobConfig.alertGroup': 'Alarm Group',
'datastudio.label.jobConfig.alertGroup': 'Alert Group',
'datastudio.label.jobConfig.alertGroup.tip': 'Select alert group',
'datastudio.label.jobConfig.other': 'Other Config',
'datastudio.label.jobConfig.other.tip': 'Other Config items will be applied to the execution environment, such as pipeline.name',
......@@ -382,8 +382,8 @@ export default {
'datastudio.label.registjar': 'Regist Jar',
'datastudio.label.registdatasource': 'Regist Datasource',
'datastudio.label.metadata': 'Metadata',
'datastudio.label.alarmInstance': 'Registration Alarm Instance',
'datastudio.label.alarmGroup': 'Alarm Group',
'datastudio.label.alertInstance': 'Registration Alert Instance',
'datastudio.label.alertGroup': 'Alert Group',
'datastudio.label.val': 'Register Global Variables',
'datastudio.label.udfTemplate': 'UDF Template',
'datastudio.label.systemInfo': 'System Info',
......@@ -508,15 +508,15 @@ export default {
'rc.clusterConfig.help.kubernets.taskManagerMemory': 'Optional,taskManagerMemory memory',
'rc.ai.management': 'Alarm Instance Management',
'rc.ai.management': 'Alert Instance Management',
'rc.ai.name': 'Name',
'rc.ai.namePleaseHolder': 'please enter alarm instance name',
'rc.ai.namePleaseHolder': 'please enter Alert instance name',
'rc.ai.type': 'Type',
'rc.ai.delete': 'Delete the Alarm Instance ',
'rc.ai.create': 'Create Alarm Instance',
'rc.ai.modify': 'Modify Alarm Instance',
'rc.ai.deleteConfirm': 'Are you sure to delete the selected Alarm Instance? ',
'rc.ai.dingTalk': 'DingDingTalk Config',
'rc.ai.delete': 'Delete the Alert Instance ',
'rc.ai.create': 'Create Alert Instance',
'rc.ai.modify': 'Modify Alert Instance',
'rc.ai.deleteConfirm': 'Are you sure to delete the selected Alert Instance? ',
'rc.ai.dingTalk': 'DingTalk Config',
'rc.ai.email': 'Email Config',
'rc.ai.feishu': 'FeiShu Config',
'rc.ai.wechat': 'WeChat Config',
......@@ -527,7 +527,7 @@ export default {
'rc.ai.proxyPleaseHolder': 'please enter proxy',
'rc.ai.portPleaseHolder': 'please enter port',
'rc.ai.userPleaseHolder': 'please enter user',
'rc.ai.atUsersPleaseHolder': 'Please enter the user ID (user ID of Feishu background is required), separated by multiple commas!',
'rc.ai.atUsersPleaseHolder': 'Please enter the user ID (user ID of FeiShu background is required), separated by multiple commas!',
'rc.ai.passwordPleaseHolder': 'please enter password',
'rc.ai.atMobilesPleaseHolder': 'Please enter the members that need @, multiple use, separated by numbers',
'rc.ai.msgtypePleaseHolder': 'please choose message Send Type`',
......@@ -583,47 +583,18 @@ export default {
'rc.ai.attachment': 'Attachment',
'rc.ai.tableAttachment': 'Table And Attachment',
'rc.alert.groupManagement': 'Alarm Group Management ',
'rc.alert.group.name': 'Alarm Group Name',
'rc.alert.group.groupid': 'Alarm group ID ',
'rc.alert.group.alertInstanceIds': 'Alarm instance',
'rc.alert.group.chooseAlertInstanceIds': 'please choose Alarm Instance',
'rc.alert.group.inputName': 'please input Alarm group name',
'rc.alert.group.create': 'Create Alarm Group',
'rc.alert.group.modify': 'Modify Alarm Group',
'rc.alert.group.delete': 'Delete the Alarm group ',
'rc.alert.group.deleteConfirm': 'Are you sure to delete the selected Alarm group? ',
'rc.alert.group.enable': 'Enable Alarm group ',
'rc.alert.group.enableConfirm': 'Are you sure you want to enable this Alarm group? ',
'rc.alert.group.disable': 'Disable the Alarm group ',
'rc.alert.group.disableConfirm': 'Are you sure you want to disable this Alarm group? ',
'rc.alert.group.disableTotalOf': 'Total Of {total} Alarm group Is Disabled',
'rc.jar.Management': 'Jar Config Management',
'rc.jar.name': 'Job Name',
'rc.jar.id': 'Jar ID',
'rc.jar.type': 'Type',
'rc.jar.filePath': 'File Path',
'rc.jar.mainClass': 'Startup Class',
'rc.jar.execParams': 'Execution Parameters',
'rc.jar.create': 'Create Jar Config',
'rc.jar.modify': 'Modify Jar Config',
'rc.jar.delete': 'Delete Jar Config',
'rc.jar.deleteConfirm': 'Are you sure you want to delete the selected Jar Config? ',
'rc.jar.enable': 'Enable Jar Config',
'rc.jar.enableConfirm': 'Are you sure to enable the selected Jar Config? ',
'rc.jar.disable': 'Disable Jar Config',
'rc.jar.disableConfirm': 'Are you sure to disable the selected Jar Config? ',
'rc.jar.disableTotalOf': 'Total Of {total} cluster Configs Is Disabled',
'rc.jar.config': 'Jar Config',
'rc.jar.filePathPleaseHolder': 'value such as: hdfs:///flink/app/demo.jar',
'rc.jar.filePathHelp': 'Please enter the file path! You need to specify the file path on hdfs,',
'rc.jar.mainClassPleaseHolder': 'com.dlink.app.MainApp',
'rc.jar.mainClassHelp': 'Specify the startup class of the executable Jar, (optional)',
'rc.jar.execParamsHelp': 'Specify the startup class input parameter of the executable Jar, (optional)',
'rc.jar.execParamsPleaseHolder': '--id 1,2',
'rc.jar.baseConfig': 'Base Config',
'rc.jar.namePlaceholder': 'Please enter name!',
'rc.ag.management': 'Alert Group Management ',
'rc.ag.name': 'Alert Group Name',
'rc.ag.groupid': 'Alert group ID ',
'rc.ag.alertInstanceIds': 'Alert instance',
'rc.ag.chooseAlertInstanceIds': 'please choose Alert Instance',
'rc.ag.inputName': 'please input Alert group name',
'rc.ag.create': 'Create Alert Group',
'rc.ag.modify': 'Modify Alert Group',
'rc.ag.delete': 'Delete the Alert group ',
'rc.ag.deleteConfirm': 'Are you sure to delete this Alert group? ',
'rc.ag.alertCount': 'Alert Count: {count}',
'rc.db.Management': 'DataSource',
'rc.db.name': 'Name',
......@@ -771,7 +742,7 @@ export default {
'devops.jobinfo.alert.status.success': 'Success',
'devops.jobinfo.alert.status.failed': 'Failed',
'devops.jobinfo.alert.log': 'Log',
'devops.jobinfo.alert.createTime':'Alarm Time',
'devops.jobinfo.alert.createTime':'Alert Time',
'devops.jobinfo.ck.id':'ID',
'devops.jobinfo.ck.taskid':'Task ID',
......@@ -819,7 +790,7 @@ export default {
'devops.jobinfo.datamap': 'Data Map',
'devops.jobinfo.olap': 'Adhoc Query',
'devops.jobinfo.version': 'History Version',
'devops.jobinfo.alert':'Alarm Record',
'devops.jobinfo.alert':'Alert Record',
'devops.jobinfo.savepoint.trigger':'SavePoint Triggers',
'devops.jobinfo.savepoint.stop':'SavePoint Pause',
'devops.jobinfo.savepoint.cancel': 'SavePoint Stop',
......
......@@ -45,9 +45,9 @@ export default {
'menu.registration.cluster.cluster-config': '集群配置',
'menu.registration.jar': 'Jar',
'menu.registration.database': '数据源',
'menu.registration.alert': '报警',
'menu.registration.alert.instance': '报警实例',
'menu.registration.alert.group': '报警组',
'menu.registration.alert': '告警',
'menu.registration.alert.instance': '告警实例',
'menu.registration.alert.group': '告警组',
'menu.registration.document': '文档',
'menu.registration.fragment': '全局变量',
'menu.auth': '认证中心',
......
......@@ -324,8 +324,8 @@ export default {
'datastudio.label.jobConfig.savePointpath': 'SavePoint路径',
'datastudio.label.jobConfig.savePointpath.tip1': '从SavePointPath恢复Flink任务',
'datastudio.label.jobConfig.savePointpath.tip2': 'hdfs://...',
'datastudio.label.jobConfig.alertGroup': '报警组',
'datastudio.label.jobConfig.alertGroup.tip': '选择报警组',
'datastudio.label.jobConfig.alertGroup': '告警组',
'datastudio.label.jobConfig.alertGroup.tip': '选择告警组',
'datastudio.label.jobConfig.other': '其他配置',
'datastudio.label.jobConfig.other.tip': '其他配置项,将被应用于执行环境,如 pipeline.name',
'datastudio.label.jobConfig.addConfig': '添加配置项',
......@@ -505,14 +505,14 @@ export default {
'rc.clusterConfig.help.kubernets.taskManagerMemory': '可选,taskManagerMemory 的内存配置',
// alert
'rc.ai.management': '报警实例管理',
'rc.ai.management': '告警实例管理',
'rc.ai.type': '类型',
'rc.ai.name': '名称',
'rc.ai.namePleaseHolder': '请输入告警实例名称',
'rc.ai.delete': '删除报警实例',
'rc.ai.delete': '删除告警实例',
'rc.ai.create': '创建告警实例',
'rc.ai.modify': '修改告警实例',
'rc.ai.deleteConfirm': '确定删除选中的报警实例吗?',
'rc.ai.deleteConfirm': '确定删除选中的告警实例吗?',
'rc.ai.dingTalk': '钉钉告警配置',
'rc.ai.email': '邮箱告警配置',
'rc.ai.feishu': '飞书告警配置',
......@@ -576,47 +576,17 @@ export default {
'rc.ai.attachment': '附件',
'rc.ai.tableAttachment': '表格和附件',
'rc.alert.groupManagement': '报警组管理',
'rc.alert.group.name': '报警组名称',
'rc.alert.group.groupid': '报警组ID',
'rc.alert.group.alertInstanceIds': '报警实例',
'rc.alert.group.chooseAlertInstanceIds': '请选择报警组实例',
'rc.alert.group.inputName': '请输入告警组名称',
'rc.alert.group.create': '创建告警组',
'rc.alert.group.modify': '修改告警组',
'rc.alert.group.delete': '删除报警组',
'rc.alert.group.deleteConfirm': '确定删除选中的报警组吗?',
'rc.alert.group.enable': '启用报警组',
'rc.alert.group.enableConfirm': '您确定要启用此报警组吗?',
'rc.alert.group.disable': '禁用报警组',
'rc.alert.group.disableConfirm': '您确定要禁用此报警组吗?',
'rc.alert.group.disableTotalOf': '被禁用的报警组共 {total} 个',
'rc.jar.Management': 'Jar 管理',
'rc.jar.name': '任务名称',
'rc.jar.id': 'Jar ID',
'rc.jar.type': '类型',
'rc.jar.filePath': '文件路径',
'rc.jar.mainClass': '启动类',
'rc.jar.execParams': '执行参数',
'rc.jar.create': '创建 Jar 配置',
'rc.jar.modify': '修改 Jar 配置',
'rc.jar.delete': '删除Jar配置',
'rc.jar.deleteConfirm': '确定删除选中的Jar配置吗?',
'rc.jar.enable': '启用Jar配置',
'rc.jar.enableConfirm': '确定启用选中的Jar配置吗?',
'rc.jar.disable': '禁用Jar配置',
'rc.jar.disableConfirm': '确定禁用选中的Jar配置吗?',
'rc.jar.disableTotalOf': '被禁用的集群配置共 {total} 个',
'rc.jar.config': 'Jar 配置',
'rc.jar.filePathPleaseHolder': '值如: hdfs:///flink/app/demo.jar',
'rc.jar.filePathHelp': '请输入文件路径! 需要指定 hdfs 上的文件路径,',
'rc.jar.mainClassPleaseHolder': 'com.dlink.app.MainApp',
'rc.jar.mainClassHelp': '指定可执行 Jar 的启动类,(可选)',
'rc.jar.execParamsHelp': '指定可执行 Jar 的启动类入参,(可选)',
'rc.jar.execParamsPleaseHolder': '--id 1,2',
'rc.jar.baseConfig': '基本配置',
'rc.jar.namePlaceholder': '请输入名称!',
'rc.ag.management': '告警组管理',
'rc.ag.name': '告警组名称',
'rc.ag.groupid': '告警组ID',
'rc.ag.alertInstanceIds': '告警实例',
'rc.ag.chooseAlertInstanceIds': '请选择告警组实例',
'rc.ag.inputName': '请输入告警组名称',
'rc.ag.create': '创建告警组',
'rc.ag.modify': '修改告警组',
'rc.ag.delete': '删除告警组',
'rc.ag.deleteConfirm': '确定删除该告警组吗?',
'rc.ag.alertCount': '告警实例数: {count}',
'rc.db.Management': '数据源',
......@@ -767,7 +737,7 @@ export default {
'devops.jobinfo.alert.status.success':'成功',
'devops.jobinfo.alert.status.failed':'失败',
'devops.jobinfo.alert.log':'日志',
'devops.jobinfo.alert.createTime':'报警时间',
'devops.jobinfo.alert.createTime':'告警时间',
'devops.jobinfo.ck.id':'ID',
......
/*
*
* 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.
*
*/
import React, {useState} from "react";
import {Button, Form, Tag} from "antd";
import {l} from "@/utils/intl";
import {Alert} from "@/types/RegCenter/data";
import {buildFormData, getFormData} from "@/pages/RegCenter/Alert/AlertGroup/function";
import {connect} from "@umijs/max";
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormSwitch,
ProFormText,
ProFormTextArea
} from "@ant-design/pro-components";
import {MODAL_FORM_STYLE, SWITCH_OPTIONS} from "@/services/constants";
import {AlertStateType} from "@/pages/RegCenter/Alert/AlertInstance/model";
/**
* alert group props
*/
type AlertGroupFormProps = {
onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<Alert.AlertGroup>) => void;
modalVisible: boolean;
values: Partial<Alert.AlertGroup>;
instance: Alert.AlertInstance[];
};
const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => {
/**
* state
*/
const [form] = Form.useForm();
const [formVals, setFormVals] = useState<Partial<Alert.AlertGroup>>({
id: props.values.id,
name: props.values.name,
alertInstanceIds: props.values.alertInstanceIds,
note: props.values.note,
enabled: props.values.enabled ? props.values.enabled : true,
});
/**
* extract props
*/
const {
onSubmit: handleSubmit,
onCancel: handleModalVisible,
modalVisible,
instance,
} = props;
/**
* build alert instance select options
*/
const buildAlertInstanceSelect = () => {
const itemList = [];
for (const item of instance) {
const tag = (<><Tag color="processing">{item.type}</Tag>{item.name}</>);
itemList.push({
label: tag,
value: item.id.toString(),
}
);
}
return itemList;
};
/**
* submit form
*/
const submitForm = async () => {
const fieldsValue = await form.validateFields();
setFormVals(buildFormData(formVals, fieldsValue));
handleSubmit(buildFormData(formVals, fieldsValue));
};
/**
* render alert group form
*/
const renderAlertGroupForm = () => {
return (
<>
<ProFormText
name="name"
label={l("rc.ag.name")}
rules={[{required: true, message: l("rc.ag.inputName")}]}
placeholder={l("rc.ag.inputName")}
/>
<ProFormSelect
name="alertInstanceIds"
label={l("rc.ag.alertInstanceIds")}
rules={[{required: true, message: l("rc.ag.chooseAlertInstanceIds")}]}
mode="multiple"
options={buildAlertInstanceSelect()}
/>
<ProFormTextArea
name="note"
label={l("global.table.note")}
placeholder={l("global.table.notePlaceholder")}
/>
<ProFormSwitch
name="enabled"
label={l("global.table.isEnable")}
{...SWITCH_OPTIONS()}
/>
</>
);
};
/**
* render footer button
*/
const renderFooter = () => {
return [
<Button key={"GroupCancel"} onClick={() => handleModalVisible(false)}>{l("button.cancel")}</Button>,
<Button key={"GroupFinish"} type="primary" onClick={() => submitForm()}>{l("button.finish")}</Button>,
];
};
/**
* render
*/
return (
<ModalForm<Alert.AlertGroup>
title={formVals.id ? l("rc.ag.modify") : l("rc.ag.create")}
open={modalVisible}
{...MODAL_FORM_STYLE}
submitter={{render: () => [...renderFooter()]}}
>
<ProForm
form={form}
initialValues={getFormData(formVals)}
submitter={false}
>
{renderAlertGroupForm()}
</ProForm>
</ModalForm>
);
};
export default connect(({Alert}: { Alert: AlertStateType }) => ({
instance: Alert.instance,
}))(AlertGroupForm);
/*
*
* 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.
*
*/
import {Alert} from "@/types/RegCenter/data";
/**
* parse alertInstanceIds to array and rebuild form data
* @param values
*/
export const getFormData = (values: Partial<Alert.AlertGroup>) => {
let alertInstanceIds: string [] = [];
if (values && values.alertInstanceIds && values.alertInstanceIds !== "") {
alertInstanceIds = values.alertInstanceIds.split(",");
}
return {...values, alertInstanceIds: alertInstanceIds};
};
/**
* build form data
* @param values
* @param params
*/
export const buildFormData = (values: Partial<Alert.AlertGroup>, params: any) => {
let newValue = values;
if (params.alertInstanceIds) {
newValue.alertInstanceIds = params.alertInstanceIds.join(",");
delete params.alertInstanceIds;
}
return {...newValue, ...params};
};
/*
*
* 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.
*
*/
import React, {useEffect, useRef, useState} from "react";
import {EditTwoTone, PlusOutlined} from "@ant-design/icons";
import {ActionType} from "@ant-design/pro-table";
import {Button, Descriptions, Modal, Space, Switch, Tag, Tooltip} from "antd";
import {PageContainer} from "@ant-design/pro-layout";
import {l} from "@/utils/intl";
import {Alert, ALERT_TYPE} from "@/types/RegCenter/data.d";
import {queryList} from "@/services/api";
import {handleAddOrUpdate, handleRemoveById, updateEnabled} from "@/services/BusinessCrud";
import {showAlertInstance} from "@/pages/RegCenter/Alert/AlertGroup/service";
import {connect} from "@umijs/max";
import {ProList} from "@ant-design/pro-components";
import {API_CONSTANTS, PROTABLE_OPTIONS_PUBLIC, SWITCH_OPTIONS} from "@/services/constants";
import {PRO_LIST_CARD_OPTIONS} from "@/pages/RegCenter/Alert/AlertInstance/constans";
import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import DescriptionsItem from "antd/es/descriptions/Item";
import AlertGroupForm from "@/pages/RegCenter/Alert/AlertGroup/components/AlertGroupForm";
const AlertGroupTableList: React.FC = (props: any) => {
/**
* state
*/
const {dispatch} = props;
const [modalVisible, handleModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [formValues, setFormValues] = useState({});
const [alertGroupList, setAlertGroupList] = useState<Alert.AlertGroup[]>([]);
const [loading, setLoading] = useState<boolean>(false);
const actionRef = useRef<ActionType>();
/**
* execute query alert instance list
* set alert instance list
*/
const queryAlertGroupList = async () => {
await queryList(API_CONSTANTS.ALERT_GROUP).then(res => {
setAlertGroupList(res.data);
});
};
/**
* mount data
*/
useEffect(() => {
queryAlertGroupList();
showAlertInstance(dispatch);
}, [modalVisible]);
/**
* execute and refresh loading
* @param callback
*/
const exexuteWithRefreshLoading = async (callback: any) => {
setLoading(true);
await callback();
await queryAlertGroupList();
setLoading(false);
};
/**
* handle delete alert instance
* @param id
*/
const handleDeleteSubmit = async (id: number) => {
Modal.confirm({
title: l("rc.ag.delete"),
content: l("rc.ag.deleteConfirm"),
okText: l("button.confirm"),
cancelText: l("button.cancel"),
onOk: async () => {
await exexuteWithRefreshLoading(async () => {
await handleRemoveById(API_CONSTANTS.ALERT_GROUP_DELETE, id);
});
}
});
};
/**
* handle enable alert instance
* @param item
*/
const handleEnable = async (item: Alert.AlertGroup) => {
await exexuteWithRefreshLoading(async () => {
await updateEnabled(API_CONSTANTS.ALERT_GROUP_ENABLE, {id: item.id});
});
};
/**
* cancel callback
*/
const handleCleanState = () => {
setFormValues({});
handleModalVisible(false);
handleUpdateModalVisible(false);
};
/**
* handle add alert instance
*/
const handleSubmit = async (value: Alert.AlertGroup) => {
await exexuteWithRefreshLoading(async () => {
await handleAddOrUpdate(API_CONSTANTS.ALERT_GROUP, value);
});
handleCleanState();
};
/**
* render right tool bar
*/
const renderToolBar = () => {
return () => [
<Button key={"CreateAlertGroup"} type="primary" onClick={() => handleModalVisible(true)}>
<PlusOutlined/> {l("button.create")}
</Button>,
];
};
/**
* edit click callback
* @param item
*/
const editClick = (item: Alert.AlertGroup) => {
setFormValues(item);
handleUpdateModalVisible(!updateModalVisible);
};
/**
* render alert instance action button
* @param item
*/
const renderAlertGroupActionButton = (item: Alert.AlertGroup) => {
return [
<Button
className={"options-button"}
key={"AlertGroupEdit"}
icon={<EditTwoTone/>}
title={l("button.edit")}
onClick={() => editClick(item)}
/>,
<Button
className={"options-button"}
key={"DeleteAlertGroupIcon"}
icon={<DangerDeleteIcon/>}
onClick={() => handleDeleteSubmit(item.id)}
/>,
];
};
/**
* render alert instance action button
* @param item
*/
const renderAlertGroupContent = (item: Alert.AlertGroup) => {
const instanceCnt= item.alertInstanceIds.split(",").length || 0
return <>
<Space className={"hidden-overflow"}>
<Switch
key={item.id}
{...SWITCH_OPTIONS()}
checked={item.enabled}
onChange={() => handleEnable(item)}
/>
<Tag color="warning">
{l("rc.ag.alertCount", "", {count: instanceCnt})}
</Tag>
</Space>
</>;
};
/**
* render alert instance sub title
* @param item
*/
const renderAlertGroupSubTitle = (item: Alert.AlertGroup) => {
return (
<Descriptions size={"small"} layout={"vertical"} column={1}>
<DescriptionsItem
className={"hidden-overflow"}
key={item.id}
>
<Tooltip key={item.id} title={item.name}>
<Tag color="success">{item.name}</Tag>
</Tooltip>
</DescriptionsItem>
</Descriptions>
);
};
/**
* render data source
*/
const renderDataSource = alertGroupList.map((item: Alert.AlertGroup) => ({
subTitle: renderAlertGroupSubTitle(item),
actions: renderAlertGroupActionButton(item),
avatar: getAlertIcon(ALERT_TYPE.GROUP, 60),
content: renderAlertGroupContent(item),
}));
return (
<PageContainer title={false}>
{/* alert group list */}
<ProList<Alert.AlertGroup>
{...PROTABLE_OPTIONS_PUBLIC}
{...PRO_LIST_CARD_OPTIONS as any}
actionRef={actionRef}
loading={loading}
headerTitle={l("rc.ag.management")}
toolBarRender={renderToolBar()}
dataSource={renderDataSource}
/>
<AlertGroupForm
onSubmit={handleSubmit}
onCancel={handleCleanState}
modalVisible={modalVisible}
values={{}}
/>
{updateModalVisible &&
<AlertGroupForm
onSubmit={handleSubmit}
onCancel={handleCleanState}
modalVisible={updateModalVisible}
values={formValues}
/>
}
</PageContainer>
);
};
export default connect()(AlertGroupTableList);
/*
* 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.
*/
/*--- get alert instance ---*/
import {getData} from "@/services/api";
import {API_CONSTANTS} from "@/services/constants";
export function showAlertInstance(dispatch: any) {
const res = getData(API_CONSTANTS.ALERT_INSTANCE_LIST_ENABLE_ALL);
res.then((result) => {
result.datas && dispatch && dispatch({
type: "Alert/saveInstance",
payload: result.datas,
});
});
}
......@@ -163,8 +163,8 @@ const WeChat: React.FC<AlertInstanceFormProps> = (props) => {
width="md"
name="users"
label={l("rc.ai.atUsers")}
rules={[{required: true, message: l("rc.ai.atUsersPleaseHolder")}]}
placeholder={l("rc.ai.atUsersPleaseHolder")}
rules={[{required: true, message: l("rc.ai.wechatAtUsersPleaseHolder")}]}
placeholder={l("rc.ai.wechatAtUsersPleaseHolder")}
/>
</>
}
......
......@@ -28,3 +28,21 @@ export type AlertInstanceFormProps = {
modalVisible: boolean;
values: Partial<Alert.AlertInstance>;
};
export const PRO_LIST_CARD_META = {
title: {},
subTitle: {},
type: {},
avatar: {},
content: {},
actions: {
cardActionProps: "actions"
},
};
export const PRO_LIST_CARD_OPTIONS = {
search: false,
metas: PRO_LIST_CARD_META,
grid: {gutter: 24, column: 6}
};
......@@ -17,7 +17,7 @@
import {Alert, ALERT_TYPE} from "@/types/RegCenter/data.d";
import {DefaultSvg, DingTalkSvg, EmailSvg, FeiShuSvg, WeChatSvg} from "@/components/Icons/AlertIcon";
import {AlertGroupSvg, DefaultSvg, DingTalkSvg, EmailSvg, FeiShuSvg, WeChatSvg} from "@/components/Icons/AlertIcon";
/**
* get json data to alert instance
......@@ -65,6 +65,8 @@ export const getAlertIcon = (type: string, size?: number) => {
return <FeiShuSvg size={size}/>;
case ALERT_TYPE.EMAIL:
return <EmailSvg size={size}/>;
case ALERT_TYPE.GROUP:
return <AlertGroupSvg size={size}/>;
default:
return <DefaultSvg size={size}/>;
}
......
......@@ -31,25 +31,9 @@ import {DangerDeleteIcon} from "@/components/Icons/CustomIcons";
import {getAlertIcon} from "@/pages/RegCenter/Alert/AlertInstance/function";
import DescriptionsItem from "antd/es/descriptions/Item";
import AlertTypeChoose from "./components/AlertTypeChoose";
import {PRO_LIST_CARD_OPTIONS} from "@/pages/RegCenter/Alert/AlertInstance/constans";
const PRO_LIST_CARD_META = {
title: {},
subTitle: {},
type: {},
avatar: {},
content: {},
actions: {
cardActionProps: "actions"
},
};
const PRO_LIST_CARD_OPTIONS = {
search: false,
metas: PRO_LIST_CARD_META,
grid: {gutter: 24, column: 6}
};
const AlertInstanceTableList: React.FC = () => {
/**
* status
......@@ -58,7 +42,7 @@ const AlertInstanceTableList: React.FC = () => {
const [formValues, setFormValues] = useState<Alert.AlertInstance>();
const [modalVisible, handleModalVisible] = useState<boolean>(false);
const [alertInstanceList, setAlertInstanceList] = useState<Alert.AlertInstance[]>([]);
const [loading, setLoading] = useState<boolean>(false);
/**
* execute query alert instance list
......@@ -71,6 +55,13 @@ const AlertInstanceTableList: React.FC = () => {
};
const executeAndCallbackRefresh = async (callback: () => void) => {
setLoading(true);
await callback();
await queryAlertInstanceList();
setLoading(false);
}
/**
* handle delete alert instance
* @param id
......@@ -82,8 +73,9 @@ const AlertInstanceTableList: React.FC = () => {
okText: l("button.confirm"),
cancelText: l("button.cancel"),
onOk: async () => {
await handleRemoveById(API_CONSTANTS.ALERT_INSTANCE_DELETE, id);
await queryAlertInstanceList();
await executeAndCallbackRefresh(async () => {
await handleRemoveById(API_CONSTANTS.ALERT_INSTANCE_DELETE, id);
})
}
});
};
......@@ -93,8 +85,9 @@ const AlertInstanceTableList: React.FC = () => {
* @param item
*/
const handleEnable = async (item: Alert.AlertInstance) => {
await updateEnabled(API_CONSTANTS.ALERT_INSTANCE_ENABLE, {id: item.id});
await queryAlertInstanceList();
await executeAndCallbackRefresh(async () => {
await updateEnabled(API_CONSTANTS.ALERT_INSTANCE_ENABLE, {id: item.id});
})
};
/**
......@@ -197,7 +190,7 @@ const AlertInstanceTableList: React.FC = () => {
* click cancel button callback
*/
const cancelHandler = () => {
handleModalVisible(false);
handleModalVisible(!modalVisible);
setFormValues(undefined);
};
......@@ -218,6 +211,7 @@ const AlertInstanceTableList: React.FC = () => {
<ProList<Alert.AlertInstance>
{...PROTABLE_OPTIONS_PUBLIC}
{...PRO_LIST_CARD_OPTIONS as any}
loading={loading}
actionRef={actionRef}
headerTitle={l("rc.ai.management")}
toolBarRender={renderToolBar()}
......@@ -231,7 +225,6 @@ const AlertInstanceTableList: React.FC = () => {
onSubmit={chooseSubmitHandler}
values={formValues}
/>
</PageContainer>
);
};
......
......@@ -86,7 +86,15 @@ export const API_CONSTANTS = {
ALERT_INSTANCE_DELETE: "/api/alertInstance/delete",
// alert instance enable or disable
ALERT_INSTANCE_ENABLE: "/api/alertInstance/enable",
// alert instance list all
ALERT_INSTANCE_LIST_ENABLE_ALL: "/api/alertInstance/listEnabledAll",
// ---- alert group ----
ALERT_GROUP: "/api/alertGroup",
// delete alert group by id
ALERT_GROUP_DELETE: "/api/alertGroup/delete",
// alert group enable or disable
ALERT_GROUP_ENABLE: "/api/alertGroup/enable",
};
......
......@@ -19,8 +19,8 @@
/**
* theme of nav
*/
export const THEME = {
NAV_THEME : "navTheme",
export const THEME = {
NAV_THEME: "navTheme",
dark: "realDark",
light: "light",
};
......@@ -29,7 +29,7 @@ export const THEME = {
/**
* MonacoEditor of CodeEdit's theme
*/
export const CODE_EDIT_THEME = {
export const CODE_EDIT_THEME = {
VS: "vs",
DARK: "vs-dark",
HC_BLACK: "hc-black",
......@@ -37,13 +37,24 @@ export const CODE_EDIT_THEME = {
};
export const MonacoEditorOptions = {
// selectOnLineNumbers: true,
renderSideBySide: false, // side by side
autoIndent: 'None', // auto indent
autoIndent: "None", // auto indent
fontSize: 16, // font size
automaticLayout: true, // auto layout
scrollBeyondLastLine:false, //is scroll beyond the last line
scrollBeyondLastLine: false, //is scroll beyond the last line
autoDetectHighContrast: true, // auto detect high contrast
};
export type BaseBeanColumns = ExcludeNameAndEnableColumns & {
name: string,
enabled: boolean,
}
export type ExcludeNameAndEnableColumns = {
id: number,
createTime: Date,
updateTime: Date,
}
......@@ -15,6 +15,8 @@
* limitations under the License.
*/
import {BaseBeanColumns} from "@/types/Public/data";
/**
* about alert
*/
......@@ -22,27 +24,17 @@ declare namespace Alert {
/**
* alert group
*/
export type AlertGroup = {
id: number,
name: string,
export type AlertGroup = BaseBeanColumns & {
alertInstanceIds: string,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
/**
* alert instance
*/
export type AlertInstance = {
id: number,
name: string,
export type AlertInstance = BaseBeanColumns & {
type: string,
params: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
}
......@@ -56,6 +48,7 @@ export const ALERT_TYPE = {
WECHAT: "WeChat",
FEISHU: "FeiShu",
EMAIL: "Email",
GROUP: "Group",
};
export const ALERT_CONFIG_LIST: AlertConfig[] = [{
......@@ -78,9 +71,7 @@ declare namespace Cluster {
* flink cluster instance
* mainly used for `yarn session` `standalone`
*/
export type ClusterInstance = {
id: number,
name: string,
export type ClusterInstance = BaseBeanColumns & {
alias: string,
type: string,
hosts: string,
......@@ -89,26 +80,18 @@ declare namespace Cluster {
version: string,
status: number,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
/**
* flink cluster config
* mainly used for `projob` `application` `k8s` and start a new session cluster
*/
export type ClusterConfig = {
id: number,
name: string,
export type ClusterConfig = BaseBeanColumns & {
type: string,
config: any,
configJson: string,
isAvailable: boolean,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
}
......@@ -120,9 +103,7 @@ declare namespace DataBases {
/**
* database info
*/
export type DataBase = {
id: number,
name: string,
export type DataBase = BaseBeanColumns & {
groupName: string,
type: string,
url: string,
......@@ -135,9 +116,6 @@ declare namespace DataBases {
status: boolean,
healthTime: Date,
heartbeatTime: Date,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
......@@ -183,9 +161,7 @@ declare namespace DataBases {
/**
* about document
*/
export type Document = {
id: number,
name: string,
export type Document = BaseBeanColumns & {
category: string,
type: string,
subtype: string,
......@@ -193,22 +169,14 @@ export type Document = {
fillValue: string,
version: string,
likeNum: number,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
/**
* global variable
*/
export type GlobalVar = {
id: number,
name: string,
export type GlobalVar = BaseBeanColumns & {
fragmentValue: string,
note: string,
enabled: boolean,
createTime: Date,
updateTime: Date,
};
......@@ -15,17 +15,16 @@
* limitations under the License.
*/
import {ExcludeNameAndEnableColumns} from "@/types/Public/data";
declare namespace UserBaseInfo {
export type User = {
id: number;
export type User = ExcludeNameAndEnableColumns & {
username: string;
nickname?: string;
password?: string;
avatar?: string;
worknum?: string;
mobile?: string;
createTime?: Date;
updateTime?: Date;
enabled: boolean;
isDelete: boolean;
isAdmin?: boolean;
......@@ -38,24 +37,18 @@ declare namespace UserBaseInfo {
newPasswordCheck?: string;
};
export type Tenant = {
id: number;
export type Tenant = ExcludeNameAndEnableColumns & {
tenantCode: string;
isDelete: boolean;
note?: string;
createTime?: Date;
updateTime?: Date;
};
export type Role = {
id: number;
export type Role = ExcludeNameAndEnableColumns & {
tenantId: number;
tenant: Tenant;
roleCode?: string;
roleName?: string;
isDelete: boolean;
note?: string;
createTime?: Date;
updateTime?: Date;
};
}
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