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