{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}

{% block breadcrumbs %}
    {{ block.super }}
    <li class="breadcrumb-item"><a href="{% url 'plugins:netbox_freeipa:freeipadnsrecord_list' %}">DNS Records</a></li>
    <li class="breadcrumb-item active">{{ object }}</li>
{% endblock %}

{% block content %}
<div class="row">
    <div class="col-md-6">
        <div class="card">
            <h5 class="card-header">Record Information</h5>
            <div class="card-body">
                <table class="table table-hover attr-table">
                    <tr>
                        <th scope="row">DNS Zone</th>
                        <td>
                            <a href="{% url 'plugins:netbox_freeipa:freeipadnszone' pk=object.dns_zone.pk %}">
                                {{ object.dns_zone.zone_name }}
                            </a>
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">Record Name</th>
                        <td>{{ object.record_name }}</td>
                    </tr>
                    <tr>
                        <th scope="row">FQDN</th>
                        <td><strong>{{ object.fqdn }}</strong></td>
                    </tr>
                    <tr>
                        <th scope="row">Record Type</th>
                        <td><span class="badge bg-info">{{ object.record_type }}</span></td>
                    </tr>
                    <tr>
                        <th scope="row">Record Value</th>
                        <td><code>{{ object.record_value }}</code></td>
                    </tr>
                    <tr>
                        <th scope="row">TTL</th>
                        <td>{{ object.ttl|placeholder }}</td>
                    </tr>
                    <tr>
                        <th scope="row">Last Synced</th>
                        <td>{{ object.last_synced }}</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    
    <div class="col-md-6">
        <div class="card">
            <h5 class="card-header">Association</h5>
            <div class="card-body">
                <table class="table table-hover attr-table">
                    <tr>
                        <th scope="row">Associated Host</th>
                        <td>
                            {% if object.host %}
                                <a href="{% url 'plugins:netbox_freeipa:freeipahost' pk=object.host.pk %}">
                                    {{ object.host.fqdn }}
                                </a>
                            {% else %}
                                {{ ''|placeholder }}
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        
        {% if object.record_type == 'A' or object.record_type == 'AAAA' %}
        <div class="card mt-3">
            <h5 class="card-header">IP Information</h5>
            <div class="card-body">
                <table class="table table-hover attr-table">
                    <tr>
                        <th scope="row">IP Address</th>
                        <td><code>{{ object.record_value }}</code></td>
                    </tr>
                    <tr>
                        <th scope="row">IP Version</th>
                        <td>
                            {% if object.record_type == 'A' %}
                                <span class="badge bg-primary">IPv4</span>
                            {% else %}
                                <span class="badge bg-secondary">IPv6</span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        {% endif %}
    </div>
</div>
{% endblock %}
