DataTables for port SSID and SSID inventory reports
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| [% USE Number.Format %] | ||||
| [% IF opt %] | ||||
|   <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>Device (Port)</th> | ||||
| @@ -10,24 +10,9 @@ | ||||
|         <th>Vendor</th> | ||||
|       </tr> | ||||
|     </thead> | ||||
|     </tbody> | ||||
|       [% WHILE (row = results.next) %] | ||||
|       <tr> | ||||
|         <td> | ||||
|           <a class="nd_linkcell" | ||||
|             href="[% device_ports %]&q=[% row.port.ip | uri %]&f=[% row.port.port | uri %]&c_nodes=on&n_ssid=on"> | ||||
|               [% row.device.dns || row.device.name || row.device.ip | html_entity %] ( [% row.port.port | html_entity %] )</a> | ||||
|         </td> | ||||
|         <td>[% row.broadcast ? 'Yes' : 'No' %]</td> | ||||
|         <td>[% row.device.model | html_entity %]</td> | ||||
|         <td>[% row.ssid | html_entity %]</td> | ||||
|         <td>[% row.device.vendor | html_entity %]</td> | ||||
|       </tr> | ||||
|       [% END %] | ||||
|     </tbody> | ||||
|   </table> | ||||
| [% ELSE %] | ||||
|   <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 class="nd_center-cell">SSID</th> | ||||
| @@ -35,18 +20,67 @@ | ||||
|       <th class="nd_center-cell">Count</th> | ||||
|       </tr> | ||||
|     </thead> | ||||
|     </tbody>   | ||||
|     [% WHILE (row = results.next) %] | ||||
|       <tr> | ||||
|         <td> | ||||
|           <a class="nd_linkcell" | ||||
|              href="[% uri_for('/report/portssid') %]?ssid=[% row.ssid | uri %]"> | ||||
|             [% row.ssid | html_entity %]</a> | ||||
|         </td> | ||||
|         <td class="nd_center-cell">[% row.broadcast ? 'Yes' : 'No' %]</td> | ||||
|         <td class="nd_center-cell">[% row.count | format_number %]</td> | ||||
|       </tr> | ||||
|     [% END %] | ||||
|     </tbody> | ||||
|   </table> | ||||
| [% END %] | ||||
|  | ||||
| <script type="text/javascript"> | ||||
| $(document).ready(function() { | ||||
|   var table = $('#data-table').dataTable({ | ||||
|     "deferRender": true, | ||||
|     "data": [% results %], | ||||
|     [% IF opt %] | ||||
|     "columns": [ | ||||
|       { | ||||
|       "data": 'ip', | ||||
|       "render": function(data, type, row, meta) { | ||||
|         return '<a href="[% device_ports %]&q=' + encodeURIComponent(data) + '&f=' + encodeURIComponent(row.port.port) + '&c_nodes=on&n_ssid=on">' + he.encode(row.device.dns || row.device.name || row.ip) + '(' + he.encode(row.port.port) + ')</a>'; | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'broadcast', | ||||
|         "render": function(data, type, full, meta) { | ||||
|           return (data ? 'Yes' : 'No'); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'device.model', | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || ''); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'ssid', | ||||
|         "searchable": false, | ||||
|         "orderable": false, | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || ''); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'device.vendor', | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || ''); | ||||
|         } | ||||
|       } | ||||
|     ] | ||||
|     [% ELSE %] | ||||
|     "columns": [ | ||||
|       { | ||||
|         "data": 'ssid', | ||||
|         "render": function(data, type, full, meta) { | ||||
|           return '<a href="[% uri_for('/report/portssid') %]?ssid=' + encodeURIComponent(data) + '">' + he.encode(data) + '</a>'; | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'broadcast', | ||||
|         "render": function(data, type, full, meta) { | ||||
|           return (data ? 'Yes' : 'No'); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'count', | ||||
|         "searchable": false, | ||||
|         "render": function(data, type, full, meta) { | ||||
|           return data.replace(/\B(?=(\d{3})+(?!\d))/g, ","); | ||||
|         } | ||||
|       }, | ||||
|     ], | ||||
|     "order": [[ 2, "desc" ]], | ||||
|   [% END %]   | ||||
|   }); | ||||
| }); | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user