Authored by wangtao
... ... @@ -60,7 +60,7 @@ layui.define(['form','table', 'admin', 'common','sessions'], function (exports)
//选择策略
$("#add_alarmtemplate_policy").on("click",function (){
$('[lay-id="/baseconfig/alarmpolicy/index"]').find('.layui-tab-close').trigger('click');
common.openWin("baseconfig/alarmpolicy/index","选择策略",{},["选择","取消"], function () {
common.openWin("baseconfig/alarmpolicy/index","选择策略",{type:'alarmTemplate'},["选择","取消"], function () {
var data = layui.alarmpolicyIndex().getData();
createAlarmtemplatePolicyTable(data);
return true;
... ... @@ -101,11 +101,6 @@ layui.define(['form','table', 'admin', 'common','sessions'], function (exports)
}
//删除
$(".delete-alarmtemplate-policy-btn").on("click",function (){
var tr = $("#alarmtemplate-policy-table-body").find('tr').length
if (tr <= 1){
layer.msg("告警模板至少绑定一条告警策略", { offset: '15px' , icon: 7 , time: 1000 });
return false;
}
$(this).parent().parent().remove();
});
}
... ...
... ... @@ -14,12 +14,14 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
exports('alarmtemplateIndex', function (data) {
var policyId = (data && data.policyId) ? data.policyId : "";
var resIdList = (data && data.resIds) ? data.resIds : '';
var resType = (data && common.isNotEmpty(data.resType)) ? data.resType : '';
var sessions = layui.sessions;
var accessToken = sessions.getToken()['access_token'];
//获得权限列表
var checkList = common.checkPermission(accessToken);
var alarmTempId = '';
// 业务类型Id
var busId = '';
//回车搜索
$('#alarmtemplatekw').keydown(function (e) {
if (e.keyCode === 13) {
... ... @@ -77,7 +79,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
}
if (tempData && tempData.length > 0) {
common.openWin("baseconfig/alarmpolicy/index", "选择策略", {oldData: oldAlarmPolicyIdList}, ["选择", "取消"], function () {
common.openWin("baseconfig/alarmpolicy/index", "选择策略", {oldData: oldAlarmPolicyIdList,type:'alarmTemplate'}, ["选择", "取消"], function () {
var policyData = layui.alarmpolicyIndex().getData();
var tempIds = [], policyIds = [];
$.each(tempData, function (i, v) {
... ... @@ -357,7 +359,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
//查看告警模板的资源数量
$(".view-alarmtemplate-res-total").on("click", function () {
var alarmTempId = $(this).data("id");
alarmTempId = $(this).data("id");
layer.open({
title: ['绑定资源', 'font-size:18px;'],
type: 1,
... ... @@ -366,13 +368,69 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
btn: ['确定','取消'],
content: laytpl($('#tempResource').html()).render(JSON.stringify({})),
success: function (index, layero) {
renderResByTemp(alarmTempId)
renderResByTemp(resType)
//新增资源权限
$('#addAuthResBtn').on('click', function () {
openResByTemp(alarmTempId,index)
})
// 查询条件框回车查询事件
$('#res-keyword').keydown(function (e) {
if (e.keyCode === 13) {
renderResByTemp(resType);
}
});
//查询按钮事件
$('#tempResBut').unbind().on('click',function () {
renderResByTemp(resType);
});
// 如果参数有busId
if(data && common.isNotEmpty(data.busId)){
busId = data.busId;
$("#templist_resListBizTypes").attr("disabled",true);
form.render()
}
//绑定业务下拉选择数据
common.bizTypeSelect("templist_resListBizTypes",function () {
$("#templist_resListBizTypes").val(busId);
form.render("select");
});
//绑定资源类型下拉选择
common.resTypeXmSelect({
el: '#templist_restype',
initValue: resType.split(','),
on(data) {
resType = data.arr.map(item => item.resTypeCode).join(',');
resType || (resType = 'all')
renderResByTemp(resType);
}
});
//绑定厂商下拉选择
common.providerSelect("templist_provider",function () {
form.render("select");
});
form.render();
bindSelectEvent();
//绑定下拉搜索事件
function bindSelectEvent() {
//选择业务搜索
form.on('select(templist_resListBizTypes)', function(data){
busId = data.value;
renderResByTemp(resType);
});
// 资源状态
form.on('select(templist_resStatus)', function(data){
renderResByTemp(resType);
});
// 厂商
form.on('select(templist_provider)', function(data){
renderResByTemp(resType);
});
}
//删除资源权限
$('#delAuthResBtn').on('click', function () {
deleteResTemp(alarmTempId)
... ... @@ -399,16 +457,16 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
});
//渲染用户所有资源权限列表表格
function renderResByTemp(alarmTempId) {
function renderResByTemp(resType) {
temResTable = table.render({
elem: '#res_temp_table',
url: domainName + '/api-web/home/res-list/all',
url: common.domainName + '/api-web/home/res-list/' + (resType ? resType : 'all'),
where: {
access_token: accessToken,
resName: '',
busId: '',
resHealth: '',
provider:'',
resName: $('#res-keyword').val(),
busId: $("#templist_resListBizTypes").val(),
resHealth: $("#templist_resStatus").val(),
provider:$("#templist_provider").val(),
collectorId: '',
trapCollectorId: '',
alarmTempId: alarmTempId,
... ... @@ -419,7 +477,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
editMode: 'true',
resCategory: 'resources'
},
height: 'full-200',
height: 615,
cellMinWidth: 80,
page: {
layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
... ... @@ -433,11 +491,11 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
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) {
, {field: 'ip', title: 'IP地址', align: 'center',sort:true,width:200}
, {field: 'port', title: '端口号', align: 'center',sort:true,width:200}
, {field: 'adminName', title: '负责人', align: 'center',sort:true,width:180}
, {field: 'resTypeName', title: '资源类型', align: 'center',sort:true,width:230}
, {field: 'state', title: '资源状态', align: 'center',sort:true,width:180, 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>'
... ... @@ -450,7 +508,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common', 'reslist', 'sessions'
}
}}
, {
title: '操作', fixed: 'right', align: 'center', fixed: 'right',
title: '操作', fixed: 'right', align: 'center', fixed: 'right',width:100,
templet: '<div><span data-id="{{d.resId}}" class="layui-table-link tem_res_delete_btn">删除</span></div>'
}
]],
... ...
... ... @@ -63,6 +63,56 @@
<div class="page-panel">
<div class="main">
<div class="layui-card">
<div class="layui-card-header">
<div class="layui-status">
<form class="layui-form layui-card-header layuiadmin-card-header-auto">
<div class="layui-form-item">
<div class="layui-inline">
<div class="layui-input-inline layui-input-inline--long">
<input type="text" id="res-keyword" placeholder="输入名称,回车搜索" autocomplete="off"
lay-tips="关键字检索包含: </br>资源名称</br>ip地址"
class="layui-input">
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline layui-input-inline--long">
<div id="templist_restype"></div>
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline">
<select name="reslist_resStatus" id="templist_resStatus" lay-filter="templist_resStatus" lay-verify="required">
<option value="">=资源状态=</option>
<option value="1"></option>
<option value="2"></option>
<option value="3"></option>
</select>
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline">
<select name="label" id="templist_resListBizTypes" lay-filter="templist_resListBizTypes" lay-search>
<option value="">=选择业务=</option>
</select>
</div>
</div>
<div class="layui-inline">
<div class="layui-input-inline">
<select name="provider" id="templist_provider" lay-filter="templist_provider" lay-search>
<option value="">=选择厂商=</option>
</select>
</div>
</div>
<div class="layui-inline">
<button id="tempResBut" type="button" class="layui-btn layui-btn-normal" ><i
class="layui-icon layui-icon-search"></i>查
</button>
</div>
</div>
</form>
</div>
</div>
<div class="layui-card-body">
<div class="warn-btns">
<button id="addAuthResBtn" type="button" class="layui-btn layui-btn-sm layui-btn-normal"><i
... ...
... ... @@ -163,7 +163,10 @@
<p class="biz-count">业务总数<span id="bizTotal">0</span></p>
</div>
<div class="layui-card-body">
<input type="text" placeholder="搜索..." autocomplete="off" class="layui-input layui-input-search">
<div>
<input type="search" placeholder="搜索..." id="bizInputSearch" autocomplete="off" class="layui-input layui-input-search" style="width: 180px">
<button class="layui-btn layui-btn-sm layui-btn-normal" id="bizSearch" style="width: 50px;height: 30px;margin-top: -6px;">搜索</button>
</div>
<div id="bizindextree"></div>
</div>
</div>
... ... @@ -340,4 +343,4 @@
layui.use('bizindex', function (fn) {
fn();
});
</script>
\ No newline at end of file
</script>
... ...
... ... @@ -274,7 +274,10 @@
<div class="layui-card">
<div class="layui-card-body">
<input type="text" placeholder="搜索..." autocomplete="off" class="layui-input layui-input-search">
<div>
<input type="search" placeholder="搜索..." autocomplete="off" id="inputSearch" class="layui-input layui-input-search" style="width: 180px">
<button class="layui-btn layui-btn-sm layui-btn-normal" id="resSearch" style="width: 50px;height: 30px;margin-top: -6px;">搜索</button>
</div>
<div id="resindextree"></div>
</div>
</div>
... ...
... ... @@ -36,6 +36,8 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
var bizParentList;
// 资源视图表格
var bizListTable;
var busHealthKeyWord = '';
var busIndexKeyWord = '';
//点击卡片
$('#bizindexTable').unbind('click').on('click', '[data-biz-card]', function () {
var resType = $(this).data("biz-card");
... ... @@ -58,9 +60,16 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
common.viewBizTopo($(this).data('busid'));
return false;
});
//搜索按钮
$('#bizSearch').unbind('click').on('click',function (){
busIndexKeyWord = $('#bizInputSearch').val();
loadBizTree(busIndexKeyWord)
})
//回车搜索
$('#bizindex_keyword').keydown(function (e) {
if (e.keyCode === 13) {
busIndexKeyWord = $(this).val();
// renderList(busId, curBizResType);
reloadTable();
return false;
... ... @@ -93,6 +102,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
// $('#bizindex_keyword').val(busIndexKeyWord)
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
... ... @@ -117,8 +127,9 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType',
}).done(function (res) {
url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType?keyword='+busHealthKeyWord,
sync: true
}).always(function (res) {
layer.close(loading);
laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
bizindexTable.html(html);
... ... @@ -171,6 +182,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
if (val == '' || val == null || val == undefined) {
val = '';
}
busHealthKeyWord = val;
admin.req({
url: common.domainName + '/api-web/home/business/getBusTree?keyword=' + val + '&notExist=machineroom',
sync: true,
... ... @@ -183,6 +195,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
showLine: false,
data: data,
click: function (node) {
// $('#bizindex_keyword').val(busIndexKeyWord)
if (node && node.data && node.data.children && node.data.children.length == 1) {
$('[data-id="' + node.data.children[0].id + '"]').find('.layui-tree-iconClick:first').click()
}
... ... @@ -262,6 +275,8 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$(".layui-input-search").keyup(function (e) {
if (e.keyCode === 13) {
loadBizTree($(this).val())
busIndexKeyWord = $(this).val();
busHealthKeyWord = $(this).val();
}
});
... ... @@ -371,7 +386,6 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$('#biztreeTableContent').hide();
//清除查询条件
$("#bizindex_keyword").val("");
$("#biz_resStatus").val("");
$("#biz_res_colony").val("");
$("#biz_res_cluster").val("");
... ... @@ -407,7 +421,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString()
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName:busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -466,11 +480,12 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$('#biztreeTableContent').hide();
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
// $('#bizindex_keyword').val(busIndexKeyWord)
var bizindexTable = $('#bizindexTable');
autoHeight(bizindexTable);
window.setResizeEvents('autoHeight', autoHeight);
admin.req({
url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId
url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId +"&keyWord="+busHealthKeyWord
, done: function (res) {
laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
bizindexTable.html(html);
... ... @@ -506,7 +521,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, drag: {toolbar: false}
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -566,7 +581,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
$('#bizDetailContent').empty();
$('#bizDetailContent').hide();
$('#biztreeTableContent').hide();
// $('#bizindex_keyword').val(busIndexKeyWord)
renderBizSerach(resType, busId);
form.render(null, 'biz-list-form');
... ... @@ -589,7 +604,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
, url: common.domainName + '/api-web/home/res-list/' + resType
, where: {
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -841,7 +856,6 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
//加载资源池、集群等查询条件
function renderBizSerach(resType, busId, subflag) {
//清空查询条件 joke add 20200409 开始
$('#bizindex_keyword').val('');
$('#biz_resStatus').val('');
$('#biz_res_colony').val('');
$('#biz_res_cluster').val('');
... ... @@ -993,7 +1007,7 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
}
,where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
access_token: accessToken,
resName: $("#bizindex_keyword").val(),
resName: busIndexKeyWord,
resHealth: $("#biz_resStatus").val(),
busId: busId,
colonlyId: $("#biz_res_colony").val(),
... ... @@ -1033,4 +1047,4 @@ layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols
}
});
});
\ No newline at end of file
});
... ...
... ... @@ -127,7 +127,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
$('#resDetailContent').empty();
$('#resDetailContent').hide();
$('#treeTableContent').hide();
$('#resindex_keyword').val(resindexKeyword)
// $('#resindex_keyword').val(resindexKeyword)
//如果是阿里云,则显示阿里云的列表
if(resType && resType == 'ALI_CLOUD_PLAT'){
$(".resindexlist").show();
... ... @@ -704,6 +704,12 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
resindexKeyword = $(this).val();
}
});
//搜索按钮
$('#resSearch').unbind('click').on('click',function (){
resindexKeyword = $('#inputSearch').val();
resHealthKeyWord = $('#inputSearch').val();
loadResTree(resindexKeyword)
})
loadResTree('');
//资源详细信息
function renderDetail(resId, resType) {
... ... @@ -1052,7 +1058,7 @@ layui.define(['common', 'tree', 'laypage', 'laytpl', 'admin', 'form', 'table', '
$('#resDetailContent').empty();
$('#resDetailContent').hide();
$('#treeTableContent').hide();
$('#resindex_keyword').val(resindexKeyword)
// $('#resindex_keyword').val(resindexKeyword)
//加载查询条件
renderSerach(resType);
... ...