mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
upgrades: Combine into single page with manual update
Manual update is placed in a new section under Configuration. Tests: - Ran manual update with packages to be upgraded. - Busy indicator is shown as expected. - Log display button appears when logs are available. - Logs can be expanded and collapsed. Closes: #1771. Signed-off-by: James Valleroy <jvalleroy@mailbox.org> [sunil: Change the update now button into default priority button] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
28b5ad9191
commit
cf7ff2d1b6
@ -1,74 +0,0 @@
|
|||||||
{% extends 'base.html' %}
|
|
||||||
{% comment %}
|
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
||||||
{% endcomment %}
|
|
||||||
|
|
||||||
{% load i18n %}
|
|
||||||
{% load static %}
|
|
||||||
|
|
||||||
{% block page_head %}
|
|
||||||
|
|
||||||
{% if is_busy %}
|
|
||||||
<noscript>
|
|
||||||
<meta http-equiv="refresh" content="3" />
|
|
||||||
</noscript>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
<h2>{{ title }}</h2>
|
|
||||||
|
|
||||||
{% if not is_busy %}
|
|
||||||
<p>
|
|
||||||
<form class="form" method="post" action="{% url 'upgrades:upgrade' %}">
|
|
||||||
{% csrf_token %}
|
|
||||||
|
|
||||||
<input type="submit" class="btn btn-primary"
|
|
||||||
value="{% trans "Update now" %}"/>
|
|
||||||
</form>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if is_busy %}
|
|
||||||
<button type="button" disabled="disabled"
|
|
||||||
class="running-status-parent btn btn-default" >
|
|
||||||
<span class="running-status loading"></span>
|
|
||||||
{% trans "Updating..." %}
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<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.
|
|
||||||
{% endblocktrans %}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{% if log %}
|
|
||||||
<p>
|
|
||||||
<a class="btn btn-default collapsed collapsible-button" role="button"
|
|
||||||
data-toggle="collapse" href="#collapse-log" aria-expanded="false"
|
|
||||||
aria-controls="collapse-log">
|
|
||||||
<span class="fa fa-chevron-right fa-fw" aria-hidden="true"></span>
|
|
||||||
{% trans "Toggle recent update logs" %}
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="collapse" id="collapse-log">
|
|
||||||
<pre>{{ log }}</pre>
|
|
||||||
</div>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block page_js %}
|
|
||||||
|
|
||||||
{% if is_busy %}
|
|
||||||
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
@ -5,10 +5,63 @@
|
|||||||
|
|
||||||
{% load bootstrap %}
|
{% load bootstrap %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
{% block status %}
|
{% block page_head %}
|
||||||
<a href="{% url 'upgrades:upgrade' %}" class="btn btn-default"
|
{% if is_busy %}
|
||||||
role="button" title="{% trans 'Manual update' %}">
|
<noscript>
|
||||||
{% trans 'Manual update' %}
|
<meta http-equiv="refresh" content="3" />
|
||||||
</a>
|
</noscript>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_content %}
|
||||||
|
<h3>{% trans "Manual update" %}</h3>
|
||||||
|
{% if is_busy %}
|
||||||
|
<p>
|
||||||
|
<button type="button" disabled="disabled"
|
||||||
|
class="running-status-parent btn btn-default" >
|
||||||
|
<span class="running-status loading"></span>
|
||||||
|
{% trans "Updating..." %}
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
{% else %}
|
||||||
|
<p>
|
||||||
|
<form class="form" method="post" action="{% url 'upgrades:upgrade' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="submit" class="btn btn-default"
|
||||||
|
value="{% trans "Update now" %}"/>
|
||||||
|
</form>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<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.
|
||||||
|
{% endblocktrans %}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
{% if log %}
|
||||||
|
<p>
|
||||||
|
<a class="btn btn-default collapsed collapsible-button" role="button"
|
||||||
|
data-toggle="collapse" href="#collapse-log" aria-expanded="false"
|
||||||
|
aria-controls="collapse-log">
|
||||||
|
<span class="fa fa-chevron-right fa-fw" aria-hidden="true"></span>
|
||||||
|
{% trans "Show recent update logs" %}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="collapse" id="collapse-log">
|
||||||
|
<pre>{{ log }}</pre>
|
||||||
|
</div>
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block page_js %}
|
||||||
|
{% if is_busy %}
|
||||||
|
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ FreedomBox app for upgrades.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.template.response import TemplateResponse
|
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 _
|
||||||
|
|
||||||
@ -26,6 +26,12 @@ class UpgradesConfigurationView(AppView):
|
|||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
return {'auto_upgrades_enabled': upgrades.is_enabled()}
|
return {'auto_upgrades_enabled': upgrades.is_enabled()}
|
||||||
|
|
||||||
|
def get_context_data(self, *args, **kwargs):
|
||||||
|
context = super().get_context_data(*args, **kwargs)
|
||||||
|
context['is_busy'] = package.is_package_manager_busy()
|
||||||
|
context['log'] = get_log()
|
||||||
|
return context
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
"""Apply the form changes."""
|
"""Apply the form changes."""
|
||||||
old_status = form.initial
|
old_status = form.initial
|
||||||
@ -62,18 +68,11 @@ def get_log():
|
|||||||
|
|
||||||
def upgrade(request):
|
def upgrade(request):
|
||||||
"""Serve the upgrade page."""
|
"""Serve the upgrade page."""
|
||||||
is_busy = package.is_package_manager_busy()
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
try:
|
try:
|
||||||
actions.superuser_run('upgrades', ['run'])
|
actions.superuser_run('upgrades', ['run'])
|
||||||
messages.success(request, _('Upgrade process started.'))
|
messages.success(request, _('Upgrade process started.'))
|
||||||
is_busy = True
|
|
||||||
except ActionError:
|
except ActionError:
|
||||||
messages.error(request, _('Starting upgrade failed.'))
|
messages.error(request, _('Starting upgrade failed.'))
|
||||||
|
|
||||||
return TemplateResponse(request, 'upgrades.html', {
|
return redirect(reverse_lazy('upgrades:index'))
|
||||||
'title': _('Manual update'),
|
|
||||||
'is_busy': is_busy,
|
|
||||||
'log': get_log()
|
|
||||||
})
|
|
||||||
|
|||||||
@ -56,4 +56,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user