|
|
@@ -1,99 +0,0 @@
|
|
|
-package cn.reghao.devops.manager.monitor.controller.page;
|
|
|
-
|
|
|
-import cn.reghao.devops.manager.app.model.constant.EnvMap;
|
|
|
-import cn.reghao.devops.manager.app.model.constant.AppType;
|
|
|
-import cn.reghao.devops.manager.app.model.vo.KeyValue;
|
|
|
-import cn.reghao.devops.manager.monitor.model.po.AppMonitor;
|
|
|
-import cn.reghao.devops.manager.monitor.model.dto.AppMonitorDto;
|
|
|
-import cn.reghao.devops.manager.monitor.model.dto.TwoTuple;
|
|
|
-import cn.reghao.devops.manager.monitor.service.page.AppMonitorPage;
|
|
|
-import cn.reghao.devops.manager.notification.model.po.NotifyGroup;
|
|
|
-import cn.reghao.devops.manager.util.db.PageList;
|
|
|
-import cn.reghao.devops.manager.util.db.PageSort;
|
|
|
-import io.swagger.annotations.Api;
|
|
|
-import io.swagger.annotations.ApiOperation;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.data.domain.PageRequest;
|
|
|
-import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.ui.Model;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.stream.Collectors;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author reghao
|
|
|
- * @date 2021-10-25 14:26:26
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Api(tags = "应用监控页面")
|
|
|
-@Controller
|
|
|
-@RequestMapping("/monitor/app")
|
|
|
-public class AppMonitorPageController {
|
|
|
- private final AppMonitorPage appMonitorPage;
|
|
|
-
|
|
|
- public AppMonitorPageController(AppMonitorPage appMonitorPage) {
|
|
|
- this.appMonitorPage = appMonitorPage;
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "应用监控页面")
|
|
|
- @GetMapping
|
|
|
- public String indexPage(@RequestParam(value = "env", required = false) String env,
|
|
|
- @RequestParam(value = "appName", required = false) String appName, Model model) {
|
|
|
- if (env == null) {
|
|
|
- env = EnvMap.getDefaultEnv();
|
|
|
- }
|
|
|
-
|
|
|
- Page<AppMonitorDto> page;
|
|
|
- if (appName != null) {
|
|
|
- page = appMonitorPage.searchResultPage(appName);
|
|
|
- } else {
|
|
|
- PageRequest pageRequest = PageSort.pageRequest();
|
|
|
- page = appMonitorPage.indexPage(env, pageRequest);
|
|
|
- }
|
|
|
-
|
|
|
- PageList<AppMonitorDto> pageList = PageList.pageList(page);
|
|
|
- model.addAttribute("env", env);
|
|
|
- model.addAttribute("page", page);
|
|
|
- model.addAttribute("list", pageList.getList());
|
|
|
- return "/monitor/app/index";
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "设置应用监控通知页面")
|
|
|
- @GetMapping("/notify/{appId}")
|
|
|
- public String setNotifyPage(@PathVariable("appId") String appId, Model model) {
|
|
|
- TwoTuple<AppMonitor, List<NotifyGroup>> twoTuple = appMonitorPage.setNotifyPage(appId);
|
|
|
- AppMonitorDto appMonitorDto = new AppMonitorDto(twoTuple.getKey());
|
|
|
- List<TwoTuple<String, String>> notifyGroups = twoTuple.getValue().stream()
|
|
|
- .map(notifyGroup -> new TwoTuple<>(notifyGroup.getNotifyAccountId(), notifyGroup.getNotifyName()))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- model.addAttribute("appMonitor", appMonitorDto);
|
|
|
- model.addAttribute("notifyGroups", notifyGroups);
|
|
|
- return "/monitor/app/notify";
|
|
|
- }
|
|
|
-
|
|
|
- @ApiOperation(value = "批量设置应用监控通知页面")
|
|
|
- @GetMapping("/notify/batch")
|
|
|
- public String setNotifyBatchPage(Model model) {
|
|
|
- List<KeyValue> envs = EnvMap.getEnvKeyValues();
|
|
|
- List<KeyValue> appTypes = new ArrayList<>();
|
|
|
- for (AppType appType : AppType.values()) {
|
|
|
- appTypes.add(new KeyValue(appType.name(), appType.name()));
|
|
|
- }
|
|
|
-
|
|
|
- List<KeyValue> notifyGroups = appMonitorPage.notifyGroups().stream()
|
|
|
- .map(notifyGroup -> new KeyValue(notifyGroup.getNotifyAccountId(), notifyGroup.getNotifyName()))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
- model.addAttribute("environments", envs);
|
|
|
- model.addAttribute("appTypes", appTypes);
|
|
|
- model.addAttribute("notifyGroups", notifyGroups);
|
|
|
- return "/monitor/app/notifybatch";
|
|
|
- }
|
|
|
-}
|