{% extends "base.html" %}

{% load bootstrap3 %}

{% block page_title %}Host - {{ host }} {% endblock %}

{% block breadcrumbs %} {{ block.super }} <li><a href="{% url 'hosts:host_list' %}">Hosts</a></li><li class="active">{{ host }}</li>{% endblock %}

{% block content_title %} Host - {{ host }} {% endblock %}

{% block content %}

<div class="well well-sm">
  <table class="table table-striped table-bordered table-hover table-condensed table-responsive">
    <tr><th>Hostname</th><td> {{ host.hostname }} </td></tr>
    <tr><th>Domain</th><td> <a href="{% url 'hosts:host_list' %}?domain={{ host.domain.id }}">{{ host.domain }}</a> </td></tr>
    <tr><th>Reporting IP Address</th><td> {{ host.ipaddress }} </td></tr>
    <tr><th>Reverse DNS</th><td> {{ host.reversedns }} </td></tr>
    <tr><th>OS</th><td> <a href="{{ host.os.get_absolute_url }}">{{ host.os }}</a> </td></tr>
    <tr><th>OS Group</th><td> <a href="{{ host.os.osgroup.get_absolute_url }}">{{ host.os.osgroup }}</a> </td></tr>
    <tr><th>Kernel</th><td> {{ host.kernel }} </td></tr>
    <tr><th>Architecture</th><td> {{ host.arch }} </td></tr>
    <tr>
      <th>Tags</th>
      <td>
      {% load tagging_tags %}
      {% tags_for_object host as tags %}
      {% for tag in tags %}
        <a href="{% url 'hosts:host_list' %}?tag={{ tag }}">{{ tag }}</a>
      {% endfor %}
      </td>
    </tr>
    <tr><th>Updated</th><td> {{ host.updated_at }} </td></tr>
    <tr><th>Last Report</th><td> {{ host.lastreport }} </td></tr>
    <tr><th>Updates Available</th><td> <a data-toggle="tab" href="{{ host.get_absolute_url }}#host_updates">{{ host.updates.count }}</a> </td></tr>
    <tr><th>Reboot Required</th><td> {{ host.reboot_required }} </td></tr>
    <tr><th>Packages Installed</th><td> <a data-toggle="tab" href="{{ host.get_absolute_url }}#host_packages">{{ host.packages.count}}</a> </td></tr>
    <tr><th>Repos In Use</th><td>{% if host.host_repos_only %}Host Repos{% else %}Host and OS Group Repos{% endif %}</td></tr>
    <tr>
      <th>Last 3 reports</th>
      <td>
      {% for report in reports %}
        <span class="label label-brick {% cycle 'bg-info' 'bg-success' %}">
          <a href="{{ report.get_absolute_url}}">{{ report.created }} </a>
        </span>
      {% endfor %}
      </td>
    </tr>
  </table>
  <div class="panel panel-danger">
    {% if user.is_authenticated and perms.is_admin %}
      <div class="panel-heading">
        Are you sure you want to delete this Host?
      </div>
      <div class="panel-body">
        <form action={{ request.path }} method="post">
          {% csrf_token %}
          <button name="delete" type="submit" class="btn btn-primary btn-sm">{% bootstrap_icon "trash" %} Delete</button>
          <button name="cancel" type="submit" class="btn btn-primary btn-sm">{% bootstrap_icon "stop" %} Cancel</button>
        </form>
      </div>
    {% else %}
      <div class="panel-heading">
        You do not have permission to delete this Host.
      </div>
      <div class="panel-body">
        <a class="btn btn-primary btn-sm" href="{{ host.get_absolute_url }}">{% bootstrap_icon "arrow-left" %} Back</a>
      </div>
    {% endif %}
  </div>
</div>

{% endblock %}
