{% load helpers %}
<div class="card">
    <h5 class="card-header">Attachments</h5>
    <div class="card-body">
        {% with netbox_attachments=netbox_attachments %}
            {% if netbox_attachments.exists %}
                <table class="table table-hover">
                    <tr>
                        <th>Name</th>
                        <th>Size</th>
                        <th>Created</th>
                        <th></th>
                    </tr>
                    {% for attachment in netbox_attachments %}
                        <tr{% if not attachment.size %} class="table-danger"{% endif %}>
                            <td>
                                <a href="{% url 'plugins:netbox_attachments:netboxattachment' pk=attachment.pk %}">{{ attachment }}</a> (<a href="{{ attachment.file.url }}" target="_blank">Download</a>)
                            </td>
                            <td>{{ attachment.size|filesizeformat }}</td>
                            <td>{{ attachment.created }}</td>
                            <td class="text-end noprint">
                                <a href="{% url 'plugins:netbox_attachments:netboxattachment' pk=attachment.pk %}?return_url={{ request.path }}"
                                   class="btn btn-info btn-sm lh-1"
                                   title="Detail">
                                    <i class="mdi mdi-information-outline" aria-hidden="true"></i>
                                </a>
                                <a href="{% url 'plugins:netbox_attachments:netboxattachment_edit' pk=attachment.pk %}?return_url={{ request.path }}"
                                   class="btn btn-warning btn-sm lh-1"
                                   title="Edit Attachment">
                                    <i class="mdi mdi-pencil" aria-hidden="true"></i>
                                </a>
                                <a href="{% url 'plugins:netbox_attachments:netboxattachment_delete' pk=attachment.pk %}?return_url={{ request.path }}"
                                   class="btn btn-danger btn-sm lh-1"
                                   title="Delete Attachment">
                                    <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
                                </a>
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            {% else %}
                <div class="text-muted">None</div>
            {% endif %}
        {% endwith %}
    </div>
    <div class="card-footer text-end noprint">
        <a href="{% url 'plugins:netbox_attachments:netboxattachment_add' %}?content_type={{ object|content_type_id }}&object_id={{ object.pk }}&return_url={{ request.path }}"
           class="btn btn-primary btn-sm">
            <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Add Attachment
        </a>
    </div>
</div>
