The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[% USE url %]
[% IF opt %]
  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th>Device</th>
        <th>Description</th>
        <th>Name</th>
        <th>Class</th>
        <th>Type</th>
        <th>Model</th>
        <th>Serial</th>
        <th>HW Version</th>
        <th>SW Version</th>
        <th>FW Version</th>
      </tr>
    </thead>
  </table>
[% ELSE %]
  <table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
    <thead>
      <tr>
        <th>Class</th>
        <th>Count</th>
      </tr>
    </thead>
  </table>
[% END %]

<script type="text/javascript">
$(document).ready(function() {
  var table = $('#data-table').dataTable({
    "processing": true,
    "stateSave": true,
    "pageLength": [% settings.table_pagesize %],
    "language": {
      "search": 'Filter records: '
    },
    [% IF opt %] 
    "serverSide": true,
    "searching": false,
    "order": [[ 0, "desc" ]],
    "ajax": "[% uri_for('/ajax/content/report/moduleinventory/data') %]?[% url(params('query').hash) %]",
    "columns": [
      {
      "data": 'ip',
      "render": function(data, type, row, meta) {
        return '<a href="[% uri_for('/device') %]?tab=modules&q=' + encodeURIComponent(data) + '">' + he.encode(row.device.dns || row.device.name || row.ip) + '</a>';
        }
      }, {
        "data": 'description',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?description=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
        }
      }, {
        "data": 'name',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?name=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
        }
      }, {
        "data": 'class',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitalizeFirstLetter(data + '')) + '</a>';
        }
      }, {
        "data": 'type',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?type=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
        }
      }, {
        "data": 'model',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?model=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
        }
      }, {
        "data": 'serial',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?serial=' + encodeURIComponent(data) + '">' + he.encode(data || '') + '</a>';
        }
      }, {
        "data": 'hw_ver',
        "render": function(data, type, row, meta) {
          return he.encode(data || '');
        }
      }, {
        "data": 'sw_ver',
        "render": function(data, type, row, meta) {
          return he.encode(data || '');
        }
      }, {
        "data": 'fw_ver',
        "render": function(data, type, row, meta) {
          return he.encode(data || '');
        }
      }
    ]
    [% ELSE %]
    "deferRender": true,
    "data": [% results %],
    "columns": [
      {
        "data": 'class',
        "render": function(data, type, row, meta) {
          return '<a href="[% uri_for('/report/moduleinventory') %]?class=' + encodeURIComponent(data) + '">' + he.encode(capitalizeFirstLetter(data + '')) + '</a>';
        }
      }, {
        "data": 'count',
        "render": function(data, type, row, meta) {
          return data.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
        }
      }
    ]
      [% END %]
  });
});
</script>