{% extends "core/base.html" %}
{% block section_title %}{{ computer }}{% endblock %}
{% block content %}
<div class="ui cards">
    <div class="card">
    <div class="content">
    <div class="header">Description</div>
    <div class="description"><p>{{ computer.description }}</p></div>
    <table class="ui celled table">
        <tr>
            <td><b>OS:</b></td>
            <td>{{ computer.os }}</td>
        </tr>
        <tr>
            <td><b>Serial Number:</b></td>
            <td><code>{{ computer.serialnumber }}</code></td>
        </tr>
        <tr>
            <td><b>Category:</b></td>
            <td>{{ computer.category }}</td>
        </tr>
        <tr>
            <td><b>Owner:</b></td>
            <td>{{ computer.owner }}</td>
        </tr>
        <tr>
            <td><b>Customer:</b></td>
            <td><a href="{% url 'customer' computer.customer.id %}">{{ computer.customer }}</a></td>
        </tr>
        <tr>
            <td><b>Manufacturer:</b></td>
            <td>{{ computer.manufacturer }}</td>
        </tr>
        <tr>
            <td><b>Location:</b></td>
            <td>{{ computer.location }}</td>
        </tr>
        {% if computer.user %}
        <tr>
            <td><b>User:</b></td>
            <td><a href="{% url 'user' computer.user.id %}">{{ computer.user }}</a></td>
        </tr>
        {% endif %}
        <tr>
            <td><b>Installation Date:</b></td>
            <td>{{ computer.installation_date }}</td>
        </tr>
        <tr>
            <td><b>IPs:</b></td>
            <td>
                {% for net_id, ip in computer.ips.items %}
                    <a href="{% url 'net' net_id %}">{{ip}}</a><br>
                {% endfor %}
            </td>
        </tr>
    </table>
    </div>
    </div>
    {% if software_relations or backup_relations or license_list %}
    <div class="card">
    <div class="content">
    {% if software_relations %}
    <div class="header">Software</div>
    <ul>
    {% for relation in software_relations %}
        <li>{{ relation.software }}</li>
    {% endfor %}
    </ul>
    {% endif %}
    {% if license_list %}
    <div class="header">Licenses</div>
    <table class="ui celled table">
    {% for license in license_list %}
    <tr>
        <td>{{ license.license.software }}</td>
        <td><code>{{ license.license.key }}</code></td>
    </tr>
    {% endfor %}
    </table>
    {% endif %}
    {% if backup_relations %}
    <div class="header">Backup</div>
    <ul>
        {% for backup in backup_relations %}
        <li><a href="{% url 'backup' backup.id %}">{{ backup }}</a></li>
        {% endfor %}
    </ul>
    {% endif %}
    </div>
    </div>
    {% endif %}

    {% if cpu_relations or ram_relations or disks_relations or raid_disk_pairs or computer.host %}
    <div class="card">
    <div class="content">
    {% if cpu_relations or ram_relations or disks_relations or computer.host %}
    <div class="header">Hardware</div>
    <table class="ui celled table">
    {% if cpu_relations %}
        <tr>
            <td><b>CPUs:</b></td>
            <td>
            {% for cpu in cpu_relations %}
                {{ cpu.amount }}x {{ cpu.cpu }}<br>
            {% endfor %}
            </td>
        </tr>
    {% endif %}
    {% if ram_relations %}
        <tr>
        <td><b>RAM Modules:</b></td>
        <td>
            {% for module in ram_relations %}
                {{ module.amount }}x {{ module.ram }}<br>
            {% endfor %}
        </td>
    </tr>
    {% endif %}
    {% if disks_relations %}
    <tr>
    <td><b>Disks:</b></td>
    <td>
            {% for disk in disks_relations %}
                {{ disk.amount }}x {{ disk.disk }}<br>
            {% endfor %}
    </td>
    </tr>
    {% endif %}
    </table>
    {% endif %}

    {% if raid_disk_pairs %}
    <div class="header">RAID</div>
    {% for raid, disks in raid_disk_pairs.items %}
    <table class="ui celled table">
        <tr>
            <td><b>Type:</b></td>
            <td>{{ raid.raid_type }}</td>
        </tr>
        <tr>
            <td><b>Usable Space</b></td>
            <td>{{ raid.usable_space }}</td>
        </tr>
        {% if disks %}
        {% for disk in disks %}
        <tr>
            <td><b>Disk Type</b></td>
            <td>{{ disk.disk }}</td>
        </tr>
        <tr>
            <td><b>Amount</b></td>
            <td>{{ disk.disk_amount }}</td>
        </tr>
        {% endfor %}
        {% endif %}
    </table>
    {% endfor %}
    {% endif %}

    {% if computer.host %}
    <div class="header">Host</div>
    <div class="description">
            <a href="{% url 'computer' computer.host.id %}">{{ computer.host }}</a>
    </div>
    {% endif %}
    </div>
    </div>
    {% endif %}

</div>
{% endblock %}
