Toggle navigation
Toggle navigation
This project
Loading...
Sign in
monitor_v3
/
hg-monitor-web
·
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
xwx
3 years ago
Commit
020dee50d32ac02eeba1fb7440bdee40d95cf2af
1 parent
a55342cc
告警策略通知合并策略代码迁移
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
49 deletions
hg-monitor-web-base/src/main/resources/static/src/controller/alarmpolicyAdd.js
hg-monitor-web-base/src/main/resources/static/src/controller/common.js
hg-monitor-web-base/src/main/resources/static/src/views/baseconfig/alarmpolicy/add.html
hg-monitor-web-base/src/main/resources/static/src/controller/alarmpolicyAdd.js
View file @
020dee5
...
...
@@ -30,6 +30,24 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
,
range
:
true
});
var
resType
=
localStorage
.
getItem
(
"currentResType"
);
// 获取合并通知开关是否开启
getNoticeMergeFlag
();
function
getNoticeMergeFlag
(){
admin
.
req
({
url
:
common
.
domainName
+
'/api-web/manage/ddic/findSucDdics/noticeMergeFlag'
,
method
:
'POST'
,
async
:
false
,
success
:
function
(
res
)
{
$
.
each
(
res
.
data
,
function
(
i
,
v
)
{
if
(
v
.
ddicCode
==
'on'
){
$
(
'#noticeMergeTab'
).
show
();
}
});
}
})
}
//编辑
if
(
data
&&
data
.
id
){
admin
.
req
({
...
...
@@ -48,6 +66,14 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
$
(
"#alarmPolicyType"
).
val
(
res
.
object
.
policyType
);
}
});
// 获取通知合并策略的表达式
admin
.
req
({
url
:
domainName
+
'/api-web/policyMerge/get?noticeMergePolicyId='
+
data
.
id
,
done
:
function
(
res
){
$
(
"#noticeMergeFlagExpr"
).
val
(
res
.
data
[
0
].
noticeMergeExpr
);
}
});
}
else
{
$
(
"#seriousTimes"
).
val
(
'00:00:00 - 23:59:59'
);
$
(
"#importantTimes"
).
val
(
'00:00:00 - 23:59:59'
);
...
...
@@ -179,7 +205,85 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
data
.
seriousTimes
=
$
(
"#seriousTimes"
).
val
();
data
.
importantTimes
=
$
(
"#importantTimes"
).
val
();
data
.
commonlyTimes
=
$
(
"#commonlyTimes"
).
val
();
var
that
=
this
;
if
(
!
data
.
kpiId
){
layer
.
msg
(
"请先选择指标!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
if
(
!
data
.
kpiId
||
data
.
kpiId
==
''
){
layer
.
msg
(
"请先选择指标!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
if
(
!
data
.
alarmContentExpr
||
data
.
alarmContentExpr
==
''
){
layer
.
msg
(
"请先填写告警内容描述表达式!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
if
(
!
data
.
alarmContentExpr
||
data
.
alarmContentExpr
==
''
){
layer
.
msg
(
"请先填写告警内容描述表达式!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
var
importantPolicy
=
data
.
seriousPolicy
;
var
importantExpr
=
data
.
importantPolicy
;
var
commonlyPolicy
=
data
.
commonlyPolicy
;
if
((
!
importantPolicy
||
importantPolicy
==
''
)
&&
(
!
importantExpr
||
importantExpr
==
''
)
&&
(
!
commonlyPolicy
||
commonlyPolicy
==
''
)){
layer
.
msg
(
"严重、重要和一般告警的表达式必须有一项不为空!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
if
(
!
data
.
noticeMergeFlagExpr
||
data
.
noticeMergeFlagExpr
==
''
){
layer
.
msg
(
"请先填写通知合并策略描述表达式!"
,
{
icon
:
7
,
time
:
3000
});
return
false
;
}
/**
* 保存通知合并策略
*/
var
noticeMergeFlagExpr
=
$
(
"#noticeMergeFlagExpr"
).
val
()
function
saveNoticeMerge
(
id
){
var
noticeMergeData
=
{
"mergePolicyId"
:
id
,
"mergePolicyName"
:
data
.
alarmPolicyName
,
"mergePolicyDesc"
:
data
.
alarmPolicyName
,
"noticeMergeExpr"
:
noticeMergeFlagExpr
,
"policyType"
:
data
.
policyType
,
"kpiId"
:
data
.
kpiId
}
admin
.
req
({
url
:
domainName
+
'/api-web/policyMerge/save?access_token='
+
accessToken
,
data
:
JSON
.
stringify
(
noticeMergeData
)
,
type
:
'post'
,
contentType
:
"application/json; charset=utf-8"
,
done
:
function
(
res
){
if
(
!
res
.
success
){
layer
.
msg
(
res
.
msg
?
res
.
msg
:
'通知合并策略保存失败'
,
{
offset
:
'15px'
,
icon
:
7
,
time
:
1000
});
}
}
});
}
charToExpr
(
data
,
'alarmContentExpr'
);
charToExpr
(
data
,
'cleanPolicy'
);
charToExpr
(
data
,
'commonlyExpr'
);
...
...
@@ -187,6 +291,7 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
charToExpr
(
data
,
'seriousExpr'
);
form
.
on
(
'submit(add-alarmpolicy-form)'
,
function
()
{
delete
data
.
noticeMergeFlagExpr
;
admin
.
req
({
url
:
domainName
+
'/api-web/alarmPolicy/save?access_token='
+
accessToken
,
data
:
JSON
.
stringify
(
data
)
...
...
@@ -194,6 +299,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
,
contentType
:
"application/json; charset=utf-8"
,
done
:
function
(
res
){
if
(
res
.
success
){
// 保存通知合并策略
saveNoticeMerge
(
res
.
str
);
localStorage
.
setItem
(
"detailPageOfcustomPolicyId"
,
res
.
str
)
layer
.
msg
(
res
.
msg
,
{
offset
:
'15px'
,
icon
:
1
,
time
:
1000
},
function
(){
localStorage
.
removeItem
(
"currentResType"
);
...
...
@@ -263,4 +371,4 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun
$
(
'#add-alarmpolicy-form'
).
find
(
'[name="policyType"]'
).
attr
(
"disabled"
,
"disabled"
);
}
});
});
\ No newline at end of file
});
...
...
hg-monitor-web-base/src/main/resources/static/src/controller/common.js
View file @
020dee5
...
...
@@ -660,6 +660,7 @@ layui.define(['xmSelect', 'md5'], function (exports) {
layer
.
open
(
Object
.
assign
({
title
:
[
name
,
'font-size:18px;'
],
type
:
1
,
id
:(
new
Date
()).
getTime
(),
area
:
area
,
resize
:
false
,
shadeClose
:
true
,
//开启遮罩层
...
...
hg-monitor-web-base/src/main/resources/static/src/views/baseconfig/alarmpolicy/add.html
View file @
020dee5
...
...
@@ -62,13 +62,13 @@
</fieldset>
<div
class=
"layui-tab layui-tab-card"
>
<ul
class=
"layui-tab-title"
>
<li
class=
"layui-this"
>
告警内容
</li>
<li
class=
"layui-this"
><span
style=
"color:red"
>
*
</span
>
告警内容
</li>
<li>
严重
</li>
<li>
重要
</li>
<li>
一般
</li>
<li>
一般
告警
</li>
<li>
过滤
</li>
<li>
消除
</li>
<!-- <li>告警内容表达式</li>--
>
<li
id=
"noticeMergeTab"
style=
"display: none"
><span
style=
"color:red"
>
*
</span>
通知合并策略
</li
>
</ul>
<div
class=
"layui-tab-content"
>
<div
class=
"layui-tab-item layui-show content-tab-item"
>
...
...
@@ -355,50 +355,19 @@
</div>
</div>
</div>
<!-- <div class="layui-tab-item">-->
<!-- <div class="content-box-group">-->
<!-- <div class="box-group-left">告警内容表达式</div>-->
<!-- <div class="box-group-right">-->
<!-- <div class="layui-form-item">-->
<!-- <div class="layui-input-block">-->
<!-- <input type="radio" name="alarmcotent-policy-type" data-flag="alarmcotent" value="1" title="基础" checked lay-filter="alarm-policy-rule-type">-->
<!-- <input type="radio" name="alarmcotent-policy-type" data-flag="alarmcotent" value="2" title="正则" lay-filter="alarm-policy-rule-type">-->
<!-- <input type="radio" name="alarmcotent-policy-type" data-flag="alarmcotent" value="3" title="自定义"lay-filter="alarm-policy-rule-type">-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="layui-form-item cont-base" id="alarmcotent-policy-box">-->
<!-- <div class="layui-input-inline smallwith">-->
<!-- <select class="alarmcotent_condition">-->
<!-- <option value="0">大于</option>-->
<!-- <option value="1">小于</option>-->
<!-- <option value="2">等于</option>-->
<!-- <option value="3">大于等于</option>-->
<!-- <option value="4">小于等于</option>-->
<!-- <option value="5">字符串等于</option>-->
<!-- <option value="6">字符串包含</option>-->
<!-- <option value="7">字符串前匹配</option>-->
<!-- <option value="8">字符串后匹配</option>-->
<!-- </select>-->
<!-- </div>-->
<!-- <div class="layui-input-inline smallwith">-->
<!-- <input type="tel" autocomplete="off" class="layui-input" flag="alarmcotent_value">-->
<!-- </div>-->
<!-- <div class="layui-form-mid layui-word-aux"><i data-id="alarmcotent-policy-box" class="layui-icon oper-icon policy-input-add"></i></div>-->
<!-- <div class="layui-form-mid layui-word-aux"><i data-id="alarmcotent-policy-box" class="layui-icon oper-icon policy-input-del hide"></i></div>-->
<!-- </div>-->
<!-- <div class="layui-form-item cont-base">-->
<!-- <div class="layui-input-block">-->
<!-- <a class="layui-btn layui-btn-sm layui-btn-normal createpolicybtn" data-flag="alarmcotent">生成策略</a>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="layui-form-item cont-other">-->
<!-- <div class="layui-input-block">-->
<!-- <textarea placeholder="请输入内容" class="layui-textarea" name="alarmContentExpr" id="alarmcotentPolicy"></textarea>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div
class=
"layui-tab-item content-tab-item"
>
<!-- 通知合并策略 -->
<div
class=
"content-box-group"
>
<div
class=
"box-group-left"
style=
"text-align: center"
>
通知合并策略
<br/>
描述表达式
</div>
<div
class=
"box-group-right"
>
<div
class=
"layui-form-item"
>
<div
class=
"layui-input-block"
>
<textarea
placeholder=
"请输入内容"
class=
"layui-textarea"
id=
"noticeMergeFlagExpr"
name=
"noticeMergeFlagExpr"
></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
@@ -408,4 +377,4 @@
layui
.
use
(
'alarmpolicyAdd'
,
function
(
fn
)
{
fn
({{
d
}});
});
</script>
\ No newline at end of file
</script>
...
...
Please
register
or
login
to post a comment