<tr class="powerport{% if pp.cable %} {{ pp.cable.get_status_class }}{% endif %}">

    {# Name #}
    <td>
        <i class="fa fa-fw fa-bolt"></i> {{ pp }}
    </td>

    {# Type #}
    <td>
        {{ pp.get_type_display }}
    </td>

    {# Current draw #}
    <td>
        {% if pp.allocated_draw %}
            {{ pp.allocated_draw }}W{% if pp.maximum_draw %} ({{ pp.maximum_draw }}W max){% endif %}
        {% elif pp.maximum_draw %}
            {{ pp.maximum_draw }}W
        {% endif %}
    </td>

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

    {# Cable #}
    <td>
        {% if pp.cable %}
            <a href="{{ pp.cable.get_absolute_url }}">{{ pp.cable }}</a>
            <a href="{% url 'dcim:powerport_trace' pk=pp.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 pp.connected_endpoint.device %}
        <td>
            <a href="{% url 'dcim:device' pk=pp.connected_endpoint.device.pk %}">{{ pp.connected_endpoint.device }}</a>
        </td>
        <td>
            {{ pp.connected_endpoint }}
        </td>
    {% elif pp.connected_endpoint %}
        <td colspan="2">
            <a href="{{ pp.connected_endpoint.get_absolute_url }}">{{ pp.connected_endpoint }}</a>
        </td>
    {% else %}
        <td colspan="2">
            <span class="text-muted">Not connected</span>
        </td>
    {% endif %}

    {# Actions #}
    <td class="text-right noprint">
        {% if pp.cable %}
            {% include 'dcim/inc/cable_toggle_buttons.html' with cable=pp.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:powerport_connect' termination_a_id=pp.pk termination_b_type='power-outlet' %}?return_url={{ device.get_absolute_url }}">Power Outlet</a></li>
                    <li><a href="{% url 'dcim:powerport_connect' termination_a_id=pp.pk termination_b_type='power-feed' %}?return_url={{ device.get_absolute_url }}">Power Feed</a></li>
                </ul>
            </span>
        {% endif %}
        {% if perms.dcim.change_powerport %}
            <a href="{% url 'dcim:powerport_edit' pk=pp.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_powerport %}
            {% if pp.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:powerport_delete' pk=pp.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>
