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

{% load i18n %}

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

{% block subsubmenu %}
  <a class="btn btn-default" role="button"
     href="{% url 'email_server:domains' %}">
    {% trans "Domains" %}
  </a>
  <a class="btn btn-default" role="button" href="/rspamd/">
    {% trans "Manage Spam" %}
    <span class="fa fa-external-link"></span>
  </a>
  <a class="btn btn-default" role="button"
     href="{% url 'email_server:aliases' %}">
    {% trans "Manage Aliases" %}
  </a>
{% endblock %}

{% block extra_content %}
  {% 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 %}
