{# SPDX-License-Identifier: AGPL-3.0-or-later #}
{% extends "app.html" %}

{% load i18n %}

{% block content %}
  {{ tabs|safe }}
  {{ block.super }}
{% endblock %}

{% block extra_content %}
  <p>
    <a href="/rspamd/">
      {% trans "Visit Rspamd administration interface" %}
    </a>
  </p>
  {% if related_diagnostics %}
    <h3>{% trans "Service Alert" %}</h3>
    <ul class="list-group">
      {% for model in related_diagnostics %}
        <li class="list-group-item clearfix">

          <span>{{ model.title }}</span>
          {% if model.critical_errors %}
            <span class="badge badge-danger">{% trans "error" %}</span>
          {% elif model.errors %}
            <span class="badge badge-warning">{% trans "failed" %}</span>
          {% else %}
            <span class="badge badge-success">{% trans "passed" %}</span>
          {% endif %}

          {% if model.has_failed and model.action %}
            <form method="post" class="float-right"
                  action="{{ request.path }}" >
              {% csrf_token %}
              <button type="submit" class="btn btn-sm btn-outline-primary"
                      name="repair" value="{{ model.action }}">
                {% trans "Repair" %}
              </button>
            </form>
          {% endif %}

          <ul>
            {% for message in model.critical_errors %}
              <li>{{ message }}</li>
            {% endfor %}
            {% for message in model.errors %}
              <li>{{ message }}</li>
            {% endfor %}
          </ul>

        </li>
      {% endfor %}
    </ul>
  {% endif %}
  {{ block.super }}
{% endblock %}
