mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-28 08:03:36 +00:00
Add information about enabled services to front page
This commit is contained in:
parent
fa0bc7471f
commit
49eadd971a
@ -27,12 +27,14 @@ def get_shortcuts():
|
||||
return sorted(shortcuts.values(), key=lambda x: x['label'])
|
||||
|
||||
|
||||
def add_shortcut(app, label, url, icon):
|
||||
def add_shortcut(app, label, url, icon, details=None):
|
||||
"""Add shortcut to front page."""
|
||||
shortcuts[app] = {
|
||||
'app': app,
|
||||
'label': label,
|
||||
'url': url,
|
||||
'icon': icon,
|
||||
'details': details,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -21,8 +21,10 @@ Plinth module for minetest.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.views import ServiceView
|
||||
@ -58,13 +60,34 @@ def init():
|
||||
global service
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['minetest-plinth'],
|
||||
is_external=True)
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('minetest', title, '?selected=minetest',
|
||||
'glyphicon-th-large', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('minetest')
|
||||
|
||||
|
||||
class MinetestServiceView(ServiceView):
|
||||
|
||||
@ -21,8 +21,10 @@ Plinth module to configure Mumble server
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.views import ServiceView
|
||||
|
||||
@ -56,7 +58,11 @@ def init():
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['mumble-plinth'], is_external=True)
|
||||
managed_services[0], title, ports=['mumble-plinth'], is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
class MumbleServiceView(ServiceView):
|
||||
@ -69,6 +75,24 @@ def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('mumble', title, '?selected=mumble',
|
||||
'glyphicon-headphones', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('mumble')
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
@ -24,6 +24,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.views import ServiceView
|
||||
@ -66,7 +67,11 @@ def init():
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['privoxy'], is_external=False)
|
||||
managed_services[0], title, ports=['privoxy'], is_external=False,
|
||||
enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
@ -74,6 +79,24 @@ def setup(helper, old_version=None):
|
||||
helper.call('pre', actions.superuser_run, 'privoxy', ['pre-install'])
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('privoxy', title, '?selected=privoxy',
|
||||
'glyphicon-cloud-upload', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('privoxy')
|
||||
|
||||
|
||||
class PrivoxyServiceView(ServiceView):
|
||||
|
||||
@ -21,8 +21,10 @@ Plinth module for Quassel.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
from plinth.views import ServiceView
|
||||
@ -64,7 +66,11 @@ def init():
|
||||
|
||||
global service
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['quassel-plinth'], is_external=True)
|
||||
managed_services[0], title, ports=['quassel-plinth'], is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
class QuasselServiceView(ServiceView):
|
||||
@ -77,6 +83,24 @@ def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('quassel', title, '?selected=quassel',
|
||||
'glyphicon-retweet', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('quassel')
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
@ -25,6 +25,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.utils import format_lazy
|
||||
|
||||
@ -63,22 +64,33 @@ def init():
|
||||
managed_services[0], title, ports=['http', 'https'], is_external=True,
|
||||
enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', actions.superuser_run, 'radicale', ['setup'])
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('radicale', title, '?selected=radicale',
|
||||
'glyphicon-calendar', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('radicale', ['enable'])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('radicale', ['disable'])
|
||||
frontpage.remove_shortcut('radicale')
|
||||
|
||||
|
||||
def load_augeas():
|
||||
|
||||
@ -24,6 +24,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
from plinth import actions
|
||||
from plinth import action_utils
|
||||
from plinth import cfg
|
||||
from plinth import frontpage
|
||||
from plinth import service as service_module
|
||||
from plinth.views import ServiceView
|
||||
|
||||
@ -69,7 +70,10 @@ def init():
|
||||
global service
|
||||
service = service_module.Service(
|
||||
managed_services[0], title, ports=['sip-plinth', 'sip-tls-plinth'],
|
||||
is_external=True)
|
||||
is_external=True, enable=enable, disable=disable)
|
||||
|
||||
if service.is_enabled():
|
||||
add_shortcut()
|
||||
|
||||
|
||||
class ReproServiceView(ServiceView):
|
||||
@ -83,6 +87,24 @@ def setup(helper, old_version=None):
|
||||
helper.install(managed_packages)
|
||||
helper.call('post', actions.superuser_run, 'repro', ['setup'])
|
||||
helper.call('post', service.notify_enabled, None, True)
|
||||
helper.call('post', add_shortcut)
|
||||
|
||||
|
||||
def add_shortcut():
|
||||
frontpage.add_shortcut('repro', title, '?selected=repro',
|
||||
'glyphicon-phone-alt', description)
|
||||
|
||||
|
||||
def enable():
|
||||
"""Enable the module."""
|
||||
actions.superuser_run('service', ['enable', managed_services[0]])
|
||||
add_shortcut()
|
||||
|
||||
|
||||
def disable():
|
||||
"""Disable the module."""
|
||||
actions.superuser_run('service', ['disable', managed_services[0]])
|
||||
frontpage.remove_shortcut('repro')
|
||||
|
||||
|
||||
def diagnose():
|
||||
|
||||
@ -22,17 +22,23 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class="row">
|
||||
{% if shortcuts %}
|
||||
|
||||
{% for shortcut in shortcuts %}
|
||||
<div class="col-sm-4">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li>
|
||||
<a href="{{ shortcut.url }}">
|
||||
<span class="{{ shortcut.icon }} glyphicon"></span>
|
||||
{{ shortcut.label }}
|
||||
</a>
|
||||
</li>
|
||||
{% if selected_app == shortcut.app %}
|
||||
<li class="active">
|
||||
<a href="{{ shortcut.url }}" class="active">
|
||||
{% else %}
|
||||
<li>
|
||||
<a href="{{ shortcut.url }}">
|
||||
{% endif %}
|
||||
<span class="{{ shortcut.icon }} glyphicon"></span>
|
||||
{{ shortcut.label }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
{% endfor %}
|
||||
@ -50,6 +56,22 @@
|
||||
</h4>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<br>
|
||||
{% if details %}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">{{ details_label }}</h3>
|
||||
</div>
|
||||
|
||||
{% for paragraph in details %}
|
||||
<div class="panel-body">
|
||||
{{ paragraph|safe }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@ -35,9 +35,20 @@ import plinth
|
||||
@public
|
||||
def index(request):
|
||||
"""Serve the main index page."""
|
||||
shortcuts = frontpage.get_shortcuts()
|
||||
selection = request.GET.get('selected')
|
||||
|
||||
details, details_label = None, None
|
||||
if selection in frontpage.shortcuts:
|
||||
details = frontpage.shortcuts[selection]['details']
|
||||
details_label = frontpage.shortcuts[selection]['label']
|
||||
|
||||
return TemplateResponse(request, 'index.html',
|
||||
{'title': _('FreedomBox'),
|
||||
'shortcuts': frontpage.get_shortcuts()})
|
||||
'shortcuts': shortcuts,
|
||||
'selected_app': selection,
|
||||
'details': details,
|
||||
'details_label': details_label})
|
||||
|
||||
|
||||
class ServiceView(FormView):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user