...
|
...
|
@@ -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()
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
|