{% load i18n %}
{% load parse_date %}

<div class="table_title">
  <h3>{% trans "Block Volumes" %}</h3>
  <div class="table_actions">
    <a id="volume_create_link" class="btn primary small" data-controls-modal="create_volume_modal" data-backdrop="static" href="{% url horizon:nova:instances_and_volumes:volumes:create %}">{% trans "Create New Volume" %}</a>
    <div class="instances table_search">
      <form action="#">
        <input class="span3" type="text">
      </form>
    </div>
    <a class="inspect" href="#">{% trans "inspect" %}</a>
  </div>
</div>

<table id="volumes" class="zebra-striped sortable">
  <thead>
    <tr>
      <th></th>
      <th>{% trans "Name" %}</th>
      <th>{% trans "Size" %}</th>
      <th>{% trans "Instance" %}</th>
      <th>{% trans "Actions" %}</th>
    </tr>
  </thead>
  <tbody>
    {% for volume in volumes %}
    <tr class="{% cycle 'odd' 'even' %}">
      <td></t<td class="select">
        <input type="checkbox" name="volume_{{volume.id}}" value="volume_{{volume.id}}" id="volume_select_{{volume.id}}" />
      </td>
      <td>{{ volume.displayName }}</td>
      <td>{{ volume.size }} {% trans "GB" %}</td>
      <td>      
        {% for attachment in volume.attachments %}
          {% if attachment %}
            <a href="{% url horizon:nova:instances_and_volumes:instances:detail attachment.serverId %}">
            {# TODO(jake): Make this the instance name #}
            Instance {{ attachment.serverId }}
            <small>({{ attachment.device }})</small>
          </a>
          {% else %}
            {% trans "Not Attached" %}
          {% endif %}
        {% endfor %}
      </td>

      <td id="name_{{instance.name}}" class="actions">
        {% if  volume.status == "in-use" or volume.status == "available" %}
          <a class="more-actions" href="#">More</a>
          <ul>
            {% if volume.status == "in-use" %}
              {% for attachment in volume.attachments %}
                <li class="form">{% include "nova/instances_and_volumes/volumes/_detach.html" with form=detach_form %}</li>
              {% endfor %}
            {% endif %}
            {% if volume.status == "available" %}
              <li><a class="btn small" href="{% url horizon:nova:instances_and_volumes:volumes:attach volume.id %}">{% trans "Attach" %}</a></li>
              <li class="form">{% include "nova/instances_and_volumes/volumes/_delete.html" with form=delete_form %}</li>
            {% endif %}
          </ul>
        {% else %}
          None
        {% endif %}
      </td>
    </tr>
    {% endfor %}
  </tbody>
</table>
