Skip to content
Snippets Groups Projects
Commit e535c412 authored by Jan Mach's avatar Jan Mach
Browse files

Fix: Fixed broken 'devtools' module.

Added listing of all currently enabled blueprints.
parent 22ee8ff4
No related branches found
No related tags found
No related merge requests found
......@@ -6,12 +6,36 @@
<div class="col-lg-12">
<h2>{{ vial_current_view.get_view_title() }}</h2>
<h3>Permissions</h3>
<h3>{{ _('Enabled modules') }}</h3>
<table class="table">
{%- for key, val in get_modules_dict().items() %}
<tr>
<!--
<td>
{# get_icon(val.get_module_icon()) #}
</td>
-->
<td>
{{ key|pprint }}
</td>
<td>
{{ val|pprint }}
</td>
<!--
<td>
{# val.get_module_title() #}
</td>
-->
</tr>
{%- endfor %}
</table>
<h3>{{ _('Endpoint permissions') }}</h3>
<table class="table">
{%- for key, val in get_endpoints_dict()|dictsort%}
<tr>
<td>
{{ get_icon('module-{}'.format(val.module_name)) }}
{{ get_module_icon(key) }}
{{ get_icon(val.get_view_icon()) }}
</td>
<td>
......@@ -30,56 +54,56 @@
{{ auitem|pprint }}
{%- endfor %}
{%- else %}
unauthorized
{{ _('unauthorized') }}
{%- endif %}
</td>
</tr>
{%- endfor %}
</table>
<h3>Timezone settings</h3>
<h3>{{ _('Timezone settings') }}</h3>
<table class="table">
<tr>
<th>UTC time:</th>
<th>{{ _('UTC time') }}:</th>
<td>{{ get_datetime_utc() }}</td>
</tr>
<tr>
<th>Server local time:</th>
<th>{{ _('Server local time') }}:</th>
<td>{{ get_datetime_local() }}</td>
</tr>
<tr>
<th>User preference timezone:</th>
<th>{{ _('User preference timezone') }}:</th>
<td>{{ babel_format_datetime(get_datetime_utc()) }} ({{ g['timezone'] }})</td>
</tr>
</table>
<h3>Configuration</h3>
<h3>{{ _('Configuration') }}</h3>
<pre class="pre-scrollable">{{ config|pprint }}</pre>
<h3>Session</h3>
<h3>{{ _('Session') }}</h3>
<pre class="pre-scrollable">{{ session|pprint }}</pre>
<h3>Current user</h3>
<h3>{{ _('Current user') }}</h3>
<pre class="pre-scrollable">{{ current_user|pprint }}</pre>
<h3>G</h3>
<h3>{{ _('G') }}</h3>
<pre class="pre-scrollable">
{% for k in g %}{{ k }}: {{ g[k]|pprint }}
{% endfor %}</pre>
<h3>Menu - main</h3>
<h3>{{ _('Menu - main') }}</h3>
<pre class="pre-scrollable">
{{ vial_current_menu_main|pprint }}
---
{{ vial_current_menu_main.get_entries()|pprint }}</pre>
<h3>Menu - auth</h3>
<h3>{{ _('Menu - auth') }}</h3>
<pre class="pre-scrollable">
{{ vial_current_menu_auth|pprint }}
---
{{ vial_current_menu_auth.get_entries()|pprint }}</pre>
<h3>Menu - anon</h3>
<h3>{{ _('Menu - anon') }}</h3>
<pre class="pre-scrollable">
{{ vial_current_menu_anon|pprint }}
---
......
......@@ -77,9 +77,10 @@ FA_ICONS = {
#
# Built-in module icons.
#
'module-auth-api': '<i class="fas fa-fw fa-key"></i>',
'module-auth-dev': '<i class="fas fa-fw fa-key"></i>',
'module-auth-env': '<i class="fas fa-fw fa-key"></i>',
'module-home': '<i class="fas fa-fw fa-home"></i>',
'module-auth-api': '<i class="fas fa-fw fa-id-card-alt"></i>',
'module-auth-dev': '<i class="fas fa-fw fa-id-card-alt"></i>',
'module-auth-env': '<i class="fas fa-fw fa-id-card-alt"></i>',
'module-changelogs': '<i class="fas fa-fw fa-clipboard-list"></i>',
'module-dashboards': '<i class="fas fa-fw fa-tachometer-alt"></i>',
'module-dbstatus': '<i class="fas fa-fw fa-database"></i>',
......
......@@ -410,7 +410,7 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
"""
Return dictionary of all registered application view endpoints.
"""
return flask.current_app.view_functions
return { k: v.view_class for k, v in flask.current_app.view_functions.items() if hasattr(v, 'view_class') }
def get_endpoint_class(endpoint, quiet = False):
"""
......@@ -449,19 +449,23 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
)
)
def get_module_icon(endpoint):
def get_module_icon(endpoint, default_icon = 'missing-icon'):
"""
Get HTML icon markup for parent module of given view endpoint.
:param str endpoint: Name of the view endpoint.
:param str default_icon: Name of the default icon.
:return: Icon including HTML markup.
:rtype: flask.Markup
"""
return flask.Markup(
vial.const.FA_ICONS[self.get_endpoint_class(endpoint).module_ref().get_module_icon()]
vial.const.FA_ICONS.get(
self.get_endpoint_class(endpoint).module_ref().get_module_icon(),
vial.const.FA_ICONS.get(default_icon)
)
)
def get_endpoint_icon(endpoint):
def get_endpoint_icon(endpoint, default_icon = 'missing-icon'):
"""
Get HTML icon markup for given view endpoint.
......@@ -470,7 +474,10 @@ class Vial(flask.Flask): # pylint: disable=locally-disabled,too-many-instance-a
:rtype: flask.Markup
"""
return flask.Markup(
vial.const.FA_ICONS[self.get_endpoint_class(endpoint).get_view_icon()]
vial.const.FA_ICONS.get(
self.get_endpoint_class(endpoint).get_view_icon(),
vial.const.FA_ICONS.get(default_icon)
)
)
def get_country_flag(country):
......
......@@ -174,6 +174,7 @@ FA_ICONS = {
#
# Built-in module icons.
#
'module-home': '<i class="fas fa-fw fa-home"></i>',
'module-auth-api': '<i class="fas fa-fw fa-key"></i>',
'module-auth-dev': '<i class="fas fa-fw fa-key"></i>',
'module-auth-env': '<i class="fas fa-fw fa-key"></i>',
......
......@@ -163,7 +163,7 @@ class BaseView(flask.views.View):
:return: View icon.
:rtype: str
"""
return 'module-{}'.format(cls.module_name)
return 'module-{}'.format(cls.module_name.replace('_', '-'))
@classmethod
def get_view_title(cls, **kwargs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment