package com.ui.ctrl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* Created by fruwei on 2016/6/17.
*/
@Controller
@RequestMapping("javaapi")
public class JavaAPICtrl {
}
... ...
... ... @@ -18,7 +18,7 @@ public class MObjectInfoCtrl {
//前台提供currentpage,pagesize,isType,typeIds,hostIps
@RequestMapping(value = "/query", method = RequestMethod.POST)
public BaseResponse queryAllMObjectInfo(MObjectInfoReq request) {
public BaseResponse queryAllMObjectInfo(@RequestBody MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/query", request, BaseResponse.class);
... ... @@ -28,7 +28,7 @@ public class MObjectInfoCtrl {
//前台提供mo_id
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public BaseResponse deleteMObjectInfo(MObjectInfoReq request) {
public BaseResponse deleteMObjectInfo(@RequestBody MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/delete", request, BaseResponse.class);
... ... @@ -37,7 +37,7 @@ public class MObjectInfoCtrl {
//前台提供 mo_id,mo_name,mo_typeId,mo_hostIP,mo_tags,mo_url
@RequestMapping(value = "/update", method = RequestMethod.POST)
public BaseResponse updateMObjectInfo(MObjectInfoReq request) {
public BaseResponse updateMObjectInfo(@RequestBody MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/update", request, BaseResponse.class);
... ... @@ -46,7 +46,7 @@ public class MObjectInfoCtrl {
//前台提供 mo_name,mo_typeId,mo_hostIp,mo_tags,mo_url
@RequestMapping(value = "/add", method = RequestMethod.POST)
public BaseResponse addMObjectInfo(MObjectInfoReq request) {
public BaseResponse addMObjectInfo(@RequestBody MObjectInfoReq request) {
BaseResponse response = httpRestClient.defaultPost("/mobject/add", request, BaseResponse.class);
... ...
... ... @@ -69,11 +69,27 @@
<script type="text/javascript">
function clickMenuToPage(page){
var g = page.replace(/\//g,"").replace(".","");
$("#"+g).addClass("active").siblings().removeClass("active");
//加载左侧内容
$("#content").load(contextPath+page);
}
var g = page.replace(/\//g,"").replace(".","");
$("#"+g).addClass("active").siblings().removeClass("active");
//加载左侧内容
$("#content").load(contextPath+page);
}
function localAlert(title,message){
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : title,
backdrop : "static",
content : message,
buttons : [{
text : "确定",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
}
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -134,11 +134,15 @@
data: param,
dataType: 'json',
success: function (data) {
$("#myModal").modal('hide');
$("#hostGroupTable").table("load");
if (!data || data.code != 200) {
localAlert('删除失败',data.message);
}else{
$("#myModal").modal('hide');
$("#hostGroupTable").table("load");
}
},
error: function (data) {
layer.msg("系统异常", {icon: 2});
localAlert('系统异常',data.message);
}
});
}
... ... @@ -171,19 +175,7 @@
dataType : "json",
success : function(data) {
if (!data || data.code != 200) {
var dialog = $("<div>").appendTo($("body"));
dialog.dialog({
title : "删除失败",
backdrop : "static",
content : '系统异常',
buttons : [{
text : "确定",
className : "btn-danger",
onclick : function() {
$(dialog).dialog("hide");
}
}]
});
localAlert('删除失败',data.message);
}
$("#hostGroupTable").table("load");
}
... ...
... ... @@ -18,7 +18,6 @@
<h5>Dynamic table</h5>
</div>
<!-- 树 -->
<div style="float: left;border: dashed;width: 300px;color: #D3D3D3;height: 600px;">
<div class="widget-title" style="height: 50px;">
... ... @@ -31,6 +30,22 @@
</div>
<!-- 列表 -->
<div class="widget-content nopadding" style="margin-left: 300px;">
<div class="widget-title" style="height: 53px;">
<div>
<div class="form-inline" role="form" id="inBoxQueryDiv"
style=" margin-top: 12px;margin-left: 25px;float: left;">
<div class="input-group" style="float: left;">
<span class="input-group-addon">名称:</span>
<input type="text" id="alias" name="alias" class="form-control" placeholder=""/>
</div>
<div class="input-group" style="float: left;">
<span class="input-group-addon">主机:</span>
<input type="text" id="hostIp" name="hostIp" class="form-control" placeholder=""/>
</div>
<button id="btn_search_type" class="btn btn-default">搜索</button>
</div>
</div>
</div>
<div id="table"></div>
</div>
</div>
... ... @@ -102,7 +117,6 @@
</div>
<!-- /.modal -->
</div>
</div>
<div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
... ... @@ -169,7 +183,6 @@
</div>
<!-- /.modal -->
</div>
</div>
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
... ... @@ -177,30 +190,25 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">确定删除?</h4>
<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="#" method="post" class="form-horizontal" id="deleteForm">
<div class="control-group" typeof="hidden" id="moId">
</div>
</form>
</div>
</div>
<div class="control-group" typeof="hidden" id="moId">
</div>
<div class="modal-body">
<p>是否确定删除该信息?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" style="margin-right: auto" data-dismiss="modal">关闭
</button>
<button type="submit" class="btn btn-success" style="margin-left: auto" id="deleteSubmit">提交</button>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
</div>
<script>
$(function () {
$("#table").table({
... ... @@ -256,53 +264,6 @@
});
//模拟数据
var jsonData = [
{"id": "1", "name": "父节点1", "url": "www.baidu.com", "pid": "0"},
{"id": "4", "name": "父节点11", "url": "", "pid": "1"},
{"id": "14", "name": "父节点112", "url": "", "pid": "4"},
{"id": "5", "name": "父节点12", "url": "", "pid": "1"},
{"id": "6", "name": "父节点13", "url": "", "pid": "1"},
{"id": "2", "name": "父节点4", "url": "", "pid": "0"},
{"id": "7", "name": "父节点41", "url": "", "pid": "2"},
{"id": "8", "name": "父节点42", "url": "", "pid": "2"},
{"id": "9", "name": "父节点43", "url": "", "pid": "2"},
{"id": "3", "name": "父节点5", "url": "", "pid": "0"},
{"id": "10", "name": "父节点51", "url": "", "pid": "3"},
{"id": "13", "name": "父节点111", "url": "", "pid": "4"},
{"id": "11", "name": "父节点52", "url": "", "pid": "3"},
{"id": "12", "name": "父节点53", "url": "", "pid": "3"}
];
//主方法,运用递归实现
function createTree(jsons, pid) {
if (jsons != null) {
var ul = '<ul class="" style="width: 120px;" >';
for (var i = 0; i < jsons.length; i++) {
if (jsons[i].pid == pid) {
ul += '<input type="checkbox" name="checkBox" value=' + jsons[i].id + ' style="float: left;margin-top: 6px;width:10px;height:10px;"><li class="tree" value=' + jsons[i].id + '><a href="#">' + jsons[i].name + "</a></li>";
ul += createTree(jsons, jsons[i].id);
}
}
ul += "</ul>";
}
return ul;
}
$(function () {
var ul = createTree(jsonData, 0);
$("#continer").append(ul);
//控制菜单的隐藏显示
$("ul[class] li").each(function () {
$(this).click(function () {
$(this).next().toggle();
});
});
});
function deleteMObject(rowData) {
$("#deleteModal #moId").val(rowData.moId);
}
... ... @@ -328,11 +289,11 @@
$("#updateModal #updateSubmit").click(function () {
if (!validEmpty($("#updateModal #moName").val())) {
alert("必须填写监控对象名称!");
layer.message("必须填写监控对象名称",{icon:2});
return;
}
if (!validIp($("#updateModal #moHostIp").val())) {
alert("Ip 填写错误!");
layer.message("Ip 填写错误!",{icon:2});
return;
}
... ... @@ -351,11 +312,11 @@
},
success: function (response) {
if (200 != response.code) {
alert(response.message);
layer.msg(response.message,{icon:2});
}
else {
var div = document.getElementById("updateModal");
div.style.display = "none";
$("#updateModal").modal("hide");
$("#table").table("load");
}
}
});
... ... @@ -370,23 +331,25 @@
data: {
moId: $("#deleteModal #moId").val()
},
success: function () {
var div = document.getElementById("deleteModal");
div.style.display = "none";
},
error: function () {
success: function (response) {
if (200 != response.code) {
layer.msg(response.message,{icon:2});
}
else {
$("#deleteModal").modal("hide");
$("#table").table("load");
}
}
});
});
$("#addModal #addSubmit").click(function () {
if (!validEmpty($("#addModal #moName").val())) {
alert("必须填写监控对象名称!");
layer.msg("必须填写监控对象名称",{icon:2});
return;
}
if (!validIp($("#addModal #moHostIp").val())) {
alert("Ip 填写错误!");
layer.msg("Ip 填写错误!",{icon:2});
return;
}
... ... @@ -405,14 +368,11 @@
},
success: function (response) {
if (200 != response.code) {
alert(response.message);
layer.msg(response.message,{icon:2});
}
else {
var div = document.getElementById("addModal");
div.style.display = "none";
$("#table").load({
})
$("#addModal").modal("hide");
$("#table").table("load");
}
}
... ... @@ -443,6 +403,20 @@
}
$("#btn_search_type").click(function(){
console.log("search..");
searchType();
});
var searchType=function(){
var ids=getSelectType(true);
if(ids.length<1)
$.toaster('未选择类型节点', '提示', 'info');
};
</script>
<script type="text/javascript" src="<%=basePath %>/script/yoho.type.tree.js"></script>
... ...
... ... @@ -106,9 +106,14 @@ var addMObjType = function (nodeid, name) {
$("#addModal #moTypeId").val(id);
alert($("#addModal #moTypeName").val());
$("#addModal #moName").val("");
$("#addModal #moHostIp").val("");
$("#addModal #moTags").val("");
$("#addModal #moUrl").val("");
}
... ...