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

{% block title %}{{ circuit }}{% endblock %}

{% block header %}
    <div class="row noprint">
        <div class="col-sm-8 col-md-9">
            <ol class="breadcrumb">
                <li><a href="{% url 'circuits:circuit_list' %}">Circuits</a></li>
                <li><a href="{% url 'circuits:circuit_list' %}?provider={{ circuit.provider.slug }}">{{ circuit.provider }}</a></li>
                <li>{{ circuit.cid }}</li>
            </ol>
        </div>
        <div class="col-sm-4 col-md-3">
            <form action="{% url 'circuits:circuit_list' %}" method="get">
                <div class="input-group">
                    <input type="text" name="q" class="form-control" />
                    <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 circuit %}
        {% if perms.circuits.add_circuit %}
            {% clone_button circuit %}
        {% endif %}
        {% if perms.circuits.change_circuit %}
            {% edit_button circuit %}
        {% endif %}
        {% if perms.circuits.delete_circuit %}
            {% delete_button circuit %}
        {% endif %}
    </div>
    <h1>{{ circuit }}</h1>
    {% include 'inc/created_updated.html' with obj=circuit %}
    <div class="pull-right noprint">
        {% custom_links circuit %}
    </div>
    <ul class="nav nav-tabs">
        <li role="presentation"{% if not active_tab %} class="active"{% endif %}>
            <a href="{{ circuit.get_absolute_url }}">Circuit</a>
        </li>
        {% if perms.extras.view_objectchange %}
            <li role="presentation"{% if active_tab == 'changelog' %} class="active"{% endif %}>
                <a href="{% url 'circuits:circuit_changelog' pk=circuit.pk %}">Change Log</a>
            </li>
        {% endif %}
    </ul>
{% endblock %}

{% block content %}
<div class="row">
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Circuit</strong>
            </div>
            <table class="table table-hover panel-body attr-table">
                <tr>
                    <td>Status</td>
                    <td>
                        <span class="label label-{{ circuit.get_status_class }}">{{ circuit.get_status_display }}</span>
                    </td>
                </tr>
                <tr>
                    <td>Provider</td>
                    <td>
                        <a href="{% url 'circuits:provider' slug=circuit.provider.slug %}">{{ circuit.provider }}</a>
                    </td>
                </tr>
                <tr>
                    <td>Circuit ID</td>
                    <td>{{ circuit.cid }}</td>
                </tr>
                <tr>
                    <td>Type</td>
                    <td><a href="{{ circuit.type.get_absolute_url }}">{{ circuit.type }}</a></td>
                </tr>
                <tr>
                    <td>Tenant</td>
                    <td>
                        {% if circuit.tenant %}
                            {% if circuit.tenant.group %}
                                <a href="{{ circuit.tenant.group.get_absolute_url }}">{{ circuit.tenant.group }}</a>
                                <i class="fa fa-angle-right"></i>
                            {% endif %}
                            <a href="{{ circuit.tenant.get_absolute_url }}">{{ circuit.tenant }}</a>
                        {% else %}
                            <span class="text-muted">None</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Install Date</td>
                    <td>{{ circuit.install_date|placeholder }}</td>
                </tr>
                <tr>
                    <td>Commit Rate</td>
                    <td>{{ circuit.commit_rate|humanize_speed|placeholder }}</td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>{{ circuit.description|placeholder }}</td>
                </tr>
            </table>
        </div>
        {% include 'inc/custom_fields_panel.html' with obj=circuit %}
        {% include 'extras/inc/tags_panel.html' with tags=circuit.tags.all url='circuits:circuit_list' %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body rendered-markdown">
                {% if circuit.comments %}
                    {{ circuit.comments|render_markdown }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
        {% plugin_left_page circuit %}
	</div>
	<div class="col-md-6">
        {% include 'circuits/inc/circuit_termination.html' with termination=termination_a side='A' %}
        {% include 'circuits/inc/circuit_termination.html' with termination=termination_z side='Z' %}
        {% plugin_right_page circuit %}
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        {% plugin_full_width_page circuit %}
    </div>
</div>
{% endblock %}
