{% extends 'mesh/base.html' %}
{% load i18n mesh_node %}

{% block heading %}{% trans 'Current firmwares' %}{% endblock %}

{% block subcontent %}
    <a class="button" href="{% url "mesh.firmwares" %}">
        {% trans 'View available firmwares' %}
    </a>

    <table>
        <tr>
            <th>{% trans 'Created / First seen' %}</th>
            <th>{% trans 'Firmware' %}</th>
            <th>{% trans 'Build' %}</th>
            <th>{% trans 'IDF version' %}</th>
            <th>{% trans 'Installed on' %}</th>
        </tr>
        {% for firmware, nodes in firmwares %}
            <tr>
                <td>{{ firmware.created }}</td>
                <td>
                    {% if firmware.build %}
                        <a href="{% url "mesh.firmwares.detail" pk=firmware.build.version.pk %}">{{ firmware.project_name }} {{ firmware.version }}</a>
                    {% else %}
                        {{ firmware.project_name }} {{ firmware.version }}<br>
                        <small>{{ firmware.sha256_hash }}</small>
                    {% endif %}
                </td>
                <td>
                    {% if firmware.build %}
                        <a href="{% url "mesh.firmwares.build.detail" pk=firmware.build.pk %}">
                            {{ firmware.build.variant }} ({{ firmware.chip.pretty_name }})
                        </a>
                    {% else %}
                        ({{ firmware.chip.pretty_name }})
                    {% endif %}
                </td>
                <td>{{ firmware.idf_version }}</td>
                <td>
                    {% for node in nodes %}
                        {% mesh_node node %}<br>
                    {% endfor %}
                </td>
            </tr>
        {% endfor %}
    </table>
{% endblock %}
