|
@@ -108,40 +108,22 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -108,40 +108,22 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
108
|
|
108
|
|
109
|
});
|
109
|
});
|
110
|
|
110
|
|
111
|
- //配置资源
|
|
|
112
|
- $("#alarmtemplate_configres").on("click", function () {
|
|
|
113
|
- if ($.inArray('back:alarmtemp:resource', checkList) == -1) {
|
|
|
114
|
- layer.msg('暂无权限!', {icon: 7, time: 3000});
|
|
|
115
|
- return;
|
|
|
116
|
- }
|
|
|
117
|
- var tempIds = [];
|
|
|
118
|
- var data = table.checkStatus('alarmtemplateTable').data;
|
|
|
119
|
- if (data && data.length > 0) {
|
|
|
120
|
- $.each(data, function (i, obj) {
|
|
|
121
|
- tempIds.push(obj.alarmTempId);
|
|
|
122
|
- });
|
|
|
123
|
- }
|
|
|
124
|
- if (tempIds.length != 1) {
|
|
|
125
|
- layer.msg('请选择一条要配置的数据', {icon: 7, time: 2000});
|
|
|
126
|
- return;
|
|
|
127
|
- }
|
111
|
+ function getOldResIdList(tempIds){
|
128
|
var oldResIdList = [];
|
112
|
var oldResIdList = [];
|
129
|
- if (tempIds.length <= 1) {
|
|
|
130
|
- admin.req({
|
|
|
131
|
- url: common.domainName + '/api-web/alarmtemplate/getResIdByTempId',
|
|
|
132
|
- async: false,
|
|
|
133
|
- data: {
|
|
|
134
|
- tempId: tempIds.toString(),
|
|
|
135
|
- },
|
|
|
136
|
- error: function () {
|
|
|
137
|
- layer.close(loading);
|
|
|
138
|
- }
|
|
|
139
|
- }).done(function (response) {
|
|
|
140
|
- if (response) {
|
|
|
141
|
- oldResIdList = response.data.map(item => item.resId)
|
|
|
142
|
- }
|
|
|
143
|
- });
|
|
|
144
|
- }
|
113
|
+ admin.req({
|
|
|
114
|
+ url: common.domainName + '/api-web/alarmtemplate/getResIdByTempId',
|
|
|
115
|
+ async: false,
|
|
|
116
|
+ data: {
|
|
|
117
|
+ tempId: tempIds.toString(),
|
|
|
118
|
+ },
|
|
|
119
|
+ error: function () {
|
|
|
120
|
+ layer.close(loading);
|
|
|
121
|
+ }
|
|
|
122
|
+ }).done(function (response) {
|
|
|
123
|
+ if (response) {
|
|
|
124
|
+ oldResIdList = response.data.map(item => item.resId)
|
|
|
125
|
+ }
|
|
|
126
|
+ });
|
145
|
common.openWin("template/res/reslist", "配置资源", {oldData: oldResIdList}, ["选择", "取消"], function () {
|
127
|
common.openWin("template/res/reslist", "配置资源", {oldData: oldResIdList}, ["选择", "取消"], function () {
|
146
|
var resObj = layui.reslist().getData();
|
128
|
var resObj = layui.reslist().getData();
|
147
|
if (resObj && resObj.length > 0) {
|
129
|
if (resObj && resObj.length > 0) {
|
|
@@ -153,21 +135,42 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -153,21 +135,42 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
153
|
url: domainName + '/api-web/manage/resource/alarmTemplate?resIds=' + resIds.toString() + '&alarmTempId=' + tempIds.toString() + '&access_token=' + accessToken,
|
135
|
url: domainName + '/api-web/manage/resource/alarmTemplate?resIds=' + resIds.toString() + '&alarmTempId=' + tempIds.toString() + '&access_token=' + accessToken,
|
154
|
done: function (res) {
|
136
|
done: function (res) {
|
155
|
if (res.success) {
|
137
|
if (res.success) {
|
156
|
- layer.msg("配置成功!", {offset: '15px', icon: 1, time: 1000}, function () {
|
138
|
+ layer.msg("配置成功!", {offset: '15px', icon: 1, time: 2000}, function () {
|
157
|
layer.closeAll();
|
139
|
layer.closeAll();
|
158
|
reloadalarmtemplateTable();
|
140
|
reloadalarmtemplateTable();
|
|
|
141
|
+
|
159
|
});
|
142
|
});
|
160
|
} else {
|
143
|
} else {
|
161
|
- layer.msg("配置失败,请重试或者与管理员联系!", {offset: '15px', icon: 7, time: 1000});
|
144
|
+ layer.msg("配置失败,请重试或者与管理员联系!", {offset: '15px', icon: 7, time: 2000});
|
162
|
}
|
145
|
}
|
163
|
}
|
146
|
}
|
164
|
});
|
147
|
});
|
165
|
} else {
|
148
|
} else {
|
166
|
- layer.msg("请至少选择一条资源", {offset: '15px', icon: 7, time: 1000});
|
149
|
+ layer.msg("请至少选择一条资源", {offset: '15px', icon: 7, time: 2000});
|
167
|
return false;
|
150
|
return false;
|
168
|
}
|
151
|
}
|
169
|
return true;
|
152
|
return true;
|
170
|
});
|
153
|
});
|
|
|
154
|
+ }
|
|
|
155
|
+
|
|
|
156
|
+ //配置资源
|
|
|
157
|
+ $("#alarmtemplate_configres").on("click", function () {
|
|
|
158
|
+ if ($.inArray('back:alarmtemp:resource', checkList) == -1) {
|
|
|
159
|
+ layer.msg('暂无权限!', {icon: 7, time: 3000});
|
|
|
160
|
+ return;
|
|
|
161
|
+ }
|
|
|
162
|
+ var tempIds = [];
|
|
|
163
|
+ var data = table.checkStatus('alarmtemplateTable').data;
|
|
|
164
|
+ if (data && data.length > 0) {
|
|
|
165
|
+ $.each(data, function (i, obj) {
|
|
|
166
|
+ tempIds.push(obj.alarmTempId);
|
|
|
167
|
+ });
|
|
|
168
|
+ }
|
|
|
169
|
+ if (tempIds.length != 1) {
|
|
|
170
|
+ layer.msg('请选择一条要配置的数据', {icon: 7, time: 2000});
|
|
|
171
|
+ return;
|
|
|
172
|
+ }
|
|
|
173
|
+ getOldResIdList(tempIds);
|
171
|
});
|
174
|
});
|
172
|
|
175
|
|
173
|
// 解除绑定
|
176
|
// 解除绑定
|
|
@@ -226,7 +229,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -226,7 +229,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
226
|
, url: domainName + '/api-web/alarmtemplate/page'
|
229
|
, url: domainName + '/api-web/alarmtemplate/page'
|
227
|
, where: {
|
230
|
, where: {
|
228
|
access_token: accessToken,
|
231
|
access_token: accessToken,
|
229
|
- alarmTempName: $("#alarmtemplatekw").val(),
|
232
|
+ keyWord: $("#alarmtemplatekw").val(),
|
230
|
policyId: policyId,
|
233
|
policyId: policyId,
|
231
|
resIdList: resIdList
|
234
|
resIdList: resIdList
|
232
|
}
|
235
|
}
|
|
@@ -355,9 +358,30 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -355,9 +358,30 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
355
|
//查看告警模板的资源数量
|
358
|
//查看告警模板的资源数量
|
356
|
$(".view-alarmtemplate-res-total").on("click", function () {
|
359
|
$(".view-alarmtemplate-res-total").on("click", function () {
|
357
|
var alarmTempId = $(this).data("id");
|
360
|
var alarmTempId = $(this).data("id");
|
358
|
- common.openWin("template/res/reslist", "资源列表", {alarmTempId: alarmTempId}, ["关闭"], function () {
|
|
|
359
|
- return true;
|
|
|
360
|
- }, null, ['90%', '80%'])
|
361
|
+ layer.open({
|
|
|
362
|
+ title: ['绑定资源', 'font-size:18px;'],
|
|
|
363
|
+ type: 1,
|
|
|
364
|
+ area: ['90%','80%'],
|
|
|
365
|
+ resize:false,
|
|
|
366
|
+ btn: ['确定','取消'],
|
|
|
367
|
+ content: laytpl($('#tempResource').html()).render(JSON.stringify({})),
|
|
|
368
|
+ success: function (index, layero) {
|
|
|
369
|
+ renderResByTemp(alarmTempId)
|
|
|
370
|
+
|
|
|
371
|
+ //新增资源权限
|
|
|
372
|
+ $('#addAuthResBtn').on('click', function () {
|
|
|
373
|
+ openResByTemp(alarmTempId,index)
|
|
|
374
|
+ })
|
|
|
375
|
+
|
|
|
376
|
+ //删除资源权限
|
|
|
377
|
+ $('#delAuthResBtn').on('click', function () {
|
|
|
378
|
+ deleteResTemp(alarmTempId)
|
|
|
379
|
+ })
|
|
|
380
|
+ },
|
|
|
381
|
+ yes: function(index, layero){
|
|
|
382
|
+ layer.close(index); //如果设定了yes回调,需进行手工关闭
|
|
|
383
|
+ }
|
|
|
384
|
+ });
|
361
|
});
|
385
|
});
|
362
|
|
386
|
|
363
|
//设置同步
|
387
|
//设置同步
|
|
@@ -374,6 +398,120 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -374,6 +398,120 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
374
|
}
|
398
|
}
|
375
|
});
|
399
|
});
|
376
|
|
400
|
|
|
|
401
|
+ //渲染用户所有资源权限列表表格
|
|
|
402
|
+ function renderResByTemp(alarmTempId) {
|
|
|
403
|
+ temResTable = table.render({
|
|
|
404
|
+ elem: '#res_temp_table',
|
|
|
405
|
+ url: domainName + '/api-web/home/res-list/all',
|
|
|
406
|
+ where: {
|
|
|
407
|
+ access_token: accessToken,
|
|
|
408
|
+ resName: '',
|
|
|
409
|
+ busId: '',
|
|
|
410
|
+ resHealth: '',
|
|
|
411
|
+ provider:'',
|
|
|
412
|
+ collectorId: '',
|
|
|
413
|
+ trapCollectorId: '',
|
|
|
414
|
+ alarmTempId: alarmTempId,
|
|
|
415
|
+ cutoverId: '',
|
|
|
416
|
+ targetType: '',
|
|
|
417
|
+ protocolFlag:'',
|
|
|
418
|
+ protocol:'',
|
|
|
419
|
+ editMode: 'true',
|
|
|
420
|
+ resCategory: 'resources'
|
|
|
421
|
+ },
|
|
|
422
|
+ height: 'auto',
|
|
|
423
|
+ cellMinWidth: 80,
|
|
|
424
|
+ page: {
|
|
|
425
|
+ layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
|
|
|
426
|
+ , theme: '#1E9FFF'
|
|
|
427
|
+ },
|
|
|
428
|
+ even: true,
|
|
|
429
|
+ cols: [[
|
|
|
430
|
+ {type:'checkbox'}
|
|
|
431
|
+ ,{type: 'numbers', title: '序号', align: 'center'}
|
|
|
432
|
+ , {
|
|
|
433
|
+ field: 'resName', title: '资源名称', align: 'center',sort:true,
|
|
|
434
|
+ 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>'
|
|
|
435
|
+ }
|
|
|
436
|
+ , {field: 'ip', title: 'IP地址', align: 'center',sort:true}
|
|
|
437
|
+ , {field: 'port', title: '端口号', align: 'center',sort:true}
|
|
|
438
|
+ , {field: 'adminName', title: '负责人', align: 'center',sort:true}
|
|
|
439
|
+ , {field: 'resTypeName', title: '资源类型', align: 'center',sort:true}
|
|
|
440
|
+ , {field: 'state', title: '资源状态', align: 'center',sort:true, templet: function (d) {
|
|
|
441
|
+ switch (d.state) {
|
|
|
442
|
+ case "new" :
|
|
|
443
|
+ return '<button type="button" class="layui-btn layui-btn-warm layui-bg-gray layui-btn-radius layui-btn-xs p-0-15">未监控</button>'
|
|
|
444
|
+ case "monitor" :
|
|
|
445
|
+ 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>'
|
|
|
446
|
+ case "stop" :
|
|
|
447
|
+ return '<button type="button" class="layui-btn layui-btn-warm layui-bg-red layui-btn-radius layui-btn-xs p-0-15">暂停</button>'
|
|
|
448
|
+ default :
|
|
|
449
|
+ return '<button type="button" class="layui-btn layui-btn-warm layui-bg-gray layui-btn-radius layui-btn-xs p-0-15">未监控</button>'
|
|
|
450
|
+ }
|
|
|
451
|
+ }}
|
|
|
452
|
+ , {
|
|
|
453
|
+ title: '操作', fixed: 'right', align: 'center', fixed: 'right',
|
|
|
454
|
+ templet: '<div><span data-id="{{d.resId}}" class="layui-table-link tem_res_delete_btn">删除</span></div>'
|
|
|
455
|
+ }
|
|
|
456
|
+ ]],
|
|
|
457
|
+ done: function (res, curr, count) {
|
|
|
458
|
+ //删除
|
|
|
459
|
+ $('.tem_res_delete_btn').on('click', function () {
|
|
|
460
|
+ var id = $(this).data('id')
|
|
|
461
|
+ deleteResTemp(alarmTempId,id)
|
|
|
462
|
+ })
|
|
|
463
|
+ },
|
|
|
464
|
+ })
|
|
|
465
|
+ }
|
|
|
466
|
+
|
|
|
467
|
+ //为用户添加资源权限
|
|
|
468
|
+ function openResByTemp(alarmTempId,index) {
|
|
|
469
|
+ getOldResIdList(alarmTempId);
|
|
|
470
|
+ }
|
|
|
471
|
+
|
|
|
472
|
+ //删除对应的资源权限
|
|
|
473
|
+ function deleteResTemp(alarmTempId,id) {
|
|
|
474
|
+ debugger
|
|
|
475
|
+ if (typeof (id) != "string") {
|
|
|
476
|
+ var ids = [];
|
|
|
477
|
+ var data = table.checkStatus('res_temp_table').data;
|
|
|
478
|
+ if (data && data.length > 0) {
|
|
|
479
|
+ $.each(data, function (i, obj) {
|
|
|
480
|
+ ids.push(obj.resId);
|
|
|
481
|
+ });
|
|
|
482
|
+ }
|
|
|
483
|
+ if (ids.length == 0) {
|
|
|
484
|
+ layer.msg('请选择要删除的数据', {icon: 7, time: 2000});
|
|
|
485
|
+ return;
|
|
|
486
|
+ }
|
|
|
487
|
+ id = ids.toString();
|
|
|
488
|
+ }
|
|
|
489
|
+ //确认提示框
|
|
|
490
|
+ layer.confirm('您确定要删除绑定的该资源吗?', {
|
|
|
491
|
+ btn: ['确定', '取消'] //按钮
|
|
|
492
|
+ }, function () {
|
|
|
493
|
+ $.ajax({
|
|
|
494
|
+ url: common.domainName + '/api-web/alarmtemplate/deleteByResIdsAndTempIds?access_token=' + accessToken
|
|
|
495
|
+ , data: {
|
|
|
496
|
+ resIds: id,
|
|
|
497
|
+ tempIds: alarmTempId.toString()
|
|
|
498
|
+ }
|
|
|
499
|
+ }).done(function (res) {
|
|
|
500
|
+ layer.msg('删除成功', {
|
|
|
501
|
+ offset: '15px'
|
|
|
502
|
+ , icon: 1
|
|
|
503
|
+ , time: 2000
|
|
|
504
|
+ }, function () {
|
|
|
505
|
+ layer.closeAll();
|
|
|
506
|
+ reloadalarmtemplateTable()
|
|
|
507
|
+ });
|
|
|
508
|
+ }).error(function (error) {
|
|
|
509
|
+ console.log(error);
|
|
|
510
|
+ });
|
|
|
511
|
+ });
|
|
|
512
|
+ }
|
|
|
513
|
+
|
|
|
514
|
+
|
377
|
//刷新表格
|
515
|
//刷新表格
|
378
|
function reloadalarmtemplateTable() {
|
516
|
function reloadalarmtemplateTable() {
|
379
|
alarmtemplateTable.reload({
|
517
|
alarmtemplateTable.reload({
|
|
@@ -381,7 +519,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
|
@@ -381,7 +519,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions' |
381
|
access_token: accessToken,
|
519
|
access_token: accessToken,
|
382
|
policyId: policyId,
|
520
|
policyId: policyId,
|
383
|
resIdList: resIdList,
|
521
|
resIdList: resIdList,
|
384
|
- alarmTempName: $("#alarmtemplatekw").val()
|
522
|
+ keyWord: $("#alarmtemplatekw").val()
|
385
|
}
|
523
|
}
|
386
|
});
|
524
|
});
|
387
|
}
|
525
|
}
|