Authored by bblu

nginx->gateway 前台修改

... ... @@ -110,7 +110,7 @@
<dd>
<ul>
<c:forEach items="${map.server}" var="server">
<li>${server}</li>
<li class="aws${map.name}Ips">${server}</li>
</c:forEach>
</ul>
</dd>
... ... @@ -124,27 +124,27 @@
<button class="btn btn-sm ">
线上切换
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','qcloud','online','${awsList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','qcloud','online')">
<i class="icon-cogs bigger-110"></i>
切向qcloud
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','aws','online','${awsList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','aws','online')">
<i class="icon-cogs bigger-110"></i>
切向aws
</button><br><br>
<button class="btn btn-sm ">
灰度切换
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','qcloud','gray','${awsList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','qcloud','gray')">
<i class="icon-cogs bigger-110"></i>
切向qcloud
</button>
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','aws','gray','${awsList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','aws','gray')">
<i class="icon-cogs bigger-110"></i>
切向aws
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','gray','gray','${awsList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('aws','gray','gray')">
<i class="icon-cogs bigger-110"></i>
切向gray
</button>
... ... @@ -167,7 +167,7 @@
<dd>
<ul>
<c:forEach items="${map.server}" var="server">
<li>${server}</li>
<li class="qcloud${map.name}Ips">${server}</li>
</c:forEach>
</ul>
</dd>
... ... @@ -180,11 +180,11 @@
<button class="btn btn-sm ">
线上切换
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','qcloud','online','${qcloudList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','qcloud','online')">
<i class="icon-cogs bigger-110"></i>
切向qcloud
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','aws','online','${qcloudList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','aws','online')">
<i class="icon-cogs bigger-110"></i>
切向aws
</button>
... ... @@ -192,15 +192,15 @@
<button class="btn btn-sm ">
灰度切换
</button>&nbsp;&nbsp;
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','qcloud','gray','${qcloudList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','qcloud','gray')">
<i class="icon-cogs bigger-110"></i>
切向qcloud
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','aws','gray','${qcloudList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','aws','gray')">
<i class="icon-cogs bigger-110"></i>
切向aws
</button>
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','gray','gray','${qcloudList}')">
<button class="btn btn-sm btn-success" onclick="initSwitch('qcloud','gray','gray')">
<i class="icon-cogs bigger-110"></i>
切向gray
</button>
... ...
... ... @@ -8,13 +8,14 @@ $(function () {
dialog3 = $("<div>").appendTo($("body"));
});
function initSwitch(cloudName, target, onlineOrGray, list) {
var arr = getNoChangeIpArr(onlineOrGray, list);
function initSwitch(cloudName, target, onlineOrGray) {
var arr = getNoChangeIpArr(cloudName, onlineOrGray);
if (undefined === arr || null === arr || 0 === arr.length) {
prompt("提示", "无可切换的gateway!");
return;
}
$(dialog2).empty();
dialog2.dialog({
title: "你确定切换吗",
backdrop: "static",
... ... @@ -43,12 +44,13 @@ function initSwitch(cloudName, target, onlineOrGray, list) {
function viewToChangeSuccess(resp) {
$(dialog2).dialog("hide");
$(dialog3).empty();
var data = JSON.parse(resp);
dialog3.dialog({
var a = dialog3.dialog({
title: "切换结果",
backdrop: "static",
content: data.data,
content: "<pre>" + data.data + "</pre>",
buttons: [{
text: "否",
className: "btn-danger",
... ... @@ -57,12 +59,15 @@ function viewToChangeSuccess(resp) {
}
}, {
text: "确定",
className: "btn-danger",
className: "btn-success",
onclick: function () {
sendAjax("post", "switchNginxConf", {}, "text", switchSuccess, errorFunc);
}
}]
});
a.find(".modal-body").css({
height: "550px",
});
}
function switchSuccess() {
... ... @@ -75,32 +80,16 @@ function switchSuccess() {
* @param list 线上和灰度的upstream配置列表
* @returns {Array} 不切换服务器的ip列表
*/
function getNoChangeIpArr(onlineOrGray, list) {
function getNoChangeIpArr(cloudName, onlineOrGray) {
var list = $("." + cloudName + ("online" === onlineOrGray ? "grayapigateway" : "apigateway") + "Ips");
if (undefined === list || null === list || 0 === list.length) {
return [];
}
var arr = [];
var p = "";
if ("online" === onlineOrGray) {
p = "grayapigateway";
} else {
p = "apigateway";
}
for (var o in list) {
if (undefined === o || null === o || undefined === o.name || null === o.name || p !== o.name) {
continue;
}
if (undefined === o.server || null === o.server || 0 === o.server.length) {
continue;
}
for (var ob in o.server) {
if (undefined === ob || null === ob || '' === ob) {
continue;
}
arr.push(ob.split(":")[0].replace(" ", "").replace("server", ""));
}
}
return arr;
var result = [];
list.each(function () {
result.push($(this).text().split(":")[0]);
})
return result;
}
/**
... ... @@ -109,6 +98,7 @@ function getNoChangeIpArr(onlineOrGray, list) {
* @param content
*/
function prompt(title, content) {
$(dialog1).empty();
dialog1.dialog({
title: title,
backdrop: "static",
... ...