{% extends "layouts/base.html" %}
{% load i18n %}
{% load static %}
{% load ooi_extra %}

{% block content %}
  {% include 'header.html' %}
  <main id="main-content">
    <section>
      <div>
        {% if ooi_past_due %}
          {% include 'oois/ooi_past_due_warning.html' with ooi_current=ooi_current %}
        {% endif %}
        {% include 'partials/ooi_head.html' with ooi=ooi view='ooi_detail' %}
        {% include 'oois/ooi_detail_object.html' with ooi=ooi object_details=object_details %}
      </div>
      <div>
        {% include 'oois/ooi_detail_origins_declarations.html' %}
        {% include 'oois/ooi_detail_origins_observations.html' %}
        {% include 'oois/ooi_detail_origins_inference.html' %}
        {% include 'partials/ooi_detail_related_object.html' with query=mandatory_fields ooi_past_due=ooi_past_due related=related ooi=ooi %}
      </div>
      <div>
        {% if not ooi|is_finding and not ooi|is_finding_type %}
          {% include "oois/ooi_detail_findings_overview.html" with severity_summary=findings_severity_summary severity_summary_totals=severity_summary_totals %}
        {% endif %}
      </div>
      <div>
          <h2>{% translate 'Scan' %} {{ ooi.human_readable }} {% translate 'using boefjes' %}</h2>


          {% if enabled_boefjes_available %}
              <div class="horizontal-view toolbar">
                <div>
                  <form method="get" class="inline">
                    <input type="hidden" name="ooi_id" value="{{ ooi }}">
                    {% include 'partials/form/form_errors.html' with form=possible_boefjes_filter_form %}
                    {% for field in possible_boefjes_filter_form %}{{ field }}{% endfor %}
                  </form>
                </div>
              </div>
          {% endif %}

      {% if boefjes %}
          <div class="horizontal-scroll">
            <table>
              <thead>
                <tr>
                  <th>{% translate 'Boefje' %}</th>
                  <th>{% translate 'Description' %}</th>
                  <th>{% translate 'Scan profile' %}</th>
                  <th>{% translate 'Scan' %}</th>
                </tr>
              </thead>
              <tbody>
                {% for boefje in boefjes %}
                  <tr>
                    <td>
                      <a href="{% url 'katalogus_detail' boefje.id %}?ooi_id={{ ooi }}">{{ boefje.name }}</a>
                    </td>
                    <td>{{ boefje.description }}</td>
                    <td>{% include 'partials/scan_level_indicator.html' with value=boefje.scan_level.value %}</td>
                    <td>
                      {% include 'partials/form/single_action_form.html' with btn_text="Start Scan" action='start_scan' key='boefje_id' value=boefje.id %}
                    </td>
                  </tr>
                {% endfor %}
              </tbody>
            </table>
          </div>
      {% else %}
          {% if not enabled_boefjes_available %}
              <p>
                {% translate 'There are no boefjes enabled to scan an OOI of type' %} "{{ ooi.get_ooi_type }}". {% translate 'See' %} <a href="{% url 'katalogus' %}">KAT-alogus</a> {% translate 'to find and enable boefjes that can scan within the current level.' %}
              </p>
          {% else %}
              <p>
                {% translate 'There are no boefjes available within the current clearance level of' %} "{{ ooi.human_readable }}". {% translate 'See' %} <a href="{% url 'katalogus' %}">KAT-alogus</a> {% translate 'to find and enable boefjes that can scan within the current level.' %}
              </p>
              <p>
                {% translate 'Or if you have the authorization, upgrade the clearance level of' %} "{{ ooi.human_readable }}".
              </p>
          {% endif %}
      {% endif %}
      </div>
    </section>
  </main>
{% endblock %}
