#1018 VLANs with Multiple Names report

This commit is contained in:
Oliver Gorwits
2023-11-25 10:16:28 +00:00
parent ba1966738b
commit 9ad34c425a
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>VLAN ID</th>
<th>VLAN Names</th>
<th>Device Count</th>
<th>Port Count</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(document).ready(function() {
var table = $('#data-table').dataTable({
"deferRender": true,
"data": [% results | none %],
"columns": [
{
"data": 'vlan',
"render": function(data, type, row, meta) {
return '<a href="[% uri_for('/search') | none %]?tab=vlan&q=' + encodeURIComponent(data) + '">' + data + '</a>';
}
}, {
"data": 'description',
"render": function(data, type, row, meta) {
let resp = '';
for (let i = 0; i < data.length; i++) {
resp += '<a href="[% uri_for('/search') | none %]?tab=vlan&q=' + encodeURIComponent(data[i]) + '">' + he.encode(data[i] || '') + '</a>';
if (i < (data.length - 1)) {
resp += ', ';
}
}
return resp;
}
}, {
"data": 'dcount',
"searchable": false,
"render": function(data, type, row, meta) {
return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}, {
"data": 'pcount',
"searchable": false,
"render": function(data, type, row, meta) {
return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
}
],
[% INCLUDE 'ajax/datatabledefaults.tt' -%]
});
});
</script>

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump([ 'VLAN ID' 'VLAN Names' 'Device Count' 'Port Count' ]) %]
[% FOREACH row IN results %]
[% mylist = [] %]
[% mylist.push(row.vlan) %]
[% mylist.push(row.description.join(',')) %]
[% mylist.push(row.dcount) %]
[% mylist.push(row.pcount) %]
[% CSV.dump(mylist) %]
[% END %]