{% load i18n parse_date launch_form %}

<div class="table_title">
  <h3>Images</h3>
  <div class="table_actions">
    <div class="images table_search">
      <form action="#">
        <input class="span3" type="text">
      </form>
    </div>
    <a class="inspect" href="#">{% trans "inspect" %}</a>
  </div>
</div>

<table id="images" class="zebra-striped sortable">
  <thead>
    <tr>
      <th></th>
      <th>{% trans "Name" %}</th>
      <th>{% trans "Type" %}</th>
      <th>{% trans "Status" %}</th>
      <th colspan="2">{% trans "Actions" %}</th>
    </tr>
  </thead>
  {% for image in images %}
  <tr class="{% cycle 'odd' 'even' %}">
      <td class="select">
        <input type="checkbox" name="image_{{ image.id }}" value="image_{{ image.id }}" id="image_select_{{ image.id }}" />
      </td>
      <td>{{ image.name }}</td>
      <td>{{ image.properties.image_type|default:"Image" }}</td>
      <td>{{ image.status|capfirst }}</td>
      <td>
        <a class="btn small primary" data-controls-modal="launch_image_{{ image.id }}" data-backdrop="static" href="{% url horizon:nova:images_and_snapshots:images:launch image.id %}">{% trans "Launch" %}</a>
      </td>
      <td id="name_{{ image.name}}" class="actions"> 
        {% if image.owner == request.user.tenant_id %}
        <a class="more-actions" href="#">More</a>
        <ul>
          <li><a class='btn small' href="{% url horizon:nova:images_and_snapshots:images:update image.id %}">{% trans "Edit" %}</a></li>
          <li class="form">{% include "nova/images_and_snapshots/images/_delete.html" with form=delete_form %}</li>
        </ul>
        {% endif %}
      </td>
  </tr>
  {% endfor %}
</table>

{% for image in images %}
  {% launch_form request request.user.tenant_id image.id as launch_form %}
  {% include 'nova/images_and_snapshots/images/_launch.html' with form=launch_form image_id=image.id hide=True %}
{% endfor %}
