<h1>Manage keys</h1>

<% if @key %>
  <div id='key-info' class="alert alert-info">
  <p>
  New key "<em><%= @key.description %></em>" created:
  </p>
  <pre id='key'><%= @key.key %></pre>
  <p>
  Please copy it now and store it in a safe location.
  <em>It will not be displayed again</em>
  </p>
  </div>
<% end %>

<table class='table table-striped'>
  <tr>
    <td>Description</td>
    <td>Creation date</td>
    <td>Actions</td>
  </tr>
  <% @keys.each do |key| %>
    <tr>
      <td><% if key.description %><%= key.description %> <% else %><em>(none)</em><% end %></td>
      <td><%= key.created_at%></td>
      <td>
        <form method="POST">
          <input name="_method" type="hidden" value="delete" />
          <input name="id" type="hidden" value="<%= key.id %>"/>
          <input class="btn btn-default" type='submit' value='Delete'/>
        </form>
      </td>
    </tr>
  <% end %>
</table>

<h2>Create new API key</h2>

<form method="POST" class="form-inline">
  <input class="form-control" type="text" name="description" placeholder="Key description"/>
  <input class="btn btn-primary" type='submit' value='Create key'/>
</form>
