Authored by qinchao

nginx切换调整

@@ -87,19 +87,19 @@ @@ -87,19 +87,19 @@
87 </button> 87 </button>
88 <div class="col-sm-8" style="display: inline"> 88 <div class="col-sm-8" style="display: inline">
89 <div class="rdio rdio-default" style="display:inline;"> 89 <div class="rdio rdio-default" style="display:inline;">
90 - <input type="radio" name="target_operate_nginx" id="az1_target_operate_az1" 90 + <input type="radio" name="target_operate_nginx" id="az1_target_operate_az1" secondgroup="az1"
91 value="az1" /> 91 value="az1" />
92 <label for="az1_target_operate_az1">az1</label> 92 <label for="az1_target_operate_az1">az1</label>
93 </div> 93 </div>
94 94
95 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 95 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
96 - <input type="radio" name="target_operate_nginx" id="az1_target_operate_az2" 96 + <input type="radio" name="target_operate_nginx" id="az1_target_operate_az2" secondgroup="az1"
97 value="az2" /> 97 value="az2" />
98 <label for="az1_target_operate_az2">az2</label> 98 <label for="az1_target_operate_az2">az2</label>
99 </div> 99 </div>
100 100
101 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 101 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
102 - <input type="radio" name="target_operate_nginx" id="az1_target_operate_az3" 102 + <input type="radio" name="target_operate_nginx" id="az1_target_operate_az3" secondgroup="az1"
103 value="az3" /> 103 value="az3" />
104 <label for="az1_target_operate_az3">az3</label> 104 <label for="az1_target_operate_az3">az3</label>
105 </div> 105 </div>
@@ -119,19 +119,19 @@ @@ -119,19 +119,19 @@
119 </button> 119 </button>
120 <div class="col-sm-8" style="display: inline"> 120 <div class="col-sm-8" style="display: inline">
121 <div class="rdio rdio-default" style="display:inline;"> 121 <div class="rdio rdio-default" style="display:inline;">
122 - <input type="radio" name="target_operate_nginx" id="az2_target_operate_az1" 122 + <input type="radio" name="target_operate_nginx" id="az2_target_operate_az1" secondgroup="az2"
123 value="az1" /> 123 value="az1" />
124 <label for="az2_target_operate_az1">az1</label> 124 <label for="az2_target_operate_az1">az1</label>
125 </div> 125 </div>
126 126
127 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 127 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
128 - <input type="radio" name="target_operate_nginx" id="az2_target_operate_az2" 128 + <input type="radio" name="target_operate_nginx" id="az2_target_operate_az2" secondgroup="az2"
129 value="az2" /> 129 value="az2" />
130 <label for="az2_target_operate_az2">az2</label> 130 <label for="az2_target_operate_az2">az2</label>
131 </div> 131 </div>
132 132
133 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 133 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
134 - <input type="radio" name="target_operate_nginx" id="az2_target_operate_az3" 134 + <input type="radio" name="target_operate_nginx" id="az2_target_operate_az3" secondgroup="az2"
135 value="az3" /> 135 value="az3" />
136 <label for="az2_target_operate_az3">az3</label> 136 <label for="az2_target_operate_az3">az3</label>
137 </div> 137 </div>
@@ -152,19 +152,19 @@ @@ -152,19 +152,19 @@
152 </button> 152 </button>
153 <div class="col-sm-8" style="display: inline"> 153 <div class="col-sm-8" style="display: inline">
154 <div class="rdio rdio-default" style="display:inline;"> 154 <div class="rdio rdio-default" style="display:inline;">
155 - <input type="radio" name="target_operate_nginx" id="az3_target_operate_az1" 155 + <input type="radio" name="target_operate_nginx" id="az3_target_operate_az1" secondgroup="az3"
156 value="az1" /> 156 value="az1" />
157 <label for="az3_target_operate_az1">az1</label> 157 <label for="az3_target_operate_az1">az1</label>
158 </div> 158 </div>
159 159
160 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 160 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
161 - <input type="radio" name="target_operate_nginx" id="az3_target_operate_az2" 161 + <input type="radio" name="target_operate_nginx" id="az3_target_operate_az2" secondgroup="az3"
162 value="az2" /> 162 value="az2" />
163 <label for="az3_target_operate_az2">az2</label> 163 <label for="az3_target_operate_az2">az2</label>
164 </div> 164 </div>
165 165
166 <div class="rdio rdio-default" style="display:inline;margin-left:30px;"> 166 <div class="rdio rdio-default" style="display:inline;margin-left:30px;">
167 - <input type="radio" name="target_operate_nginx" id="az3_target_operate_az3" 167 + <input type="radio" name="target_operate_nginx" id="az3_target_operate_az3" secondgroup="az3"
168 value="az3" /> 168 value="az3" />
169 <label for="az3_target_operate_az3">az3</label> 169 <label for="az3_target_operate_az3">az3</label>
170 </div> 170 </div>
@@ -186,7 +186,7 @@ @@ -186,7 +186,7 @@
186 </div> 186 </div>
187 187
188 <script src="<%=basePath %>script/common/genarate_left_panel.js?v=<%=ProjectConstant.MENU_VERSION %>"></script> 188 <script src="<%=basePath %>script/common/genarate_left_panel.js?v=<%=ProjectConstant.MENU_VERSION %>"></script>
189 -<script src="<%=basePath %>script/switch.js?v=20180528-003"></script> 189 +<script src="<%=basePath %>script/switch.js?v=20180529-001"></script>
190 190
191 <script type="text/javascript"> 191 <script type="text/javascript">
192 $("#li_switch").addClass("active open"); 192 $("#li_switch").addClass("active open");
@@ -317,6 +317,76 @@ function resetLbNodeIp(node,data) { @@ -317,6 +317,76 @@ function resetLbNodeIp(node,data) {
317 } 317 }
318 } 318 }
319 319
  320 +/**
  321 + * "切向*"按钮点击事件,打开确认操作对话框
  322 + * @param cloudName 源中心名称
  323 + * @param target 目标中心名称
  324 + * @param onlineOrGray 切换:线上/灰度
  325 + */
  326 +function nginxInitSwitch(cloudName) {
  327 + var target = $('input:radio[name=target_operate_nginx]:checked').val();
  328 +
  329 + if(!target){
  330 + prompt("提示", "请选择目标nginx!");
  331 + return;
  332 + }
  333 +
  334 + if(cloudName!=$('input:radio[name=target_operate_nginx]:checked').attr("secondgroup")){
  335 + prompt("提示", "请选择["+cloudName+"区]目标nginx!");
  336 + return;
  337 + }
  338 +
  339 + var dialog = $("<div>").appendTo($("body"));
  340 + dialog.dialog({
  341 + title: "你确定切换吗",
  342 + backdrop: "static",
  343 + content: "你确定要将 " + cloudName + " 上的lb " + "流量切向 " + target + " 吗?",
  344 + buttons: [{
  345 + text: "否",
  346 + className: "btn-danger",
  347 + onclick: function () {
  348 + dialog.dialog("hide");
  349 + }
  350 + }, {
  351 + text: "是",
  352 + className: "btn-success",
  353 + onclick: function () {
  354 + var param = {
  355 + cloudName: cloudName,
  356 + target: target
  357 + };
  358 +
  359 + var layerMirror=layer.open( {
  360 + type:3,
  361 + //area: ['800px', '500px'],
  362 + content:"准备切换,请等待",
  363 + time: 0 //不自动关闭
  364 + });
  365 +
  366 + $.ajax({
  367 + url: contextPath+'topoSwitch/switchLbWeight',
  368 + type: "post",
  369 + dataType: "json",
  370 + data: param ,
  371 + success: function (data) {
  372 + console.log(data);
  373 + if(data.code != 200){
  374 + layer.close(layerMirror);
  375 + alert(data.message);
  376 + }else{
  377 + window.location.href = contextPath + "topoSwitch/toTopoSwitch";
  378 + }
  379 + },
  380 + error: function (e) {
  381 + alert("系统错误");
  382 + }
  383 + });
  384 + dialog.dialog("hide");
  385 + }
  386 + }]
  387 + });
  388 +}
  389 +
320 390
321 /** 391 /**
322 * 创建lua切换按钮 392 * 创建lua切换按钮
@@ -505,75 +575,7 @@ function switchSuccess() { @@ -505,75 +575,7 @@ function switchSuccess() {
505 window.location.href = getUrlBasePath() + "/topoSwitch/toTopoSwitch"; 575 window.location.href = getUrlBasePath() + "/topoSwitch/toTopoSwitch";
506 } 576 }
507 577
508 -/**  
509 - * "切向*"按钮点击事件,打开确认操作对话框  
510 - * @param cloudName 源中心名称  
511 - * @param target 目标中心名称  
512 - * @param onlineOrGray 切换:线上/灰度  
513 - */  
514 -function nginxInitSwitch(cloudName, target, onlineOrGray) {  
515 - //var arr = getNoChangeIpArr(cloudName, onlineOrGray);  
516 - //if (undefined === arr || null === arr || 0 === arr.length) {  
517 - // prompt("提示", "无可切换的gateway!");  
518 - // return;  
519 - //}  
520 - var target = $('input:radio[name=target_operate_nginx]:checked').val();  
521 -  
522 - if(!target){  
523 - prompt("提示", "请选择目标nginx!");  
524 - return;  
525 - }  
526 -  
527 - var dialog = $("<div>").appendTo($("body"));  
528 - dialog.dialog({  
529 - title: "你确定切换吗",  
530 - backdrop: "static",  
531 - content: "你确定要将 " + cloudName + " 上的lb " + "流量切向 " + target + " 吗?",  
532 - buttons: [{  
533 - text: "否",  
534 - className: "btn-danger",  
535 - onclick: function () {  
536 - dialog.dialog("hide");  
537 - }  
538 - }, {  
539 - text: "是",  
540 - className: "btn-success",  
541 - onclick: function () {  
542 - var param = {  
543 - cloudName: cloudName,  
544 - target: target  
545 - };  
546 -  
547 - var layerMirror=layer.open( {  
548 - type:3,  
549 - //area: ['800px', '500px'],  
550 - content:"准备切换,请等待",  
551 - time: 0 //不自动关闭  
552 - });  
553 578
554 - $.ajax({  
555 - url: contextPath+'topoSwitch/switchLbWeight',  
556 - type: "post",  
557 - dataType: "json",  
558 - data: param ,  
559 - success: function (data) {  
560 - console.log(data);  
561 - if(data.code != 200){  
562 - layer.close(layerMirror);  
563 - alert(data.message);  
564 - }else{  
565 - window.location.href = contextPath + "topoSwitch/toTopoSwitch";  
566 - }  
567 - },  
568 - error: function (e) {  
569 - alert("系统错误");  
570 - }  
571 - });  
572 - dialog.dialog("hide");  
573 - }  
574 - }]  
575 - });  
576 -}  
577 579
578 /** 580 /**
579 * 打开对话框,展示切换后的配置 581 * 打开对话框,展示切换后的配置