<%
content_for :title do 'File List' end
%>
<h1>Listing files</h1>

<h2>Showing <%= @total %> files</h2>

<table class="records">
  <tr>
    <th>Name</th>
    <th>Type</th>
    <th>OUI</th>
    <th>Product class</th>
    <th>Version</th>
    <th></th>
  </tr>

<% @files.each do |file| %>
  <tr>
    <td><%= file['filename'] %></td>
    <td><%= file['metadata']['fileType'] rescue '' %></td>
    <td><%= file['metadata']['oui'] rescue '' %></td>
    <td><%= file['metadata']['productClass'] rescue '' %></td>
    <td><%= file['metadata']['version'] rescue '' %></td>
    <td class="action"><%= link_to 'Destroy', {controller: 'files', action: 'destroy', id: file['filename']}, method: :delete, data: { confirm: 'Are you sure?' } if can?(:delete, 'files') %></td>
  </tr>
<% end %>
</table>

<%= render partial: 'pagination' %>

<br />

<%= link_to 'New File', {:action => :new} if can?(:create, 'files') %>
