mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
views: New view to show setup need and progress
This commit is contained in:
parent
80d9f0d41e
commit
7a4a8fbc99
101
plinth/templates/setup.html
Normal file
101
plinth/templates/setup.html
Normal file
@ -0,0 +1,101 @@
|
||||
{% 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 setup_helper.current_operation %}
|
||||
<meta http-equiv="refresh" content="3" />
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2>{% trans "Installation" %}: {{ setup_helper.module.title }}</h2>
|
||||
|
||||
{% for paragraph in setup_helper.module.description %}
|
||||
<p>{{ paragraph|safe }}</p>
|
||||
{% endfor %}
|
||||
|
||||
{% if not setup_helper.current_operation %}
|
||||
|
||||
{% if setup_helper.get_state == 'needs-setup' %}
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
Install this application?
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="submit" class="btn btn-md btn-primary"
|
||||
value="{% trans "Install" %}" />
|
||||
</form>
|
||||
{% elif setup_helper.get_state == 'needs-update' %}
|
||||
<p>
|
||||
{% blocktrans trimmed %}
|
||||
This application needs an update. Update now?
|
||||
{% endblocktrans %}
|
||||
</p>
|
||||
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
|
||||
<input type="submit" class="btn btn-md btn-primary"
|
||||
value="{% trans "Update" %}" />
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
|
||||
{% if setup_helper.current_operation.step == 'pre' %}
|
||||
{% trans "Performing pre-install operation" %}
|
||||
{% elif setup_helper.current_operation.step == 'post' %}
|
||||
{% trans "Performing post-install operation" %}
|
||||
{% elif setup_helper.current_operation.step == 'install' %}
|
||||
{% with transaction=setup_helper.current_operation.transaction %}
|
||||
<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>
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
@ -22,6 +22,7 @@ Main Plinth views
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.views.generic import TemplateView
|
||||
import time
|
||||
|
||||
from plinth import package as package_module
|
||||
|
||||
@ -61,3 +62,28 @@ class PackageInstallView(TemplateView):
|
||||
before_install=self.kwargs.get('before_install'),
|
||||
on_install=self.kwargs.get('on_install'))
|
||||
return self.render_to_response(self.get_context_data())
|
||||
|
||||
|
||||
class SetupView(TemplateView):
|
||||
"""View to prompt and setup applications."""
|
||||
template_name = 'setup.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Return the context data rendering the template."""
|
||||
context = super(SetupView, self).get_context_data(**kwargs)
|
||||
context['setup_helper'] = self.kwargs['setup_helper']
|
||||
return context
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
"""Handle installing/upgrading applications.
|
||||
|
||||
Start the application setup, and refresh the page every few
|
||||
seconds to keep displaying the status.
|
||||
"""
|
||||
self.kwargs['setup_helper'].run_in_thread()
|
||||
|
||||
# Give a moment for the setup process to start and show
|
||||
# meaningful status.
|
||||
time.sleep(1)
|
||||
|
||||
return self.render_to_response(self.get_context_data())
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user