mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
upgrades: Add progress page for initial update
Signed-off-by: James Valleroy <jvalleroy@mailbox.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
8b02c2bf3a
commit
f968ac6023
@ -0,0 +1,50 @@
|
|||||||
|
{% extends "base_firstboot.html" %}
|
||||||
|
{% comment %}
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% load bootstrap %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
{% block page_head %}
|
||||||
|
<style type="text/css">
|
||||||
|
.processing {
|
||||||
|
color: var(--progress-color);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<h2>{% trans "Update" %}</h2>
|
||||||
|
|
||||||
|
{% if is_busy %}
|
||||||
|
<div class="upgrades-status-frame clearfix">
|
||||||
|
<div class="upgrade-status-icon pull-left">
|
||||||
|
<span class="fa fa-refresh fa-spin fa-3x fa-pull-left processing"></span>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<strong>{% trans "Updating, please wait..." %}</strong>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
{% blocktrans trimmed %}
|
||||||
|
<strong>This may take a long time to complete.</strong> During
|
||||||
|
an update, this web interface may be temporarily unavailable and
|
||||||
|
show an error. In that case, refresh the page to continue.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
{% blocktrans %}
|
||||||
|
{{ box_name }} is up to date. Press Next to continue.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
<a title="{% trans 'Next' %}"
|
||||||
|
role="button" class="btn btn-primary"
|
||||||
|
href={% url next_step %}>
|
||||||
|
{% trans 'Next' %}
|
||||||
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@ -18,10 +18,9 @@
|
|||||||
|
|
||||||
<p>
|
<p>
|
||||||
{% blocktrans trimmed %}
|
{% blocktrans trimmed %}
|
||||||
<strong>This may take a long time to complete.</strong> During an update,
|
<strong>This may take a long time to complete.</strong> During
|
||||||
you cannot install apps. Also, this web interface may be temporarily
|
an update, this web interface may be temporarily unavailable and
|
||||||
unavailable and show an error. In that case, refresh the page to
|
show an error. In that case, refresh the page to continue.
|
||||||
continue.
|
|
||||||
{% endblocktrans %}
|
{% endblocktrans %}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|||||||
@ -16,5 +16,8 @@ urlpatterns = [
|
|||||||
views.BackportsFirstbootView.as_view(), name='backports-firstboot'),
|
views.BackportsFirstbootView.as_view(), name='backports-firstboot'),
|
||||||
url(r'^sys/upgrades/firstboot/update/$',
|
url(r'^sys/upgrades/firstboot/update/$',
|
||||||
views.UpdateFirstbootView.as_view(), name='update-firstboot'),
|
views.UpdateFirstbootView.as_view(), name='update-firstboot'),
|
||||||
|
url(r'^sys/upgrades/firstboot/update/progress/$',
|
||||||
|
views.UpdateFirstbootProgressView.as_view(),
|
||||||
|
name='update-firstboot-progress'),
|
||||||
url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'),
|
url(r'^sys/upgrades/upgrade/$', views.upgrade, name='upgrade'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect
|
|||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
|
from django.views.generic import TemplateView
|
||||||
from django.views.generic.edit import FormView
|
from django.views.generic.edit import FormView
|
||||||
|
|
||||||
from plinth import __version__, actions, package
|
from plinth import __version__, actions, package
|
||||||
@ -179,14 +180,35 @@ class UpdateFirstbootView(FormView):
|
|||||||
template_name = 'update-firstboot.html'
|
template_name = 'update-firstboot.html'
|
||||||
form_class = UpdateFirstbootForm
|
form_class = UpdateFirstbootForm
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""Define instance attribute."""
|
||||||
|
self.update = True
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
"""Return next firstboot step."""
|
"""Return next firstboot step."""
|
||||||
|
if self.update:
|
||||||
|
return reverse_lazy('upgrades:update-firstboot-progress')
|
||||||
|
|
||||||
return reverse_lazy(first_boot.next_step())
|
return reverse_lazy(first_boot.next_step())
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Run update if selected, and mark step as done."""
|
"""Run update if selected, and mark step as done."""
|
||||||
if form.cleaned_data['update_now']:
|
self.update = form.cleaned_data['update_now']
|
||||||
|
if self.update:
|
||||||
actions.superuser_run('upgrades', ['run'])
|
actions.superuser_run('upgrades', ['run'])
|
||||||
|
|
||||||
first_boot.mark_step_done('initial_update')
|
first_boot.mark_step_done('initial_update')
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
class UpdateFirstbootProgressView(TemplateView):
|
||||||
|
"""View to show initial update progress."""
|
||||||
|
template_name = 'update-firstboot-progress.html'
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['is_busy'] = (_is_updating()
|
||||||
|
or package.is_package_manager_busy())
|
||||||
|
context['next_step'] = first_boot.next_step()
|
||||||
|
context['refresh_page_sec'] = 3 if context['is_busy'] else None
|
||||||
|
return context
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user