{% extends '_base.html' %}

{% block title %}{{ device }} - Inventory{% endblock %}

{% block content %}
{% include 'dcim/inc/_device_header.html' with active_tab='inventory' %}
<div class="row">
    <div class="col-md-4">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Chassis</strong>
            </div>
            <table class="table table-hover panel-body">
                <tr>
                    <td>Model</td>
                    <td>{{ device.device_type }}</td>
                </tr>
                <tr>
                    <td>Serial Number</td>
                    <td>{{ device.serial }}</td>
                </tr>
            </table>
        </div>
    </div>
    <div class="col-md-8">
        <div class="panel panel-default">
            <div class="panel-heading">
                <strong>Hardware</strong>
            </div>
            <table class="table table-hover table-condensed panel-body" id="hardware">
                <thead>
                    <tr>
                        <th>Module</th>
                        <th></th>
                        <th>Part Number</th>
                        <th>Serial Number</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    {% for m in modules %}
                        <tr>
                            <td>{{ m.name }}</td>
                            <td>{% if not m.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
                            <td>{{ m.part_id }}</td>
                            <td>{{ m.serial }}</td>
                            <td class="text-right">
                                {% if perms.dcim.change_module %}
                                    <a href="{% url 'dcim:module_edit' pk=m.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
                                {% endif %}
                                {% if perms.dcim.delete_module %}
                                    <a href="{% url 'dcim:module_delete' pk=m.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                                {% endif %}
                            </td>
                        </tr>
                        {% for m2 in m.submodules.all %}
                            <tr>
                                <td style="padding-left: 20px">{{ m2.name }}</td>
                                <td>{% if not m2.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
                                <td>{{ m2.part_id }}</td>
                                <td>{{ m2.serial }}</td>
                                <td class="text-right">
                                    {% if perms.dcim.change_module %}
                                        <a href="{% url 'dcim:module_edit' pk=m.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
                                    {% endif %}
                                    {% if perms.dcim.delete_module %}
                                        <a href="{% url 'dcim:module_delete' pk=m.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                                    {% endif %}
                                </td>
                            </tr>
                            {% for m3 in m2.submodules.all %}
                                <tr>
                                    <td style="padding-left: 40px">{{ m3.name }}</td>
                                    <td>{% if not m3.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
                                    <td>{{ m3.part_id }}</td>
                                    <td>{{ m3.serial }}</td>
                                    <td class="text-right">
                                        {% if perms.dcim.change_module %}
                                            <a href="{% url 'dcim:module_edit' pk=m.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
                                        {% endif %}
                                        {% if perms.dcim.delete_module %}
                                            <a href="{% url 'dcim:module_delete' pk=m.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                                        {% endif %}
                                    </td>
                                </tr>
                                {% for m4 in m3.submodules.all %}
                                    <tr>
                                        <td style="padding-left: 60px">{{ m4.name }}</td>
                                        <td>{% if not m4.discovered %}<i class="fa fa-asterisk" title="Manually created"></i>{% endif %}</td>
                                        <td>{{ m4.part_id }}</td>
                                        <td>{{ m4.serial }}</td>
                                        <td class="text-right">
                                            {% if perms.dcim.change_module %}
                                                <a href="{% url 'dcim:module_edit' pk=m.pk %}" class="btn btn-xs btn-warning"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>
                                            {% endif %}
                                            {% if perms.dcim.delete_module %}
                                                <a href="{% url 'dcim:module_delete' pk=m.pk %}" class="btn btn-xs btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                                            {% endif %}
                                        </td>
                                    </tr>
                                {% endfor %}
                            {% endfor %}
                        {% endfor %}
                    {% endfor %}
                </tbody>
            </table>
        </div>
        {% if perms.dcim.add_module %}
            <a href="{% url 'dcim:module_add' pk=device.pk %}" class="btn btn-success">
                <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
                Add a Module
            </a>
        {% endif %}
    </div>
</div>
{% endblock %}
