Browse Source

update CompilerPageController

reghao 6 tháng trước cách đây
mục cha
commit
dd0d4fe049

+ 12 - 33
mgr/src/main/java/cn/reghao/devops/mgr/build/controller/CompilerPageController.java

@@ -23,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -42,7 +43,7 @@ public class CompilerPageController {
         this.compilerConfigService = compilerConfigService;
     }
 
-    @ApiOperation(value = "编译配置页面", notes = "N")
+    @ApiOperation(value = "编译配置列表页面", notes = "N")
     @PreAuthorize("hasRole('ROLE_ADMIN')")
     @GetMapping
     public String compilerConfigPage(Model model) {
@@ -62,14 +63,6 @@ public class CompilerPageController {
         return "/devops/build/compiler/add";
     }
 
-    @ApiOperation(value = "编译更新页面", notes = "N")
-    @PreAuthorize("hasRole('ROLE_ADMIN')")
-    @GetMapping("/edit/{id}")
-    public String editCompilerPage(@PathVariable("id") CompilerConfig compilerConfig, Model model) {
-        model.addAttribute("compiler", compilerConfig);
-        return "/devops/build/compiler/edit";
-    }
-
     private void setCompilerModel(Model model) {
         List<KeyValue> compileTypes = new ArrayList<>();
         for (CompileType compileType : CompileType.values()) {
@@ -80,40 +73,26 @@ public class CompilerPageController {
         model.addAttribute("machineIpv4", Machine.IPV4);
     }
 
-    @ApiOperation(value = "编译详情页面", notes = "N")
-    @PreAuthorize("hasRole('ROLE_ADMIN')")
-    @GetMapping("/detail/{id}")
-    public String compilerDetailPage(@PathVariable("id") CompilerConfig compilerConfig, Model model) {
-        model.addAttribute("compiler", compilerConfig);
-        return "/devops/build/compiler/detail";
-    }
-
-    @ApiOperation(value = "编译器版本页面", notes = "N")
-    @PreAuthorize("hasRole('ROLE_ADMIN')")
-    @GetMapping("/version/{id}")
-    public String compilerVersionPage(@PathVariable("id") int id, Model model) {
-        String result = compilerConfigService.getCompilerVersion(id);
-        model.addAttribute("content", result);
-        return "/devops/build/compiler/version";
-    }
-
     @ApiOperation(value = "docker 编译器映射目录页面", notes = "N")
     @PreAuthorize("hasRole('ROLE_ADMIN')")
     @GetMapping("/bind/{id}")
     public String compilerBindPage(@PathVariable("id") int id, Model model) {
         CompilerConfig compilerConfig = compilerConfigRepository.findById(id).orElse(null);
+        boolean dockerType = true;
+        List<CompilerBind> list;
         if (compilerConfig != null && compilerConfig.getType().equals(CompileType.docker.getName())) {
-            List<CompilerBind> list = compilerConfig.getCompilerBinds();
-            model.addAttribute("list", list);
-            return "/devops/build/compiler/bind";
+            list = compilerConfig.getCompilerBinds();
         } else {
-            String content = "not docker type";
-            model.addAttribute("content", content);
-            return "/devops/build/compiler/version";
+            dockerType = false;
+            list = new ArrayList<>();
         }
+
+        model.addAttribute("dockerType", dockerType);
+        model.addAttribute("list", list);
+        return "/devops/build/compiler/bind";
     }
 
-    @ApiOperation(value = "添加/修改应用编译配置", notes = "N")
+    @ApiOperation(value = "添加编译配置", notes = "N")
     @PreAuthorize("hasRole('ROLE_ADMIN')")
     @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
     @ResponseBody

+ 6 - 1
mgr/src/main/resources/templates/devops/build/compiler/bind.html

@@ -13,7 +13,7 @@
 </head>
 <body>
 <div class="timo-detail-page">
-    <table class="layui-table">
+    <table th:if="${dockerType}" class="layui-table">
         <thead>
         <tr>
             <th>host 路径</th>
@@ -27,6 +27,11 @@
         </tr>
         </tbody>
     </table>
+    <div th:if="${!dockerType}" class="page-error" style="color: #009688">
+        <div style="font-size: 18px">
+            not docker type
+        </div>
+    </div>
 </div>
 </body>
 </html>

+ 0 - 25
mgr/src/main/resources/templates/devops/build/compiler/detail.html

@@ -1,25 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body>
-<div class="timo-detail-page">
-    <table class="layui-table timo-detail-table">
-        <thead>
-        <tr>
-            <th data-field="name">编译名字</th>
-            <th data-field="compileCmd">编译命令</th>
-            <th data-field="versionCmd">编译器版本命令</th>
-        </tr>
-        </thead>
-        <tbody>
-        <tr>
-            <td th:text="${compiler.name}"></td>
-            <td th:text="${compiler.compileCmd}"></td>
-            <td th:text="${compiler.versionCmd}"></td>
-        </tr>
-        </tbody>
-    </table>
-</div>
-</body>
-</html>

+ 0 - 45
mgr/src/main/resources/templates/devops/build/compiler/edit.html

@@ -1,45 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})"></head>
-
-<body>
-<div class="layui-form timo-compile">
-    <form th:action="@{/build/compiler}">
-        <!--<input type="hidden" name="machineId" th:value="${machineId}"/>-->
-        <input type="hidden" name="id" th:value="${compiler.id}"/>
-        <div class="layui-form-item">
-            <label class="layui-form-label">编译类型</label>
-            <div class="layui-input-inline">
-                <input class="layui-input" type="text" name="type" readonly th:value="${compiler.type}">
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <label class="layui-form-label">编译名字</label>
-            <div class="layui-input-inline">
-                <input class="layui-input" type="text" name="name" readonly th:value="${compiler.name}">
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <label class="layui-form-label required">编译命令</label>
-            <div class="layui-input-inline">
-                <textarea class="layui-textarea" name="compileCmd" th:text="${compiler.compileCmd}"></textarea>
-            </div>
-        </div>
-        <div class="layui-form-item">
-            <label class="layui-form-label required">编译器版本命令</label>
-            <div class="layui-input-inline">
-                <textarea class="layui-textarea" name="versionCmd" th:text="${compiler.versionCmd}"></textarea>
-            </div>
-        </div>
-        <div class="layui-form-item timo-finally">
-            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
-            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
-        </div>
-    </form>
-</div>
-<script th:replace="/common/template :: script"></script>
-<script type="text/javascript">
-</script>
-</body>
-</html>

+ 4 - 12
mgr/src/main/resources/templates/devops/build/compiler/index.html

@@ -27,9 +27,9 @@
                     <th class="sortable" data-field="name">编译名字</th>
                     <th class="sortable" data-field="homePath">编译器主目录</th>
                     <th class="sortable" data-field="compilerImage">编译器镜像</th>
+                    <th class="sortable" data-field="compileCmd">编译命令</th>
+                    <th class="sortable" data-field="versionCmd">编译器版本命令</th>
                     <th class="sortable" data-field="binds">镜像映射</th>
-                    <th class="sortable" data-field="cmd">命令</th>
-                    <th class="sortable" data-field="version">版本</th>
                     <th>操作</th>
                 </tr>
                 </thead>
@@ -39,21 +39,13 @@
                     <td th:text="${item.name}">编译名字</td>
                     <td th:text="${item.homePath}">编译器主目录</td>
                     <td th:text="${item.compilerImage}">编译器镜像</td>
+                    <td th:text="${item.compileCmd}">编译命令</td>
+                    <td th:text="${item.versionCmd}">编译器版本命令</td>
                     <td>
                         <a class="open-popup" data-title="镜像映射" th:attr="data-url=@{'/build/compiler/bind/'+${item.id}}"
                            data-size="720,480" href="#">查看</a>
                     </td>
                     <td>
-                        <a class="open-popup" data-title="命令" th:attr="data-url=@{'/build/compiler/detail/'+${item.id}}"
-                           data-size="720,480" href="#">查看</a>
-                    </td>
-                    <td>
-                        <a class="open-popup" th:attr="data-title='编译器 ' + ${item.name} + ' 版本', data-url=@{'/build/compiler/version/'+${item.id}}"
-                           data-size="720,480" href="#">查看</a>
-                    </td>
-                    <td>
-                        <a class="open-popup" data-title="修改命令" th:attr="data-url=@{'/build/compiler/edit/'+${item.id}}"
-                           data-size="720,480" href="#">编辑</a>
                         <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.name} + '?'"
                            th:href="@{'/build/compiler/' + ${item.id}}">删除</a>
                     </td>

+ 0 - 29
mgr/src/main/resources/templates/devops/build/compiler/version.html

@@ -1,29 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
-    <style>
-        .page-error {
-            display: -webkit-box;
-            display: -ms-flexbox;
-            display: flex;
-            -webkit-box-align: center;
-            -ms-flex-align: center;
-            align-items: center;
-            -webkit-box-pack: center;
-            -ms-flex-pack: center;
-            justify-content: center;
-            -webkit-box-orient: vertical;
-            -webkit-box-direction: normal;
-            -ms-flex-direction: column;
-            flex-direction: column;
-            min-height: calc(100vh - 110px);
-            margin-bottom: 0;
-        }
-    </style>
-</head>
-<body>
-<div class="page-error" style="color: #009688">
-    <div style="font-size: 18px" th:utext="${content}"></div>
-</div>
-</body>
-</html>