Authored by zhengyouwei

nginx 切换修改

@@ -45,30 +45,16 @@ public class NginxSwitchCtrl { @@ -45,30 +45,16 @@ public class NginxSwitchCtrl {
45 } 45 }
46 46
47 /** 47 /**
48 - * 发送验证码  
49 - *  
50 - * @return 2016年5月23日下午13:39:48  
51 - */  
52 - @RequestMapping(value = "switchbefore")  
53 - @ResponseBody  
54 - public BaseResponse switchbefore(String cloudName, String target) {  
55 - Map map = new HashMap<>();  
56 - map.put("cloudName",cloudName);  
57 - map.put("target",target);  
58 - return httpRestClient.defaultGet(HttpUriContants.SWITCH_BEFORE, BaseResponse.class, map);  
59 - }  
60 -  
61 - /**  
62 * 修改配置 48 * 修改配置
63 * 49 *
64 * @return 2016年5月12日下午1:49:48 50 * @return 2016年5月12日下午1:49:48
65 */ 51 */
66 @RequestMapping(value = "switchNginxConf") 52 @RequestMapping(value = "switchNginxConf")
67 @ResponseBody 53 @ResponseBody
68 - public BaseResponse switchNginxConf(String token, String ticket) { 54 + public BaseResponse switchNginxConf(String cloudName, String target) {
69 Map map = new HashMap<>(); 55 Map map = new HashMap<>();
70 - map.put("token",token);  
71 - map.put("ticket",ticket); 56 + map.put("cloudName",cloudName);
  57 + map.put("target",target);
72 return httpRestClient.defaultGet(HttpUriContants.SWITCH_NGINX, BaseResponse.class, map); 58 return httpRestClient.defaultGet(HttpUriContants.SWITCH_NGINX, BaseResponse.class, map);
73 } 59 }
74 60
@@ -131,26 +131,18 @@ @@ -131,26 +131,18 @@
131 loadFilter: function (data) { 131 loadFilter: function (data) {
132 return defaultLoadFilter(data); 132 return defaultLoadFilter(data);
133 }, 133 },
134 - columns: [{  
135 - title: "id",  
136 - field: "localid",  
137 - width: "5%"  
138 - }, { 134 + columns: [ {
139 title: "环境", 135 title: "环境",
140 field: "environment", 136 field: "environment",
141 - width: "5%" 137 + width: "10%"
142 }, { 138 }, {
143 title: "操作", 139 title: "操作",
144 field: "operate", 140 field: "operate",
145 - width: "5%" 141 + width: "10%"
146 }, { 142 }, {
147 title: "用户", 143 title: "用户",
148 field: "user", 144 field: "user",
149 - width: "5%"  
150 - }, {  
151 - title: "分支",  
152 - field: "branch",  
153 - width: "5%" 145 + width: "10%"
154 }, { 146 }, {
155 title: "当前项目", 147 title: "当前项目",
156 field: "currentProject", 148 field: "currentProject",
@@ -160,13 +152,13 @@ @@ -160,13 +152,13 @@
160 field: "status", 152 field: "status",
161 formatter : function(value, rowData, rowIndex) { 153 formatter : function(value, rowData, rowIndex) {
162 if(value == 1){ 154 if(value == 1){
163 - return '正在进行'; 155 + return '成功';
164 } else if(value == 2){ 156 } else if(value == 2){
165 - return '正常结束'; 157 + return '成功';
166 }else if(value == 3){ 158 }else if(value == 3){
167 - return '强制取消'; 159 + return '取消发布';
168 }else if(value == 4){ 160 }else if(value == 4){
169 - return '出错取消'; 161 + return '失败';
170 }else{ 162 }else{
171 return '其他'; 163 return '其他';
172 } 164 }
@@ -179,7 +171,7 @@ @@ -179,7 +171,7 @@
179 },{ 171 },{
180 title: "执行顺序", 172 title: "执行顺序",
181 field: "projectOrder", 173 field: "projectOrder",
182 - width: "30%" 174 + width: "25%"
183 },{ 175 },{
184 title: "时间", 176 title: "时间",
185 field: "createTime", 177 field: "createTime",
@@ -228,43 +228,6 @@ @@ -228,43 +228,6 @@
228 228
229 </div> 229 </div>
230 230
231 -  
232 -  
233 -  
234 -  
235 -<div class="modal fade" id="validateToken" tabindex="-1" role="dialog" aria-labelledby="validateTokenLabel"  
236 - aria-hidden="true" style="padding-top: 10%">  
237 - <div class="modal-dialog">  
238 - <div class="modal-content">  
239 - <div class="modal-header">  
240 - <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>  
241 - <h2 class="modal-title" id="validateTokenLabel">  
242 - <span style="font-weight: bold;"> 验证短信</span>  
243 - </h2>  
244 - </div>  
245 - <div class="modal-body">  
246 - <form class="bs-example bs-example-form" action="" role="form" id="tokenForm">  
247 - <br>  
248 -  
249 - <div class="input-group">  
250 - <span class="input-group-addon">SMS</span>  
251 - <input type="text" name="ticket" class="form-control">  
252 - <input type="hidden" name="token">  
253 - </div>  
254 - <br>  
255 -  
256 - <div class="alert alert-danger" id="validateTokenRltInfo">  
257 - 验证失败,请重试;  
258 - </div>  
259 - </form>  
260 - </div>  
261 - <div class="modal-footer">  
262 - <button type="button" class="btn btn-primary" onclick="switchNginxConf()">验证</button>  
263 - <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>  
264 - </div>  
265 - </div>  
266 - </div>  
267 -</div>  
268 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script> 231 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
269 <script> 232 <script>
270 $("#li_switch").addClass("active open"); 233 $("#li_switch").addClass("active open");
@@ -3,49 +3,39 @@ $(function () { @@ -3,49 +3,39 @@ $(function () {
3 }); 3 });
4 4
5 function initSwitch(cloudName,target){ 5 function initSwitch(cloudName,target){
6 - $("input[name='ticket']").val("");  
7 - var param = {  
8 - cloudName:cloudName,  
9 - target:target  
10 - }  
11 - $.ajax({  
12 - type : 'post',  
13 - url : 'switchbefore',  
14 - data : param,  
15 - dataType : 'text',  
16 - success : function(resp) {  
17 - var data = JSON.parse(resp);  
18 - if(data.code=="201"){  
19 - layer.msg("Token异常", {icon: 2});  
20 - }else{  
21 - $("input[name='token']").val(data.data);  
22 - $("#validateToken").modal('show');  
23 - $("#validateTokenRltInfo").hide(); 6 + var dialog = $("<div>").appendTo($("body"));
  7 + dialog.dialog({
  8 + title: "你确定切换吗",
  9 + backdrop: "static",
  10 + content: "你确定要将"+cloudName +"上的流量切向"+target +"吗?",
  11 + buttons: [{
  12 + text: "否",
  13 + className: "btn-danger",
  14 + onclick: function () {
  15 + $(dialog).dialog("hide");
24 } 16 }
25 - },  
26 - error : function(data) {  
27 - layer.msg("Token异常", {icon: 2});  
28 - }  
29 - });  
30 -}  
31 -  
32 -function switchNginxConf(){  
33 - $.ajax({  
34 - type : 'post',  
35 - url : 'switchNginxConf',  
36 - data : $('#tokenForm').serialize(),  
37 - dataType : 'text',  
38 - success : function(resp) {  
39 - var data = JSON.parse(resp);  
40 - if(data.code=="201"){  
41 - $("#validateTokenRltInfo").show();  
42 - }else{  
43 - window.location.href= getUrlBasePath() + "/nginxswitch/toNginxSwitch"; 17 + }, {
  18 + text: "是",
  19 + className: "btn-success",
  20 + onclick: function () {
  21 + var param = {
  22 + cloudName:cloudName,
  23 + target:target
  24 + }
  25 + $.ajax({
  26 + type : 'post',
  27 + url : 'switchNginxConf',
  28 + data : param,
  29 + dataType : 'text',
  30 + success : function(resp) {
  31 + window.location.href= getUrlBasePath() + "/nginxswitch/toNginxSwitch";
  32 + },
  33 + error : function(data) {
  34 + layer.msg("Token异常", {icon: 2});
  35 + }
  36 + });
44 } 37 }
45 - },  
46 - error : function(data) {  
47 - $("#validateTokenRltInfo").hide();  
48 - layer.msg("切换失败", {icon: 2});  
49 - } 38 + }]
50 }); 39 });
  40 +
51 } 41 }