{% load helpers %}
{% load perms %}
<form method="post">
    {% csrf_token %}
    <div class="card">
        <h5 class="card-header">
            {{ title }}
        </h5>
        <div class="card-body">
            <table class="table table-hover component-list">
                {% for obj in components %}
                    {% include component_template %}
                {% endfor %}
            </table>
        </div>
        {% if components and perms.dcim.change_consoleport %}
            <div class="card-footer noprint">
                <button type="submit" name="_rename" formaction="{% url 'dcim:consoleport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-sm">
                    <span class="mdi mdi-pencil" aria-hidden="true"></span> Rename
                </button>
                <button type="submit" name="_edit" formaction="{% url 'dcim:consoleport_bulk_edit' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-sm">
                    <span class="mdi mdi-pencil" aria-hidden="true"></span> Edit
                </button>
                <button type="submit" name="_disconnect" formaction="{% url 'dcim:consoleport_bulk_disconnect' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-sm">
                    <span class="mdi mdi-ethernet-cable-off" aria-hidden="true"></span> Disconnect
                </button>
            {% endif %}
            {% if components and perms.dcim.delete_consoleport %}
                <button type="submit" name="_delete" formaction="{% url 'dcim:consoleport_bulk_delete' %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-sm">
                    <span class="mdi mdi-trash-can-outline" aria-hidden="true"></span> Delete
                </button>
            {% endif %}
            {% if components and perms.dcim.add_consoleport %}
                <div class="float-end">
                    <a href="{% url 'dcim:consoleport_add' %}?device={{ device.pk }}&return_url={{ device.get_absolute_url }}" class="btn btn-sm btn-primary">
                        <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add console port
                    </a>
                </div>
            </div>
        {% endif %}
    </div>
</form>
