Authored by fanzelei

Merge branch 'master' of http://git.yoho.cn/ops/monitor-ui

... ... @@ -8,6 +8,8 @@ import lombok.Data;
@Data
public class HostInfoReq extends PageRequest {
private int id;
private String alias;
private String hostIp;
... ...
package com.ui.ctrl;
import com.alibaba.fastjson.JSON;
import com.ui.http.HttpRestClient;
import com.ui.model.BaseResponse;
import com.ui.model.req.HostInfoReq;
... ... @@ -30,7 +29,29 @@ public class HostInfoCtrl {
@ResponseBody
public BaseResponse getHostInfos(HostInfoReq req) throws Exception {
BaseResponse response=httpRestClient.defaultPost("/hostInfo/getHostInfos", req, BaseResponse.class);
System.out.println("*****************************"+ JSON.toJSON(response));
return response;
}
@RequestMapping("/saveHostInfo")
@ResponseBody
public BaseResponse saveHostInfo(HostInfoReq req) throws Exception {
BaseResponse response=httpRestClient.defaultPost("/hostInfo/saveHostInfo", req, BaseResponse.class);
return response;
}
@RequestMapping("/delHostInfo")
@ResponseBody
public BaseResponse<Integer> delHostInfo(int id ) throws Exception {
BaseResponse response=httpRestClient.defaultGet("/hostInfo/delHostInfo?id=" + id, BaseResponse.class);
return response;
}
@RequestMapping("/getHostInfoById")
@ResponseBody
public BaseResponse getHostInfoById(int id) throws Exception {
BaseResponse response=httpRestClient.defaultGet("/hostInfo/getHostInfoById?id="+id, BaseResponse.class);
return response;
}
... ...
... ... @@ -27,6 +27,7 @@
<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>
... ... @@ -52,11 +53,9 @@
<div id="sidebar">
<ul>
<li class=""><a href="#"><i class="icon icon-home"></i> <span>Dashboard</span></a></li>
<li class="" id="jsptablejsp" onclick="clickMenuToPage('/jsp/table.jsp')"><a href="#" ><i class="icon icon-th"></i> <span>Tables</span></a></li>
<li class="" id="jspmobjectmobjectInfojsp" onclick="clickMenuToPage('/jsp/mobject/mobjectInfo.jsp')"><a href="#" ><i class="icon icon-th"></i> <span>Tables</span></a></li>
<li class="" id="jsphosthostGroupListjsp" onclick="clickMenuToPage('jsp/host/hostGroupList.jsp')" ><a href="#" ><i class="icon icon-th"></i> <span>主机组</span></a></li>
<li class="" id="jsphosthostInfoListjsp" onclick="clickMenuToPage('jsp/host/hostInfoList.jsp')" ><a href="#" ><i class="icon icon-th"></i> <span>主机信息</span></a></li>
</ul>
</div>
<!-- 右侧具体内容 -->
... ...
<%@page language="java" contentType="text/html;charset=utf-8" %>
<form method="post" class="form-horizontal" id="smsTemplateForm" name="smsTemplateForm">
<form method="post" class="form-horizontal" id="hostInfoForm" name="hostInfoForm">
<div>
<label> <span style="color:red">*</span>主机别名:</label>
<input type="text" class="form-control" id="alias" name="alias" placeholder="输入主机别名" maxlength="30" size="40"/>
<div class="form-group" >
<label class="col-sm-2 control-label"> <span style="color:red">*</span>主机别名:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="alias" name="alias" placeholder="输入主机别名" maxlength="30" size="40"/>
</div>
</div>
<div>
<label> <span style="color:red">*</span>主机IP:label>
<input type="text" class="form-control" id="hostIP" name="hostIP" placeholder="输入IP地址" maxlength="30" size="40"/>
<div class="form-group" >
<label class="col-sm-2 control-label"> <span style="color:red">*</span>主机IP:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="hostIp" name="hostIp" placeholder="输入IP地址" maxlength="30" size="40"/>
</div>
</div>
<div>
<label> <span style="color:red">*</span>云类型:</label>
<input type="text" class="form-control" id="smsTemplateTitle" name="smsTemplateTitle" placeholder="最多30个汉字" maxlength="30" size="40"/>
<div class="form-group" >
<label class="col-sm-2 control-label"> <span style="color:red">*</span>云类型:</label>
<div class="col-sm-8">
<select id="cloudType" name="cloudType" class="form-control">
<option value="1">AWS</option>
<option value="2">腾讯云</option>
<option value="3">其他</option>
</select>
</div>
</div>
<br/>
<div class="form-group">
<input type="button" class="btn btn-primary" style="margin-left:100px" id="saveSmsTemplateBtn" value="保存" />
<div class="form-group" >
<label class="col-sm-2 control-label"> <span style="color:red">*</span>主机组:</label>
<div class="col-sm-8">
<select id="groupId" name="groupId" class="form-control">
<option value="1">AWS</option>
<option value="2">腾讯云</option>
<option value="3">其他</option>
</select>
</div>
</div>
<div class="form-group" >
<label class="col-sm-2 control-label"> <span style="color:red">*</span>安装软件:</label>
<div class="col-sm-8">
<input type="checkbox" name="appName" value="JAVA"> JAVA <input type="checkbox" name="appName" value="Redis" > Redis
</div>
</div>
</form>
<script>
var TextCount = (function () {
var _bind = function (that) {
that.input.on('keyup', function () {
that.render();
});
}
var _getNum = function (that) {
return that.input.val().length;
}
var TextCountFun = function (config) {
this.id = config.id;
}
TextCountFun.prototype.init = function () {
this.input = $(this.id);
this.render();
_bind(this);
};
TextCountFun.prototype.render = function () {
var num = _getNum(this);
if ($('#_test_count').length == 0) {
$('#countDiv').append('<span id="_test_count"></span>');
};
if (num < 71) {
$('#_test_count').html(num + '/990');
} else if (num <= 990) {
var message = "共" + num + "字符,含短信签名,将被做" + Math.ceil(num / 70) + "条短信计价。每条短信最多70个字符";
$('#_test_count').html(num + '/990' + '&nbsp;&nbsp;<span style="color: red">' + message + '</span>');
} else {
$('#_test_count').html('990/990');
}
};
return TextCountFun;
})();
$(function () {
$("#smsTemplateForm #smsTemplateTitle").validate({
required: true,
validateOnBlur : false
});
$("form #smsTemplateContent").validate({
required: true,
validateOnBlur : false
});
if(paramObj.hoseInfoId > 0){
//保存
$("#saveSmsTemplateBtn").click(function(){
var smsTemplateId = $("#smsTemplateId").val();
var btn = $(this);
btn.prop("disabled", true);
$("#smsTemplateForm").form("submit", {
submitUrl : contextPath + "/SmsTemplateController/saveSmsTemplate.do",
submitData : {
smsTemplateId : paramObj.smsTemplateId
//加载form
$("#hostInfoForm").form({
loadUrl : contextPath + "/hostInfo/getHostInfoById.do",
loadParams : {
id : paramObj.hoseInfoId
},
onBeforeSubmit : function() {
if (!$("#smsTemplateForm").form("validate")) {
btn.removeAttr("disabled");
loadFilter : function(data) {
return defaultLoadFilter(data);
},
onBeforeLoad : function(loadParams) {
if (loadParams.hoseInfoId == 0) {
return false;
}
},
onLoadSuccess : function(data) {
success : function(data) {
btn.removeAttr("disabled");
if (!data || data.code != 200) {
$.messageAlert("错误", data.message);
return;
}else{
$("#body").load(contextPath + "/html/chatChannel/smsTemplate/smsTemplateList.html")
}
}
});
});
//加载form
$("#smsTemplateForm").form({
loadUrl : contextPath + "/SmsTemplateController/getTemplateById.do",
loadParams : {
smsTemplateId : paramObj.smsTemplateId
},
loadFilter : function(data) {
return defaultLoadFilter(data);
},
onBeforeLoad : function(loadParams) {
if (loadParams.smsTemplateId == 0) {
return false;
}
},
onLoadSuccess : function(data) {
new TextCount({id: '#smsTemplateContent'}).init();
}
});
new TextCount({id: '#smsTemplateContent'}).init();
}
});
</script>
\ No newline at end of file
... ...
... ... @@ -2,7 +2,7 @@
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div id="breadcrumb">
<a href="#" title="Go to Home" class="tip-bottom"><i
class="icon-home"></i> Home</a> <a href="#" class="current">Tables</a>
class="icon-home"></i> 主机组</a> <a href="#" class="current">主机信息</a>
</div>
<div class="container-fluid">
... ... @@ -26,17 +26,21 @@
<input type="text" id="hostIp" name="hostIp" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">安装软件:</span>
<input type="text" id="tags" name="tags" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">云类型:</span>
<select id="cloudType" name="cloudType" class="form-control">
<option value="">全部</option>
<option value="0">全部</option>
<option value="1">AWS</option>
<option value="2">腾讯云</option>
<option value="2">其他</option>
<option value="3">其他</option>
</select>
</div>
<button id="searchHostInfoBtn" class="btn btn-default">搜索</button>
</div>
<button id="addHostInfoBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 900px;">新增</button>
<button id="addHostInfoBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 100px;">新增</button>
</div>
</div>
<div id="hostInfoTable">
... ... @@ -90,9 +94,77 @@
}
},
width : "12%"
}, {
title : "安装软件",
field : "tags",
formatter : function(value, rowData, rowIndex) {
if(value != null && value != ""){
return value.substr(0,value.length-1);
}
},
width : "12%"
}, {
title : "操作",
field : "op",
formatter : function(value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button>").addClass("btn btn-xs btn-success").html("修改").appendTo(div);
editBtn.click(function() {
editHostInfo(rowData.id);
});
div.append("&nbsp;");
var delBtn = $("<button>").addClass("btn btn-xs btn-danger").html("删除").appendTo(div);
delBtn.click(function() {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "你确定删除吗",
backdrop : "static",
content : "你确定要删除该主机信息吗?",
buttons : [{
text : "否",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}, {
text : "是",
className : "btn-success",
onclick : function() {
$(dialog).dialog("hide");
$.ajax({
url : contextPath +"/hostInfo/delHostInfo.do",
type : 'post',
async : false,
data : {
id : rowData.id
},
dataType : "json",
success : function(data) {
if (!data || data.code != 200) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "删除失败",
backdrop : "static",
content : data.message,
buttons : [{
text : "确定",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
$("#smsListTable").table("load");
}
});
}
}]
});
});
return div;
},
width : "15%"
}]
});
... ... @@ -107,17 +179,18 @@
var alias = $("#alias").val();
var hostIp = $("#hostIp").val();
var cloudType = $("#cloudType").val();
var tags=$("#tags").val();
$("#hostInfoTable").table("load", {
'alias': alias,
'hostIp': hostIp,
'cloudType': cloudType
'cloudType': cloudType,
'tags':tags
});
});
//打开新增或修改页面
function editHostInfo(hoseInfoId) {
alert(1);
paramObj.hoseInfoId = hoseInfoId;
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
... ... @@ -137,10 +210,15 @@
onclick : function() {
var btn = $(this);
this.prop("disabled", "disabled");
$("#smsTmplateEditForm").form("submit", {
var tags="";
$("input[name='appName']:checked").each(function(){
tags += $(this).attr('value')+',';
});
$("#hostInfoForm").form("submit", {
submitUrl : contextPath + "/hostInfo/saveHostInfo.do",
submitData : {
smTemplateId : hoseInfoId
id : hoseInfoId,
tags:tags
},
onBeforeSubmit : function() {
if (!$(this).form("validate")) {
... ... @@ -151,13 +229,13 @@
success : function(data) {
if (!data || data.code != 200) {
btn.removeAttr("disabled");
$("#smsTmplateEditForm #messageAlert").alerts({
$("#hostInfoForm #messageAlert").alerts({
content : data.message,
type : "danger"
});
return;
}
$("#smsListTable").table("load");
$("#hostInfoTable").table("load");
$(dialog).dialog("hide");
}
});
... ...
... ... @@ -49,13 +49,75 @@
</div>
<button id="submit" class="btn btn-default">搜索</button>
</div>
<button id="addBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 500px;">新增</button>
<button id="addBtn" class="btn btn-primary" style="margin-top: 12px;margin-left: 500px;" data-target="#myModal" data-toggle="modal">新增</button>
</div>
</div>
<div id="table"></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">
<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">
<div class="row-fluid">
<div class="span12">
<div class="widget-content nopadding">
<form action="/mobject/add" method="post" class="form-horizontal">
<div class="control-group">
<label class="control-label" style="float: left;">名称</label>
<div class="controls">
<input type="text" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">所属主机</label>
<div class="controls">
<input type="text" placeholder="请填写主机IP" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">类型</label>
<div class="controls">
<input type="text" value="" readonly="readonly" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">标签</label>
<div class="controls">
<input type="text" />
</div>
</div>
<div class="control-group">
<label class="control-label" style="float: left;">域名</label>
<div class="controls">
<input type="text" />
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭
</button>
<button type="submit" class="btn btn-primary" value="Validate">提交</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
</div>
<script>
$(function () {
$("#table").table({
... ... @@ -87,10 +149,9 @@
formatter: function (value, rowData, rowIndex) {
var div = $("<div>");
var editBtn = $("<button>").addClass("btn btn-inverse btn-mini").html("修改").appendTo(div);
var editBtn = $("<button data-target='#myModal' data-toggle='modal'>").addClass("btn btn-inverse btn-mini").html("修改").appendTo(div);
//修改
editBtn.click(function () {
alert(rowData.moId);
});
div.append("&nbsp;");
var delBtn = $("<button>").addClass("btn btn-danger btn-mini").html("删除").appendTo(div);
... ... @@ -163,5 +224,16 @@
function editbtn() {
alert(2);
}
</script>
<script src="js/jquery.min.js"></script>
<script src="js/jquery.ui.custom.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.uniform.js"></script>
<script src="js/select2.min.js"></script>
<script src="js/jquery.validate.js"></script>
<script src="js/unicorn.js"></script>
<script src="js/unicorn.form_validation.js"></script>
 
\ No newline at end of file
... ...
... ... @@ -289,9 +289,7 @@
alert("请选择节点");
}
var checkValue = [];
$.each(data, function(i,val){
});
alert(checkValue);
$("#inBoxQueryDiv").form("submit", {
submitUrl : '',
... ...