{% extends "base.html" %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}


{% block content %}
<div class="boxes">
    <div class="contentblock" id="state">
        <h2>{% trans "Virtual machines" %}</h2>
        <ul class="wm-list">
            {% include "box-vmlist.html" %}
            <li id="new-wm-button" class="wm new">
                <div class="summary">
                    <div class="name">{% trans "Start new machine" %}</div>
                    <div class="clear"></div>
                </div>
            </li>
            <li id="new-wm" style="display: none">
            <h2>{% trans "Available templates" %}</h2>
                <p>
                {% trans "Choose one of the following templates to launch." %}
                </p>
                <div class="container">
                    <ul class="wm-list modal">
                        {% for m in templates %}
                        <li class="wm">
                            <div class="summary">
                                <div class="quota">
                                    <div class="used" style="width: 40%"></div>
                                </div>
                                <div class="name wm-on">{{m.name}}</div>
                                <div class="status">
                                    3/10
                                </div>
                                <div class="clear"></div>
                            </div>
                            <div class="details">
                                <div class="details-container">
                                    <ul>
                                        <li class="os-{{m.os_type}}">{% trans "System" %}: <span class="value">{{m.system}}</span><div class="clear"></div></li>
                                        <li class="type">{% trans "Size" %}: <span class="value">{{m.instance_type.name}}</span></li>
                                        <li class="memory">{% trans "Memory" %}:
                                            <span class="value">{% blocktrans with m=m.instance_type.RAM %}{{m}} MiB{% endblocktrans %}</span></li>
                                        <li class="cpu">{% trans "CPU cores" %}: <span class="value">{{m.instance_type.CPU}}</span></li>
                                        <li class="description">{% trans "Description" %}:<span class="value">{{m.description}}</span><div class="clear"></div></li>
                                        <li>
                                            &nbsp;
                                            <span class="value">
                                                <form method="POST" action="/vm/new/{{m.pk}}/">{% csrf_token %}
                                                    <input type="submit" value="{% trans "Launch" %}"/>
                                                </form>
                                            </span>
                                            <div class="clear"></div>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </li>
            <li class="wm small">
                <div class="summary">
                    <div class="quota">
                        <div class="used" style="background-color: rgba(0,255,0,0.2); width: {{userdetails.get_instance_pc}}%"></div>
                    </div>
                    <div class="name">{% blocktrans with used=userdetails.get_weighted_instance_count all=userdetails.instance_quota %}Personal quota: {{used}}/{{all}}{% endblocktrans %}</div>
                    <div class="clear"></div>
                </div>
            </li>
        </ul>
    </div>
    {% for box in boxes %}
    {% if forloop.counter0|divisibleby:2 %}
        <div class="contentblock">
            <h2>{{ box.title }}</h2>
            <div class="content">
                {{ box.text|safe }}
            </div>
        </div>
    {% endif %}
    {% endfor %}
{% include "box-templatelist.html" %}
</div>
{% include "box-filelist.html" %}
{% include "box-grouplist.html" %}
{% endblock %}
