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

{% block title %}{{ circuit.provider }} - {{ circuit.cid }}{% endblock %}

{% block content %}
<div class="row">
    <div class="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-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>{{ circuit.provider }} - {{ circuit.cid }}</h1>
<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">
                <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 %}
                            <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>Speed</td>
                    <td>
                        {% if circuit.upstream_speed %}
                            <i class="fa fa-arrow-down" title="Downstream"></i> {{ circuit.port_speed_human }} &nbsp;
                            <i class="fa fa-arrow-up" title="Upstream"></i> {{ circuit.upstream_speed_human }}
                        {% else %}
                            {{ circuit.port_speed_human }}
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Commit Rate</td>
                    <td>
                        {% if circuit.commit_rate %}
                            {{ circuit.commit_rate_human }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        {% include 'inc/created_updated.html' with obj=circuit %}
	</div>
	<div class="col-md-6">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Termination</strong>
            </div>
            <table class="table table-hover panel-body">
                <tr>
                    <td>Site</td>
                    <td>
                        <a href="{% url 'dcim:site' slug=circuit.site.slug %}">{{ circuit.site }}</a>
                    </td>
                </tr>
                <tr>
                    <td>Termination</td>
                    <td>
                        {% if circuit.interface %}
                            <span><a href="{% url 'dcim:device' pk=circuit.interface.device.pk %}">{{ circuit.interface.device }}</a> {{ circuit.interface }}</span>
                        {% else %}
                            <span class="text-muted">Not defined</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Cross-Connect</td>
                    <td>
                        {% if circuit.xconnect_id %}
                            {{ circuit.xconnect_id }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
                <tr>
                    <td>Patch Panel/Port</td>
                    <td>
                        {% if circuit.pp_info %}
                            {{ circuit.pp_info }}
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
            </table>
        </div>
        <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>
{% endblock %}
