1[% USE url %]
2[% IF opt %]
3  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
4    <thead>
5      <tr>
6        <th>MAC</th>
7        <th>Vendor</th>
8        <th>Device (IP)</th>
9        <th>Port</th>
10        <th>VLAN</th>
11      </tr>
12    </thead>
13  </table>
14[% ELSE %]
15  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
16    <thead>
17      <tr>
18      <th class="nd_center-cell">Vendor</th>
19      <th class="nd_center-cell">Count</th>
20      </tr>
21    </thead>
22  </table>
23[% END %]
24
25<script type="text/javascript">
26$(document).ready(function() {
27  var table = $('#data-table').dataTable({
28    [% IF opt %]
29    "serverSide": true,
30    "order": [[ 0, "desc" ]],
31    "ajax": "[% uri_for('/ajax/content/report/nodevendor/data') | none %]?[% url(params('query').hash) | none %]",
32    "columns": [
33      {
34        "data": 'mac',
35        "render": function(data, type, row, meta) {
36          var icon = '&nbsp;&nbsp;<i class="icon-book text-warning"></i> ';
37          if (row.active) {
38            icon = '';
39          }
40          return '<a href="[% search_node | none %]&q=' + encodeURIComponent(data) + '">' + he.encode(data.toUpperCase()) + icon + '</a>';
41        }
42      }, {
43        "data": 'oui.abbrev',
44        "render": function(data, type, row, meta) {
45          return '<a href="[% uri_for('/report/nodevendor') | none %]?vendor=' + encodeURIComponent(row.oui.abbrev || 'blank') + '">' + he.encode(row.oui.company ||'(Unknown Vendor)') + '</a>';
46        }
47      }, {
48        "data": 'switch',
49        "render": function(data, type, row, meta) {
50          return '<a href="[% uri_for('/device') | none %]?q=' + encodeURIComponent(data) + '">' + he.encode(row.device.dns || row.device.name || data) + ' (' + he.encode(data) + ')</a>';
51        }
52      }, {
53        "data": 'port',
54        "render": function(data, type, row, meta) {
55          return '<a href="[% device_ports | none %]&q=' + encodeURIComponent(row.switch) + '&f=' + encodeURIComponent(data) + '&c_nodes=on&n_ssid=on&prefer=port">' + he.encode(data) + '</a>';
56        }
57      }, {
58        "data": 'vlan',
59        "render": function(data, type, row, meta) {
60          return '<a href="[% device_ports | none %]&q=' + encodeURIComponent(row.switch) + '&f=' + encodeURIComponent(data) + '&c_nodes=on&n_ssid=on&prefer=vlan">' + he.encode(data) + '</a>';
61        }
62      }
63    ],
64    [% ELSE %]
65    "deferRender": true,
66    "data": [% results | none %],
67    "columns": [
68      {
69        "data": 'vendor',
70        "render": function(data, type, row, meta) {
71          return '<a href="[% uri_for('/report/nodevendor') | none %]?vendor=' + encodeURIComponent(row.abbrev || 'blank') + '">' + he.encode(row.vendor ||'(Unknown Vendor)') + '</a>';
72        }
73      }, {
74        "data": 'count',
75        "render": function(data, type, row, meta) {
76          return data.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
77        }
78      }
79    ],
80    "order": [[1, "desc"]],
81    [% END %]
82[% INCLUDE 'ajax/datatabledefaults.tt' -%]
83  });
84});
85</script>
86