clients: implement launch button feature

Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Alice Kile 2019-11-14 12:14:17 +05:30 committed by Joseph Nuthalapati
parent 42949bf212
commit 8e3bbdb089
No known key found for this signature in database
GPG Key ID: 5398F00A2FA43C35
7 changed files with 22 additions and 13 deletions

View File

@ -42,10 +42,6 @@
{% endif %}
</p>
<p>
<a href='{% url "jsxc:jsxc" %}' target='_blank' class='btn btn-primary'>
{% trans "Launch web client" %}</a>
</p>
{% endblock %}

View File

@ -26,11 +26,6 @@
<p>{{ paragraph|safe }}</p>
{% endfor %}
<p>
<a href='{% url "jsxc:jsxc" %}' target='_blank' class='btn btn-primary'>
{% trans "Launch web client" %}</a>
</p>
{% endblock %}
{% block configuration %}

View File

@ -29,6 +29,6 @@ urlpatterns = [
AppView.as_view(app_id='roundcube', name=roundcube.name,
diagnostics_module_name='roundcube',
description=roundcube.description,
show_status_block=False,
show_status_block=False, clients=roundcube.clients,
manual_page=roundcube.manual_page), name='index'),
]

View File

@ -45,7 +45,20 @@
</p>
{% endif %}
{% include "clients.html" with clients=clients enabled=is_enabled %}
{% if clients|length == 1 and clients|first|lookup:'platforms'|length == 1 and clients|first|lookup:'platforms'|first|lookup:'type' == 'web' %}
{% block launch_button %}
<p>
<a href='{{ clients|first|lookup:"platforms"|first|lookup:"url" }}' target='_blank' class='btn btn-primary'>
{% trans "Launch web client" %}</a>
</p>
{% endblock %}
{% else %}
{% include "clients.html" with clients=clients enabled=is_enabled %}
{% endif %}
{% block subsubmenu %}
{% if subsubmenu %}

View File

@ -44,7 +44,7 @@
<td>{{ client.name }}</td>
<td>
<a target="_blank" rel="noopener noreferrer"
class="btn btn-success" role="button"
class="btn btn-default" role="button"
{% if not enabled %} disabled="disabled"
{% else %} href="{{ platform.url }}"
{% endif %}>

View File

@ -67,3 +67,9 @@ def show_subsubmenu(context, menu):
def clients_of_type(clients, client_type):
"""Filter and get clients of a particular type"""
return clients_module.of_type(clients, client_type)
@register.filter(name='lookup')
def lookup(dictionary, key):
"""Get the value in the dictionary at given key"""
return dictionary[key]

View File

@ -76,7 +76,6 @@ def is_user_admin(request, cached=False):
class YAMLFile(object):
"""A context management class for updating YAML files"""
def __init__(self, yaml_file):
"""Return a context object for the YAML file.