{% extends 'generic/object.html' %}
{% load helpers %}
{% load plugins %}
{% load render_table from django_tables2 %}
{% load i18n %}

{% block content %}
<div class="row">
	<div class="col col-md-4">
      <div class="card">
          <h2 class="card-header">{% trans "IP Address" %}</h2>
          <table class="table table-hover attr-table">
              <tr>
                  <th scope="row">{% trans "Family" %}</th>
                  <td>IPv{{ object.family }}</td>
              </tr>
              <tr>
                  <th scope="row">{% trans "VRF" %}</th>
                  <td>
                      {% if object.vrf %}
                          <a href="{% url 'ipam:vrf' pk=object.vrf.pk %}">{{ object.vrf }}</a>
                      {% else %}
                          <span>{% trans "Global" %}</span>
                      {% endif %}
                  </td>
              </tr>
              <tr>
                  <th scope="row">{% trans "Tenant" %}</th>
                  <td>
                      {% if object.tenant.group %}
                          {{ object.tenant.group|linkify }} /
                      {% endif %}
                      {{ object.tenant|linkify|placeholder }}
                  </td>
              </tr>
              <tr>
                  <th scope="row">{% trans "Status" %}</th>
                  <td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
              </tr>
              <tr>
                  <th scope="row">{% trans "Role" %}</th>
                  <td>
                      {% if object.role %}
                          <a href="{% url 'ipam:ipaddress_list' %}?role={{ object.role }}">{{ object.get_role_display }}</a>
                      {% else %}
                          {{ ''|placeholder }}
                      {% endif %}
                  </td>
              </tr>
              <tr>
                  <th scope="row">{% trans "DNS Name" %}</th>
                  <td>{{ object.dns_name|placeholder }}</td>
              </tr>
              <tr>
                  <th scope="row">{% trans "Description" %}</th>
                  <td>{{ object.description|placeholder }}</td>
              </tr>
              <tr>
                  <th scope="row">{% trans "Assignment" %}</th>
                  <td>
                    {% if object.assigned_object %}
                      {% if object.assigned_object.parent_object %}
                        {{ object.assigned_object.parent_object|linkify }} /
                      {% endif %}
                      {{ object.assigned_object|linkify }}
                    {% else %}
                      {{ ''|placeholder }}
                    {% endif %}
                  </td>
              </tr>
              <tr>
                  <th scope="row">{% trans "NAT (inside)" %}</th>
                  <td>
                      {% if object.nat_inside %}
                          {{ object.nat_inside|linkify }}
                          {% if object.nat_inside.assigned_object %}
                              ({{ object.nat_inside.assigned_object.parent_object|linkify }})
                          {% endif %}
                      {% else %}
                          {{ ''|placeholder }}
                      {% endif %}
                  </td>
              </tr>
              <tr>
                  <th scope="row">{% trans "NAT (outside)" %}</th>
                  <td>
                    {% for ip in object.nat_outside.all %}
                      {{ ip|linkify }}
                      {% if ip.assigned_object %}
                        ({{ ip.assigned_object.parent_object|linkify }})
                      {% endif %}<br/>
                    {% empty %}
                      {{ ''|placeholder }}
                    {% endfor %}
                  </td>
              </tr>
              <tr>
                <th scope="row">Primary IP</th>
                <td>{% checkmark object.is_primary_ip %}</td>
              </tr>
              <tr>
                <th scope="row">OOB IP</th>
                <td>{% checkmark object.is_oob_ip %}</td>
              </tr>
          </table>
      </div>
      {% include 'inc/panels/tags.html' %}
      {% include 'inc/panels/custom_fields.html' %}
      {% include 'inc/panels/comments.html' %}
      {% plugin_left_page object %}
	</div>
	<div class="col col-md-8">
    {% include 'inc/panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %}
    {% if duplicate_ips_table.rows %}
      {% include 'inc/panel_table.html' with table=duplicate_ips_table heading='Duplicate IPs' panel_class='danger' %}
    {% endif %}
    <div class="card">
      <h2 class="card-header">{% trans "Services" %}</h2>
      {% htmx_table 'ipam:service_list' ip_address_id=object.pk %}
    </div>
    {% plugin_right_page object %}
	</div>
</div>
<div class="row">
  <div class="col col-md-12">
    {% plugin_full_width_page object %}
  </div>
</div>
{% endblock %}
