{% extends "base.html" %}

{% load common %}

{% block page_title %}Patchman Dashboard{% endblock %}

{% block content_title %} Patch Management Dashboard for {{ site.name }} {% endblock %}

{% block content %}

{% with count=lonely_oses.count %}
  {% if lonely_oses.count > 0 %}
    <div class="well well-sm">
      <button class="btn btn-sm" data-toggle="collapse" data-target="#lonely_oses"><span class="badge">{{ count }}</span> Operating Systems are not linked to any OS Group</button>
      <div class="collapse" id="lonely_oses">
        {% gen_table lonely_oses %}
      </div>
    </div>
  {% endif %}
{% endwith %}

{% with count=nohost_oses.count %}
  {% if nohost_oses.count > 0 %}
    <div class="well well-sm">
      <button class="btn btn-sm" data-toggle="collapse" data-target="#nohost_oses"><span class="badge">{{ count }}</span> Operating Systems are not installed on any Host</button>
        <div class="collapse" id="nohost_oses">
          {% gen_table nohost_oses %}
        </div>
    </div>
  {% endif %}
{% endwith %}

{% with count=norepo_osgroups.count %}
  {% if count > 0 and norepo_osgroups != None %}
    <div class="well well-sm">
      <button class="btn btn-sm" data-toggle="collapse" data-target="#norepo_osgroups"><span class="badge">{{ count }}</span> OS Groups have no associated Repositories</button>
        <div class="collapse" id="norepo_osgroups">
          {% gen_table norepo_osgroups %}
        </div>
    </div>
  {% endif %}
{% endwith %}

{% with count=stale_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#stale_hosts"><span class="badge">{{ count }}</span> Hosts have not reported since {% reports_timedelta %}</button>
    <div class="collapse" id="stale_hosts">
      {% gen_table stale_hosts %}
    </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=reboot_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#reboot_hosts"><span class="badge">{{ count }}</span> Hosts require a reboot for security reasons (e.g. kernel update)</button>
      <div class="collapse" id="reboot_hosts">
        {% gen_table reboot_hosts %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=secupdate_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#secupdate_hosts"><span class="badge">{{ count }}</span> Hosts have security updates pending</button>
      <div class="collapse" id="secupdate_hosts">
        {% gen_table secupdate_hosts %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=bugupdate_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#bugupdate_hosts"><span class="badge">{{ count }}</span> Hosts have bugfix-only updates pending</button>
      <div class="collapse" id="bugupdate_hosts">
        {% gen_table bugupdate_hosts %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=norepo_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#norepo_hosts"><span class="badge">{{ count }}</span> Hosts have no associated Repositories</button>
      <div class="collapse" id="norepo_hosts">
        {% gen_table norepo_hosts %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=diff_rdns_hosts.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#diff_rdns_hosts"><span class="badge">{{ count }}</span> Hosts have a different rDNS entry (and have rDNS checking enabled)</button>
      <div class="collapse" id="diff_rdns_hosts">
        {% gen_table diff_rdns_hosts %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=failed_mirrors.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#failed_mirrors"><span class="badge">{{ count }}</span> Repositories have some Mirrors that are failing</button>
      <div class="collapse" id="failed_mirrors">
        {% gen_table failed_mirrors %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=disabled_mirrors.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#disabled_mirrors"><span class="badge">{{ count }}</span> Repositories have some Mirrors that are disabled</button>
      <div class="collapse" id="disabled_mirrors">
        {% gen_table disabled_mirrors %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=norefresh_mirrors.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#norefresh_mirrors"><span class="badge">{{ count }}</span> Repositories have some Mirrors that are not set to refresh (possibly failed too many times)</button>
      <div class="collapse" id="norefresh_mirrors">
        {% gen_table norefresh_mirrors %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=failed_repos.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#failed_repos"><span class="badge">{{ count }}</span> Repositories where all Mirrors are failing</button>
      <div class="collapse" id="failed_repos">
        {% gen_table failed_repos %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=unused_repos.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#unused_repos"><span class="badge">{{ count }}</span> Repositories are unused (no associated Hosts or OS Groups)</button>
      <div class="collapse" id="unused_repos">
        {% gen_table unused_repos %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=nomirror_repos.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#nomirror_repos"><span class="badge">{{ count }}</span> Repositories have no Mirrors</button>
      <div class="collapse" id="nomirror_repos">
        {% gen_table nomirror_repos %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=nohost_repos.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#nohost_repos"><span class="badge">{{ count }}</span> Repositories are not used by any Hosts</button>
      <div class="collapse" id="nohost_repos">
        {% gen_table nohost_repos %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=possible_mirrors|length %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#possible_mirrors"><span class="badge">{{ count }}</span> Sets of Mirrors have the same checksum and are not linked</button>
      <div class="collapse" id="possible_mirrors">
        {% for checksum in possible_mirrors %}
        <span class="label label-brick {% cycle 'bg-info' 'bg-success' %}">
          <a href="../repos/mirrors/?checksum={{ checksum }}">{{ checksum }}</a>
        </span>
        {% endfor %}
      </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=norepo_packages.count %}
  {% if count > 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#norepo_packages"><span class="badge">{{ count }}</span> Installed Packages are not from any Repository</button>
      <div class="collapse" id="norepo_packages">
        <div class="well">
          {% for package in norepo_packages %}
            <span class="label label-brick {% cycle 'bg-info' 'bg-success' %}">
              <a href="{{ package.get_absolute_url }}">{{ package }}</a>
            </span>
          {% endfor %}
        </div>
     </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=orphaned_packages.count %}
  {% if count < 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#orphaned_packages"><span class="badge">{{ count }}</span> Packages are orphaned (not from any Repository, not installed on any Host)</button>
      <div class="collapse" id="orphaned_packages">
        {% for package in orphaned_packages %}
          <span class="label label-brick {% cycle 'bg-info' 'bg-success' %}">
            <a href="{{ package.get_absolute_url }}">{{ package }}</a>
          </span>
        {% endfor %}
     </div>
  </div>
  {% endif %}
{% endwith %}

{% with count=unprocessed_reports.count %}
  {% if count < 0 %}
  <div class="well well-sm">
    <button class="btn btn-sm" data-toggle="collapse" data-target="#unprocessed_reports"><span class="badge">{{ count }}</span> Reports have not yet been processed</button>
      <div class="collapse" id="unprocessed_reports">
        {% gen_table unprocessed_reports %}
     </div>
  </div>
  {% endif %}
{% endwith %}

{% endblock %}
