<tr class="consoleport{% if cp.cable %} {{ cp.cable.get_status_class }}{% endif %}">

    {# Name #}
    <td>
        <i class="fa fa-fw fa-keyboard-o"></i> {{ cp }}
    </td>

    {# Type #}
    <td>
        {% if cp.type %}{{ cp.get_type_display }}{% else %}&mdash;{% endif %}
    </td>

    <td></td>

    {# Description #}
    <td>
        {{ cp.description }}
    </td>

    {# Cable #}
    <td>
        {% if cp.cable %}
            <a href="{{ cp.cable.get_absolute_url }}">{{ cp.cable }}</a>
            <a href="{% url 'dcim:consoleport_trace' pk=cp.pk %}" class="btn btn-primary btn-xs" title="Trace">
                <i class="fa fa-share-alt" aria-hidden="true"></i>
            </a>
        {% else %}
            &mdash;
        {% endif %}
    </td>

    {# Connection #}
    {% if cp.connected_endpoint %}
        <td>
            <a href="{% url 'dcim:device' pk=cp.connected_endpoint.device.pk %}">{{ cp.connected_endpoint.device }}</a>
        </td>
        <td>
            {{ cp.connected_endpoint }}
        </td>
    {% else %}
        <td colspan="2">
            <span class="text-muted">Not connected</span>
        </td>
    {% endif %}

    {# Actions #}
    <td class="text-right noprint">
        {% if cp.cable %}
            {% include 'dcim/inc/cable_toggle_buttons.html' with cable=cp.cable %}
        {% elif perms.dcim.add_cable %}
            <span class="dropdown">
                <button type="button" class="btn btn-success btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="glyphicon glyphicon-resize-small" aria-hidden="true"></span>
                </button>
                <ul class="dropdown-menu dropdown-menu-right">
                    <li><a href="{% url 'dcim:consoleport_connect' termination_a_id=cp.pk termination_b_type='console-server-port' %}?return_url={{ device.get_absolute_url }}">Console Server Port</a></li>
                    <li><a href="{% url 'dcim:consoleport_connect' termination_a_id=cp.pk termination_b_type='front-port' %}?return_url={{ device.get_absolute_url }}">Front Port</a></li>
                    <li><a href="{% url 'dcim:consoleport_connect' termination_a_id=cp.pk termination_b_type='rear-port' %}?return_url={{ device.get_absolute_url }}">Rear Port</a></li>
                </ul>
            </span>
        {% endif %}
        {% if perms.dcim.change_consoleport %}
            <a href="{% url 'dcim:consoleport_edit' pk=cp.pk %}" title="Edit port" class="btn btn-info btn-xs">
                <i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
            </a>
        {% endif %}
        {% if perms.dcim.delete_consoleport %}
            {% if cp.connected_endpoint %}
                <button class="btn btn-danger btn-xs" disabled="disabled">
                    <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                </button>
            {% else %}
                <a href="{% url 'dcim:consoleport_delete' pk=cp.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs">
                    <i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
                </a>
            {% endif %}
        {% endif %}
    </td>
</tr>
