|
|
@@ -1,17 +1,13 @@
|
|
|
-package cn.reghao.autodop.dmaster.app.controller;
|
|
|
+package cn.reghao.autodop.dmaster.app.controller.view;
|
|
|
|
|
|
-import cn.reghao.autodop.common.result.Result;
|
|
|
-import cn.reghao.autodop.common.result.ResultStatus;
|
|
|
-import cn.reghao.autodop.dmaster.app.constant.AppType;
|
|
|
import cn.reghao.autodop.dmaster.app.constant.EnvType;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.config.AppOrchestration;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.AppDeploying;
|
|
|
+import cn.reghao.autodop.dmaster.app.entity.AppRunning;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.log.BuildLog;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.log.DeployLog;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.AppBuildingRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.AppDeployingRepository;
|
|
|
-import cn.reghao.autodop.dmaster.app.repository.config.AppOrchestrationRepository;
|
|
|
+import cn.reghao.autodop.dmaster.app.repository.AppRunningRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.entity.AppBuilding;
|
|
|
-import cn.reghao.autodop.dmaster.app.entity.AppDeploying;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.log.BuildLogRepository;
|
|
|
import cn.reghao.autodop.dmaster.app.repository.log.DeployLogRepository;
|
|
|
import cn.reghao.autodop.dmaster.common.db.PageList;
|
|
|
@@ -25,11 +21,7 @@ import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.Model;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -40,20 +32,20 @@ import java.util.stream.Collectors;
|
|
|
@Controller
|
|
|
@RequestMapping("/app")
|
|
|
public class AppPageController {
|
|
|
- private AppOrchestrationRepository appRepository;
|
|
|
private AppBuildingRepository appBuildingRepository;
|
|
|
private AppDeployingRepository appDeployingRepository;
|
|
|
+ private AppRunningRepository appRunningRepository;
|
|
|
private BuildLogRepository buildLogRepository;
|
|
|
private DeployLogRepository deployLogRepository;
|
|
|
|
|
|
- public AppPageController(AppOrchestrationRepository appRepository,
|
|
|
- AppBuildingRepository appBuildingRepository,
|
|
|
+ public AppPageController(AppBuildingRepository appBuildingRepository,
|
|
|
AppDeployingRepository appDeployingRepository,
|
|
|
+ AppRunningRepository appRunningRepository,
|
|
|
BuildLogRepository buildLogRepository,
|
|
|
DeployLogRepository deployLogRepository) {
|
|
|
- this.appRepository = appRepository;
|
|
|
this.appBuildingRepository = appBuildingRepository;
|
|
|
this.appDeployingRepository = appDeployingRepository;
|
|
|
+ this.appRunningRepository = appRunningRepository;
|
|
|
this.buildLogRepository = buildLogRepository;
|
|
|
this.deployLogRepository = deployLogRepository;
|
|
|
}
|
|
|
@@ -62,13 +54,11 @@ public class AppPageController {
|
|
|
@GetMapping("/build")
|
|
|
public String buildPage(Model model) {
|
|
|
String env = EnvType.test.name();
|
|
|
- String appType = AppType.npm.name();
|
|
|
int page = 1;
|
|
|
int size = 10;
|
|
|
PageRequest pageRequest =
|
|
|
PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "updateTime"));
|
|
|
|
|
|
- //Page<AppBuilding> appBuildings = appBuildingRepository.findAllByEnvAndAppType(env, appType, pageRequest);
|
|
|
Page<AppBuilding> appBuildings = appBuildingRepository.findAllByEnv(env, pageRequest);
|
|
|
PageList<AppBuilding> pageList = PageList.pageList(appBuildings);
|
|
|
|
|
|
@@ -78,34 +68,10 @@ public class AppPageController {
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "部署页面")
|
|
|
- @GetMapping("/deploy/{appId}")
|
|
|
- public String deployPage(@PathVariable("appId") String appId, Model model) {
|
|
|
- int page = 1;
|
|
|
- int size = 10;
|
|
|
- PageRequest pageRequest =
|
|
|
- PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "updateTime"));
|
|
|
-
|
|
|
- Page<BuildLog> buildLogPage = buildLogRepository.findByAppId(appId, pageRequest);
|
|
|
- Map<String, List<DeployLog>> map = new HashMap<>();
|
|
|
- for (BuildLog buildLog : buildLogPage.getContent()) {
|
|
|
- if (buildLog.getResult().getCode() != ResultStatus.SUCCESS.getCode()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- String buildLogId = buildLog.getId();
|
|
|
- List<DeployLog> deployLogs = deployLogRepository.findByBuildLogId(buildLogId);
|
|
|
- if (!deployLogs.isEmpty()) {
|
|
|
- map.put(buildLogId, deployLogs);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- AppOrchestration app = appRepository.findByAppId(appId);
|
|
|
- List<AppDeploying> list = new ArrayList<>();
|
|
|
- /*PageList<AppBuilding> pageList = PageList.emptyPageList(appPage);
|
|
|
- pageList.setList(apps);
|
|
|
- model.addAttribute("list", pageList.getList());
|
|
|
- model.addAttribute("page", pageList);*/
|
|
|
-
|
|
|
+ @GetMapping("/deploy/{buildLogId}")
|
|
|
+ public String deployPage(@PathVariable("buildLogId") String buildLogId, Model model) {
|
|
|
+ List<AppDeploying> list = appDeployingRepository.findByBuildLogId(buildLogId);
|
|
|
+ model.addAttribute("list", list);
|
|
|
return "/app/deploy";
|
|
|
}
|
|
|
|
|
|
@@ -124,19 +90,28 @@ public class AppPageController {
|
|
|
int size = 10;
|
|
|
PageRequest pageRequest =
|
|
|
PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "updateTime"));
|
|
|
- Page<AppDeploying> appDeployingPage = appDeployingRepository.findAll(pageRequest);
|
|
|
- PageList<AppDeploying> pageList = PageList.pageList(appDeployingPage);
|
|
|
+ Page<AppRunning> appRunningPage = appRunningRepository.findAll(pageRequest);
|
|
|
+ PageList<AppRunning> pageList = PageList.pageList(appRunningPage);
|
|
|
|
|
|
- model.addAttribute("page", appDeployingPage);
|
|
|
+ model.addAttribute("page", appRunningPage);
|
|
|
model.addAttribute("list", pageList.getList());
|
|
|
return "/app/status";
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "应用配置详情页面")
|
|
|
- @GetMapping("/config/app/detail/{appId}")
|
|
|
- public String appConfigPage(@PathVariable("appId") String appId, Model model) {
|
|
|
- AppOrchestration app = appRepository.findByAppId(appId);
|
|
|
- model.addAttribute("app", app);
|
|
|
- return "/app/config/app/detail";
|
|
|
+ @ApiOperation(value = "构建历史页面")
|
|
|
+ @GetMapping("/log/build")
|
|
|
+ public String buildLogPage(Model model) {
|
|
|
+ String env = EnvType.test.name();
|
|
|
+ int page = 1;
|
|
|
+ int size = 10;
|
|
|
+ PageRequest pageRequest =
|
|
|
+ PageRequest.of(page-1, size, Sort.by(Sort.Direction.DESC, "updateTime"));
|
|
|
+
|
|
|
+ Page<AppBuilding> appBuildings = appBuildingRepository.findAllByEnv(env, pageRequest);
|
|
|
+ PageList<AppBuilding> pageList = PageList.pageList(appBuildings);
|
|
|
+
|
|
|
+ model.addAttribute("page", appBuildings);
|
|
|
+ model.addAttribute("list", pageList.getList());
|
|
|
+ return "/app/log";
|
|
|
}
|
|
|
}
|