Authored by zhaoqi

Merge branch 'dev_degrade'

@@ -129,4 +129,6 @@ public class HttpUriContants { @@ -129,4 +129,6 @@ public class HttpUriContants {
129 public static final String TASK__DELETE = "/taskConfigure/delTaskModel"; 129 public static final String TASK__DELETE = "/taskConfigure/delTaskModel";
130 public static final String TASK__GET_ID = "/taskConfigure/getTaskModelById"; 130 public static final String TASK__GET_ID = "/taskConfigure/getTaskModelById";
131 131
  132 + public static final String GET_DEGRADE_INFO = "/degrade/getList";
  133 + public static final String EDIT_DEGRADE_INFO = "/degrade/change";
132 } 134 }
  1 +package com.ui.model.domain;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * Created by zhaoqi on 2016/8/26 0026.
  7 + */
  8 +@Data
  9 +public class DegradeConfig {
  10 +
  11 + private int id;
  12 +
  13 + private String configName;
  14 +
  15 + private String configDesc;
  16 +
  17 + private String level;
  18 +
  19 + private String imgUrl;
  20 +
  21 + private String switchOn;
  22 +
  23 +}
  1 +package com.ui.model.req;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * Created by zhaoqi on 2016/8/30 0030.
  7 + */
  8 +@Data
  9 +public class DegradeInfoReq extends PageRequest {
  10 +
  11 + private String cloudType;
  12 +
  13 + private String configName;
  14 +
  15 + private Integer level;
  16 +
  17 + private String switchOn;
  18 +
  19 + private int id;
  20 +
  21 + private String configDesc;
  22 +}
  1 +package com.ui.ctrl;
  2 +
  3 +import com.ui.contants.HttpUriContants;
  4 +import com.ui.http.HttpRestClient;
  5 +import com.ui.model.BaseResponse;
  6 +import com.ui.model.domain.DegradeConfig;
  7 +import com.ui.model.rep.PageResponse;
  8 +import com.ui.model.req.DegradeInfoReq;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Controller;
  11 +import org.springframework.web.bind.annotation.RequestMapping;
  12 +import org.springframework.web.bind.annotation.ResponseBody;
  13 +import org.springframework.web.servlet.ModelAndView;
  14 +
  15 +/**
  16 + * Created by zhaoqi on 2016/8/29 0029.
  17 + */
  18 +@Controller
  19 +@RequestMapping("degrade")
  20 +public class DegradeInfoCtrl {
  21 +
  22 + @Autowired
  23 + private HttpRestClient httpClient;
  24 +
  25 + @RequestMapping("/info")
  26 + public ModelAndView toDegradeList() {
  27 + return new ModelAndView("degrade/degradeList");
  28 + }
  29 +
  30 + @ResponseBody
  31 + @RequestMapping("/getList")
  32 + public BaseResponse getDegradeInfoList(DegradeInfoReq req) {
  33 + return httpClient.defaultPost(HttpUriContants.GET_DEGRADE_INFO,req,BaseResponse.class);
  34 + }
  35 +
  36 + @ResponseBody
  37 + @RequestMapping("/edit")
  38 + public BaseResponse editDegradeInfo(DegradeInfoReq req) {
  39 + return httpClient.defaultPost(HttpUriContants.EDIT_DEGRADE_INFO,req,BaseResponse.class);
  40 + }
  41 +}
  1 +<%@page language="java" contentType="text/html;charset=utf-8" %>
  2 +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3 +<%
  4 + String path = request.getContextPath();
  5 + String basePath = request.getScheme() + "://"
  6 + + request.getServerName() + ":" + request.getServerPort()
  7 + + path + "/";
  8 +%>
  9 +<form class="form-horizontal" id="degradeInfoForm" name="degradeInfoForm">
  10 +
  11 + <div class="form-group">
  12 + <label class="col-sm-2 control-label">配置名称:</label>
  13 + <div class="col-sm-8">
  14 + <input type="text" class="form-control" id="configName" name="configName" maxlength="30" size="40" readonly="readonly"/>
  15 + </div>
  16 + </div>
  17 +
  18 + <div class="form-group">
  19 + <label class="col-sm-2 control-label">配置描述:</label>
  20 + <div class="col-sm-8">
  21 + <input type="text" class="form-control" id="configDesc" name="configDesc" maxlength="30" size="40"/>
  22 + </div>
  23 + </div>
  24 +
  25 + <div class="form-group">
  26 + <label class="col-sm-2 control-label">配置级别:</label>
  27 + <div class="col-sm-8">
  28 + <select id="level" name="level" class="form-control">
  29 + <option value="0">全部</option>
  30 + <option value="1">一级</option>
  31 + <option value="2">二级</option>
  32 + </select>
  33 + </div>
  34 + </div>
  35 +
  36 + <div class="form-group">
  37 + <label class="col-sm-2 control-label">服务器:</label>
  38 + <div class="col-sm-8">
  39 + <select id="cloudType" name="cloudType" class="form-control">
  40 + <option value="all">全部</option>
  41 + <option value="zookeeper_aws">aws</option>
  42 + <option value="zookeeper_qq">qCloud</option>
  43 + </select>
  44 + </div>
  45 + </div>
  46 +
  47 + <div class="form-group">
  48 + <label class="col-sm-2 control-label">开关:</label>
  49 + <div class="col-sm-8">
  50 + <select id="switchOn" name="switchOn" class="form-control">
  51 + <option value="N">关</option>
  52 + <option value="Y">开</option>
  53 + </select>
  54 + </div>
  55 + </div>
  56 +</form>
  57 +<script>
  58 +$(function(){
  59 + $("#degradeInfoForm #configName").val(paramObj.configName);
  60 + $("#degradeInfoForm #configDesc").val(paramObj.configDesc);
  61 + $("#degradeInfoForm #level").val(paramObj.level);
  62 + $("#degradeInfoForm #switchOn").val(paramObj.switchOn);
  63 +})
  64 +</script>
  1 +<%@page language="java" contentType="text/html;charset=utf-8" %>
  2 +<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  3 +<%
  4 + String path = request.getContextPath();
  5 + String basePath = request.getScheme() + "://"
  6 + + request.getServerName() + ":" + request.getServerPort()
  7 + + path + "/";
  8 +%>
  9 +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  10 +<html>
  11 +<head>
  12 + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  13 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
  14 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-datetimepicker.css"/>
  15 + <link href="<%=basePath %>js/bootstrap-plugin/css/bootstrap.table.css" rel="stylesheet" media="screen"/>
  16 + <link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
  17 + <link rel="stylesheet" href="<%=basePath %>css/fullcalendar.css"/>
  18 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
  19 + <link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
  20 + <link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
  21 + <link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
  22 + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
  23 + <link rel="stylesheet" href="<%=basePath %>js/jstree/themes/proton/style.css"/>
  24 + <link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
  25 + <link rel="stylesheet" href="<%=basePath %>css/yoho.css"/>
  26 + <script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
  27 + <script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
  28 + <script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
  29 + <script src="<%=basePath %>/js/bootstrap.min.js"></script>
  30 + <script src="<%=basePath %>/js/unicorn.js"></script>
  31 + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
  32 + type="text/javascript"></script>
  33 + <script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
  34 + type="text/javascript"></script>
  35 + <script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
  36 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
  37 + type="text/javascript"></script>
  38 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
  39 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
  40 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  41 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
  42 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
  43 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
  44 + type="text/javascript"></script>
  45 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
  46 + type="text/javascript"></script>
  47 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
  48 + type="text/javascript"></script>
  49 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
  50 + <script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
  51 + <script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
  52 + <script src="<%=basePath %>js/jstree/jstree.js"></script>
  53 + <script src="<%=basePath %>js/jquery.toaster.js"></script>
  54 + <link href="<%=basePath %>css/jquery.tagsinput.css" rel="stylesheet"/>
  55 + <script src="<%=basePath %>js/jquery.tagsinput.min.js" type="text/javascript"></script>
  56 + <script>
  57 + var contextPath = '<%=basePath %>';
  58 +
  59 + </script>
  60 + <title>YOHO!运维</title>
  61 +</head>
  62 +<body>
  63 +
  64 +<!-- 头部 -->
  65 +<div id="head">
  66 +
  67 +</div>
  68 +<!-- 右侧具体内容 -->
  69 +<div id="content">
  70 +
  71 +<div id="breadcrumb">
  72 + <a href="#" title="Go to Home" class="tip-bottom"><i
  73 + class="icon-home"></i> Home</a> <a href="#" class="current">降级服务配置</a>
  74 +</div>
  75 +
  76 +<div class="container-fluid">
  77 + <div class="widget-box">
  78 + <div class="widget-title">
  79 +
  80 + <h5>ZK配置</h5>
  81 +
  82 + </div>
  83 + <div class="widget-content nopadding">
  84 + <div class="widget-title" style="height: 53px;">
  85 + <div>
  86 + <div class="form-inline" role="form" id="inBoxQueryDiv"
  87 + style=" margin-top: 12px;margin-left: 25px;float: left;">
  88 + <div class="input-group" style="float: left;">
  89 + <span class="input-group-addon">服务器:</span>
  90 + <select id="cloudType" name="cloudType" class="form-control">
  91 + <option value="zookeeper_aws">aws</option>
  92 + <option value="zookeeper_qq">qCloud</option>
  93 + </select>
  94 + </div>
  95 + <div class="input-group" style="float: left;">
  96 + <span class="input-group-addon">配置名称:</span>
  97 + <input type="text" id="configName" name="configName" class="form-control" placeholder=""/>
  98 + </div>
  99 + <div class="input-group" style="float: left;">
  100 + <span class="input-group-addon">级别:</span>
  101 + <select id="level" name="level" class="form-control">
  102 + <option value="">全部</option>
  103 + <option value="1">一级</option>
  104 + <option value="2">二级</option>
  105 + </select>
  106 + </div>
  107 + <div class="input-group" style="float: left;">
  108 + <span class="input-group-addon">开关:</span>
  109 + <select id="switch" name="switch" class="form-control">
  110 + <option value="">全部</option>
  111 + <option value="Y"></option>
  112 + <option value="N"></option>
  113 + </select>
  114 + </div>
  115 + <button id="searchDegradeInfoBtn" class="btn btn-primary" style="margin-left: 18px;">搜索</button>
  116 + </div>
  117 + </div>
  118 + </div>
  119 + <div id="degradeInfoTable">
  120 +
  121 + </div>
  122 + </div>
  123 + </div>
  124 +</div>
  125 +</div>
  126 +</body>
  127 +<script>
  128 + $(function () {
  129 + $("#degradeInfoTable").table({
  130 + url: contextPath + "degrade/getList?",
  131 + striped : true,
  132 + pagination : true,
  133 + pageSize : 10,
  134 + loadFilter: function (data) {
  135 + return defaultLoadFilter(data);
  136 + },
  137 + columns: [{
  138 + title: "配置名称",
  139 + width:"25%",
  140 + align:"left",
  141 + field: "configName"
  142 + }, {
  143 + title: "配置描述",
  144 + width:"35%",
  145 + field: "configDesc"
  146 + }, {
  147 + title: "级别",
  148 + width:"10%",
  149 + field: "level",
  150 + formatter : function(value, rowData, rowIndex) {
  151 + if(value == 1){
  152 + return '一级';
  153 + }else if(value == 2){
  154 + return '二级';
  155 + }
  156 + },
  157 + }, {
  158 + title: "图片",
  159 + width:"10%",
  160 + field: "img"
  161 + }, {
  162 + title: "开关",
  163 + width:"10%",
  164 + field: "switchOn",
  165 + formatter : function(value, rowData, rowIndex) {
  166 + if(value == "Y"){
  167 + return '开';
  168 + }else{
  169 + return '关';
  170 + }
  171 + },
  172 + }, {
  173 + title: "操作",
  174 + width:"10%",
  175 + formatter: function (value, rowData, rowIndex) {
  176 + var div = $("<div>");
  177 + //修改
  178 + var editBtn = $("<button data-target='#updateModal' data-toggle='modal'>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
  179 + editBtn.click(function () {
  180 + updateDegradeInfo(rowData);
  181 + });
  182 + return div;
  183 + }
  184 + }],
  185 + });
  186 +
  187 + });
  188 +
  189 +function updateDegradeInfo(rowData){
  190 + paramObj.id = rowData.id;
  191 + paramObj.configName = rowData.configName;
  192 + paramObj.configDesc = rowData.configDesc;
  193 + paramObj.level = rowData.level;
  194 + paramObj.switchOn = rowData.switchOn;
  195 + var dialog0 = $("<div>").appendTo($("body"));
  196 + dialog0.dialog({
  197 + size : "modal-lg",
  198 + title : "修改路径",
  199 + backdrop : "static",
  200 + href : contextPath +"/jsp/degrade/degradeEdit.jsp",
  201 + buttons : [{
  202 + text : "关闭",
  203 + className : "btn-danger",
  204 + onclick : function() {
  205 + $(dialog0).dialog("hide");
  206 + }
  207 + }, {
  208 + text : "提交",
  209 + className : "btn-success",
  210 + onclick : function() {
  211 +
  212 + var btn = $(this);
  213 + $(dialog0).dialog("hide");
  214 + $("#degradeInfoForm").form("submit", {
  215 + submitUrl : contextPath + "/degrade/edit.do",
  216 + submitData : {
  217 + id : rowData.id
  218 + },
  219 + onBeforeSubmit : function() {
  220 +
  221 + if (!$(this).form("validate")) {
  222 + btn.removeAttr("disabled");
  223 + return false;
  224 + }
  225 + },
  226 + success : function(data) {
  227 + var mes="";
  228 + if(data.data==1){
  229 + mes="修改成功";
  230 + }else{
  231 + mes="修改失败";
  232 + }
  233 + if(data.data==1){
  234 +
  235 + var dialog = $("<div>").appendTo($("body"));
  236 + dialog.dialog({
  237 + title :mes,
  238 + backdrop : "static",
  239 + content : mes,
  240 + buttons : [{
  241 + text : "确定",
  242 + className : "btn-success",
  243 + onclick : function() {
  244 + $(dialog).dialog("hide");
  245 + $("#degradeInfoTable").table("load");
  246 + }
  247 + }]
  248 + });
  249 + }
  250 + $(dialog0).dialog("hide");
  251 + }
  252 + });
  253 + }
  254 + }]
  255 + });
  256 +}
  257 +
  258 + //点击查询按钮
  259 + $("#searchDegradeInfoBtn").click(function () {
  260 + var level = $("#level").val();//=="0"?null:$("#level").val();
  261 + var cloudType = $("#cloudType").val();
  262 + var configName=$("#configName").val();
  263 + var switchOn= $("#switch").val();//=="0"?null:$("#switch").val();
  264 +
  265 + $("#degradeInfoTable").table("load", {
  266 + 'cloudType': cloudType,
  267 + 'level': level ,
  268 + 'configName': configName ,
  269 + 'switchOn' : switchOn
  270 + });
  271 + });
  272 +
  273 +</script>
  274 +<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
  275 +</html>
@@ -22,6 +22,7 @@ innerHTML += "<li id='li_redisInfo'><a id='li_redisInfo_a' href=''><i class='ico @@ -22,6 +22,7 @@ innerHTML += "<li id='li_redisInfo'><a id='li_redisInfo_a' href=''><i class='ico
22 innerHTML += "<li id='li_nginxview'><a id='li_nginxview_a' href=''><i class='icon icon-th'></i> <span>Nginx监控</span></a></li>"; 22 innerHTML += "<li id='li_nginxview'><a id='li_nginxview_a' href=''><i class='icon icon-th'></i> <span>Nginx监控</span></a></li>";
23 innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>"; 23 innerHTML += "<li id='li_nginxSync'><a id='li_nginxSync_a' href=''><i class='icon icon-th'></i> <span>Nginx配置同步</span></a></li>";
24 innerHTML += "<li id='li_dns_monitor'><a id='li_dns_monitor_a' href=''><i class='icon icon-th'></i> <span>DNS反劫持监控</span></a></li>"; 24 innerHTML += "<li id='li_dns_monitor'><a id='li_dns_monitor_a' href=''><i class='icon icon-th'></i> <span>DNS反劫持监控</span></a></li>";
  25 +innerHTML += "<li id='li_dns_monitor'><a id='li_degrade_info_a' href=''><i class='icon icon-th'></i> <span>降级服务配置</span></a></li>";
25 26
26 /*Hystrix*/ 27 /*Hystrix*/
27 innerHTML += "<li class='submenu' id='li_hystrix'><a id='a_hystrix' href='#'><i class='icon icon-th-list'></i> <span>Hystrix</span><span class='label'>2</span></a>"; 28 innerHTML += "<li class='submenu' id='li_hystrix'><a id='a_hystrix' href='#'><i class='icon icon-th-list'></i> <span>Hystrix</span><span class='label'>2</span></a>";
@@ -85,6 +86,7 @@ document.getElementById("li_dns_monitor_a").setAttribute("href", path + "/dns_mo @@ -85,6 +86,7 @@ document.getElementById("li_dns_monitor_a").setAttribute("href", path + "/dns_mo
85 document.getElementById("li_nginxSync_a").setAttribute("href", path + "/nginxSync/toNginxSync"); 86 document.getElementById("li_nginxSync_a").setAttribute("href", path + "/nginxSync/toNginxSync");
86 document.getElementById("li_om_a").setAttribute("href", path + "/project/toOm"); 87 document.getElementById("li_om_a").setAttribute("href", path + "/project/toOm");
87 document.getElementById("li_node_a").setAttribute("href", path + "/project/toNode"); 88 document.getElementById("li_node_a").setAttribute("href", path + "/project/toNode");
  89 +document.getElementById("li_degrade_info_a").setAttribute("href", path + "/degrade/info");
88 90
89 91
90 function getUrlBasePath() { 92 function getUrlBasePath() {