Authored by bblu

lua切换前台功能修改

... ... @@ -103,6 +103,7 @@ public class HttpUriContants {
* luaswitch
*/
public static final String VIEW_LUA_CONF= "/luaswitch/viewConf";
public static final String VIEW_TOCHANGE_LUA_CONF= "/luaswitch/viewToChangeLuaConf";
public static final String SWITCH_LUA= "/luaswitch/switchConf";
/**
... ...
... ... @@ -46,11 +46,23 @@ public class LuaSwitchCtrl {
*
* @return 2016年5月12日下午1:49:48
*/
@RequestMapping(value = "switchConf")
@RequestMapping(value = "viewToChangeLuaConf")
@ResponseBody
public BaseResponse switchConf(String cloudName) {
public BaseResponse viewToChangeLuaConf(String cloudName) {
Map map = new HashMap<>();
map.put("cloudName",cloudName);
return httpRestClient.defaultGet(HttpUriContants.VIEW_TOCHANGE_LUA_CONF, BaseResponse.class, map);
}
/**
* 修改配置
*
* @return 2016年5月12日下午1:49:48
*/
@RequestMapping(value = "switchConf")
@ResponseBody
public BaseResponse switchConf() {
Map map = new HashMap<>();
return httpRestClient.defaultGet(HttpUriContants.SWITCH_LUA, BaseResponse.class, map);
}
... ...
... ... @@ -28,7 +28,6 @@
<script src="<%=basePath %>js/typeahead-bs2.min.js" type="text/javascript"></script>
<script src="<%=basePath %>js/ace-elements.min.js" type="text/javascript"></script>
<script src="<%=basePath %>js/ace.min.js" type="text/javascript"></script>
<script src="<%=basePath %>script/nginx_switch.js" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" type="text/javascript"></script>
<script src="<%=basePath %>/js/unicorn.js" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
... ... @@ -117,9 +116,10 @@
<script src="<%=basePath %>script/common/genarate_left_panel.js" type="text/javascript"></script>
<script type="text/javascript">
var dialog1, dialog2;
function initSwitch(cloudName) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
dialog1 = $("<div>").appendTo($("body"));
dialog1.dialog({
title: "你确定切换吗",
backdrop: "static",
content: "你确定要将脚本切换至" + cloudName + "吗?",
... ... @@ -127,7 +127,7 @@
text: "否",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
$(dialog1).dialog("hide");
}
}, {
text: "是",
... ... @@ -136,37 +136,57 @@
var param = {
cloudName: cloudName
};
$.ajax({
type: 'post',
url: 'switchConf',
data: param,
dataType: 'text',
success: function (resp) {
$(dialog).dialog("hide");
var data = JSON.parse(resp);
var dialog2 = $("<div>").appendTo($("body"));
dialog2.dialog({
title: "切换结果",
backdrop: "static",
content: data.data,
buttons: [{
text: "确定",
className: "btn-danger",
onclick: function () {
window.location.href = contextPath + "/luaswitch/toLuaSwitch";
}
}]
});
},
error: function () {
layer.msg("异常", {icon: 2});
}
});
sendAjax("post", "viewToChangeLuaConf", param, "text", viewToChangeSuccess, errorFunc);
}
}]
});
}
function viewToChangeSuccess(resp) {
$(dialog1).dialog("hide");
var data = JSON.parse(resp);
dialog2 = $("<div>").appendTo($("body"));
dialog2.dialog({
title: "切换结果",
backdrop: "static",
content: data.data,
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
$(dialog2).dialog("hide");
}
}, {
text: "确定",
className: "btn-success",
onclick: function () {
sendAjax("post", "switchConf", {}, "text", switchSuccess, errorFunc);
}
}]
}).find(".modal-body").css({
height: "550px"
});
}
function switchSuccess() {
window.location.href = contextPath + "/luaswitch/toLuaSwitch";
}
function sendAjax(type, url, data, dataType, success, error) {
$.ajax({
type: type,
url: url,
data: data,
dataType: dataType,
success: success,
error: error
});
}
function errorFunc() {
layer.msg("Token异常", {icon: 2});
}
</script>
</body>
</html>
... ...
$(function () {});
var dialog1;
var dialog2;
var dialog3;
var dialog1, dialog2, dialog3;
function initSwitch(cloudName, target, onlineOrGray) {
var arr = getNoChangeIpArr(cloudName, onlineOrGray);
if (undefined === arr || null === arr || 0 === arr.length) {
... ...