{% load helpers %}
{% load plugins %}
{% load storage %}
{% load render_table from django_tables2 %}
{% load perms %}

<div class="card">
    <h5 class="card-header">Template Drives & Partition</h5>
    <div class="card-body">
        {% if lonely_drives or drives %}
        <table class="table table-hover">
            <tr>
                <td>Drive</td>
                <td>Drive Size</td>
                <td>Drive Cluster</td>
                <td>Amount Partition</td>
            </tr>
            {% for key,value in partition_dict.items %}
            <tr>
                <td>{{ value|placeholder }}</td>
                <td>{{ drive.size|placeholder }} MB</td>
                <td>{{ drive.cluster|linkify|placeholder }}</td>
                <td>{{ 0 }}</td>
            </tr>
            {% endfor %}
            {% for drive in lonely_drives %}
            <tr>
                <td>{{ drive.identifier|placeholder }}</td>
                <td>{{ drive.size|placeholder }} MB</td>
                <td>{{ drive.cluster|linkify|placeholder }}</td>
                <td>{{ 0 }}</td>
            </tr>
            {% endfor %}
            {% for drive in drives %}
            <tr>
                <td>{{ drive.identifier|placeholder }}</td>
                <td>{{ drive.size|placeholder }} MB</td>
                <td>{{ drive.cluster|linkify|placeholder }}</td>
                <td>{% get_partition_amount drive %}</td>
                <td>{% get_partitions drive %}</td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="text-muted">None</div>
        {% endif %}
    </div>
    <div class="card-footer text-end noprint">
        <a href="{% url 'plugins:netbox_storage:template_partition_add' %}?platform={{ object.id }}&return_url={% url 'dcim:platform' pk=object.pk %}" class="btn btn-sm btn-primary">
            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Partition to drive
        </a>
        <a href="{% url 'plugins:netbox_storage:template_drive_add' %}?platform={{ object.id }}&return_url={% url 'dcim:platform' pk=object.pk %}" class="btn btn-sm btn-primary">
            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Drive
        </a>
    </div>
</div>