Authored by 鲁尚清

Merge branch 'master' of http://192.168.1.136:82/monitor_v3/hg-monitor-web into …

…master-v32-lushangqing
... ... @@ -108,40 +108,22 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
});
//配置资源
$("#alarmtemplate_configres").on("click", function () {
if ($.inArray('back:alarmtemp:resource', checkList) == -1) {
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
var tempIds = [];
var data = table.checkStatus('alarmtemplateTable').data;
if (data && data.length > 0) {
$.each(data, function (i, obj) {
tempIds.push(obj.alarmTempId);
});
}
if (tempIds.length != 1) {
layer.msg('请选择一条要配置的数据', {icon: 7, time: 2000});
return;
}
function getOldResIdList(tempIds){
var oldResIdList = [];
if (tempIds.length <= 1) {
admin.req({
url: common.domainName + '/api-web/alarmtemplate/getResIdByTempId',
async: false,
data: {
tempId: tempIds.toString(),
},
error: function () {
layer.close(loading);
}
}).done(function (response) {
if (response) {
oldResIdList = response.data.map(item => item.resId)
}
});
}
admin.req({
url: common.domainName + '/api-web/alarmtemplate/getResIdByTempId',
async: false,
data: {
tempId: tempIds.toString(),
},
error: function () {
layer.close(loading);
}
}).done(function (response) {
if (response) {
oldResIdList = response.data.map(item => item.resId)
}
});
common.openWin("template/res/reslist", "配置资源", {oldData: oldResIdList}, ["选择", "取消"], function () {
var resObj = layui.reslist().getData();
if (resObj && resObj.length > 0) {
... ... @@ -153,21 +135,42 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
url: domainName + '/api-web/manage/resource/alarmTemplate?resIds=' + resIds.toString() + '&alarmTempId=' + tempIds.toString() + '&access_token=' + accessToken,
done: function (res) {
if (res.success) {
layer.msg("配置成功!", {offset: '15px', icon: 1, time: 1000}, function () {
layer.msg("配置成功!", {offset: '15px', icon: 1, time: 2000}, function () {
layer.closeAll();
reloadalarmtemplateTable();
});
} else {
layer.msg("配置失败,请重试或者与管理员联系!", {offset: '15px', icon: 7, time: 1000});
layer.msg("配置失败,请重试或者与管理员联系!", {offset: '15px', icon: 7, time: 2000});
}
}
});
} else {
layer.msg("请至少选择一条资源", {offset: '15px', icon: 7, time: 1000});
layer.msg("请至少选择一条资源", {offset: '15px', icon: 7, time: 2000});
return false;
}
return true;
});
}
//配置资源
$("#alarmtemplate_configres").on("click", function () {
if ($.inArray('back:alarmtemp:resource', checkList) == -1) {
layer.msg('暂无权限!', {icon: 7, time: 3000});
return;
}
var tempIds = [];
var data = table.checkStatus('alarmtemplateTable').data;
if (data && data.length > 0) {
$.each(data, function (i, obj) {
tempIds.push(obj.alarmTempId);
});
}
if (tempIds.length != 1) {
layer.msg('请选择一条要配置的数据', {icon: 7, time: 2000});
return;
}
getOldResIdList(tempIds);
});
// 解除绑定
... ... @@ -226,7 +229,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
, url: domainName + '/api-web/alarmtemplate/page'
, where: {
access_token: accessToken,
alarmTempName: $("#alarmtemplatekw").val(),
keyWord: $("#alarmtemplatekw").val(),
policyId: policyId,
resIdList: resIdList
}
... ... @@ -355,9 +358,30 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
//查看告警模板的资源数量
$(".view-alarmtemplate-res-total").on("click", function () {
var alarmTempId = $(this).data("id");
common.openWin("template/res/reslist", "资源列表", {alarmTempId: alarmTempId}, ["关闭"], function () {
return true;
}, null, ['90%', '80%'])
layer.open({
title: ['绑定资源', 'font-size:18px;'],
type: 1,
area: ['90%','80%'],
resize:false,
btn: ['确定','取消'],
content: laytpl($('#tempResource').html()).render(JSON.stringify({})),
success: function (index, layero) {
renderResByTemp(alarmTempId)
//新增资源权限
$('#addAuthResBtn').on('click', function () {
openResByTemp(alarmTempId,index)
})
//删除资源权限
$('#delAuthResBtn').on('click', function () {
deleteResTemp(alarmTempId)
})
},
yes: function(index, layero){
layer.close(index); //如果设定了yes回调,需进行手工关闭
}
});
});
//设置同步
... ... @@ -374,6 +398,120 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
}
});
//渲染用户所有资源权限列表表格
function renderResByTemp(alarmTempId) {
temResTable = table.render({
elem: '#res_temp_table',
url: domainName + '/api-web/home/res-list/all',
where: {
access_token: accessToken,
resName: '',
busId: '',
resHealth: '',
provider:'',
collectorId: '',
trapCollectorId: '',
alarmTempId: alarmTempId,
cutoverId: '',
targetType: '',
protocolFlag:'',
protocol:'',
editMode: 'true',
resCategory: 'resources'
},
height: 'auto',
cellMinWidth: 80,
page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
, theme: '#1E9FFF'
},
even: true,
cols: [[
{type:'checkbox'}
,{type: 'numbers', title: '序号', align: 'center'}
, {
field: 'resName', title: '资源名称', align: 'center',sort:true,
templet: '<div><span resmanage-data-edit="{{d.resId}}" data-zymc="{{ d.resId }}" data-ip="{{ d.ip }}" data-resTypeName="{{ d.resTypeName }}" data-admin="{{ d.admin }}" data-restype="{{d.resType}}" data-name="{{d.resName}}" data-pingenable="{{d.pingEnable}}">{{ d.resName }}</span></div>'
}
, {field: 'ip', title: 'IP地址', align: 'center',sort:true}
, {field: 'port', title: '端口号', align: 'center',sort:true}
, {field: 'adminName', title: '负责人', align: 'center',sort:true}
, {field: 'resTypeName', title: '资源类型', align: 'center',sort:true}
, {field: 'state', title: '资源状态', align: 'center',sort:true, templet: function (d) {
switch (d.state) {
case "new" :
return '<button type="button" class="layui-btn layui-btn-warm layui-bg-gray layui-btn-radius layui-btn-xs p-0-15">未监控</button>'
case "monitor" :
return '<button type="button" class="layui-btn layui-btn-radius layui-bg-green layui-btn-xs p-0-15" style="background-color: #0BAC33 !important;">监控中</button>'
case "stop" :
return '<button type="button" class="layui-btn layui-btn-warm layui-bg-red layui-btn-radius layui-btn-xs p-0-15">暂停</button>'
default :
return '<button type="button" class="layui-btn layui-btn-warm layui-bg-gray layui-btn-radius layui-btn-xs p-0-15">未监控</button>'
}
}}
, {
title: '操作', fixed: 'right', align: 'center', fixed: 'right',
templet: '<div><span data-id="{{d.resId}}" class="layui-table-link tem_res_delete_btn">删除</span></div>'
}
]],
done: function (res, curr, count) {
//删除
$('.tem_res_delete_btn').on('click', function () {
var id = $(this).data('id')
deleteResTemp(alarmTempId,id)
})
},
})
}
//为用户添加资源权限
function openResByTemp(alarmTempId,index) {
getOldResIdList(alarmTempId);
}
//删除对应的资源权限
function deleteResTemp(alarmTempId,id) {
debugger
if (typeof (id) != "string") {
var ids = [];
var data = table.checkStatus('res_temp_table').data;
if (data && data.length > 0) {
$.each(data, function (i, obj) {
ids.push(obj.resId);
});
}
if (ids.length == 0) {
layer.msg('请选择要删除的数据', {icon: 7, time: 2000});
return;
}
id = ids.toString();
}
//确认提示框
layer.confirm('您确定要删除绑定的该资源吗?', {
btn: ['确定', '取消'] //按钮
}, function () {
$.ajax({
url: common.domainName + '/api-web/alarmtemplate/deleteByResIdsAndTempIds?access_token=' + accessToken
, data: {
resIds: id,
tempIds: alarmTempId.toString()
}
}).done(function (res) {
layer.msg('删除成功', {
offset: '15px'
, icon: 1
, time: 2000
}, function () {
layer.closeAll();
reloadalarmtemplateTable()
});
}).error(function (error) {
console.log(error);
});
});
}
//刷新表格
function reloadalarmtemplateTable() {
alarmtemplateTable.reload({
... ... @@ -381,7 +519,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
access_token: accessToken,
policyId: policyId,
resIdList: resIdList,
alarmTempName: $("#alarmtemplatekw").val()
keyWord: $("#alarmtemplatekw").val()
}
});
}
... ...
... ... @@ -27,7 +27,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
, url: domainName + '/api-web/alarmtemplate/list'
, where:{
access_token:accessToken,
alarmTempName:$("#alarmtemplatekw").val(),
keyWord:$("#alarmtemplatekw").val(),
policyId:policyId
}
, height: 'full-310'
... ... @@ -145,9 +145,9 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions'], function
alarmtemplatelistTable.reload({
where:{
access_token:accessToken,
alarmTempName:$("#alarmtemplatelistkw").val(),
keyWord:$("#alarmtemplatelistkw").val(),
}
});
}
});
});
\ No newline at end of file
});
... ...
... ... @@ -253,33 +253,36 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
// 发送状态 1已发送,2未发送
noticeTimely.sendState = 2;//statusChange(document.querySelector("#switch_noticeTimely_sendState").checked ? 0 : 1);
noticeTimely.noticeNames = userNames;
var noticeStateList = [];
//获取消息状态列表
$.each($('#editNoticeTimely_add_table').find('tbody tr'), function (i, v) {
var noticeState = {};
noticeState.noticeName = $(this).find('input[name="noticeName"]').val();
noticeState.sendTime = $(this).find('input[name="sendTime"]').val();
noticeState.sendContent = $(this).find('input[name="sendContent"]').val();
noticeState.noticeState = $(this).find('select[name="noticeState"]').val();
noticeStateList.push(noticeState);
});
noticeTimely.noticeStateList = noticeStateList;
// var noticeStateList = [];
// //获取消息状态列表
// $.each($('#editNoticeTimely_add_table').find('tbody tr'), function (i, v) {
// var noticeState = {};
// noticeState.noticeName = $(this).find('input[name="noticeName"]').val();
// noticeState.sendTime = $(this).find('input[name="sendTime"]').val();
// noticeState.sendContent = $(this).find('input[name="sendContent"]').val();
// noticeState.noticeState = $(this).find('select[name="noticeState"]').val();
// noticeStateList.push(noticeState);
// });
// noticeTimely.noticeStateList = noticeStateList;
if (!noticeTimely.noticeNames) {
layer.msg('请选择用户', {icon: 7, time: 3000});
return false;
}
if (!noticeTimely.templates) {
layer.msg('请配置自定义展示中的展示内容', {icon: 7, time: 3000});
return false;
}
noticeTimely.site = $('#notice_timely_select').val() + $('#notice_timely_site').val();
//获取配置参数
var map = getParam();
if(!map){
return ;
return false;
}
if(map.msgSetting && map.msgSetting != '' && map.msgSetting != null){
noticeTimely.msgSetting = JSON.stringify(map.msgSetting);
}
noticeTimely.msgSetting = JSON.stringify(map.msgSetting);
noticeTimely.templates = map.templates;
if (!noticeTimely.templates || map.msgSetting == '' || map.msgSetting == null) {
layer.msg('请配置自定义展示中的展示内容', {icon: 7, time: 3000});
return false;
}
layer.load(2);
admin.req({
url: domainName + '/api-web/noticeTimely/save?access_token=' + accessToken,
... ... @@ -449,8 +452,6 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
$('#details_tags').append(details_tags);
$('#details_tags span').on('click',function (){
$('[name="templates"]').val($('[name="templates"]').val() + '#{'+$(this).text() + '}');
noticeTimely.templates += '#{'+$(this).text() + '}';
});
}
... ... @@ -459,8 +460,8 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
//获取模板和等级
var obj = {
msgSetting: null,
templates: null
msgSetting: '',
templates: ''
};
var errMsg = '';
... ...
... ... @@ -186,46 +186,41 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'sessions', 'treeTabl
cols: [[{
type: 'checkbox'
}, {
field: 'name', title: '名称', align: 'center', width: '250',
field: 'name', title: '名称', align: 'center', width: '15%',
templet:
'<div>' +
' <span data-id="{{d.id}}" class="link link-noticeTimely-edit">{{d.name}}</span>' +
'</div>'
}, {
field: 'details', title: '内容', align: 'left', minWidth: '650',
field: 'details', title: '内容', align: 'left', width: '25%',
templet: function (d) {
// return '<input type="text" class="layui-input" style= "background-color:transparent;border:0;padding-bottom: 10px" readonly="readonly" name="details" value="' + d.details + '">'
return '<code>' + d.details + '</code>'
}
}, {
field: 'frequency', title: '频率', align: 'center', width: '130'
field: 'frequency', title: '频率', align: 'center', minWidth: '130'
}, {
field: 'noticeNicknames', title: '用户', align: 'center', minWidth: '180'
}, {
field: 'state', title: '是否启用', align: 'center', width: '100',
field: 'lastSendTime', title: '最后发送时间', align: 'center', minWidth: '170',templet: function (d) {
if(d.noticeStateNew && d.noticeStateNew.sendTime){
return d.noticeStateNew.sendTime;
}
return '';
}
},{
field: 'state', title: '是否启用', align: 'center', minWidth: '100',
templet: function (d) {
var checked = d.state == 2 ? 'checked' : '';
return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_state" name="state" lay-skin="switch" lay-text="启用|禁用" ' + checked + ' ></div>'
}
}, /*{
field: 'broadcast', title: '是否广播', align: 'center', width: '100',
templet: function (d) {
var checked = d.broadcast == 1 ? 'checked' : '';
return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_broadcast" name="broadcast" lay-skin="switch" lay-text="是|否" ' + checked + ' ></div>'
}
}, {
field: 'retry', title: '是否轮循', align: 'center', width: '100',
templet: function (d) {
var checked = d.retry == 1 ? 'checked' : '';
return '<div><input type="checkbox" data-id="' + d.id + '" lay-filter="switch_noticeTimely_checkbox_retry" name="retry" lay-skin="switch" lay-text="重发|不重发" ' + checked + ' ></div>'
}
}, */{
title: '操作', align: 'center', minWidth: '150', fixed: 'right',
templet:
'<div>' +
' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-delete" lay-tips="删除"><i class="layui-icon">&#xe640;</i></button>' +
' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-history" lay-tips="历史记录"><i class="layui-icon">&#xe705;</i></button>' +
'</div>'
title: '操作', align: 'center', minWidth: '120', fixed: 'right',
templet:
'<div>' +
' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-delete" lay-tips="删除"><i class="layui-icon">&#xe640;</i></button>' +
' <button data-id="{{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal link-noticeTimely-history" lay-tips="历史记录"><i class="layui-icon">&#xe705;</i></button>' +
'</div>'
}]],
done: function (res) {
// 点击名称编辑事件
... ...
... ... @@ -27,10 +27,10 @@ layui.define(['table', 'form', 'sessions', 'common', 'view', 'admin'], function
}
});
// //按钮搜索
// $('#heartbeatQueryBtn').unbind().on('click',function (e) {
// reloadTable();
// })
//按钮搜索
$('#heartbeatQueryBtn').unbind().on('click',function (e) {
reloadTable();
})
// 渲染表格
... ... @@ -63,10 +63,12 @@ layui.define(['table', 'form', 'sessions', 'common', 'view', 'admin'], function
}, {
field: 'currTime', title: '最近心跳时间', align: 'center',sort: true,
templet: function (d) {
var durationVal = $('[name="durationVal"]').val();
if(!durationVal || durationVal == '' || durationVal == null){
durationVal = 10;
}
var beatTime = new Date(d.currTime);
var time = new Date();
time.setMinutes(time.getMinutes() - 10);
if (time > beatTime) {
if (d.between > parseInt(durationVal)) {
return `<div class="red">${beatTime.format("yyyy-MM-dd HH:mm:ss")}</div>`
} else {
return `<div>${beatTime.format("yyyy-MM-dd HH:mm:ss")}</div>`
... ... @@ -85,7 +87,7 @@ layui.define(['table', 'form', 'sessions', 'common', 'view', 'admin'], function
heartbeatTable.reload({
where: {
access_token: accessToken,
keyword: $('#condition-heartbeat-name').val(),
keyword: $('#condition-heartbeat-name').val()
},
page: {
curr: 1
... ... @@ -93,4 +95,4 @@ layui.define(['table', 'form', 'sessions', 'common', 'view', 'admin'], function
});
}
});
});
\ No newline at end of file
});
... ...
... ... @@ -9,7 +9,7 @@
<div class="layui-form-item">
<div class="layui-inline">
<div class="layui-input-inline layui-input-inline--long">
<input type="text" id="alarmtemplatekw" lay-tips="关键字检索包含 </br>模板名称" name="alarmtemplatekw" placeholder="输入关键字,回车搜索" autocomplete="off" class="layui-input">
<input type="text" id="alarmtemplatekw" lay-tips="关键字检索包含 </br>模板名称</br>资源名称" name="alarmtemplatekw" placeholder="输入关键字,回车搜索" autocomplete="off" class="layui-input">
</div>
</div>
<div class="layui-inline">
... ... @@ -57,6 +57,28 @@
</div>
<textarea class="hide" id="alarmtemplate-params">{{d}}</textarea>
</article>
<script id="tempResource" type="text/html">
<article class="page-container">
<div class="page-panel">
<div class="main">
<div class="layui-card">
<div class="layui-card-body">
<div class="warn-btns">
<button id="addAuthResBtn" type="button" class="layui-btn layui-btn-sm layui-btn-normal"><i
class="layui-icon">&#xe654;</i>新增资
</button>
<button id="delAuthResBtn" type="button" class="layui-btn layui-btn-sm layui-btn-normal"><i
class="layui-icon">&#xe640;</i>删除资
</button>
</div>
<table id="res_temp_table"></table>
</div>
</div>
</div>
</div>
</article>
</script>
<!--<script template lay-done="layui.data.sendParams(d.params)"></script>-->
<script>
var params = document.getElementById("alarmtemplate-params").value;
... ... @@ -74,4 +96,4 @@
// fn(params);
// });
// };
</script>
\ No newline at end of file
</script>
... ...
... ... @@ -13,8 +13,7 @@
</div>
</div>
<div class="layui-inline">
<button id="noticeTimelyQueryBtn" type="button" class="layui-btn layui-btn-normal" ><i
class="layui-icon layui-icon-search"></i>查询
<button id="noticeTimelyQueryBtn" type="button" class="layui-btn layui-btn-normal" >查询
</button>
</div>
</div>
... ...
... ... @@ -14,11 +14,16 @@
placeholder="输入关键字,回车搜索" autocomplete="off" class="layui-input">
</div>
</div>
<!-- <div class="layui-inline">-->
<!-- <button id="heartbeatQueryBtn" type="button" class="layui-btn layui-btn-normal" ><i-->
<!-- class="layui-icon layui-icon-search"></i>查询-->
<!-- </button>-->
<!-- </div>-->
<div class="layui-inline">
<div class="layui-input-inline">
<input type="number" name="durationVal"
lay-tips="最近心跳时间(单位:分钟)" placeholder="最近心跳时间" value="10" class="layui-input">
<!-- <span>分钟</span>-->
</div>
</div>
<div class="layui-inline">
<button id="heartbeatQueryBtn" type="button" class="layui-btn layui-btn-normal">查询</button>
</div>
</div>
</form>
</div>
... ... @@ -45,4 +50,4 @@
layui.use('selfmonitor', function (fn) {
fn();
});
</script>
\ No newline at end of file
</script>
... ...