{% extends 'app-subsubmenu.html' %}
{% comment %}
#
# This file is part of FreedomBox.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
{% endcomment %}

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

{% block page_head %}

  {% if is_busy %}
    <noscript>
      <meta http-equiv="refresh" content="3" />
    </noscript>
  {% endif %}

{% endblock %}


{% block configuration %}

  {% if not is_busy %}
  <p>
    <form class="form" method="post" action="{% url 'upgrades:upgrade' %}">
      {% csrf_token %}

      <input type="submit" class="btn btn-primary"
             value="{% trans "Update now" %}"/>
    </form>
  </p>
  {% endif %}

  {% if is_busy %}
  <button type="button" disabled="disabled"
          class="running-status-parent btn btn-default" >
    <span class="running-status loading"></span>
    {% trans "Updating..." %}
  </button>
  {% endif %}

  <p>
    {% blocktrans trimmed %}
      <strong>This may take a long time to complete</strong>. During an update,
      you cannot install apps. Also, this web interface may be temporarily
      unavailable and show an error. In that case, refresh the page to
      continue.
    {% endblocktrans %}
  </p>

  {% if log %}
  <p>
    <a class="btn btn-default collapsed collapsible-button" role="button"
       data-toggle="collapse" href="#collapse-log" aria-expanded="false"
       aria-controls="collapse-log">
      <span class="fa fa-chevron-right fa-fw" aria-hidden="true"></span>
      {% trans "Toggle recent update logs" %}
    </a>

    <div class="collapse" id="collapse-log">
      <pre>{{ log }}</pre>
    </div>
  </p>
  {% endif %}

{% endblock %}

{% block page_js %}

  {% if is_busy %}
    <script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
  {% endif %}
{% endblock %}
