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

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

{% block extra_content %}
  <h3>{% trans "Status" %}</h3>

  {% if domains_status %}
    <div class="table-responsive">
      <table class="table">
        <thead>
          <tr>
            <th>{% trans "Domain" %}</th>
            <th>{% trans "Last update" %}</th>
            <th>{% trans "Result" %}</th>
            <th>{% trans "IP Address" %}</th>
          </tr>
        </thead>
        <tbody>
          {% for domain in domains_status.values %}
            <tr>
              <td>{{ domain.domain }}</td>
              <td>{{ domain.timestamp|timesince }}</td>
              <td>
                {% if domain.result %}
                  <span class="badge badge-success">
                    {% trans "Success" %}
                  </span>
                {% else %}
                  <span class="badge badge-warning">
                    {% trans "Failed" %}
                  </span>
                {% endif %}
                {% if domain.error_message %}
                  ({{ domain.error_message }})
                {% elif domain.error_code %}
                  ({{ domain.error_code }})
                {% endif %}
              </td>
              <td>{{ domain.ip_address|default_if_none:'-' }}</td>
            </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>
  {% else %}
    {% trans "No status available." %}
  {% endif %}
{% endblock %}

{% block page_js %}
  <script type="text/javascript" src="{% static 'dynamicdns/dynamicdns.js' %}"></script>
{% endblock %}
