Parcourir la source

更新 AliyunController

reghao il y a 5 mois
Parent
commit
f89fb6e85d

+ 11 - 36
mgr/src/main/java/cn/reghao/devops/mgr/aliyun/controller/AliyunController.java

@@ -1,8 +1,7 @@
 package cn.reghao.devops.mgr.aliyun.controller;
 
-import cn.reghao.devops.mgr.app.model.vo.AppConfigVO;
-import cn.reghao.devops.mgr.admin.service.DefaultSetting;
-import cn.reghao.devops.mgr.util.PageSort;
+import cn.reghao.devops.mgr.aliyun.db.repository.AliyunAccountRepository;
+import cn.reghao.devops.mgr.aliyun.model.po.AliyunAccount;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.data.domain.Page;
@@ -11,7 +10,6 @@ import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
 
 /**
  * @author reghao
@@ -19,45 +17,22 @@ import org.springframework.web.bind.annotation.RequestParam;
  */
 @Api(tags = "阿里云管理页面")
 @Controller
-@RequestMapping("/aliyun")
+@RequestMapping("/machine/aliyun")
 public class AliyunController {
-    private final DefaultSetting defaultSetting;
+    private final AliyunAccountRepository aliyunAccountRepository;
 
-    public AliyunController(DefaultSetting defaultSetting) {
-        this.defaultSetting = defaultSetting;
+    public AliyunController(AliyunAccountRepository aliyunAccountRepository) {
+        this.aliyunAccountRepository = aliyunAccountRepository;
     }
 
-    @ApiOperation(value = "阿里云 key 页面", notes = "N")
-    @GetMapping("/key")
-    public String aliyunKeyPage(@RequestParam(value = "env", required = false) String env,
-                                Model model) {
-        if (env == null) {
-            env = defaultSetting.getDefaultEnv();
-        }
+    @ApiOperation(value = "阿里云帐号列表页面", notes = "N")
+    @GetMapping("/account")
+    public String aliyunKeyPage(Model model) {
+        PageRequest pageRequest = PageRequest.of(0, 100);
+        Page<AliyunAccount> page = aliyunAccountRepository.findAll(pageRequest);
 
-        PageRequest pageRequest = PageSort.pageRequest();
-        Page<AppConfigVO> page = Page.empty();
-
-        model.addAttribute("env", env);
         model.addAttribute("page", page);
         model.addAttribute("list", page.getContent());
         return "/devops/aliyun/keylist";
     }
-
-    @ApiOperation(value = "证书列表页面", notes = "N")
-    @GetMapping("/cert")
-    public String certPage(@RequestParam(value = "env", required = false) String env,
-                                Model model) {
-        if (env == null) {
-            env = defaultSetting.getDefaultEnv();
-        }
-
-        PageRequest pageRequest = PageSort.pageRequest();
-        Page<AppConfigVO> page = Page.empty();
-
-        model.addAttribute("env", env);
-        model.addAttribute("page", page);
-        model.addAttribute("list", page.getContent());
-        return "/devops/aliyun/certlist";
-    }
 }

+ 0 - 110
mgr/src/main/resources/templates/devops/aliyun/certlist.html

@@ -1,110 +0,0 @@
-<!DOCTYPE html>
-<html xmlns:th="http://www.thymeleaf.org"
-      xmlns:mo="https://gitee.com/aun/Timo">
-<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
-    <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
-</head>
-
-<body class="timo-layout-page">
-<div class="layui-card">
-    <div class="layui-card-header timo-card-header">
-        <span><i class="fa fa-bars"></i> 证书列表</span>
-        <i class="layui-icon layui-icon-refresh refresh-btn"></i>
-    </div>
-    <div class="layui-card-body">
-        <div class="layui-row timo-card-screen put-row">
-            <div class="layui-row timo-card-screen put-row">
-                <div class="pull-left layui-form-pane">
-                    <div class="layui-inline">
-                        <label class="layui-form-label">环境</label>
-                        <div class="layui-input-block timo-search-status">
-                            <select id="getPageByEnv" class="timo-search-select" name="env" onchange="getPageByCriteria()"
-                                    mo:dict="ENVIRONMENT" mo-selected="${env}"></select>
-                        </div>
-                    </div>
-                    <div class="layui-inline">
-                        <button class="layui-btn timo-search-btn">
-                            <i class="fa fa-search"></i>
-                        </button>
-                    </div>
-                </div>
-                <div class="pull-right">
-                    <div class="btn-group-right">
-                        <button class="layui-btn open-popup" data-title="添加域名" th:attr="data-url=@{/app/config/app/add}"
-                                data-size="max">
-                            <i class="fa fa-plus"></i> 添加
-                        </button>
-                    </div>
-                </div>
-            </div>
-        </div>
-        <div class="timo-table-wrap">
-            <table class="layui-table timo-table">
-                <thead>
-                <tr>
-                    <th class="timo-table-checkbox">
-                        <label class="timo-checkbox"><input type="checkbox">
-                            <i class="layui-icon layui-icon-ok"></i></label>
-                    </th>
-                    <th class="sortable" data-field="appName">域名</th>
-                    <th class="sortable" data-field="appType">证书 ID</th>
-                    <th class="sortable" data-field="appId">证书状态</th>
-                    <th class="sortable" data-field="repoBranch">过期时间</th>
-                    <th class="sortable" data-field="bindPorts">监听端口</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody>
-                <tr th:each="item:${list}">
-                    <td>
-                        <label class="timo-checkbox">
-                            <input type="checkbox" th:value="${item.appId}">
-                            <i class="layui-icon layui-icon-ok"></i>
-                        </label>
-                    </td>
-                    <td th:text="${item.appName}">应用名</td>
-                    <td th:text="${item.appId}">应用 ID</td>
-                    <td th:text="${item.repoBranch}">分支</td>
-                    <td th:text="${item.appType}">应用类型</td>
-                    <td th:text="${item.bindPorts?: ''}">监听端口</td>
-                    <td>
-                        <span style="color: red" th:text="${item.total}"></span>
-                        <a class="open-popup" data-title="部署配置" th:attr="data-url=@{'/app/config/app/deploy/'+${item.appId}}"
-                           data-size="max" href="#">配置</a>
-                    </td>
-                    <td>
-                        <a class="open-popup" data-title="拷贝应用" th:attr="data-url=@{'/app/config/app/copy/'+${item.appId}}"
-                           href="#">证书列表</a>
-                        <a class="open-popup" data-title="应用详细信息" th:attr="data-url=@{'/app/config/app/detail/'+${item.appId}}"
-                           data-size="1200,500" href="#">详细</a>
-                        <a class="open-popup" data-title="编辑" th:attr="data-url=@{'/app/config/app/edit/'+${item.id}}"
-                           data-size="1200,500" href="#">编辑</a>
-                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.appId}"
-                           th:href="@{'/api/app/config/app/' + ${item.id}}">删除</a>
-                        <a class="ajax-delete" th:attr="data-msg='确定要清空 ' + ${item.appId} + ' 的本地仓库'"
-                           th:href="@{'/api/app/config/app/repo/' + ${item.id}}">清空本地仓库</a>
-                    </td>
-                </tr>
-                </tbody>
-            </table>
-        </div>
-        <div th:replace="/common/fragment :: page"></div>
-    </div>
-</div>
-
-<script th:replace="/common/template :: script"></script>
-<script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
-<script type="text/javascript">
-    function getPageByCriteria() {
-        var envSelectedOption = $("#getPageByEnv option:selected")
-        var envParam = envSelectedOption.text()
-
-        var typeSelectedOption = $("#getPageByType option:selected")
-        var typeParam = typeSelectedOption.text()
-
-        url = '?env=' + envParam + '&type=' + typeParam
-        window.location.href = window.location.pathname + url;
-    }
-</script>
-</body>
-</html>

+ 10 - 41
mgr/src/main/resources/templates/devops/aliyun/keylist.html

@@ -8,7 +8,7 @@
 <body class="timo-layout-page">
 <div class="layui-card">
     <div class="layui-card-header timo-card-header">
-        <span><i class="fa fa-bars"></i> 阿里云Key</span>
+        <span><i class="fa fa-bars"></i> 阿里云帐号列表</span>
         <i class="layui-icon layui-icon-refresh refresh-btn"></i>
     </div>
     <div class="layui-card-body">
@@ -28,45 +28,24 @@
             <table class="layui-table timo-table">
                 <thead>
                 <tr>
-                    <th class="timo-table-checkbox">
-                        <label class="timo-checkbox"><input type="checkbox">
-                            <i class="layui-icon layui-icon-ok"></i></label>
-                    </th>
-                    <th class="sortable" data-field="appId">阿里云帐号</th>
-                    <th class="sortable" data-field="appName">ACCESS_KEY_ID</th>
-                    <th class="sortable" data-field="appType">ACCESS_KEY_SECRET</th>
+                    <th class="sortable" data-field="type">类型</th>
+                    <th class="sortable" data-field="endpoint">Endpoint</th>
+                    <th class="sortable" data-field="accessKeyId">AccessKeyId</th>
+                    <th class="sortable" data-field="accessKeySecret">AccessKeySecret</th>
                     <th>操作</th>
                 </tr>
                 </thead>
                 <tbody>
                 <tr th:each="item:${list}">
+                    <td th:text="${item.type}">应用名</td>
+                    <td th:text="${item.endpoint}">应用 ID</td>
+                    <td th:text="${item.accessKeyId}">分支</td>
+                    <td th:text="${item.accessKeySecret}">应用类型</td>
                     <td>
-                        <label class="timo-checkbox">
-                            <input type="checkbox" th:value="${item.appId}">
-                            <i class="layui-icon layui-icon-ok"></i>
-                        </label>
-                    </td>
-                    <td th:text="${item.appName}">应用名</td>
-                    <td th:text="${item.appId}">应用 ID</td>
-                    <td th:text="${item.repoBranch}">分支</td>
-                    <td th:text="${item.appType}">应用类型</td>
-                    <td th:text="${item.bindPorts?: ''}">监听端口</td>
-                    <td>
-                        <span style="color: red" th:text="${item.total}"></span>
-                        <a class="open-popup" data-title="部署配置" th:attr="data-url=@{'/app/config/app/deploy/'+${item.appId}}"
-                           data-size="max" href="#">配置</a>
-                    </td>
-                    <td>
-                        <a class="open-popup" data-title="拷贝应用" th:attr="data-url=@{'/app/config/app/copy/'+${item.appId}}"
-                           href="#">Endpoint 列表</a>
-                        <a class="open-popup" data-title="应用详细信息" th:attr="data-url=@{'/app/config/app/detail/'+${item.appId}}"
-                           data-size="1200,500" href="#">详细</a>
                         <a class="open-popup" data-title="编辑" th:attr="data-url=@{'/app/config/app/edit/'+${item.id}}"
                            data-size="1200,500" href="#">编辑</a>
-                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.appId}"
+                        <a class="ajax-delete" th:attr="data-msg='确定要删除 '+ ${item.id}"
                            th:href="@{'/api/app/config/app/' + ${item.id}}">删除</a>
-                        <a class="ajax-delete" th:attr="data-msg='确定要清空 ' + ${item.appId} + ' 的本地仓库'"
-                           th:href="@{'/api/app/config/app/repo/' + ${item.id}}">清空本地仓库</a>
                     </td>
                 </tr>
                 </tbody>
@@ -79,16 +58,6 @@
 <script th:replace="/common/template :: script"></script>
 <script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
 <script type="text/javascript">
-    function getPageByCriteria() {
-        var envSelectedOption = $("#getPageByEnv option:selected")
-        var envParam = envSelectedOption.text()
-
-        var typeSelectedOption = $("#getPageByType option:selected")
-        var typeParam = typeSelectedOption.text()
-
-        url = '?env=' + envParam + '&type=' + typeParam
-        window.location.href = window.location.pathname + url;
-    }
 </script>
 </body>
 </html>