Authored by zhengyouwei

update centerswitch

@@ -14,6 +14,4 @@ public class CenterSwitchModel { @@ -14,6 +14,4 @@ public class CenterSwitchModel {
14 14
15 private String exe; 15 private String exe;
16 16
17 - private String toCloud;  
18 -  
19 } 17 }
@@ -78,6 +78,36 @@ @@ -78,6 +78,36 @@
78 </div> 78 </div>
79 79
80 </div> 80 </div>
  81 +
  82 +<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
  83 + <div class="modal-dialog" style="margin-top: 5%;
  84 + margin-left: auto;
  85 + height:50.333%;
  86 + width: 60%;
  87 + overflow:scroll;
  88 + overflow-x:auto;
  89 + overflow-y:auto ">
  90 + <div class="modal-content">
  91 + <div class="modal-header">
  92 + <button type="button" class="close" data-dismiss="modal"
  93 + aria-hidden="true">&times;</button>
  94 + <h4 class="modal-title" id="myModalLabel"></h4>
  95 + </div>
  96 + <div class="modal-body">
  97 + <div id="check_result_div" style="">
  98 +
  99 + </div>
  100 +
  101 + </div>
  102 + <div class="modal-footer">
  103 + <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
  104 + </div>
  105 + </div>
  106 + <!-- /.modal-content -->
  107 + </div>
  108 + <!-- /.modal -->
  109 +</div>
  110 +
81 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script> 111 <script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
82 <script type="text/javascript"> 112 <script type="text/javascript">
83 $("#li_switch").addClass("active open"); 113 $("#li_switch").addClass("active open");
@@ -99,36 +129,54 @@ @@ -99,36 +129,54 @@
99 columns: [{ 129 columns: [{
100 title: "切换项", 130 title: "切换项",
101 field: "cName", 131 field: "cName",
102 - width: "20%" 132 + width: "15%"
103 }, { 133 }, {
104 title: "切向QQ", 134 title: "切向QQ",
105 field: "name", 135 field: "name",
106 formatter: function (value, rowData, rowIndex) { 136 formatter: function (value, rowData, rowIndex) {
107 var div = $("<div>"); 137 var div = $("<div>");
108 - $("<button onclick=\"doExe(\'" + value + "\',\'qcloud\')\">").addClass("btn btn-primary").html("切换").appendTo(div); 138 + $("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
  139 + div.append("&nbsp;");
  140 + $("<button onclick=\"toDoExe(\'" + value + "\',\'toQcloud\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
  141 + div.append("&nbsp;");
  142 + $("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);
  143 +
109 return div; 144 return div;
110 }, 145 },
111 - width: "40%" 146 + width: "35%"
112 },{ 147 },{
113 title: "切回AWS", 148 title: "切回AWS",
114 field: "name", 149 field: "name",
115 formatter: function (value, rowData, rowIndex) { 150 formatter: function (value, rowData, rowIndex) {
116 var div = $("<div>"); 151 var div = $("<div>");
117 - $("<button onclick=\"doExe(\'" + value + "\',\'aws\')\">").addClass("btn btn-primary").html("切换").appendTo(div); 152 + $("<button onclick=\"doExe(\'" + value + "\',\'afterCheck\')\">").addClass("btn btn-xs btn-success").html("前检测").appendTo(div);
  153 + div.append("&nbsp;");
  154 + $("<button onclick=\"toDoExe(\'" + value + "\',\'toAws\')\">").addClass("btn btn-primary").html("切换").appendTo(div);
  155 + div.append("&nbsp;");
  156 + $("<button onclick=\"doExe(\'" + value + "\',\'beforeCheck\')\">").addClass("btn btn-xs btn-success").html("后检测").appendTo(div);
  157 + return div;
  158 + },
  159 + width: "35%"
  160 + },{
  161 + title: "状态查看",
  162 + field: "name",
  163 + formatter: function (value, rowData, rowIndex) {
  164 + var div = $("<div>");
  165 + $("<button onclick=\"doExe(\'" + value + "\',\'status\')\">").addClass("btn btn-primary").html("当前状态").appendTo(div);
118 return div; 166 return div;
119 }, 167 },
120 - width: "40%" 168 + width: "35%"
121 }] 169 }]
122 }); 170 });
123 }); 171 });
124 172
125 //执行切换 173 //执行切换
126 - function doExe(name, toCloud) { 174 + function toDoExe(name, toCloud) {
127 var dialog = $("<div>").appendTo($("body")); 175 var dialog = $("<div>").appendTo($("body"));
128 dialog.dialog({ 176 dialog.dialog({
129 title: "切换确定", 177 title: "切换确定",
130 backdrop: "static", 178 backdrop: "static",
131 - content: "name:"+name+" 切向:"+toCloud, 179 + content: "name:"+name+" exe:"+toCloud,
132 buttons: [{ 180 buttons: [{
133 text: "否", 181 text: "否",
134 className: "btn-danger", 182 className: "btn-danger",
@@ -140,11 +188,51 @@ @@ -140,11 +188,51 @@
140 className: "btn-success", 188 className: "btn-success",
141 onclick: function () { 189 onclick: function () {
142 $(dialog).dialog("hide"); 190 $(dialog).dialog("hide");
143 - window.open(contextPath + "centerSwitch/todoExe?name=" + name + "&toCloud=" + toCloud, "_self"); 191 + doExe(name,toCloud);
144 } 192 }
145 }] 193 }]
146 }); 194 });
147 } 195 }
148 196
  197 + //执行切换
  198 + function doExe(name, exe) {
  199 + var jq = $("#switchTable");
  200 +
  201 + $.ajax({
  202 + type: 'post',
  203 + url: contextPath + "/centerSwitch/doExe",
  204 + data:{
  205 + 'name':name,
  206 + 'exe':exe
  207 + },
  208 + dataType: 'json',
  209 + beforeSend:function(){
  210 + var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide();
  211 + var tableOffset = jq.offset();
  212 + var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true);
  213 + div.append($("<div>").addClass("table-loading").css({
  214 + left : (tableWidth - 124) / 2,
  215 + top : (tableHeight - 124) / 2
  216 + }));
  217 + div.css({
  218 + width : tableWidth,
  219 + height : tableHeight,
  220 + left : tableOffset.left,
  221 + top : tableOffset.top
  222 + });
  223 + div.show();
  224 + },
  225 + success: function (resp) {
  226 + $("body").find("div[tableSelector='"+ jq.selector +"']").remove();
  227 + $("#check_result_div").html(resp.data);
  228 + $("#myModalLabel").text("name:"+name+" exe:"+exe);
  229 + $("#myModal").modal('show');
  230 +
  231 + },
  232 + error: function (resp) {
  233 + }
  234 + });
  235 + }
  236 +
149 </script> 237 </script>
150   238  
@@ -100,10 +100,10 @@ @@ -100,10 +100,10 @@
100 url: contextPath + "/centerSwitch/doExe", 100 url: contextPath + "/centerSwitch/doExe",
101 data:{ 101 data:{
102 'name':name, 102 'name':name,
103 - 'toCloud':toCloud 103 + 'exe':toCloud
104 }, 104 },
105 dataType: 'json', 105 dataType: 'json',
106 - beforeSend:function(XMLHttpRequest){ 106 + beforeSend:function(){
107 var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide(); 107 var div = $("<div>").attr("tableSelector", jq.selector).addClass("modal-backdrop fade in").appendTo($("body")).hide();
108 var tableOffset = jq.offset(); 108 var tableOffset = jq.offset();
109 var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true); 109 var tableWidth = jq.outerWidth(true), tableHeight = jq.outerHeight(true);
@@ -129,12 +129,12 @@ @@ -129,12 +129,12 @@
129 129
130 }); 130 });
131 131
132 -// document.onkeydown = function()  
133 -// {  
134 -// if(event.keyCode==116 || event.keyCode==8 || (event.ctrlKey && event.keyCode==82) || event.keyCode == 13) {  
135 -// event.keyCode=0;  
136 -// event.returnValue = false;  
137 -// }  
138 -// }  
139 -// document.oncontextmenu = function() {event.returnValue = false;} 132 + document.onkeydown = function()
  133 + {
  134 + if(event.keyCode==116 || event.keyCode==8 || (event.ctrlKey && event.keyCode==82) || event.keyCode == 13) {
  135 + event.keyCode=0;
  136 + event.returnValue = false;
  137 + }
  138 + }
  139 + document.oncontextmenu = function() {event.returnValue = false;}
140 </script> 140 </script>
@@ -62,7 +62,7 @@ innerHTML += "<li id='li_projectHistory'><a id='li_projectHistory_a' href=''><i @@ -62,7 +62,7 @@ innerHTML += "<li id='li_projectHistory'><a id='li_projectHistory_a' href=''><i
62 innerHTML += "</ul></li>"; 62 innerHTML += "</ul></li>";
63 63
64 /*switch*/ 64 /*switch*/
65 -innerHTML += "<li class='submenu' id='li_switch'><a id='li_switch_a' href='#'><i class='icon icon-th-list'></i> <span>关键切换</span><span class='label'>3</span></a>"; 65 +innerHTML += "<li class='submenu' id='li_switch'><a id='li_switch_a' href='#'><i class='icon icon-th-list'></i> <span>关键切换</span><span class='label'>4</span></a>";
66 innerHTML += "<ul><li id='li_nginxswitch'><a id='li_nginxswitch_a' href=''>nginx切换</a></li>"; 66 innerHTML += "<ul><li id='li_nginxswitch'><a id='li_nginxswitch_a' href=''>nginx切换</a></li>";
67 innerHTML += "<li id='li_luaswitch'><a id='li_luaswitch_a' href='#'>LUA切换</a></li>"; 67 innerHTML += "<li id='li_luaswitch'><a id='li_luaswitch_a' href='#'>LUA切换</a></li>";
68 innerHTML += "<li id='li_javarestart'><a id='li_javarestart_a' href='#'>java重启</a></li>"; 68 innerHTML += "<li id='li_javarestart'><a id='li_javarestart_a' href='#'>java重启</a></li>";