{% import "macros.html" as macros %}
{% extends "bases/app.html" %}

{% block title %}Records - {{ current_zone }} - {% endblock title %}

{% block main %}
    <h1>{{ tr(msg="zone_records_title", lang=lang, zone_name="<strong>" ~ current_zoned ~ "</strong>") | safe }}</h1>
    <svg width="0" height="0" aria-hidden="true" style="position: absolute;">
        <defs>
          <clipPath id="corner-folder-tab-right" clipPathUnits="objectBoundingBox">
            <path d="m 0,0 c .25,0 0.75,1 1,1 l -1,0 z"/>
          </clipPath>
        </defs>
    </svg>
    <section>
        <h2>Records</h2>
        {% for group in records.records %}
            <article class="domain">
                <header>
                    <h3 class="folder-tab">{{ group.owner }}</h3>
                    <span class="sep"></span>
                    <a href="{{ url }}/new?subdomain={{ group.owner | trim_end_matches(pat=current_zone) | trim_end_matches(pat=".") }}" class="button">
                        <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16" aria-hidden="true">
                            <path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/>
                            <path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4"/>
                        </svg>
                        Add record
                    </a>
                </header>
                <div class="records">
                    {% if group.web %}
                    <h4>Web</h4>
                    <ul>
                        {% if group.web.addresses %}
                            {{ macros::rrset(
                                rtype=group.web.addresses.rtype,
                                ttl=group.web.addresses.ttl,
                                data=group.web.addresses.data,
                                zone=current_zone,
                                lang=lang) }}
                        {% endif %}
                    </ul>
                    {% endif %}

                    {% if group.mail %}
                    <h4>E-mails</h4>
                    <ul>
                        {% if group.mail.servers %}
                            {{ macros::rrset(
                                rtype=group.mail.servers.rtype,
                                ttl=group.mail.servers.ttl,
                                data=group.mail.servers.data,
                                zone=current_zone,
                                lang=lang) }}
                        {% endif %}
                        {% if group.mail.spf %}
                            {{ macros::rrset(
                                rtype=group.mail.spf.rtype,
                                ttl=group.mail.spf.ttl,
                                data=group.mail.spf.data,
                                zone=current_zone,
                                lang=lang) }}
                        {% endif %}
                    </ul>
                    {% endif %}

                    {% if group.general_records %}
                    <h4>General</h4>
                    <ul>
                        {% for rrset in group.general_records %}
                            {{ macros::rrset(
                                rtype=rrset.rtype,
                                ttl=rrset.ttl,
                                data=rrset.data,
                                zone=current_zone,
                                lang=lang) }}
                        {% endfor %}
                    </ul>
                    {% endif %}

                </div>
            </article>
        {% endfor %}
    </section>
    <section>
        <h2>Aliases</h2>

        <ul>
        {% for alias in records.aliases %}
            <li>{{ alias.from }} → {{ alias.target }}</li>
        {% endfor %}
        </ul>
    </section>
{% endblock main %}