{% extends '_base.html' %}

{% block content %}
<div class="row">
    <div class="col-sm-8 col-md-9">
        <ol class="breadcrumb">
            <li><a href="{% url 'ipam:vlan_list' %}">VLANs</a></li>
            {% if vlan.site %}
                <li><a href="{% url 'ipam:vlan_list' %}?site={{ vlan.site.slug }}">{{ vlan.site }}</a></li>
            {% endif %}
            {% if vlan.group %}
                <li><a href="{% url 'ipam:vlan_list' %}?group={{ vlan.group.slug }}">{{ vlan.group.name }}</a></li>
            {% endif %}
            <li>{{ vlan.name }} ({{ vlan.vid }})</li>
        </ol>
    </div>
    <div class="col-sm-4 col-md-3">
    <form action="{% url 'ipam:vlan_list' %}" method="get">
        <div class="input-group">
            <input type="text" name="q" class="form-control" placeholder="Search VLANs" />
            <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">
    {% if perms.ipam.change_vlan %}
        <a href="{% url 'ipam:vlan_edit' pk=vlan.pk %}" class="btn btn-warning">
            <span class="fa fa-pencil" aria-hidden="true"></span>
            Edit this VLAN
        </a>
    {% endif %}
    {% if perms.ipam.delete_vlan %}
        <a href="{% url 'ipam:vlan_delete' pk=vlan.pk %}" class="btn btn-danger">
            <span class="fa fa-trash" aria-hidden="true"></span>
            Delete this VLAN
        </a>
    {% endif %}
</div>
<h1>{% block title %}VLAN {{ vlan.display_name }}{% endblock %}</h1>
{% include 'inc/created_updated.html' with obj=vlan %}
<div class="row">
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>VLAN</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Site</td>
                    <td>
                        {% if vlan.site %}
                            {% if vlan.site.region %}
                                <a href="{{ vlan.site.region.get_absolute_url }}">{{ vlan.site.region }}</a>
                                <i class="fa fa-angle-right"></i>
                            {% endif %}
                            <a href="{% url 'dcim:site' slug=vlan.site.slug %}">{{ vlan.site }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Group</td>
                    <td>
                        {% if vlan.group %}
                            <a href="{{ vlan.group.get_absolute_url }}">{{ vlan.group.name }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>VLAN ID</td>
                    <td>{{ vlan.vid }}</td>
                </tr>
                <tr>
                    <td>Name</td>
                    <td>{{ vlan.name }}</td>
                </tr>
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if vlan.tenant %}
                            {% if vlan.tenant.group %}
                                <a href="{{ vlan.tenant.group.get_absolute_url }}">{{ vlan.tenant.group.name }}</a>
                                <i class="fa fa-angle-right"></i>
                            {% endif %}
                            <a href="{{ vlan.tenant.get_absolute_url }}">{{ vlan.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Status</td>
                    <td>
                        <span class="label label-{{ vlan.get_status_class }}">{{ vlan.get_status_display }}</span>
                    </td>
                </tr>
                <tr>
                    <td>Role</td>
                    <td>
                        {% if vlan.role %}
                            <a href="{% url 'ipam:vlan_list' %}?role={{ vlan.role.slug }}">{{ vlan.role }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>
                        {% if vlan.description %}
                            {{ vlan.description }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
		    </table>
        </div>
        {% with vlan.get_custom_fields as custom_fields %}
            {% include 'inc/custom_fields_panel.html' %}
        {% endwith %}
	</div>
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Prefixes</strong>
            </div>
            {% include 'responsive_table.html' with table=prefix_table %}
            {% if perms.ipam.add_prefix %}
                <div class="panel-footer text-right">
                    <a href="{% url 'ipam:prefix_add' %}?{% if vlan.tenant %}tenant={{ vlan.tenant.pk }}&{% endif %}site={{ vlan.site.pk }}&vlan={{ vlan.pk }}" class="btn btn-primary btn-xs">
                        <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                        Add a prefix
                    </a>
                </div>
            {% endif %}
        </div>
	</div>
</div>
{% endblock %}
