mirror of
https://github.com/yogeshojha/rengine.git
synced 2026-10-01 22:24:53 +02:00
Vulnerability grouping added 🚀
This commit is contained in:
@@ -30,6 +30,8 @@ All Vulnerabilities
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
const ps2 = new PerfectScrollbar(document.querySelector('.vulnerability-search'));
|
||||
var is_grouping = false;
|
||||
var grouping_col = 3;
|
||||
var vulnerability_table = $('#vulnerability_results').DataTable({
|
||||
"destroy": true,
|
||||
"oLanguage": {
|
||||
@@ -230,12 +232,53 @@ $(document).ready(function() {
|
||||
"targets": 16,
|
||||
},
|
||||
],
|
||||
drawCallback: function (settings) {
|
||||
drawCallback_api = this.api();
|
||||
"initComplete": function(settings, json) {
|
||||
api = this.api();
|
||||
// row grouping
|
||||
// vulnerability_datatable_grouping(vulnerability_table, drawCallback_api, vuln_datatable_columns);
|
||||
var radioGroup = document.getElementsByName('grouping_vuln_row');
|
||||
radioGroup.forEach(function(radioButton) {
|
||||
radioButton.addEventListener('change', function() {
|
||||
if (this.checked) {
|
||||
var groupRows = document.querySelectorAll('tr.group');
|
||||
// Remove each group row
|
||||
groupRows.forEach(function(row) {
|
||||
row.parentNode.removeChild(row);
|
||||
});
|
||||
var col_index = get_datatable_col_index(vuln_datatable_columns, this.value);
|
||||
api.page.len(-1).draw();
|
||||
api.order([col_index, 'asc']).draw();
|
||||
is_grouping = true;
|
||||
grouping_col = col_index;
|
||||
}
|
||||
});
|
||||
});
|
||||
// column visibility
|
||||
vulnerability_datatable_col_visibility(vulnerability_table);
|
||||
// row grouping
|
||||
vulnerability_datatable_grouping(vulnerability_table, drawCallback_api, vuln_datatable_columns);
|
||||
},
|
||||
drawCallback: function (settings) {
|
||||
drawCallback_api = this.api();
|
||||
var last = null;
|
||||
var rows = drawCallback_api.rows({ page: 'current' }).nodes();
|
||||
|
||||
if (is_grouping) {
|
||||
drawCallback_api.column(grouping_col)
|
||||
.data()
|
||||
.each(function (group, i) {
|
||||
console.log(group);
|
||||
if (last !== group) {
|
||||
$(rows)
|
||||
.eq(i)
|
||||
.before(
|
||||
'<tr class="group"><td colspan="7"><b class="text-primary">' +
|
||||
group +
|
||||
'</b></td></tr>'
|
||||
);
|
||||
last = group;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
createdRow: function( row, data, dataIndex ) {
|
||||
if (!data['open_status']){
|
||||
|
||||
@@ -54,39 +54,3 @@ function vulnerability_datatable_col_visibility(table){
|
||||
table.column(get_datatable_col_index('status')).visible(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function vulnerability_datatable_grouping(table, api, cols){
|
||||
var rows = api.rows({ page: 'current' }).nodes();
|
||||
var last = null;
|
||||
|
||||
var radioGroup = document.getElementsByName('grouping_vuln_row');
|
||||
|
||||
radioGroup.forEach(function(radioButton) {
|
||||
radioButton.addEventListener('change', function() {
|
||||
if (this.checked) {
|
||||
var groupRows = document.querySelectorAll('tr.group');
|
||||
// Remove each group row
|
||||
groupRows.forEach(function(row) {
|
||||
row.parentNode.removeChild(row);
|
||||
});
|
||||
var col_index = get_datatable_col_index(cols, this.value);
|
||||
// table.order([[col_index, 'asc']]).draw();
|
||||
api.column(col_index, { page: 'current' })
|
||||
.data()
|
||||
.each(function (group, i) {
|
||||
if (last !== group) {
|
||||
$(rows)
|
||||
.eq(i)
|
||||
.before(
|
||||
'<tr class="group"><td colspan="7">' +
|
||||
group +
|
||||
'</td></tr>'
|
||||
);
|
||||
last = group;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user