{% extends '_base.html' %}
{% load helpers %}

{% block content %}
<div class="row">
    <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">
    {% if perms.circuits.change_circuit %}
		<a href="{% url 'circuits:circuit_edit' pk=circuit.pk %}" class="btn btn-warning">
			<span class="fa fa-pencil" aria-hidden="true"></span>
			Edit this circuit
		</a>
    {% endif %}
    {% if perms.circuits.delete_circuit %}
		<a href="{% url 'circuits:circuit_delete' pk=circuit.pk %}" class="btn btn-danger">
			<span class="fa fa-trash" aria-hidden="true"></span>
			Delete this circuit
		</a>
    {% endif %}
</div>
<h1>{% block title %}{{ circuit.provider }} - {{ circuit.cid }}{% endblock %}</h1>
{% include 'inc/created_updated.html' with obj=circuit %}
<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>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.name }}</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>
                        {% if circuit.install_date %}
                            {{ circuit.install_date }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Commit Rate</td>
                    <td>
                        {% if circuit.commit_rate %}
                            {{ circuit.commit_rate|humanize_speed }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Description</td>
                    <td>
                        {% if circuit.description %}
                            {{ circuit.description }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% with circuit.get_custom_fields as custom_fields %}
            {% include 'inc/custom_fields_panel.html' %}
        {% endwith %}
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Comments</strong>
            </div>
            <div class="panel-body">
                {% if circuit.comments %}
                    {{ circuit.comments|gfm }}
                {% else %}
                    <span class="text-muted">None</span>
                {% endif %}
            </div>
        </div>
	</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' %}
    </div>
</div>
{% endblock %}
