Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ops
/
monitor-ui
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
qinchao
7 years ago
Commit
82c12672570180076e0c96879b8f2836eab87f9c
1 parent
f051e99f
cmdb添加依赖服务
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
309 additions
and
6 deletions
monitor-ui-ctrl/src/main/java/com/ui/ctrl/MObjectInfoCtrl.java
monitor-ui-web/src/main/webapp/jsp/mobject/mobjectInfo.jsp
monitor-ui-web/src/main/webapp/script/yoho.type.tree.js
monitor-ui-ctrl/src/main/java/com/ui/ctrl/MObjectInfoCtrl.java
View file @
82c1267
...
...
@@ -5,6 +5,7 @@ import com.ui.model.BaseResponse;
import
com.ui.model.req.DependencyRequest
;
import
com.ui.model.req.MObjectHostInfoReq
;
import
com.ui.model.req.MObjectInfoReq
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
...
...
@@ -100,7 +101,12 @@ public class MObjectInfoCtrl {
//更新绑定服务
@RequestMapping
(
value
=
"/updateBindDependency"
)
public
BaseResponse
updateBindDependency
(
DependencyRequest
request
)
{
public
BaseResponse
updateBindDependency
(
DependencyRequest
request
,
String
dependenciesString
)
{
if
(
StringUtils
.
isNotBlank
(
dependenciesString
)){
for
(
String
str:
dependenciesString
.
split
(
","
)){
request
.
getDependencies
().
add
(
str
);
}
}
BaseResponse
response
=
httpRestClient
.
defaultPost
(
"/mobject/updateBindDependency"
,
request
,
BaseResponse
.
class
);
return
response
;
}
...
...
monitor-ui-web/src/main/webapp/jsp/mobject/mobjectInfo.jsp
View file @
82c1267
...
...
@@ -126,7 +126,6 @@
</div>
</div>
<div
class=
"modal fade"
id=
"addModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
style=
"margin:0 auto;margin-top:20px;width: 1000px;min-height:400px;"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
style=
"width: 800px"
>
...
...
@@ -203,6 +202,82 @@
<!-- /.modal -->
</div>
<!-- 添加服务的依赖对象 -->
<div
class=
"modal fade"
id=
"addDependModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
style=
"margin:0 auto;margin-top:20px;width: 1000px;min-height:400px;"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
style=
"width: 800px"
>
<div
class=
"modal-header"
>
<button
type=
"button"
class=
"close"
data-dismiss=
"modal"
aria-hidden=
"true"
>
×
</button>
<h4
class=
"modal-title"
id=
"addDependModalLabel"
>
添加依赖服务
</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=
"addDependForm"
>
<div
class=
"control-group"
typeof=
"hidden"
>
<input
type=
"hidden"
id=
"addDependTypeId"
/>
<input
type=
"hidden"
id=
"oldBindServicesInput"
/>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
style=
"float: left;"
>
当前服务
</label>
<div
class=
"controls"
>
<input
type=
"text"
readonly=
"readonly"
disabled
id=
"addDependMoTypeName"
/>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
style=
"float: left;"
>
服务组
</label>
<div
class=
"controls"
>
<div
id=
"denpendGroupDiv"
>
<select
id=
'denpendGroup'
class=
'form-control select2'
style=
'width: 500px'
onchange=
"dependGroupSelectOnChange()"
></select>
</div>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
style=
"float: left;"
>
添加服务
</label>
<div
class=
"controls"
>
<div
id=
"denpendGroupDetailDiv"
>
<
%--
<select
id=
'denpendGroupDetail'
class=
'form-control select2'
style=
'width: 500px'
multiple=
'multiple'
></select>
--%>
</div>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
style=
"float: left;"
>
依赖服务
</label>
<div
class=
"col-sm-8"
id=
"addDependTagsDiv"
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
></label>
<div
class=
"col-sm-8"
name=
"messageAlert"
></div>
</div>
</form>
</div>
</div>
</div>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-danger"
data-dismiss=
"modal"
id=
"addDependClose"
>
关闭
</button>
<button
type=
"submit"
class=
"btn btn-success"
id=
"addDependSubmit"
>
提交
</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal -->
</div>
<!--添加服务的依赖对象 end-->
<div
class=
"modal fade"
id=
"updateModal"
tabindex=
"-1"
role=
"dialog"
aria-labelledby=
"myModalLabel"
aria-hidden=
"true"
>
<div
class=
"modal-dialog"
>
<div
class=
"modal-content"
>
...
...
@@ -763,6 +838,46 @@
}
);
$
(
"#addDependModal #addDependSubmit"
).
click
(
function
()
{
// var data = $("#addDependTags").tagsInput('item');
var
value
=
""
;
/* $.each(data,function(i,e){//i是索引,e是json对象
if(value.length>0){
value+=",";
}
value += e.value ;
});*/
var
div
=
document
.
getElementById
(
"addDependTagsDiv"
);
var
detailServices
=
""
;
if
(
div
.
children
[
0
].
tagName
.
toLowerCase
()
==
"input"
)
{
value
=
div
.
children
[
0
].
value
;
}
$
.
ajax
(
{
url
:
contextPath
+
"/mobject/updateBindDependency"
,
type
:
"post"
,
dataType
:
"json"
,
data
:
{
typeId
:
$
(
"#addDependTypeId"
).
val
(),
dependenciesString
:
value
},
success
:
function
(
response
)
{
if
(
200
!=
response
.
code
)
{
layer
.
msg
(
response
.
message
,
{
icon
:
2
});
}
else
{
$
(
"#addDependModal"
).
modal
(
"hide"
);
}
}
}
);
}
);
function
validIp
(
ip
)
{
var
iPattern
=
/^
([
0-9
]
|
[
1-9
]\d
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.([
0-9
]
|
[
1-9
]\d
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.([
0-9
]
|
[
1-9
]\d
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])\.([
0-9
]
|
[
1-9
]\d
|1
\d\d
|2
[
0-4
]\d
|25
[
0-5
])
$/
;
...
...
@@ -847,7 +962,9 @@
})*/
</script>
<script
type=
"text/javascript"
src=
"<%=basePath %>/script/yoho.type.tree.js?v=20171129-1"
></script>
<script
type=
"text/javascript"
src=
"<%=basePath %>/script/yoho.type.tree.js?v=20171211-27"
></script>
<div
class=
"modal fade"
id=
"myModal"
tabindex=
"-1"
role=
"dialog"
...
...
monitor-ui-web/src/main/webapp/script/yoho.type.tree.js
View file @
82c1267
...
...
@@ -128,8 +128,6 @@ var addMObjType = function (nodeid, name) {
isGroup
:
1
},
success
:
function
(
response
)
{
//console.log(response.data)
//将查询到的数据,update到选择框中
genarateGroupSelectOption
(
response
.
data
.
groupListJson
,
response
.
data
.
selectGroup
);
genarateIpSelectOption
(
response
.
data
.
ipListJson
,
response
.
data
.
selectIp
);
...
...
@@ -141,6 +139,176 @@ var addMObjType = function (nodeid, name) {
}
/**
* 添加依赖关系
*/
var
AddDepend
=
function
(
nodeid
,
name
)
{
var
id
=
nodeId2id
(
nodeid
);
//服务对象id
var
path
=
getPath
(
nodeid
);
//服务对象完整类型路径
console
.
log
(
"id: "
+
id
+
" path: "
+
path
+
" name :"
+
name
);
//TODO 打开新增服务对象对话框
$
.
ajax
({
url
:
contextPath
+
"/mobject/queryBindDependency"
,
type
:
"post"
,
dataType
:
"json"
,
data
:
{
typeId
:
id
},
success
:
function
(
responseBindData
)
{
$
(
"#addDependModal #addDependMoTypeName"
).
val
(
"/"
+
path
.
substr
(
0
,
path
.
length
-
1
));
$
(
"#addDependModal #addDependTypeId"
).
val
(
id
);
//将查询到的数据,update到选择框中
var
bindServices
=
""
;
for
(
var
tmpDataIndex
in
responseBindData
.
data
.
selectDependencies
){
if
(
bindServices
.
length
>
0
){
bindServices
+=
","
;
}
bindServices
+=
responseBindData
.
data
.
selectDependencies
[
tmpDataIndex
];
}
$
(
"#oldBindServicesInput"
).
val
(
bindServices
);
document
.
getElementById
(
"addDependTagsDiv"
).
innerHTML
=
""
;
var
input
=
$
(
"<input name='tags' id='addDependTags' class='form-control'>"
);
input
.
val
(
bindServices
);
$
(
"#addDependModal #addDependTagsDiv"
).
append
(
input
);
// Tags Input
jQuery
(
"#addDependModal #addDependTags"
).
tagsInput
({
interactive
:
false
,
width
:
'auto'
,
height
:
'200px'
});
queryDependGroups
(
""
);
$
(
'#addDependModal'
).
modal
({
keyboard
:
true
});
},
error
:
function
(
e
)
{
alert
(
"load BindDependency error"
);
}
});
}
function
queryDependGroups
(
selectGroup
){
$
.
ajax
({
url
:
contextPath
+
"/mobject/queryDependency"
,
type
:
"post"
,
dataType
:
"json"
,
data
:
{
selectGroup
:
selectGroup
},
success
:
function
(
response
)
{
//将查询到的数据,update到选择框中
genarateDenpendGroupSelectOption
(
response
.
data
.
selectGroupsJsonArray
);
dependGroupSelectOnChange
();
},
error
:
function
(
e
)
{
alert
(
"load host error"
);
}
});
}
/**
* 依赖服务组变化时,设置服务列表
*/
function
dependGroupSelectOnChange
(){
var
reslist
=
$
(
"#addDependModal #denpendGroup"
).
select2
(
"data"
);
var
group
=
""
if
(
reslist
!=
null
&&
reslist
.
length
>
0
)
{
for
(
var
tmp
=
0
;
tmp
<
reslist
.
length
;
tmp
++
){
if
(
group
.
length
>
0
){
group
+=
","
;
}
group
+=
reslist
[
tmp
].
text
;
}
}
$
.
ajax
({
url
:
contextPath
+
"/mobject/queryDependency"
,
type
:
"post"
,
dataType
:
"json"
,
data
:
{
selectGroup
:
group
},
success
:
function
(
response
)
{
//将查询到的数据,update到选择框中
//genarateDenpendGroupSelectOption(response.data.selectGroupsJsonArray);
genarateDenpendGroupDetailSelectOption
(
response
.
data
.
selectDependenciesJsonArray
);
},
error
:
function
(
e
)
{
alert
(
"load queryDependency error"
);
}
});
}
function
genarateDenpendGroupDetailSelectOption
(
optionList
){
//先清空
var
innerHTML
=
"<select id='denpendGroupDetail' class='form-control select2' style='width: 500px' multiple='multiple' onchange='dependGroupDetailSelectOnChange()'></select>"
;
document
.
getElementById
(
"denpendGroupDetailDiv"
).
innerHTML
=
innerHTML
;
//再初始化
$
(
"#addDependModal #denpendGroupDetail"
).
select2
({
placeholder
:
"请选择标签"
,
dropdownParent
:
$
(
"#addDependModal"
),
allowClear
:
true
,
data
:
optionList
});
//再赋值
//var oldValue=$("#oldBindServicesInput").val();
//$("#addDependModal #denpendGroupDetail").val(oldValue.split(",")).trigger("change");
}
function
dependGroupDetailSelectOnChange
(){
var
div
=
document
.
getElementById
(
"addDependTagsDiv"
);
var
detailServices
=
""
;
if
(
div
.
children
[
0
].
tagName
.
toLowerCase
()
==
"input"
)
{
detailServices
=
div
.
children
[
0
].
value
;
}
//再添加
var
detailreslist
=
$
(
"#denpendGroupDetail"
).
select2
(
"data"
);
//多选
if
(
detailreslist
!=
null
&&
detailreslist
.
length
>
0
)
{
if
(
detailServices
.
length
>
0
){
detailServices
+=
","
;
}
for
(
var
tmp
=
0
;
tmp
<
detailreslist
.
length
;
tmp
++
)
{
var
tmpWithComm
=
detailreslist
[
tmp
].
text
+
","
;
if
(
detailServices
.
indexOf
(
tmpWithComm
)
<
0
){
console
.
log
(
detailreslist
[
tmp
].
text
);
///// 保留這個打印,有时候浏览器执行有问题
// $('#addDependModal #addDependTags').addTag(detailreslist[tmp].text);
detailServices
+=
detailreslist
[
tmp
].
text
+
","
;
}
}
console
.
log
(
detailServices
);
// $('#addDependTags').importTags(detailServices);
document
.
getElementById
(
"addDependTagsDiv"
).
innerHTML
=
""
;
var
input
=
$
(
"<input name='tags' id='addDependTags' class='form-control'>"
);
input
.
val
(
detailServices
);
$
(
"#addDependModal #addDependTagsDiv"
).
append
(
input
);
// Tags Input
jQuery
(
"#addDependModal #addDependTags"
).
tagsInput
({
interactive
:
false
,
width
:
'auto'
,
height
:
'200px'
});
}
}
/**
* 根据查询到的服务组
*/
function
genarateDenpendGroupSelectOption
(
optionList
)
{
$
(
"#addDependModal #denpendGroup"
).
select2
({
placeholder
:
"请选择标签"
,
dropdownParent
:
$
(
"#addDependModal"
),
allowClear
:
true
,
data
:
optionList
});
}
/**
* 根据查询到的主机组列表,生成主机组选择下拉框
*
* @param optionList
...
...
@@ -206,7 +374,6 @@ function groupSelectOnChange() {
},
success
:
function
(
response
)
{
//将查询到的数据,update到选择框中
//console.log(response.data);
genarateIpSelectOption
(
response
.
data
.
ipListJson
,
response
.
data
.
selectIp
);
},
error
:
function
(
e
)
{
...
...
@@ -359,6 +526,7 @@ var refreshTypeTree = function () {
treeNode
.
id
=
"node_"
+
val
.
typeId
;
treeNode
.
parent
=
(
val
.
typeParentId
==
0
?
"#"
:
"node_"
+
val
.
typeParentId
);
treeNode
.
text
=
val
.
typeName
;
treeNode
.
data
=
{
isLeaf
:
val
.
typeIsLeaf
,
descr
:
val
.
descr
,
...
...
@@ -438,6 +606,18 @@ $('#jstree').jstree({
}
addMObjType
(
clickedNode
.
id
,
clickedNode
.
text
);
}
},
"ADDDepend"
:
{
"label"
:
"添加依赖服务"
,
"action"
:
function
(
obj
)
{
var
inst
=
jQuery
.
jstree
.
reference
(
obj
.
reference
);
var
clickedNode
=
inst
.
get_node
(
obj
.
reference
);
console
.
log
(
"add minfo--clickedNode's id is : "
+
clickedNode
.
id
);
if
(
clickedNode
.
data
.
isLeaf
!=
1
)
{
$
.
toaster
(
'非叶子节点无法添加子类型'
,
'提示'
,
'info'
);
return
;
}
AddDepend
(
clickedNode
.
id
,
clickedNode
.
text
);
}
}
}
}
...
...
Please
register
or
login
to post a comment