Authored by zhengyouwei

nginx 切换修改

... ... @@ -45,30 +45,16 @@ public class NginxSwitchCtrl {
}
/**
* 发送验证码
*
* @return 2016年5月23日下午13:39:48
*/
@RequestMapping(value = "switchbefore")
@ResponseBody
public BaseResponse switchbefore(String cloudName, String target) {
Map map = new HashMap<>();
map.put("cloudName",cloudName);
map.put("target",target);
return httpRestClient.defaultGet(HttpUriContants.SWITCH_BEFORE, BaseResponse.class, map);
}
/**
* 修改配置
*
* @return 2016年5月12日下午1:49:48
*/
@RequestMapping(value = "switchNginxConf")
@ResponseBody
public BaseResponse switchNginxConf(String token, String ticket) {
public BaseResponse switchNginxConf(String cloudName, String target) {
Map map = new HashMap<>();
map.put("token",token);
map.put("ticket",ticket);
map.put("cloudName",cloudName);
map.put("target",target);
return httpRestClient.defaultGet(HttpUriContants.SWITCH_NGINX, BaseResponse.class, map);
}
... ...
... ... @@ -131,26 +131,18 @@
loadFilter: function (data) {
return defaultLoadFilter(data);
},
columns: [{
title: "id",
field: "localid",
width: "5%"
}, {
columns: [ {
title: "环境",
field: "environment",
width: "5%"
width: "10%"
}, {
title: "操作",
field: "operate",
width: "5%"
width: "10%"
}, {
title: "用户",
field: "user",
width: "5%"
}, {
title: "分支",
field: "branch",
width: "5%"
width: "10%"
}, {
title: "当前项目",
field: "currentProject",
... ... @@ -160,13 +152,13 @@
field: "status",
formatter : function(value, rowData, rowIndex) {
if(value == 1){
return '正在进行';
return '成功';
} else if(value == 2){
return '正常结束';
return '成功';
}else if(value == 3){
return '强制取消';
return '取消发布';
}else if(value == 4){
return '出错取消';
return '失败';
}else{
return '其他';
}
... ... @@ -179,7 +171,7 @@
},{
title: "执行顺序",
field: "projectOrder",
width: "30%"
width: "25%"
},{
title: "时间",
field: "createTime",
... ...
... ... @@ -228,43 +228,6 @@
</div>
<div class="modal fade" id="validateToken" tabindex="-1" role="dialog" aria-labelledby="validateTokenLabel"
aria-hidden="true" style="padding-top: 10%">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h2 class="modal-title" id="validateTokenLabel">
<span style="font-weight: bold;"> 验证短信</span>
</h2>
</div>
<div class="modal-body">
<form class="bs-example bs-example-form" action="" role="form" id="tokenForm">
<br>
<div class="input-group">
<span class="input-group-addon">SMS</span>
<input type="text" name="ticket" class="form-control">
<input type="hidden" name="token">
</div>
<br>
<div class="alert alert-danger" id="validateTokenRltInfo">
验证失败,请重试;
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="switchNginxConf()">验证</button>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
</div>
</div>
</div>
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_switch").addClass("active open");
... ...
... ... @@ -3,49 +3,39 @@ $(function () {
});
function initSwitch(cloudName,target){
$("input[name='ticket']").val("");
var param = {
cloudName:cloudName,
target:target
}
$.ajax({
type : 'post',
url : 'switchbefore',
data : param,
dataType : 'text',
success : function(resp) {
var data = JSON.parse(resp);
if(data.code=="201"){
layer.msg("Token异常", {icon: 2});
}else{
$("input[name='token']").val(data.data);
$("#validateToken").modal('show');
$("#validateTokenRltInfo").hide();
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title: "你确定切换吗",
backdrop: "static",
content: "你确定要将"+cloudName +"上的流量切向"+target +"吗?",
buttons: [{
text: "否",
className: "btn-danger",
onclick: function () {
$(dialog).dialog("hide");
}
},
error : function(data) {
layer.msg("Token异常", {icon: 2});
}
});
}
function switchNginxConf(){
$.ajax({
type : 'post',
url : 'switchNginxConf',
data : $('#tokenForm').serialize(),
dataType : 'text',
success : function(resp) {
var data = JSON.parse(resp);
if(data.code=="201"){
$("#validateTokenRltInfo").show();
}else{
window.location.href= getUrlBasePath() + "/nginxswitch/toNginxSwitch";
}, {
text: "是",
className: "btn-success",
onclick: function () {
var param = {
cloudName:cloudName,
target:target
}
$.ajax({
type : 'post',
url : 'switchNginxConf',
data : param,
dataType : 'text',
success : function(resp) {
window.location.href= getUrlBasePath() + "/nginxswitch/toNginxSwitch";
},
error : function(data) {
layer.msg("Token异常", {icon: 2});
}
});
}
},
error : function(data) {
$("#validateTokenRltInfo").hide();
layer.msg("切换失败", {icon: 2});
}
}]
});
}
\ No newline at end of file
... ...