{% extends "app.html" %}
{% comment %}
# SPDX-License-Identifier: AGPL-3.0-or-later
{% endcomment %}

{% load bootstrap %}
{% load i18n %}
{% load static %}

{% block configuration %}
  <form class="form" method="post">
    <div class="button-table">

      <div class="btn-toolbar">
        {% csrf_token %}
        <input type="submit" class="btn btn-primary" name="create"
               value="{% trans 'Create Snapshot' %}"/>
        <input type="submit" class="btn btn-danger button-secondary"
               name="delete_selected"
               value="{% trans 'Delete Snapshots' %}"
               {{ has_deletable_snapshots|yesno:',disabled="disabled"' }}/>
      </div>

      <div class="table-responsive">
        <table class="table">
          <thead>
            <th>{% trans "Number" %}</th>
            <th>{% trans "Date" %}</th>
            <th>{% trans "Description" %}</th>
            <th class="centered-column">{% trans "Rollback" %}</th>
            <th class="centered-column"><input type="checkbox" id="select-all"></th>
          </thead>
          <tbody>
            {% for snapshot in snapshots %}
              <tr>
                <td>
                  {{ snapshot.number }}
                  {% if snapshot.is_default %}
                    <span class="badge badge-secondary">
                      {% trans "will be used at next boot" %}
                    </span>
                  {% endif %}
                  {% if snapshot.is_active %}
                    <span class="badge badge-success">
                      {% trans "in use" %}
                    </span>
                  {% endif %}
                </td>
                <td>{{ snapshot.date }}</td>
                <td>{% trans snapshot.description %}</td>
                <td class="centered-column">
                  <a href="{% url 'snapshot:rollback' snapshot.number %}"
                     class="btn btn-default btn-sm" role="button"
                     title="{% blocktrans trimmed with number=snapshot.number %}
                           Rollback to snapshot #{{ number }}
                     {% endblocktrans %}">
                    <span class="fa fa-repeat"
                          aria-hidden="true"></span>
                  </a>
                </td>
                <td class="centered-column">
                  {% if not snapshot.is_default and not snapshot.is_active %}
                    <input type="checkbox" name="snapshot_list" value={{ snapshot.number }} />
                  {% endif %}
                </td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
      </div>
    </div>
</form>
{% endblock %}

{% block page_js %}
  <script type="text/javascript" src="{% static 'snapshot/snapshot.js' %}"></script>
{% endblock %}

