DataTables for port search results tab
Use device_port_vlan table to search for VLANs rather than the device_port table
This commit is contained in:
@@ -1,23 +1,45 @@
|
||||
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Description</th>
|
||||
<th>Port</th>
|
||||
<th>Name</th>
|
||||
<th>Port</th>
|
||||
<th>Description</th>
|
||||
<th>Vlan</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td>[% row.name | html_entity %]</td>
|
||||
<td><a href="[% device_ports %]&q=[% row.ip | uri %]&f=[% row.port | uri %]">
|
||||
[% row.ip | html_entity %] [ [% row.port | html_entity %] ]</a>
|
||||
[% ' (' _ row.device.dns _ ')' IF row.device.dns %]
|
||||
</td>
|
||||
<td>[% row.descr | html_entity %]</td>
|
||||
<td>[% row.vlan | html_entity %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var table = $('#data-table').dataTable({
|
||||
"deferRender": true,
|
||||
"data": [% results %],
|
||||
"columns": [{
|
||||
"data": 'name',
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'ip',
|
||||
"render": function(data, type, row, meta) {
|
||||
var ddns = '';
|
||||
if (row.device.dns || row.device.name) {
|
||||
ddns = ' (' + he.encode(row.device.dns || row.device.name) + ')';
|
||||
}
|
||||
return '<a href="[% device_ports %]&q=' + encodeURIComponent(data) + '&f=' + encodeURIComponent(row.port) + '">' + he.encode(data) + '[' + he.encode(row.port) + ']</a>' + ddns;
|
||||
}
|
||||
}, {
|
||||
"data": 'descr',
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'port_vlans.vlan',
|
||||
"render": function(data, type, row, meta) {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
});</script>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[% USE CSV -%]
|
||||
[% CSV.dump([ 'Description' 'Port' 'Name' 'Vlan' ]) %]
|
||||
|
||||
[% WHILE (row = results.next) %]
|
||||
[% FOREACH row IN results %]
|
||||
[% mylist = [] %]
|
||||
[% myport = "$row.ip [ $row.port ] (" _ row.device.dns _ ")" IF row.device.dns %]
|
||||
[% FOREACH col IN [ row.name myport row.descr row.vlan ] %]
|
||||
|
||||
Reference in New Issue
Block a user