Authored by mlge

新增 管理员--告警开关模块

... ... @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
/**
* Created by craig.qin on 2017/10/20.
... ... @@ -18,6 +19,49 @@ public class OpsSmsOnOffCtrl {
@Autowired
private HttpRestClient httpRestClient;
/**
* 跳转到 告警开关页面
* @return
*/
@RequestMapping("/toAlarmSwitch")
public ModelAndView toAlarmSwitch(){
ModelAndView mv = new ModelAndView("alarmgroup/alarmSwitch");
BaseResponse<String> resp = httpRestClient.defaultGet("/OpsSmsOnOff/getSmsSwitchValue", BaseResponse.class, null);
mv.addObject("smsSwitchValue",resp.getMessage());
resp = httpRestClient.defaultGet("/OpsSmsOnOff/getVoiceSmsSwitchValue", BaseResponse.class, null);
mv.addObject("voiceSwitchValue",resp.getMessage());
resp = httpRestClient.defaultGet("/OpsSmsOnOff/getDevSmsSwitchValue", BaseResponse.class, null);
mv.addObject("devSmsSwitchValue",resp.getMessage());
return mv;
}
/**
*
* @param switchName--开关名称
* @param value--切换操作(off:关闭;on:打开)
* @return
*/
@RequestMapping("/switchAlarm")//切换告警状态
@ResponseBody
public BaseResponse switchAlarm(String switchName,String value){
BaseResponse resp = null;
if("smsSwitchValue".equals(switchName) ){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turn?key=" + value, BaseResponse.class, null);
}else if("voiceSwitchValue".equals(switchName)){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turnVoice?key=" + value, BaseResponse.class, null);
}else if("devSmsSwitchValue".equals(switchName)){
resp = httpRestClient.defaultGet("/OpsSmsOnOff/turnDev?key=" + value, BaseResponse.class, null);
}
return resp;
}
//短信报警
@RequestMapping("/turnOn")
@ResponseBody
... ...
<%--
Created by IntelliJ IDEA.
User: meiling.ge
Date: 2017/10/24
Time: 16:14
To change this template use File | Settings | File Templates.
--%>
<%@page language="java" contentType="text/html;charset=utf-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=basePath %>css/bootstrap.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.main.css"/>
<link rel="stylesheet" href="<%=basePath %>css/unicorn.grey.css"/>
<link rel="stylesheet" href="<%=basePath %>css/jquery-ui.css"/>
<link rel="stylesheet" href="<%=basePath %>css/bootstrap-responsive.min.css"/>
<link rel="stylesheet" href="<%=basePath %>css/uniform.css"/>
<link rel="stylesheet" href="<%=basePath %>css/select2.css"/>
<link rel="stylesheet" href="<%=basePath %>js/select2/dist/css/select2.css"/>
<script src="<%=basePath %>js/excanvas.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-1.12.0.min.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/jquery-ui.custom.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>/js/bootstrap.min.js"></script>
<script src="<%=basePath %>/js/unicorn.js"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/moment-with-locales.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/datetimepicker/bootstrap-datetimepicker.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/global.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.pagination.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.table.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.dialog.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.panel.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.alerts.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.accordion.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.breadcrumb.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.validate.js" charset="UTF-8"
type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.form.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/layer/layer.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/bootstrap-plugin/bootstrap.select.js" charset="UTF-8" type="text/javascript"></script>
<script src="<%=basePath %>js/select2/dist/js/select2.full.js"></script>
<script src="<%=basePath %>js/jstree/jstree.min.js"></script>
<script src="<%=basePath %>js/jquery.toaster.js"></script>
<script>
var contextPath = '<%=basePath %>';
</script>
<title>YOHO!运维</title>
</head>
<body>
<!-- 头部 -->
<div id="head">
</div>
<!-- 右侧具体内容 -->
<div id="content">
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">管理员</a>
</div>
<div class="container-fluid">
<div class="widget-box">
<div class="widget-title">
<h5>告警开关配置</h5>
</div>
<div class="widget-content nopadding">
<div class="widget-title" style="height: 53px;">
</div>
</div>
<div id="taskTable" class="panel panel-default">
<div class="widget-content">告警开关列表</div>
<div class="panel-body" tablerole="body">
<table class="table table-striped table-bordered table-hover" >
<thead class="thin-border-bottom">
<tr>
<th align="center">告警系统</th>
<th align="center">告警类型</th>
<th align="center">开关当前状态</th>
<th align="center">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center" width="10%">运维ops</td>
<td align="center" width="10%">短信<a href="#"></a></td>
<td align="center" width="10%">
<c:choose>
<c:when test="${smsSwitchValue == 'false' }">
off
</c:when>
<c:otherwise>
on
</c:otherwise>
</c:choose>
</td>
<td align="center" width="10%">
<c:choose>
<c:when test="${smsSwitchValue == 'false' }">
<button onclick="switchValue('smsSwitchValue','on')" class="btn btn-xs btn-success">打开</button>
</c:when>
<c:otherwise>
<button onclick="switchValue('smsSwitchValue','off')" class="btn btn-xs btn-success">关闭</button>
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td align="center" width="10%">运维ops<a href="#"></a></td>
<td align="center" width="10%">语音<a href="#"></a></td>
<td align="center" width="10%">
<c:choose>
<c:when test="${voiceSwitchValue == 'false' }">
off
</c:when>
<c:otherwise>
on
</c:otherwise>
</c:choose>
<td align="center"width="10%">
<c:choose>
<c:when test="${voiceSwitchValue == 'false' }"><%--关闭状态--%>
<button onclick="switchValue('voiceSwitchValue','on')" class="btn btn-xs btn-success">打开</button>
</c:when>
<c:otherwise>
<button onclick="switchValue('voiceSwitchValue','off')" class="btn btn-xs btn-success">关闭</button>
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<td align="center" width="10%">监控dev<a href="#"></a></td>
<td align="center" width="10%">短信<a href="#"></a></td>
<td align="center" width="10%">
<c:choose>
<c:when test="${devSmsSwitchValue == 'false' }">
off
</c:when>
<c:otherwise>
on
</c:otherwise>
</c:choose>
</td>
<td align="center" width="10%">
<c:choose>
<c:when test="${devSmsSwitchValue == 'false' }">
<button onclick="switchValue('devSmsSwitchValue','on')" class="btn btn-xs btn-success">打开</button>
</c:when>
<c:otherwise>
<button onclick="switchValue('devSmsSwitchValue','off')" class="btn btn-xs btn-success">关闭</button>
</c:otherwise>
</c:choose>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" >
<div class="modal-dialog">
<div class="modal-content"style="width: 140%">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times</button>
<h4 class="modal-title" id="myModalLabel"></h4>
</div>
<div class="modal-body" style="height: 680px;;overflow :auto" >
<form id="taskForm" class="form-horizontal">
<input type="hidden" name="id">
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>数据源:</label>
<div class="col-sm-8">
<select id="influxdbs" name="influxdbs" class="form-control" autocomplete="off"style="width:296px">
<option value="aws,qcloud"> aws,qcloud</option>
<option value="aws"> aws</option>
<option value="qcloud"> qcloud</option>
</select>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal" onclick="clearData()">关闭</button>
<button type="button" class="btn btn-success" value="Validate" onclick="saveTask()">提交</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<script src="<%=basePath %>script/common/genarate_left_panel.js"></script>
<script>
$("#li_manager").addClass("active open");
$("#li_alarmSwitch").addClass("active");
</script>
<script type="text/javascript">
function switchValue(switchName,value) {
$.ajax({
url: contextPath + "OpsSmsOnOff/switchAlarm",
type: 'post',
async:false,//同步请求
data: {
switchName: switchName,
value: value
},
success: function (data) {
if (!data || data.code != 200) {
alert('切换失败!'+data.message);
}else{
alert('切换成功!');
window.location.href = contextPath + "/OpsSmsOnOff/toAlarmSwitch";
}
},
error: function (data) {
alert('系统异常');
}
});
}
</script>
</body>
</html>
... ...
... ... @@ -105,12 +105,14 @@ innerHTML += "<li id='li_switchtopo'><a id='li_switchtopo_a' href='#'>NGINX切
innerHTML += "</ul></li>";
/*manage*/
innerHTML += "<li class='submenu' id='li_manager'><a id='li_manager_a' href='#'><i class='icon icon-th-list'></i> <span>管理员</span><span class='label'>4</span></a>";
innerHTML += "<li class='submenu' id='li_manager'><a id='li_manager_a' href='#'><i class='icon icon-th-list'></i> <span>管理员</span><span class='label'>5</span></a>";
innerHTML += "<ul><li id='li_user'><a id='li_user_a' href=''>用户管理</a></li>";
innerHTML += "<li id='li_module'><a id='li_module_a' href=''>模块管理</a></li>";
innerHTML += "<li id='li_alarmgroup'><a id='li_alarmgroup_a' href=''>报警组管理</a></li>";
//innerHTML += "<li id='li_elbinfo'><a id='li_elbinfo_a' href=''>负载均衡</a></li>";
innerHTML += "<li id='li_autoscaling'><a id='li_autoscaling_a' href=''>伸缩组</a></li>";
innerHTML += "<li id='li_alarmSwitch'><a id='li_alarmSwitch_a' href=''>告警开关</a></li>";
innerHTML += "</ul></li>";
/*influxdb告警配置*/
... ... @@ -166,6 +168,7 @@ document.getElementById("li_yoho_event_taskConfigure_a").setAttribute("href", pa
document.getElementById("li_alarmgroup_a").setAttribute("href", path + "/alarmGroup/toAlarmGroupPage");
//document.getElementById("li_elbinfo_a").setAttribute("href", path + "/elbInfo/toElbInfoPage");
document.getElementById("li_autoscaling_a").setAttribute("href", path + "/autoScalingTool/toautoscalingpage");
document.getElementById("li_alarmSwitch_a").setAttribute("href", path + "/OpsSmsOnOff/toAlarmSwitch");
//document.getElementById("li_nginxswitch_a").setAttribute("href", path + "/nginxswitch/toNginxSwitch");
//document.getElementById("li_luaswitch_a").setAttribute("href", path + "/luaswitch/toLuaSwitch");
document.getElementById("li_projectHistory_a").setAttribute("href", path + "/project/toHistory");
... ...