{% extends 'base.html' %}
{% from 'nodes/macros.html' import list_nodes, list_nodes_by_environment %}
{% block title %}{{ name }} - {{ type }} package{% endblock %}
{% block header -%}
  {{ name }} <small><a href="{{ url_for('.packages_for_type', type=type) }}">{{ type }} package</a></small>
{%- endblock %}
{% block body %}
<div class="row">
  <div class="col-md-12">
    <h3>Package versions</h3>
  {% if packages_by_version %}
    <ul>
    {% for version, packages in packages_by_version %}
      <li><a href="#{{ version }}">{{ version }}</a></li>
    {% endfor %}
    </ul>
  {% else %}
    <p class="text-danger">No package versions to display.</p>
  {% endif %}
  </div>
</div>

<div class="row">
  <div class="col-md-12">
    <h3>Nodes by package version</h3>
  {% if packages_by_version | count > 1 %}
    <p class="text-warning">
      {{ packages_by_version | count }} versions of {{ name }} are installed across {{ nodes | count }} nodes.
    </p>
  {% endif %}

  {% for version, packages in packages_by_version %}
    <h4 id="{{ version }}">{{ version }}</h4>
    {{ list_nodes(packages) }}
  {% else %}
    <p class="text-danger">No nodes to display.</p>
  {% endfor %}
  </div>
</div>
{% endblock %}
