{% extends 'base.html' %}
{% load buttons %}
{% load custom_links %}
{% load helpers %}
{% load plugins %}

{% block header %}
    <div class="row noprint">
        <div class="col-sm-8 col-md-9">
            <ol class="breadcrumb">
                <li><a href="{% url 'ipam:ipaddress_list' %}">IP Addresses</a></li>
                {% if ipaddress.vrf %}
                    <li><a href="{% url 'ipam:vrf' pk=ipaddress.vrf.pk %}">{{ ipaddress.vrf }}</a></li>
                {% endif %}
                <li>{{ ipaddress }}</li>
            </ol>
        </div>
        <div class="col-sm-4 col-md-3">
            <form action="{% url 'ipam:ipaddress_list' %}" method="get">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" placeholder="Search IPs" />
                    <span class="input-group-btn">
                        <button type="submit" class="btn btn-primary">
                            <span class="fa fa-search" aria-hidden="true"></span>
                        </button>
                    </span>
                </div>
            </form>
        </div>
    </div>
    <div class="pull-right noprint">
        {% plugin_buttons ipaddress %}
        {% if perms.ipam.add_ipaddress %}
            {% clone_button ipaddress %}
        {% endif %}
        {% if perms.ipam.change_ipaddress %}
            {%edit_button ipaddress %}
        {% endif %}
        {% if perms.ipam.delete_ipaddress %}
            {% delete_button ipaddress %}
        {% endif %}
    </div>
    <h1>{% block title %}{{ ipaddress }}{% endblock %}</h1>
    {% include 'inc/created_updated.html' with obj=ipaddress %}
    <div class="pull-right noprint">
        {% custom_links ipaddress %}
    </div>
    <ul class="nav nav-tabs">
        <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
            <a href="{{ ipaddress.get_absolute_url }}">IP Address</a>
        </li>
        {% if perms.extras.view_objectchange %}
            <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
                <a href="{% url 'ipam:ipaddress_changelog' pk=ipaddress.pk %}">Change Log</a>
            </li>
        {% endif %}
    </ul>
{% endblock %}

{% block content %}
<div class="row">
	<div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>IP Address</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Family</td>
                    <td>IPv{{ ipaddress.family }}</td>
                </tr>
                <tr>
                    <td>VRF</td>
                    <td>
                        {% if ipaddress.vrf %}
                            <a href="{% url 'ipam:vrf' pk=ipaddress.vrf.pk %}">{{ ipaddress.vrf }}</a>
                        {% else %}
                            <span>Global</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if ipaddress.tenant %}
                            {% if ipaddress.tenant.group %}
                                <a href="{{ ipaddress.tenant.group.get_absolute_url }}">{{ ipaddress.tenant.group }}</a>
                                <i class="fa fa-angle-right"></i>
                            {% endif %}
                            <a href="{{ ipaddress.tenant.get_absolute_url }}">{{ ipaddress.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Status</td>
                    <td>
                        <span class="label label-{{ ipaddress.get_status_class }}">{{ ipaddress.get_status_display }}</span>
                    </td>
                </tr>
                <tr>
                    <td>Role</td>
                    <td>
                        {% if ipaddress.role %}
                            <a href="{% url 'ipam:ipaddress_list' %}?role={{ ipaddress.role }}">{{ ipaddress.get_role_display }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>DNS Name</td>
                    <td>{{ ipaddress.dns_name|placeholder }}</td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>{{ ipaddress.description|placeholder }}</td>
                </tr>
                <tr>
                    <td>Assignment</td>
                    <td>
                        {% if ipaddress.interface %}
                            <span><a href="{{ ipaddress.interface.parent.get_absolute_url }}">{{ ipaddress.interface.parent }}</a> ({{ ipaddress.interface }})</span>
                        {% else %}
                            <span class="text-muted">&mdash;</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>NAT (inside)</td>
                    <td>
                        {% if ipaddress.nat_inside %}
                            <a href="{% url 'ipam:ipaddress' pk=ipaddress.nat_inside.pk %}">{{ ipaddress.nat_inside }}</a>
                            {% if ipaddress.nat_inside.interface %}
                                (<a href="{{ ipaddress.nat_inside.interface.parent.get_absolute_url }}">{{ ipaddress.nat_inside.interface.parent }}</a>)
                            {% endif %}
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>NAT (outside)</td>
                    <td>
                        {% if ipaddress.nat_outside %}
                            <a href="{% url 'ipam:ipaddress' pk=ipaddress.nat_outside.pk %}">{{ ipaddress.nat_outside }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% include 'inc/custom_fields_panel.html' with obj=ipaddress %}
        {% include 'extras/inc/tags_panel.html' with tags=ipaddress.tags.all url='ipam:ipaddress_list' %}
        {% plugin_left_page ipaddress %}
	</div>
	<div class="col-md-8">
        {% include 'panel_table.html' with table=parent_prefixes_table heading='Parent Prefixes' %}
        {% if duplicate_ips_table.rows %}
            {% include 'panel_table.html' with table=duplicate_ips_table heading='Duplicate IP Addresses' panel_class='danger' %}
        {% endif %}
        {% include 'utilities/obj_table.html' with table=related_ips_table table_template='panel_table.html' heading='Related IP Addresses' panel_class='default noprint' %}
        {% plugin_right_page ipaddress %}
	</div>
</div>
<div class="row">
    <div class="col-md-12">
        {% plugin_full_width_page ipaddress %}
    </div>
</div>
{% endblock %}
