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

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

{% block page_head %}

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

{% endblock %}


{% block content %}

  <h2>{{ title }}</h2>

  {% 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 %}
