Authored by xuhui

Merge branch 'master' into qcloudOnly

@@ -209,6 +209,8 @@ public class HttpUriContants { @@ -209,6 +209,8 @@ public class HttpUriContants {
209 public static final String CENTERSWITCH_SWITCH_CHECK = "/centerSwitch/doExeAndCheck"; 209 public static final String CENTERSWITCH_SWITCH_CHECK = "/centerSwitch/doExeAndCheck";
210 public static final String CENTERSWITCH_SWITCH_BEFORE = "/centerSwitch/doExeAndCheckBefore"; 210 public static final String CENTERSWITCH_SWITCH_BEFORE = "/centerSwitch/doExeAndCheckBefore";
211 public static final String CENTERSWITCH_SWITCH_SMS_CHECK = "/centerSwitch/checkSmsCode"; 211 public static final String CENTERSWITCH_SWITCH_SMS_CHECK = "/centerSwitch/checkSmsCode";
  212 + //只是查看状态
  213 + public static final String CENTERSWITCH_STATUS = "/centerSwitch/checkStatus";
212 214
213 //java监控信息 215 //java监控信息
214 public static final String JAVA_MONITOR_GET = "/newJavaApiInfo/queryByServiceType"; 216 public static final String JAVA_MONITOR_GET = "/newJavaApiInfo/queryByServiceType";
@@ -48,11 +48,8 @@ public class CenterSwitchCtrl { @@ -48,11 +48,8 @@ public class CenterSwitchCtrl {
48 public BaseResponse doExe(CenterSwitchModel centerSwitchModel){ 48 public BaseResponse doExe(CenterSwitchModel centerSwitchModel){
49 BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH, centerSwitchModel, BaseResponse.class); 49 BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH, centerSwitchModel, BaseResponse.class);
50 return baseResponse; 50 return baseResponse;
51 -  
52 } 51 }
53 52
54 -  
55 -  
56 @RequestMapping("/toCenterSwitchNew") 53 @RequestMapping("/toCenterSwitchNew")
57 public ModelAndView toCenterSwitchNew(){ 54 public ModelAndView toCenterSwitchNew(){
58 55
@@ -63,7 +60,6 @@ public class CenterSwitchCtrl { @@ -63,7 +60,6 @@ public class CenterSwitchCtrl {
63 public BaseResponse doExeAndCheck(CenterSwitchModel centerSwitchModel){ 60 public BaseResponse doExeAndCheck(CenterSwitchModel centerSwitchModel){
64 BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_CHECK, centerSwitchModel, BaseResponse.class); 61 BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_CHECK, centerSwitchModel, BaseResponse.class);
65 return baseResponse; 62 return baseResponse;
66 -  
67 } 63 }
68 64
69 @RequestMapping("/doExeAndCheckBefore") 65 @RequestMapping("/doExeAndCheckBefore")
@@ -78,4 +74,9 @@ public class CenterSwitchCtrl { @@ -78,4 +74,9 @@ public class CenterSwitchCtrl {
78 return httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_SMS_CHECK+"?code="+code, null, BaseResponse.class); 74 return httpClient.defaultPost(HttpUriContants.CENTERSWITCH_SWITCH_SMS_CHECK+"?code="+code, null, BaseResponse.class);
79 } 75 }
80 76
  77 + @RequestMapping("/checkStatus")
  78 + public BaseResponse checkStatus(CenterSwitchModel centerSwitchModel){
  79 + BaseResponse baseResponse = httpClient.defaultPost(HttpUriContants.CENTERSWITCH_STATUS, centerSwitchModel, BaseResponse.class);
  80 + return baseResponse;
  81 + }
81 } 82 }
@@ -77,6 +77,9 @@ @@ -77,6 +77,9 @@
77 <h4 style="display: inline">切换操作</h4> 77 <h4 style="display: inline">切换操作</h4>
78 </div> 78 </div>
79 <div class="panel-body"> 79 <div class="panel-body">
  80 + <button class="btn btn-large btn-primary" style="background-color: green" id="status-btn" onclick="checkStatus()">
  81 + 查看状态(可以随时查看)
  82 + </button>
80 <button class="btn btn-large btn-primary" id="toaws-btn" onclick="toDoExe('toAws')"> 83 <button class="btn btn-large btn-primary" id="toaws-btn" onclick="toDoExe('toAws')">
81 所有流量切向aws 84 所有流量切向aws
82 </button> 85 </button>
@@ -156,6 +159,15 @@ @@ -156,6 +159,15 @@
156 </html> 159 </html>
157 160
158 <script> 161 <script>
  162 + var array = new Array();
  163 + $(document).ready(function () {
  164 + array.push("switch_redis");
  165 + array.push("switch_internel_dns");
  166 + array.push("switch_cobar");
  167 + array.push("switch_lua");
  168 + array.push("switch_dnspod");
  169 + });
  170 +
159 //执行切换 171 //执行切换
160 function toDoExe(toCloud) { 172 function toDoExe(toCloud) {
161 $("input[name='cloud_name']").val(toCloud); 173 $("input[name='cloud_name']").val(toCloud);
@@ -186,12 +198,6 @@ @@ -186,12 +198,6 @@
186 if(resp.code == 200){ 198 if(resp.code == 200){
187 $('#confirmSubmitDivId').modal('hide'); 199 $('#confirmSubmitDivId').modal('hide');
188 $("#detail-div").empty(); 200 $("#detail-div").empty();
189 - var array = new Array();  
190 - array.push("switch_redis");  
191 - array.push("switch_internel_dns");  
192 - array.push("switch_cobar");  
193 - array.push("switch_lua");  
194 - array.push("switch_dnspod");  
195 for (var i = 0; i < array.length; i++) { 201 for (var i = 0; i < array.length; i++) {
196 $("#" + array[i] + "-btn").removeClass("btn-success"); 202 $("#" + array[i] + "-btn").removeClass("btn-success");
197 } 203 }
@@ -218,6 +224,7 @@ @@ -218,6 +224,7 @@
218 'exe': commond 224 'exe': commond
219 }, 225 },
220 dataType: 'json', 226 dataType: 'json',
  227 + async: false,
221 success: function (resp) { 228 success: function (resp) {
222 $("#"+name+"-btn").removeClass("btn-warning"); 229 $("#"+name+"-btn").removeClass("btn-warning");
223 $("#"+name+"-btn").addClass("btn-success"); 230 $("#"+name+"-btn").addClass("btn-success");
@@ -234,4 +241,35 @@ @@ -234,4 +241,35 @@
234 } 241 }
235 }); 242 });
236 } 243 }
  244 +
  245 + function checkStatus(){
  246 + $("#detail-div").empty();
  247 + for (var i = 0; i < array.length; i++) {
  248 + $.ajax({
  249 + type: 'post',
  250 + url: contextPath + "/centerSwitch/checkStatus",
  251 + data: {
  252 + 'name': array[i],
  253 + 'exe': 'status'
  254 + },
  255 + dataType: 'json',
  256 + async: false,
  257 + success: function (data) {
  258 + if (!data || data.code != 200) {
  259 + var div = "<h4 class=\"alert-heading\">"+data.message+"</h4>";
  260 + $("#detail-div").append(div);
  261 + return;
  262 + }
  263 + var div = "<div class=\"alert alert-info alert-block\">";
  264 + div = div + "<h4 class=\"alert-heading\">" + array[i] + "</h4>";
  265 + div = div + data.data + "</div>";
  266 + $("#detail-div").append(div);
  267 + },
  268 + error: function () {
  269 + var div = "<div>查看状态请求异常</div>";
  270 + $("#detail-div").append(div);
  271 + }
  272 + });
  273 + }
  274 + }
237 </script> 275 </script>