Last active
October 15, 2019 08:31
-
-
Save XDavidT/77d9916f7b59e5c7aad8fa17b75e4626 to your computer and use it in GitHub Desktop.
tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getJSON('/api/logs/data2table',function(data){ | |
$(document).ready(function() { | |
$('#dataTableLogs thead tr').clone(true).appendTo( '#dataTableLogs thead' ); | |
$('#dataTableLogs thead tr:eq(1) th').each( function (i) { | |
var title = $(this).text(); | |
$(this).html( '<input type="text" placeholder="Search '+title+'" />' ); | |
$( 'input', this ).on( 'keyup change', function () { | |
if ( table.column(i).search() !== this.value ) { | |
table | |
.column(i) | |
.search( this.value ) | |
.draw(); | |
} | |
} ); | |
} ); | |
var table = $('#dataTableLogs').DataTable({ | |
orderCellsTop: true, | |
fixedHeader: true, | |
data:data, | |
columns: [ | |
{data: 'logid'}, | |
{data: 'insert_time'}, | |
{data: 'type'}, | |
{data: 'src'}, | |
{data: 'cat'}, | |
{data: 'hostname'}, | |
{data: 'ip_add'}, | |
{data: 'mac_add'}, | |
{data: 'username'}, | |
{data: 'os'} | |
] | |
}); | |
}); | |
}).done(function() { | |
$('.loading-section').hide(); //Hide Loading GIF when done to load the logs | |
}).fail(function() { | |
console.log( "error" ); | |
}) | |
//rules table// | |
$.getJSON('/api/policy/data2table',function(data){ | |
$(document).ready(function() { | |
var table = $('.RuleDataTable').DataTable({ | |
orderCellsTop: true, | |
fixedHeader: true, | |
data:data, | |
"pageLength": 5, | |
columns: [ | |
{data: '_id'}, | |
{data: 'name'}, | |
{data: 'field'}, | |
{data: 'value'} | |
] | |
}); | |
}); | |
}) | |
//event table/// | |
$.getJSON('/api/policy/eventData2table',function(data){ | |
$(document).ready(function() { | |
var table = $('.eventDataTable').DataTable({ | |
orderCellsTop: true, | |
fixedHeader: true, | |
data:data, | |
"pageLength": 5, | |
columns: [ | |
{data: '_id'}, | |
{data: 'name'}, | |
{data: 'Description'}, | |
{data: 'Type'}, | |
{data: 'full.rules.rule_id', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.rule_id; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
}, | |
{data: 'full.rules.repeated', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.repeated; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
}, | |
{data: 'full.rules.timeout', | |
render: function ( full, type, full, meta ) { | |
var result = ''; | |
$.each(full.rules, function( index, value ) { | |
result_temp = value.timeout; | |
if (index < full.rules.length) | |
result = result + result_temp + ', ' ; | |
}); | |
return result.split(", ").join("<br/>"); | |
}, | |
"className": "text-center" | |
} | |
] | |
}); | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment