{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% if instances %}
{% for i in instances %}
<li class="wm {% if id == i.id %}opened{% endif %}">
<div class="summary {% if id == i.id %}selected-summary{% endif %} {% if i.template.state == "NEW" %}unfinished{% endif %}">
        <!--<div class="id"></div>-->
        <div class="name {% if i.state == 'ACTIVE' %}wm-on{% else %}wm-off{% endif %}">
            {{i.name|truncatechars:20}}
        </div>
        <div class="status">
            {{i.state}}
        </div>
        <div class="actions">
            {% if i.state == 'ACTIVE' %}
            <a href="{{i.get_connect_uri}}" title="{% trans "Connect" %}">
                <img src="/static/icons/plug.png" alt="{% trans "Connect" %}" />
            </a>
            <a href="#"  class="stop-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Pause" %}">
                <img src="/static/icons/control-pause.png" alt="{% trans "Pause" %}" />
            </span>
            <a href="#"  class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
                <img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
            </a>
            <a href="#"  class="restart-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Restart" %}">
                <img src="/static/icons/arrow-circle-double.png" alt="↺" />
            </a>
            {% endif %}
            {% if i.state == 'PENDING' %}
            <img src="/static/load.gif" /> {% trans "starting…" %}
            {% endif %}
            {% if i.state == 'STOPPED' %}
            <a href="#"  class="resume-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Resume" %}">
                <img src="/static/icons/control.png" alt="{% trans "Resume" %}" />
            </span>
            <a href="#"  class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
                <img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
            </a>
            {% endif %}
            {% if i.state == 'FAILED' %}
            <a href="#"  class="delete-vm-button" data-name="{{ i.name}}" data-id="{{ i.id }}" title="{% trans "Delete" %}">
                <img src="/static/icons/minus-circle.png" alt="{% trans "Delete" %}" />
            </a>
            {% endif %}
        </div>
        <div class="clear"></div>
    </div>
    <div class="details" {% if id == i.id %}style="display: block;"{% endif %}>
        <div class="details-container">
            <ul>
                <li class="name">{% trans "Hostname" %}: <span class="value">{{i.name}}</span><div class="clear"></div></li>
                <li class="os-{{i.template.os_type}}">{% trans "System" %}: <span class="value">{{i.template.system}}</span><div class="clear"></div></li>
                <li class="template">{% trans "Template" %}: <span class="value">{{i.template.name}}</span><div class="clear"></div></li>
                <li class="type">{% trans "Size" %}: <span class="value">{{i.template.instance_type.name}}:
                    <span class="cpu">{{i.template.instance_type.CPU}}</span>
                    <span class="memory">{{i.template.instance_type.RAM}}</span>
                    <span class="credit">{{i.template.instance_type.credit}}</span>
                </span></li>
                <li class="date">{% trans "Created at" %}: <span class="value">{{i.created_at}}</span></li>
                {% if i.time_of_suspend %}
                <li class="date">{% trans "time of suspend"|capfirst %}: <span class="value"><abbr title="{{i.time_of_suspend}}">{{i.time_of_suspend|timeuntil}}</abbr></span></li>
                {% endif %}
                {% if i.time_of_delete %}
                <li class="date">{% trans "time of delete"|capfirst %}: <span class="value"><abbr title="{{i.time_of_delete}}">{{i.time_of_delete|timeuntil}}</abbr></span></li>
                {% endif %}
                <li>&nbsp;<span class="value"><a href="/vm/show/{{i.id}}/" title="{{i.name}}">{% trans "More details" %}</a></span></li>
            </ul>
        </div>
    </div>
</li>
{% endfor %}
{% else %}
<div id="new-wm-tooltip">
    <div id="new-wm-tooltip-container">
        <p>
            {% trans "You have not started any machines yet." %}
        </p>
        <p>
            {% trans "Choose a template, and you can use the system in a minute." %}
        </p>
        <div id="new-wm-tooltip-tail"></div>
    </div>
</div>
{% endif %}