Sunil Mohan Adapa de82f5002d
setup: Handle showing setup page after app completes installation
- During the rendering of the view, the state of installation may keep changing.
  This may lead to inconsistencies in the page. Avoid that by collecting the
  state once and then reusing that throughout the rendering process.

- During the time that setup middleware's checked of setup state of an app and
  rendering of app's setup view, if the setup process could get completed. This
  will lead to setup page being shown even after the application is installed.
  Handle this case and show a proper page instead of 'Submit Query' button on
  the page. Fixes #1360. This can be easily replicated by introducing a 10
  second sleep after setup middle checks of the application is 'up-to-date'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-01-14 17:40:02 -05:00

146 lines
4.7 KiB
HTML

{% extends "base.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 bootstrap %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if setup_current_operation or setup_state == 'up-to-date' %}
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
{% block content %}
<h2>{% trans "Installation" %}: {{ setup_helper.module.short_description }} ({{ setup_helper.module.name }}) </h2>
{% for paragraph in setup_helper.module.description %}
<p>{{ paragraph|safe }}</p>
{% endfor %}
{% if setup_helper.module.manual_page %}
<p class="manual-page">
<a href="{% url 'help:manual-page' setup_helper.module.manual_page %}">
{% trans 'Learn more...' %}
</a>
</p>
{% endif %}
{% include "clients.html" with clients=setup_helper.module.clients %}
{% if setup_state == 'up-to-date' %}
{% trans "Application installated." %}
{% elif not setup_current_operation %}
<p>
{% if setup_state == 'needs-setup' %}
{% blocktrans trimmed %}
Install this application?
{% endblocktrans %}
{% elif setup_state == 'needs-update' %}
{% blocktrans trimmed %}
This application needs an update. Update now?
{% endblocktrans %}
{% endif %}
</p>
<form class="form-install" action="" method="post">
{% csrf_token %}
{% if package_manager_is_busy %}
<div class="alert alert-warning" role="alert">
{% blocktrans trimmed %}
Another installation or upgrade is already running.
Please wait for a few moments before trying again.
{% endblocktrans %}
</div>
{% elif setup_helper.has_unavailable_packages %}
<div class="alert alert-warning" role="alert">
{% blocktrans trimmed %}
This application is currently not available in your distribution.
{% endblocktrans %}
<button type="submit" class="btn btn-default btn-sm" name="refresh-packages">
<span class="glyphicon glyphicon-refresh"></span> Check again
</button>
</div>
{% endif %}
<input type="submit" class="btn btn-md btn-primary" name="install"
{% if package_manager_is_busy or setup_helper.has_unavailable_packages %}
disabled="disabled"
{% endif %}
{% if setup_state == 'needs-setup' %}
value="{% trans "Install" %}"
{% elif setup_state == 'needs-upgrade' %}
value="{% trans "Update" %}"
{% endif %} />
</form>
{% else %}
{% if setup_current_operation.step == 'pre' %}
<div class="install-state-pre">
{% trans "Performing pre-install operation" %}
</div>
{% elif setup_current_operation.step == 'post' %}
<div class="install-state-post">
{% trans "Performing post-install operation" %}
</div>
{% elif setup_current_operation.step == 'install' %}
{% with transaction=setup_current_operation.transaction %}
<div class="install-state-installing">
{% 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>
{% endwith %}
{% endif %}
{% endif %}
{% endblock %}
{% block page_js %}
{% if setup_current_operation or setup_state == 'up-to-date' %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}