{% load i18n %}
{% load url from future%}

<div class="nodes row">
  <div class="col-xs-4">
    <h3>{% trans 'Hardware Inventory' %}</h3>
    <hr>
    <div class="widget-info pull-left">
      <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__all">
        <span class="info">{{ nodes_all_count }}</span>
        <p>{% trans 'Nodes' %}</p>
      </a>
    </div>
    <div>
      <p>{{ cpus }} {% trans 'CPU cores' %}</p>
      <p>{{ memory_gb|floatformat:"0" }} {% trans 'GB of memory' %}</p>
      <p>{{ local_gb|floatformat:"0" }} {% trans 'GB of storage' %}</p>
    </div>
  </div>
  <div class="col-xs-4">
    <h3>{% trans 'Nodes Status' %}</h3>
    <hr>
    <div class="d3_pie_chart_distribution" data-used="{{ nodes_status_data }}"></div>
  </div>
  <div class="col-xs-4">
    <h3>{% trans 'Power Status' %}</h3>
    <hr>
    <div class="d3_pie_chart_distribution" data-used="Running={{ nodes_up_count }}|Stopped={{ nodes_down_count }}"></div>
  </div>
</div>

<h3>{% trans "Provisioned nodes" %}</h3>
<hr>
<div class="nodes row">
  <div class="col-xs-3">
    <div class="widget-info pull-left">
      <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__provisioned">
        <span class="info">{{ nodes_provisioned_count }}</span>
        <p>{% trans 'Provisioned' %}</p><p>{% trans 'Nodes' %}</p>
      </a>
      {% if nodes_provisioning_count %}
      <div class="widget-info">
        <i class="fa fa-spinner fa-spin text-info"></i>
        <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__all">
          {% blocktrans count nodes_provisioning_count as counter %}
          {{ counter }} node
          {% plural %}
          {{ counter }} nodes
          {% endblocktrans %}
        </a>
        {% blocktrans count nodes_provisioning_count as counter %}
        is being provisioned
        {% plural %}
        are being provisioned
        {% endblocktrans %}
      </div>
      {% endif %}
      {% if nodes_deleting_count %}
      <div class="widget-info">
        <i class="fa fa-spinner fa-spin text-info"></i>
        <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__all">
          {% blocktrans count nodes_deleting_count as counter %}
          {{ counter }} node
          {% plural %}
          {{ counter }} nodes
          {% endblocktrans %}
        </a>
        {% blocktrans count nodes_deleting_count as counter %}
        is being deleted
        {% plural %}
        are being deleted
        {% endblocktrans %}
      </div>
      {% endif %}
      {% if nodes_error_count %}
      <div class="widget-info">
        <i class="fa fa-exclamation-circle text-info"></i>
        <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__all">
          {% blocktrans count nodes_error_count as counter %}
          {{ counter }} node
          {% plural %}
          {{ counter }} nodes
          {% endblocktrans %}
        </a>
        {% trans 'failed' %}
      </div>
      {% endif %}
    </div>
  </div>
  <div>
    {% if nodes_provisioned_count or nodes_provisioning_count %}
    {% url 'horizon:infrastructure:nodes:nodes_performance' as node_perf_url %}
    {% include "infrastructure/_performance_chart_box.html" with meter_conf=meter_conf node_perf_url=node_perf_url col_size=2 %}
    {% endif %}
  </div>
</div>
{% if nodes_provisioned_count or nodes_provisioning_count %}
{% include "infrastructure/_top_5_box.html" %}
{% endif %}
{% if nodes_on_discovery_count or nodes_discovered_count or nodes_discovery_failed_count %}
<h3>{% trans "Nodes Discovery" %}</h3>
<hr>
<div class="nodes row">
  <div class="col-xs-3">
    <div class="widget-info pull-left">
      {% if nodes_discovered_count %}
      <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__maintenance">
        <span class="info">{{ nodes_discovered_count }}</span>
        <p>{% trans 'Discovered' %}</p><p>{% trans 'Nodes' %}</p>
      </a>
      ({{ nodes_discovered_count }} {% trans 'waiting for activation' %})
      {% endif %}
      {% if nodes_on_discovery_count %}
      <div class="widget-info">
        <i class="fa fa-spinner fa-spin text-info"></i>
        <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__maintenance">
          {% blocktrans count nodes_on_discovery_count as counter %}
          {{ counter }} node
          {% plural %}
          {{ counter }} nodes
          {% endblocktrans %}
        </a>
        {% blocktrans count nodes_on_discovery_count as counter %}
        is being discovered
        {% plural %}
        are being discovered
        {% endblocktrans %}
      </div>
      {% endif %}
      {% if nodes_discovery_failed_count %}
      <div class="widget-info">
        <i class="fa fa-exclamation-circle text-danger"></i>
        <a href="{% url 'horizon:infrastructure:nodes:index' %}?tab=nodes__maintenance">
          {% blocktrans count nodes_discovery_failed_count as counter %}
          {{ counter }} node
          {% plural %}
          {{ counter }} nodes
          {% endblocktrans %}
        </a>
        {% trans 'discovery failed' %}
      </div>
      {% endif %}
    </div>
  </div>
</div>
{% endif %}
