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

{% load bootstrap %}
{% load i18n %}

{% block status %}
  {{ block.super }}

  <h3>{% trans "Domains" %}</h3>

  <div class="table-responsive">
    <table class="table names-table">
      <thead>
        <tr>
          <th>{% trans "Type" %}</th>
          <th class="names-domain-column">{% trans "Domain Name" %}</th>
          <th>{% trans "Services" %}</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
        {% for domain in status.domains|dictsort:"domain_type.display_name" %}
          <tr>
            <td>{{ domain.domain_type.display_name }}</td>
            <td class="names-domain-column">{{ domain.name }}</td>
            <td>{{ domain.get_readable_services|join:', ' }}</td>
            <td>
              <a href="{% url domain.domain_type.configuration_url %}"
                 role="button" class="btn btn-md btn-default">
                {% trans "Configure" %}
              </a>
            </td>
          </tr>
        {% endfor %}

        {% for domain_type in status.unused_domain_types %}
          <tr>
            <td>{{ domain_type.display_name }}</td>
            <td>-</td>
            <td>-</td>
            <td>
              <a href="{% url domain_type.configuration_url %}"
                 role="button" class="btn btn-md btn-default">
                {% trans "Configure" %}
              </a>
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>

  <h3>{% trans "Resolver Status" %}</h3>

  {% if resolved_status %}
    <div class="table-responsive">
      <table class="table resolved-status-table">
        <tbody>
          {% for link in resolved_status %}
            <tr>
              <th colspan="2">
                {% if link.link_index == 0 %}
                  {% trans "Global" %}
                {% else %}
                  {% trans "Link" %} {{ link.link_index }} ({{link.interface_name}})
                {% endif %}
              </th>
            </tr>
            <tr>
              <td>{% trans "DNS-over-TLS" %}</td>
              <td>{{ link.dns_over_tls_string }}</td>
            </tr>
            <tr>
              <td>{% trans "DNSSEC" %}</td>
              <td>{{ link.dnssec_string }}/{{ link.dnssec_supported_string }}</td>
            </tr>
            {% if link.current_dns_server %}
              <tr>
                <td>{% trans "Current DNS Server" %}</td>
                <td>{{ link.current_dns_server }}</td>
              </tr>
            {% endif %}
            {% if link.dns_servers %}
              <tr>
                <td>{% trans "DNS Servers" %}</td>
                <td>
                  {% for server in link.dns_servers %}
                    {{ server }}<br />
                  {% endfor %}
                </td>
              </tr>
            {% endif %}
            {% if link.fallback_dns_servers %}
              <tr>
                <td>{% trans "Fallback DNS Servers" %}</td>
                <td>
                  {% for server in link.fallback_dns_servers %}
                  {{ server }}<br />
                  {% endfor %}
                </td>
              </tr>
            {% endif %}
          {% endfor %}
        </tbody>
      </table>
    </div>
  {% else %}
    <div class="alert alert-danger">
      {% trans "Error retrieving status:" %} {{ resolved_status_error }}
    </div>
  {% endif %}

{% endblock %}
