{% load i18n %}
<div class="panel panel-default">
  <div class="panel-heading">
    <div class="pull-right toolbar">
      <div class="btn-group">
        <a href="#index-graph-view" data-index-box="vm" class="btn btn-default btn-xs"
          data-container="body"
          title="{% trans "summary view" %}"><i class="fa fa-dashboard"></i></a>
        <a href="#index-list-view" data-index-box="vm" class="btn btn-default btn-xs disabled"
          data-container="body"
          title="{% trans "list view" %}"><i class="fa fa-list"></i></a>
      </div>
      <span class="btn btn-default btn-xs infobtn" data-container="body" title="{% trans "List of your current virtual machines. Favourited ones are ahead of others." %}"><i class="fa fa-info-circle"></i></span>
    </div>
    <h3 class="no-margin">
      <span class="visible-xs">
        <i class="fa fa-desktop"></i>
        {% trans "VMs" %}
      </span>
      <span class="hidden-xs">
        <i class="fa fa-desktop"></i>
        {% trans "Virtual machines" %}
      </span>
    </h3>
  </div>
  <div class="list-group" id="vm-list-view">
    <div id="dashboard-vm-list">
      {% for i in instances %}
      <a href="{{ i.get_absolute_url }}" class="list-group-item
        {% if forloop.last and instances|length < 5 %} list-group-item-last{% endif %}">
        <span class="index-vm-list-name">
          <i class="fa {{ i.get_status_icon }}" title="{{ i.get_status_display }}"></i>
          {{ i.name }}
        </span>
        <small class="text-muted index-vm-list-host">
          {{ i.short_hostname }}
        </small>
        <div class="pull-right dashboard-vm-favourite" data-vm="{{ i.pk }}">
          {% if i.fav %}
            <i class="fa fa-star text-primary title-favourite" title="{% trans "Unfavourite" %}"></i>
          {% else %}
            <i class="fa fa-star-o text-primary title-favourite" title="{% trans "Mark as favorite" %}"></i>
          {% endif %}
        </div>
      <div style="clear: both;"></div>
      </a>
      {% empty %}
        <div class="list-group-item list-group-item-last">
          {% trans "You have no virtual machines." %}
        </div>
      <div id="empty-vm-help">
        {% trans "Use the <strong>new</strong> button to start a new VM" %}<br />
        <i class="fa fa-arrow-down"></i>
      </div>
      {% endfor %}
    </div>
    <div class="list-group-item list-group-footer">
      <div class="row">
        <div class="col-xs-6">
        <form action="{% url "dashboard.views.vm-list" %}" method="GET" id="dashboard-vm-search-form">
          <div class="input-group input-group-sm">
            <input id="dashboard-vm-search-input" type="text" class="form-control" name="s" 
            placeholder="{% trans "Search..." %}" />
            <div class="input-group-btn">
              <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
            </div>
          </div>
        </form>
        </div>
        <div class="col-xs-6 text-right">
          <a class="btn btn-primary btn-xs" href="{% url "dashboard.views.vm-list" %}">
            <i class="fa fa-chevron-circle-right"></i>
            {% if more_instances > 0 %}
            {% blocktrans count counter=more_instances %}
              <strong>{{ counter }}</strong>  more
              {% plural %}
              <strong>{{ counter }}</strong>  more
            {% endblocktrans %}
            {% else %}
              {% trans "list" %}
            {% endif %}
          </a>
          <a class="btn btn-success btn-xs vm-create" href="{% url "dashboard.views.vm-create" %}"><i class="fa fa-plus-circle"></i> {% trans "new" %}</a>
        </div>
      </div>
    </div>
  </div>
  <div class="panel-body" id="vm-graph-view" style="display: none">
    <p class="pull-right">
    <input class="knob" data-fgColor="chartreuse" data-thickness=".4" data-max="{{ request.user.profile.instance_limit }}" data-width="100" data-height="100" data-readOnly="true" value="{{ instances|length|add:more_instances }}">
    </p>
    <span class="bigbig">{% blocktrans with count=running_vm_num %}<span class="big-tag">{{ count }}</span> running{% endblocktrans %}</span>
      <ul class="list-inline" style="max-height: 95px; overflow: hidden;">
        {% for vm in running_vms %}
        <li style="display: inline-block; padding: 2px;">
          <a href="{{vm.get_absolute_url}}" title="{{vm.primary_host.get_fqdn}}"  class="label label-success">
            <i class="fa {{vm.get_status_icon}}"></i> {{vm.name}}
          </a>
        </li>
        {% endfor %}
      </ul>

    <div class="clearfix"></div>
    <div>
      <a style="float: right; margin-top: 17px;" href="{% url "dashboard.views.vm-list" %}" class="btn btn-primary btn-xs">
        <i class="fa fa-chevron-circle-right"></i>
        {% blocktrans count counter=instances|length|add:more_instances %}
          <strong>{{ counter }}</strong> machine total
          {% plural %}
          <strong>{{ counter }}</strong> machines total
        {% endblocktrans %}
      </a>
      <p class="big text-warning">
      {% blocktrans with count=stopped_vm_num %}{{ count }} stopped{% endblocktrans %}
      </p>
    </div>
  </div>
</div>
