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

{% block breadcrumbs %}
<li class="breadcrumb-item"><a href="{% url 'plugins:netbox_bgp:session_list' %}">BGP Sessions</a></li>
{% endblock %}
{% block controls %}
<div class="pull-right noprint">
    {% if perms.netbox_bgp.change_session %}
    <a href="{% url 'plugins:netbox_bgp:session_edit' pk=object.pk %}" class="btn btn-sm btn-warning">
        <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
    </a>
    {% endif %}
    {% if perms.netbox_bgp.delete_session %}
    <a href="{% url 'plugins:netbox_bgp:session_delete' pk=object.pk %}" class="btn btn-sm btn-danger">
        <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
    </a>
    {% endif %}
</div>
{% endblock controls %}
{% block tabs %}
<ul class="nav nav-tabs px-3">
    {% block tab_items %}
    <li class="nav-item" role="presentation">
        <a class="nav-link{% if not active_tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object|meta:"verbose_name"|bettertitle }}</a>
    </li>
    {% endblock tab_items %}
    {% if perms.extras.view_objectchange %}
    <li role="presentation" class="nav-item">
        <a href="{% url 'plugins:netbox_bgp:asn_changelog' pk=object.pk %}" class="nav-link{% if active_tab == 'changelog'%} active{% endif %}">Change Log</a>
    </li>
    {% endif %}
</ul>
{% endblock tabs %}

{% block content %}
<div class="row mb-3">
    <div class="col-md-4">
        <div class="card">
            <h5 class="card-header">
                BGP Session
            </h5>
            <div class="card-body">
                <table class="table table-hover attr-table">
                    <tr>
                        <td>Name</td>
                        <td>
                            {% if object.name %}
                            {{ object.name }}
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Device</td>
                        <td>
                            {% if object.device %}
                            <a href="{{ object.device.get_absolute_url }}">{{ object.device }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Local AS</td>
                        <td>
                            {% if object.local_as %}
                            <a href="{{ object.local_as.get_absolute_url }}">{{ object.local_as }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Local IP</td>
                        <td>
                            {% if object.local_address %}
                            <a href="{{ object.local_address.get_absolute_url }}">{{ object.local_address }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Remote AS</td>
                        <td>
                            {% if object.remote_as %}
                            <a href="{{ object.remote_as.get_absolute_url }}">{{ object.remote_as }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Remote IP</td>
                        <td>
                            {% if object.remote_address %}
                            <a href="{{ object.remote_address.get_absolute_url }}">{{ object.remote_address }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Status</td>
                        <td>
                            <span class="label label-{{ object.get_status_class }}">{{ object.get_status_display }}</span>
                        </td>
                    </tr>
                    <tr>
                        <td>Description</td>
                        <td>{{ object.description|placeholder }}</td>
                    </tr>
                    <tr>
                        <td>Peer Group</td>
                        <td>
                            {% if object.peer_group %}
                            <a href="{{ object.peer_group.get_absolute_url }}">{{ object.peer_group }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                    <tr>
                        <td>Tenant</td>
                        <td>
                            {% if object.tenant %}
                            <a href="{{ object.tenant.get_absolute_url }}">{{ object.tenant }}</a>
                            {% else %}
                            <span class="text-muted">None</span>
                            {% endif %}
                        </td>
                    </tr>
                </table>
            </div>
        </div>
        {% include 'inc/panels/custom_fields.html' %}
        {% include 'inc/panels/tags.html' %}
        {% plugin_left_page object %}
    </div>
    <div class="col-md-8">
        <div class="card">
            <h5 class="card-header">
                Import Policies
            </h5>
            <div class="card-body">
                {% render_table import_policies_table 'inc/table.html' %}
            </div>
        </div>
        <div class="card">
            <h5 class="card-header">
                Export Policies
            </h5>
            <div class="card-body">
                {% render_table export_policies_table 'inc/table.html' %}
            </div>
        </div>
        {% plugin_right_page object %}
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        {% plugin_full_width_page object %}
    </div>
</div>
{% endblock %}