{% extends 'base.html' %}
{% block title %}Chef node: {{ node.name }}{% endblock %}
{% block header %}
  {{ node.name }}
  <small>
    <a class="environment" href="{{ url_for('.environment', name=node['chef_environment']) }}">
      {{ node['chef_environment'] }}
    </a>
  </small>
{% endblock %}
{% block body %}
<div class="row">
  <div class="col-md-6">
    <h3>Run list</h3>
    <ul>
    {% for item in node['run_list'] %}
      <li>
        <code>{{ item }}</code>
      </li>
    {% endfor %}
    </ul>
  </div>

  <div class="col-md-6">
    <h3>Roles</h3>
    <ul>
    {% for role in node['roles'] | sort %}
      <li>
        <a href="{{ url_for('.role', name=role) }}">
          <code>{{ role }}</code>
        </a>
      </li>
    {% endfor %}
    </ul>
  </div>
</div>

{% if node['packages'] %}
<div class="row">
  <div class="col-md-12">
  {% for package_type, packages in node['packages'] | dictsort %}
    <h3>Packages (<code>{{ package_type }}</code>)</h3>
    <table class="table table-condensed table-hover">
      <thead>
        <tr>
          <th>Package</th>
          <th>Version</th>
        </tr>
      </thead>
      <tbody>
      {% for package, metadata in packages | dictsort %}
        <tr>
          <td>
            <a href="{{ url_for('.package', type=package_type, name=package) }}">
              <code>{{ package }}</code>
            </a>
          </td>
          <td>
            <a href="{{ url_for('.package', type=package_type, name=package, _anchor=metadata['version']) }}">
              <code>{{ metadata['version'] }}</code>
            </a>
          </td>
        </tr>
      {% endfor %}
      </tbody>
    </table>
  {% endfor %}
  </div>
</div>
{% endif %}
{% endblock %}
