{% load sizeformat %}
{% load i18n %}

<div class="table_title">
  <h3>{% trans "My Instances" %}</h3>
  <div class="table_actions">
    <a class="btn small primary" href='{% url horizon:nova:images_and_snapshots:images:index %}'>{% trans "Launch Instance" %}</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='instances' class="zebra-striped sortable">
  <thead>
    <tr>
      <th></th>
      <th>{% trans "Name" %}</th>
      <th>{% trans "Size" %}</th>
      <th>{% trans "State" %}</th>
      <th>{% trans "Actions" %}</th>
    </tr>
  </thead>
  <tbody>
    {% for instance in instances %}
      <tr class="{% cycle 'odd' 'even' %}">
        <td class="select">
          <input type="checkbox" name="instance_{{ instance.id }}" value="instance_{{ instance.id }}" id="instance_select_{{ instance.id }}" />
        </td>
        <td class="name">
          <a href="{% url horizon:nova:instances_and_volumes:instances:detail instance.id %}">{{ instance.name }}</a>
        </td>
        <td>
          {{ instance.full_flavor.ram|mbformat }} Ram | {{ instance.full_flavor.vcpus }} VCPU | {{ instance.full_flavor.disk }}GB Disk
        </td>
        <td>{{ instance.status|lower|capfirst }}</td>
        <td id="name_{{ instance.name }}" class="actions">
          <a class="more-actions" href="#">More</a>
          <ul>
            {% if instance.status == "ACTIVE" %}
              <li><a class="btn small" target='_blank' href='{% url horizon:nova:instances_and_volumes:instances:vnc instance.id %}'>{% trans 'VNC Console' %}</a></li>
              <li><a class='btn small' target='_blank' href='{% url horizon:nova:instances_and_volumes:instances:console instance.id %}'>{% trans 'Log' %}</a></li>
              <li><a class='btn small' href='{% url horizon:nova:images_and_snapshots:snapshots:create instance.id %}'>{% trans 'Snapshot' %}</a></li>
              <li>{% include 'nova/instances_and_volumes/instances/_reboot.html' with form=reboot_form %}</li>
            {% endif %}
            <li><a class='btn small' href='{% url horizon:nova:instances_and_volumes:instances:update instance.id %}'>{% trans 'Edit' %}</a></li>
            <li>{% include 'nova/instances_and_volumes/instances/_terminate.html' with form=terminate_form %}</li>
          </ul>
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>
