mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
apps: Do not show status block if service is running
If at least one related service/daemon is not running, show the alert if app is enabled, otherwise set alert as hidden (for functional tests). Closes #1752 Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Minor code simplification in app template, status section] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
b668e62f6f
commit
995af05866
@ -23,12 +23,12 @@ def get_service_module(service_name):
|
||||
|
||||
def is_running(browser, service_name):
|
||||
interface.nav_to_module(browser, get_service_module(service_name))
|
||||
return len(browser.find_by_css('.running-status.active')) != 0
|
||||
return len(browser.find_by_id('service-not-running')) == 0
|
||||
|
||||
|
||||
def is_not_running(browser, service_name):
|
||||
interface.nav_to_module(browser, get_service_module(service_name))
|
||||
return len(browser.find_by_css('.running-status.inactive')) != 0
|
||||
return len(browser.find_by_id('service-not-running')) != 0
|
||||
|
||||
|
||||
def eventually(function, args=[], timeout=30):
|
||||
|
||||
@ -17,7 +17,6 @@ from .forms import BindForm
|
||||
class BindAppView(AppView): # pylint: disable=too-many-ancestors
|
||||
"""A specialized view for configuring Bind."""
|
||||
app_id = 'bind'
|
||||
show_status_block = True
|
||||
form_class = BindForm
|
||||
template_name = 'bind.html'
|
||||
port_forwarding_info = port_forwarding_info
|
||||
|
||||
@ -8,7 +8,6 @@ from plinth.views import AppView
|
||||
|
||||
class CockpitAppView(AppView):
|
||||
app_id = 'cockpit'
|
||||
show_status_block = True
|
||||
template_name = 'cockpit.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
|
||||
@ -22,7 +22,6 @@ class ConfigAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
form_class = ConfigurationForm
|
||||
app_id = 'config'
|
||||
show_status_block = False
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the current status"""
|
||||
|
||||
@ -17,7 +17,6 @@ class CoquelicotAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'coquelicot'
|
||||
form_class = CoquelicotForm
|
||||
show_status_block = True
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the status of the service to fill in the form."""
|
||||
|
||||
@ -23,7 +23,6 @@ class GitwebAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
|
||||
app_id = 'gitweb'
|
||||
show_status_block = False
|
||||
template_name = 'gitweb_configure.html'
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
|
||||
@ -26,7 +26,6 @@ subsubmenu = [{
|
||||
class I2PAppView(AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'i2p'
|
||||
show_status_block = True
|
||||
template_name = 'i2p.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
@ -18,7 +18,6 @@ from .forms import IkiwikiCreateForm
|
||||
class IkiwikiAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'ikiwiki'
|
||||
show_status_block = False
|
||||
template_name = 'ikiwiki_configure.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
||||
@ -13,7 +13,6 @@ class JSXCAppView(AppView):
|
||||
"""Show ejabberd as an app."""
|
||||
app_id = 'jsxc'
|
||||
template_name = 'jsxc.html'
|
||||
show_status_block = False
|
||||
|
||||
|
||||
class JsxcView(TemplateView):
|
||||
|
||||
@ -22,7 +22,6 @@ class MediaWikiAppView(views.AppView):
|
||||
"""App configuration page."""
|
||||
app_id = 'mediawiki'
|
||||
form_class = MediaWikiForm
|
||||
show_status_block = False
|
||||
template_name = 'mediawiki.html'
|
||||
|
||||
def get_initial(self):
|
||||
|
||||
@ -17,7 +17,6 @@ from .forms import MinetestForm
|
||||
class MinetestAppView(AppView): # pylint: disable=too-many-ancestors
|
||||
"""A specialized view for configuring minetest."""
|
||||
app_id = 'minetest'
|
||||
show_status_block = True
|
||||
template_name = 'minetest.html'
|
||||
form_class = MinetestForm
|
||||
port_forwarding_info = minetest.port_forwarding_info
|
||||
|
||||
@ -8,9 +8,5 @@ from django.conf.urls import url
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/mldonkey/$',
|
||||
AppView.as_view(
|
||||
app_id='mldonkey',
|
||||
show_status_block=True,
|
||||
), name='index'),
|
||||
url(r'^apps/mldonkey/$', AppView.as_view(app_id='mldonkey'), name='index')
|
||||
]
|
||||
|
||||
@ -48,7 +48,6 @@ def index(request):
|
||||
'port_forwarding_info': openvpn.port_forwarding_info,
|
||||
'status': status,
|
||||
'form': form,
|
||||
'show_status_block': True,
|
||||
'is_running': status['is_running'],
|
||||
'has_diagnostics': True,
|
||||
'is_enabled': status['enabled'],
|
||||
|
||||
@ -8,7 +8,6 @@ from django.conf.urls import url
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/roundcube/$',
|
||||
AppView.as_view(app_id='roundcube', show_status_block=False),
|
||||
name='index'),
|
||||
url(r'^apps/roundcube/$', AppView.as_view(app_id='roundcube'),
|
||||
name='index')
|
||||
]
|
||||
|
||||
@ -17,7 +17,6 @@ class SearxAppView(views.AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'searx'
|
||||
form_class = SearxForm
|
||||
show_status_block = False
|
||||
|
||||
def get_initial(self):
|
||||
"""Return the status of the service to fill in the form."""
|
||||
|
||||
@ -8,7 +8,5 @@ from django.conf.urls import url
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/shaarli/$',
|
||||
AppView.as_view(app_id='shaarli', show_status_block=False),
|
||||
name='index'),
|
||||
url(r'^apps/shaarli/$', AppView.as_view(app_id='shaarli'), name='index')
|
||||
]
|
||||
|
||||
@ -26,7 +26,6 @@ class StorageAppView(views.AppView):
|
||||
"""Show storage information."""
|
||||
app_id = 'storage'
|
||||
template_name = 'storage.html'
|
||||
show_status_block = False
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
"""Return template context data."""
|
||||
|
||||
@ -8,7 +8,6 @@ from django.conf.urls import url
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/syncthing/$',
|
||||
AppView.as_view(app_id='syncthing', show_status_block=True),
|
||||
name='index'),
|
||||
url(r'^apps/syncthing/$', AppView.as_view(app_id='syncthing'),
|
||||
name='index')
|
||||
]
|
||||
|
||||
@ -45,7 +45,6 @@ def index(request):
|
||||
'firewall': tor.app.get_components_of_type(Firewall),
|
||||
'has_diagnostics': True,
|
||||
'is_enabled': status['enabled'],
|
||||
'show_status_block': True,
|
||||
'is_running': status['is_running'],
|
||||
})
|
||||
|
||||
|
||||
@ -8,6 +8,5 @@ from django.conf.urls import url
|
||||
from plinth.views import AppView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^apps/ttrss/$',
|
||||
AppView.as_view(app_id='ttrss', show_status_block=True), name='index'),
|
||||
url(r'^apps/ttrss/$', AppView.as_view(app_id='ttrss'), name='index')
|
||||
]
|
||||
|
||||
@ -23,7 +23,6 @@ class UpgradesConfigurationView(AppView):
|
||||
success_url = reverse_lazy('upgrades:index')
|
||||
template_name = "upgrades_configure.html"
|
||||
app_id = 'upgrades'
|
||||
show_status_block = False
|
||||
|
||||
def get_initial(self):
|
||||
return {'auto_upgrades_enabled': upgrades.is_enabled()}
|
||||
|
||||
@ -58,7 +58,6 @@ class UserList(AppView, ContextMixin, django.views.generic.ListView):
|
||||
template_name = 'users_list.html'
|
||||
title = ugettext_lazy('Users')
|
||||
app_id = 'users'
|
||||
show_status_block = False
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
context = super(UserList, self).get_context_data(*args, **kwargs)
|
||||
|
||||
@ -25,7 +25,6 @@ class WireguardView(AppView):
|
||||
"""Serve configuration page."""
|
||||
app_id = 'wireguard'
|
||||
diagnostics_module_name = 'wireguard'
|
||||
show_status_block = False
|
||||
template_name = 'wireguard.html'
|
||||
port_forwarding_info = wireguard.port_forwarding_info
|
||||
|
||||
|
||||
@ -23,23 +23,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block status %}
|
||||
{% if show_status_block %}
|
||||
<h3>{% trans "Status" %}</h3>
|
||||
<p class="running-status-parent">
|
||||
{% with service_name=app_info.name %}
|
||||
{% if is_running %}
|
||||
<span class="running-status active"></span>
|
||||
{% blocktrans trimmed %}
|
||||
Service <em>{{ service_name }}</em> is running.
|
||||
{% endblocktrans %}
|
||||
{% else %}
|
||||
<span class="running-status inactive"></span>
|
||||
{% blocktrans trimmed %}
|
||||
Service <em>{{ service_name }}</em> is not running.
|
||||
{% endblocktrans %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</p>
|
||||
{% if is_running is not None and not is_running %}
|
||||
<div id='service-not-running' role="alert"
|
||||
class="alert alert-danger {{ is_enabled|yesno:',hidden' }}">
|
||||
{% blocktrans trimmed with service_name=app_info.name %}
|
||||
Service <em>{{ service_name }}</em> is not running.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@ -117,9 +117,6 @@ class AppView(FormView):
|
||||
'form_class' is the Django form class that is used by this view. By default
|
||||
the AppForm class is used.
|
||||
|
||||
'show_status_block' is a boolean to determine if the status section must be
|
||||
shown in this app's page.
|
||||
|
||||
'template_name' is the template used to render this view. By default it is
|
||||
app.html. It may be overridden with a template that derives from app.html
|
||||
to customize the appearance of the app to achieve more complex presentation
|
||||
@ -131,10 +128,6 @@ class AppView(FormView):
|
||||
|
||||
"""
|
||||
form_class = forms.AppForm
|
||||
# Display the 'status' block of the app.html template
|
||||
# This block uses information from service.is_running. This method is
|
||||
# optional, so allow not showing this block here.
|
||||
show_status_block = True
|
||||
app_id = None
|
||||
template_name = 'app.html'
|
||||
port_forwarding_info = None
|
||||
@ -202,7 +195,6 @@ class AppView(FormView):
|
||||
context['is_running'] = app_is_running(self.app)
|
||||
context['app_info'] = self.app.info
|
||||
context['has_diagnostics'] = self.app.has_diagnostics()
|
||||
context['show_status_block'] = self.show_status_block
|
||||
context['port_forwarding_info'] = self.port_forwarding_info
|
||||
|
||||
from plinth.modules.firewall.components import Firewall
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user