1[% USE date(format = '%Y-%m-%d %H:%M') %] 2[% USE Number.Format %] 3<table id="nsbi-data-table" class="table table-bordered table-hover" width="100%" cellspacing="0"> 4 <thead> 5 <tr> 6 <th>MAC</th> 7 <th>Match</th> 8 <th class="nd_center-cell">Device or Node</th> 9 [% IF params.stamps %] 10 <th>First Seen</th> 11 <th>Last Seen</th> 12 [% END %] 13 </tr> 14 </thead> 15 <tbody> 16 [% WHILE (row = macs.next) %] 17 [% IF row.nbname %] 18 <tr> 19 <td>MAC: <a href="[% search_node | none %]&q=[% row.net_mac.$mac_format_call | uri %]"> 20 [% row.net_mac.$mac_format_call | html_entity %]</a> 21 [% IF params.show_vendor %] 22 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% row.oui.abbrev | uri %]"> 23 [% row.oui.company | html_entity %]</a> ) 24 [% END %] 25 </td> 26 <td>NetBIOS</td> 27 <td class="nd_linkcell nd_center-cell">\\<a href="[% uri_for('/report/netbios') | none %]?domain=[% row.domain | uri %]" title="Devices in this Domain">[% row.domain | html_entity %]</a>\<a href="[% search_node | none %]&q=[% row.nbname | uri %]">[% row.nbname | html_entity %]</a> 28 <br>[% row.nbuser || '[No User]' | html_entity %]@<a href="[% search_node | none %]&q=[% row.ip | uri %]">[% row.ip | html_entity %]</a> 29 </td> 30 [% IF params.stamps %] 31 <td>[% row.time_first_stamp | html_entity %]</td> 32 <td>[% row.time_last_stamp | html_entity %]</td> 33 [% END %] 34 </tr> 35 [% ELSE %] 36 <tr> 37 <td>MAC: <a href="[% search_node | none %]&q=[% row.net_mac.$mac_format_call | uri %]"> 38 [% row.net_mac.$mac_format_call | html_entity %]</a> 39 [% IF params.show_vendor %] 40 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% row.oui.abbrev | uri %]"> 41 [% row.oui.company | html_entity %]</a> ) 42 [% END %] 43 </td> 44 <td>IP → MAC</td> 45 <td class="nd_center-cell"> 46 <a href="[% search_node | none %]&q=[% row.ip | uri %]">[% row.ip | html_entity %]</a> 47 [% ' <i class="icon-book text-warning"></i> ' IF NOT row.active %] 48 [% ' (' _ row.dns.remove(settings.domain_suffix) _ ')' IF row.dns %] 49 </td> 50 [% IF params.stamps %] 51 <td>[% row.time_first_stamp | html_entity %]</td> 52 <td>[% row.time_last_stamp | html_entity %]</td> 53 [% END %] 54 </tr> 55 [% END %] 56 [% FOREACH nbt IN row.netbios %] 57 <tr> 58 <td>MAC: <a href="[% search_node | none %]&q=[% nbt.net_mac.$mac_format_call | uri %]"> 59 [% nbt.net_mac.$mac_format_call | html_entity %]</a> 60 [% IF params.show_vendor %] 61 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% nbt.oui.abbrev | uri %]"> 62 [% nbt.oui.company | html_entity %]</a> ) 63 [% END %] 64 </td> 65 <td>NetBIOS</td> 66 <td class="nd_linkcell nd_center-cell">\\<a href="[% uri_for('/report/netbios') | none %]?domain=[% nbt.domain | uri %]" title="Devices in this Domain">[% nbt.domain | html_entity %]</a>\<a href="[% search_node | none %]&q=[% nbt.nbname | uri %]">[% nbt.nbname | html_entity %]</a> 67 <br>[% nbt.nbuser || '[No User]' | html_entity %]@<a href="[% search_node | none %]&q=[% nbt.ip | uri %]">[% nbt.ip | html_entity %]</a> 68 </td> 69 [% IF params.stamps %] 70 <td>[% date.format(nbt.time_first) | html_entity %]</td> 71 <td>[% date.format(nbt.time_last) | html_entity %]</td> 72 [% END %] 73 </tr> 74 [% END %] 75 [% FOREACH ni IN row.nodeips %] 76 <tr> 77 <td>MAC: <a href="[% search_node | none %]&q=[% ni.net_mac.$mac_format_call | uri %]"> 78 [% ni.net_mac.$mac_format_call | html_entity %]</a> 79 [% IF params.show_vendor %] 80 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% ni.oui.abbrev | uri %]"> 81 [% ni.oui.company | html_entity %]</a> ) 82 [% END %] 83 </td> 84 <td>IP → MAC</td> 85 <td class="nd_center-cell"> 86 <a href="[% search_node | none %]&q=[% ni.ip | uri %]">[% ni.ip | html_entity %]</a> 87 [% ' <i class="icon-book text-warning"></i> ' IF NOT ni.active %] 88 [% ' (' _ ni.dns.remove(settings.domain_suffix) _ ')' IF ni.dns %] 89 </td> 90 [% IF params.stamps %] 91 <td>[% date.format(ni.time_first) | html_entity %]</td> 92 <td>[% date.format(ni.time_last) | html_entity %]</td> 93 [% END %] 94 </tr> 95 [% END %] 96 [% FOREACH node IN row.node_sightings(archive_filter) %] 97 <tr> 98 <td>MAC: <a href="[% search_node | none %]&q=[% node.net_mac.$mac_format_call | uri %]"> 99 [% node.net_mac.$mac_format_call | html_entity %]</a> 100 [% IF params.show_vendor %] 101 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% node.oui.abbrev | uri %]"> 102 [% node.oui.company | html_entity %]</a> ) 103 [% END %] 104 </td> 105 <td>Switch Port</td> 106 <td class="nd_center-cell"> 107 <a class="nd_linkcell" 108 href="[% device_ports | none %]&q=[% node.switch | uri %]&f=[% node.port | uri %]&c_nodes=on&c_neighbors=on&prefer=port"> 109 [% node.switch | html_entity %] - [% node.port | html_entity %] 110 [% ' <i class="icon-book text-warning"></i>' IF NOT node.active %]</a> 111 [% IF node.device.dns AND node.device_port AND node.device_port.name %] 112 ([% node.device.dns | html_entity %] - [% node.device_port.name | html_entity %]) 113 [% END %] 114 on vlan [% node.vlan | html_entity %] 115 </td> 116 [% IF params.stamps %] 117 <td>[% node.time_first_stamp | html_entity %]</td> 118 <td>[% node.time_last_stamp | html_entity %]</td> 119 [% END %] 120 </tr> 121 [% FOREACH wlan IN node.wireless %] 122 <tr> 123 <td>MAC: <a href="[% search_node | none %]&q=[% wlan.net_mac.$mac_format_call | uri %]"> 124 [% wlan.net_mac.$mac_format_call | html_entity %]</a> 125 [% IF params.show_vendor %] 126 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% wlan.oui.abbrev | uri %]"> 127 [% wlan.oui.company | html_entity %]</a> ) 128 [% END %] 129 </td> 130 <td>Wireless Info</td> 131 <td class="nd_center-cell">SSID: [% wlan.ssid | html_entity %]<br> 132 MaxRate: [% wlan.maxrate | html_entity %]Mbps TxRate: [% wlan.txrate | html_entity %]Mbps<br> 133 SigStr: [% wlan.sigstrength | html_entity %] SigQual: [% wlan.sigqual | html_entity %]<br> 134 Rx: [% wlan.rxpkt | format_number %] pkts, [% wlan.rxbyte | format_number %] bytes<br> 135 Tx: [% wlan.txpkt | format_number %] pkts, [% wlan.txbyte | format_number %] bytes<br> 136 </td> 137 [% IF params.stamps %] 138 <td> </td> 139 <td>[% date.format(wlan.time_last) | html_entity %]</td> 140 [% END %] 141 </tr> 142 [% END %] 143 [% END %] 144 [% FOREACH nodeip IN row.ip_aliases(archive_filter) %] 145 <tr> 146 <td>MAC: <a href="[% search_node | none %]&q=[% nodeip.net_mac.$mac_format_call | uri %]"> 147 [% nodeip.net_mac.$mac_format_call | html_entity %]</a> 148 [% IF params.show_vendor %] 149 ( <a href="[% uri_for('/report/nodevendor') | none %]?vendor=[% nodeip.oui.abbrev | uri %]"> 150 [% nodeip.oui.company | html_entity %]</a> ) 151 [% END %] 152 </td> 153 <td>MAC → IP</td> 154 <td class="nd_center-cell"> 155 <a href="[% search_node | none %]&q=[% nodeip.ip | uri %]">[% nodeip.ip | html_entity %]</a> 156 [% ' <i class="icon-book text-warning"></i> ' IF NOT nodeip.active %] 157 [% ' (' _ nodeip.dns.remove(settings.domain_suffix) _ ')' IF nodeip.dns %] 158 </td> 159 [% IF params.stamps %] 160 <td>[% nodeip.time_first_stamp | html_entity %]</td> 161 <td>[% nodeip.time_last_stamp | html_entity %]</td> 162 [% END %] 163 </tr> 164 [% END %] 165 [% END %] 166 </tbody> 167</table> 168 169<style> 170tr.group, 171tr.group:hover { 172 background-color: #ddd !important; 173} 174</style> 175 176<script> 177$(document).ready(function() { 178 var table = $('#nsbi-data-table').DataTable({ 179 "columnDefs": [ 180 { "visible": false, "targets": 0 } 181 ], 182 "order": [[ 0, 'asc' ]], 183 "drawCallback": function ( settings ) { 184 var api = this.api(); 185 var rows = api.rows( {page:'current'} ).nodes(); 186 var last=null; 187 188 api.column(0, {page:'current'} ).data().each( function ( group, i ) { 189 if ( last !== group ) { 190 $(rows).eq( i ).before( 191 [% IF params.stamps %] 192 '<tr class="group"><td colspan="4">'+group+'</td></tr>' 193 [% ELSE %] 194 '<tr class="group"><td colspan="2">'+group+'</td></tr>' 195 [% END %] 196 ); 197 198 last = group; 199 } 200 } ); 201 }, 202[% INCLUDE 'ajax/datatabledefaults.tt' -%] 203 } ); 204 205 // Order by the grouping 206 $('#nsbi-data-table tbody').on( 'click', 'tr.group', function () { 207 var currentOrder = table.order()[0]; 208 if ( currentOrder[0] === 0 && currentOrder[1] === 'asc' ) { 209 table.order( [ 0, 'desc' ] ).draw(); 210 } 211 else { 212 table.order( [ 0, 'asc' ] ).draw(); 213 } 214 } ); 215} ); 216</script> 217