DataTables for device addresses tab

This commit is contained in:
Eric A. Miller
2014-06-04 23:14:21 -04:00
parent 87e1875da0
commit 9fa54f3fae
3 changed files with 46 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
<table id="da-data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
<thead>
<tr>
<th>Address</th>
@@ -8,18 +8,42 @@
<th>Prefix</th>
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td>[% row.alias | html_entity %]</a>
<td>[% row.dns | html_entity %]</a>
<td class="nd_center-cell"><a class="nd_linkcell"
href="[% device_ports %]&q=[% params.q | uri %]&f=[% row.port | uri %]">[% row.port | html_entity %]</a></td>
<td>[% row.device_port.name | html_entity %]</td>
<td><a class="nd_linkcell"
href="[% search_device %]&q=[% row.subnet | uri %]&ip=[% row.subnet | uri %]">[% row.subnet | html_entity %]</a></td>
</tr>
[% END %]
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
var table = $('#da-data-table').dataTable({
"deferRender": true,
"pageLength": 25,
"data": [% results %],
"columns": [
{
"data": 'alias',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'dns',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'port',
"render": function(data, type, row, meta) {
return '<a href="[% device_ports %]&q=' + encodeURIComponent(row.ip) + '&f=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}, {
"data": 'name',
"render": function(data, type, row, meta) {
return he.encode(data || '');
}
}, {
"data": 'subnet',
"render": function(data, type, row, meta) {
return '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '&ip=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
}
}
]
});
});
</script>

View File

@@ -1,7 +1,7 @@
[% USE CSV -%]
[% CSV.dump([ 'Address' 'DNS' 'Interface' 'Description' 'Prefix' ]) %]
[% WHILE (row = results.next) %]
[% FOREACH row IN results %]
[% mylist = [] %]
[% FOREACH col IN [ row.alias row.dns row.port row.device_port.name row.subnet ] %]
[% mylist.push(col) %]