{% extends "base.html" %}
{% comment %}
#
# This file is part of Plinth.
#
# 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 bootstrap %}
{% load i18n %}

{% block page_head %}

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

{% endblock %}


{% block content %}

  <h2>{% trans "Installation" %}</h2>

  {% if not is_installing %}

    <p>
      {% blocktrans trimmed %}
        This feature requires addtional packages to be installed.  Do
        you wish to install them?
      {% endblocktrans %}
    </p>

    <table class="table">
      <thead>
        <tr>
          <th>{% trans "Package" %}</th>
          <th>{% trans "Summary" %}</th>
        </tr>
      </thead>
      <tbody>
        {% for package_name, package in packages.items %}
          <tr>
            <td>{{ package_name }}</td>
            <td>{{ package.get_summary }}</td>
          </tr>
        {% endfor %}
      </tbody>
    </table>

    <form action="" method="post">
      {% csrf_token %}

      <input type="submit" class="btn btn-md btn-primary"
             value="{% trans "Install" %}" />
    </form>

  {% else %}

    {% for key, transaction in transactions.items %}
      <div>
        {% blocktrans trimmed with package_names=transaction.package_names|join:", " status=transaction.status_string %}
          Installing {{ package_names }}: {{ status }}
        {% endblocktrans %}
      </div>
      <div class="progress">
        <div class="progress-bar progress-bar-striped active"
             role="progressbar" aria-valuemin="0" aria-valuemax="100"
             aria-valuenow="{{ transaction.percentage }}"
             style="width: {{ transaction.percentage }}%">
          <span class="sr-only">
            {% blocktrans trimmed with percentage=transaction.percentage %}
              {{ percentage }}% complete
            {% endblocktrans %}
          </span>
        </div>
      </div>
    {% endfor %}

  {% endif %}

{% endblock %}
