{% load i18n horizon humanize bootstrap %}

{% block help_message %}
{% endblock %}

<h4>{% trans "Flavor Details" %}</h4>
<table class="flavor_table table table-striped table-fixed">
  <tbody>
    <tr><td class="flavor_name">{% trans "Name" %}</td><td><span id="flavor_name" class="truncate"></span></td></tr>
    <tr><td class="flavor_name">{% trans "VCPUs" %}</td><td><span id="flavor_vcpus"></span></td></tr>
    <tr><td class="flavor_name">{% trans "Root Disk" %}</td><td><span id="flavor_disk"></span> {% trans "GB" %}</td></tr>
    <tr><td class="flavor_name">{% trans "Ephemeral Disk" %}</td><td><span id="flavor_ephemeral"></span> {% trans "GB" %}</td></tr>
    <tr><td class="flavor_name">{% trans "Total Disk" %}</td><td><span id="flavor_disk_total"></span> {% trans "GB" %}</td></tr>
    <tr><td class="flavor_name">{% trans "RAM" %}</td><td><span id="flavor_ram"></span> {% trans "MB" %}</td></tr>
  </tbody>
</table>

<div class="quota-dynamic">
  <h4>{% trans "Project Limits" %}</h4>
  <div class="quota_title">
    <strong class="pull-left">{% trans "Number of Instances" %}</strong>
    <span class="pull-right">
      {% blocktrans trimmed with used=usages.instances.used|intcomma quota=usages.instances.quota|intcomma|quotainf %}
      {{ used }} of {{ quota }} Used
      {% endblocktrans %}
    </span>
  </div>

 {{ minifyspace }}
  <div id="{{ resize_instance|yesno:"quota_resize_instance,quota_instances" }}"
       class="quota_bar"
       data-progress-indicator-flavor
       data-quota-limit="{{ usages.instances.quota }}"
       data-quota-used="{{ usages.instances.used }}">
    {% widthratio usages.instances.used usages.instances.quota 100 as instance_percent %}
    {% bs_progress_bar instance_percent 0 %}
  </div>
 {{ endminifyspace }}

  <div class="quota_title">
    <strong class="pull-left">{% trans "Number of VCPUs" %}</strong>
    <span class="pull-right">
      {% blocktrans trimmed with used=usages.cores.used|intcomma quota=usages.cores.quota|intcomma|quotainf %}
      {{ used }} of {{ quota }} Used
      {% endblocktrans %}
    </span>
  </div>

  {{ minifyspace }}
  <div id="quota_vcpus"
       class="quota_bar"
       data-progress-indicator-flavor
       data-quota-limit="{{ usages.cores.quota }}"
       data-quota-used="{{ usages.cores.used }}">
    {% widthratio usages.cores.used usages.cores.quota 100 as vcpu_percent %}
    {% bs_progress_bar vcpu_percent 0 %}
  </div>
  {{ endminifyspace }}

  <div class="quota_title">
    <strong class="pull-left">{% trans "Total RAM" %}</strong>
    <span class="pull-right">
      {% blocktrans trimmed with used=usages.ram.used|intcomma quota=usages.ram.quota|intcomma|quotainf %}
      {{ used }} of {{ quota }} MB Used
      {% endblocktrans %}
    </span>
  </div>

  {{ minifyspace }}
  <div id="quota_ram"
       class="quota_bar"
       data-progress-indicator-flavor
       data-quota-limit="{{ usages.ram.quota }}"
       data-quota-used="{{ usages.ram.used }}">
    {% widthratio usages.ram.used usages.ram.quota 100 as vcpu_percent %}
    {% bs_progress_bar vcpu_percent 0 %}
  </div>
  {{ endminifyspace }}

  {% if cinder_enabled %}
  <div class="quota_title">
    <strong class="pull-left">{% trans "Number of Volumes" %}</strong>
    <span class="pull-right">
      {% blocktrans with used=usages.volumes.used|intcomma quota=usages.volumes.quota|intcomma|quotainf %}
      {{ used }} of {{ quota }} Used
      {% endblocktrans %}
    </span>
  </div>
  <div id="quota_volume"
       class="quota_bar"
       data-progress-indicator-flavor
       data-quota-limit="{{ usages.volumes.quota }}"
       data-quota-used="{{ usages.volumes.used }}">
    {% widthratio usages.volumes.used usages.volumes.quota 100 as volume_percent %}
    {% bs_progress_bar volume_percent 0 %}
  </div>

  <div class="quota_title">
    <strong class="pull-left">{% trans "Total Volume Storage" %}</strong>
    <span class="pull-right">
      {% blocktrans with used=usages.gigabytes.used|intcomma quota=usages.gigabytes.quota|intcomma|quotainf %}
      {{ used }} of {{ quota }} GiB Used
      {% endblocktrans %}
    </span>
  </div>
  <div id="quota_volume_storage"
       class="quota_bar"
       data-progress-indicator-flavor
       data-quota-limit="{{ usages.gigabytes.quota }}"
       data-quota-used="{{ usages.gigabytes.used }}">
     {% widthratio usages.gigabytes.used usages.gigabytes.quota 100 as volume_storage_percent %}
     {% bs_progress_bar volume_storage_percent 0 %}
  </div>
  {% endif %}

</div>


<script type="text/javascript" charset="utf-8">
  some_disabled_msg = '{{_("Some flavors not meeting minimum boot source requirements have been disabled.")|escapejs }}';
  all_disabled_msg = '{{_("No flavors meet minimum criteria for selected boot source.")|escapejs }}';

  if(typeof horizon.Quota !== 'undefined') {
    horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }});
    horizon.Quota.initWithImages({{ images|safe|default:"{}"}}, some_disabled_msg, all_disabled_msg);
  } else {
    addHorizonLoadEvent(function() {
      horizon.Quota.initWithFlavors({{ flavors|safe|default:"{}" }});
      horizon.Quota.initWithImages({{ images|safe|default:"{}"}}, some_disabled_msg, all_disabled_msg);
    });
  }
</script>
