mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +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>
|
||||
{% 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.
|
||||
<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>
|
||||
|
||||
|
||||
@ -16,5 +16,8 @@ urlpatterns = [
|
||||
views.BackportsFirstbootView.as_view(), name='backports-firstboot'),
|
||||
url(r'^sys/upgrades/firstboot/update/$',
|
||||
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'),
|
||||
]
|
||||
|
||||
@ -10,6 +10,7 @@ from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import redirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.generic import TemplateView
|
||||
from django.views.generic.edit import FormView
|
||||
|
||||
from plinth import __version__, actions, package
|
||||
@ -179,14 +180,35 @@ class UpdateFirstbootView(FormView):
|
||||
template_name = 'update-firstboot.html'
|
||||
form_class = UpdateFirstbootForm
|
||||
|
||||
def __init__(self):
|
||||
"""Define instance attribute."""
|
||||
self.update = True
|
||||
|
||||
def get_success_url(self):
|
||||
"""Return next firstboot step."""
|
||||
if self.update:
|
||||
return reverse_lazy('upgrades:update-firstboot-progress')
|
||||
|
||||
return reverse_lazy(first_boot.next_step())
|
||||
|
||||
def form_valid(self, form):
|
||||
"""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'])
|
||||
|
||||
first_boot.mark_step_done('initial_update')
|
||||
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