defaults.jinja 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. {# Set defaults for variables #}
  2. {# Front-end app naming #}
  3. {# Front-end menu, as columns with href, id, caption, and (fa fa-)icon #}
  4. {% set navigation_bar = [] %}
  5. {% set nav_bar_specs = {
  6. "dashboard": dict(title="Dashboard", icon="dashboard"),
  7. "upload": dict(title="Upload data", icon="cloud-upload"),
  8. "control": dict(title="Flexibility actions", icon="wrench")
  9. }
  10. %}
  11. {% set FLEXMEASURES_PLATFORM_NAME = FLEXMEASURES_PLATFORM_NAME | find_first_applicable_config_entry("FLEXMEASURES_PLATFORM_NAME") %}
  12. {% for view_name in FLEXMEASURES_MENU_LISTED_VIEWS %}
  13. {% set view_name = view_name | parse_config_entry_by_account_roles("FLEXMEASURES_MENU_LISTED_VIEWS") %}
  14. {% if view_name %}
  15. {# add specs for views we don't know (plugin views) #}
  16. {% do nav_bar_specs.update({view_name: dict(title=view_name.capitalize(), tooltip="", icon= "info")}) if view_name not in nav_bar_specs %}
  17. {# update specs for view titles by configuration #}
  18. {% do nav_bar_specs[view_name].update(dict(title=FLEXMEASURES_MENU_LISTED_VIEW_TITLES[view_name])) if view_name in FLEXMEASURES_MENU_LISTED_VIEW_TITLES %}
  19. {# update specs for view icons by configuration #}
  20. {% do nav_bar_specs[view_name].update(dict(icon=FLEXMEASURES_MENU_LISTED_VIEW_ICONS[view_name])) if view_name in FLEXMEASURES_MENU_LISTED_VIEW_ICONS %}
  21. {# add view to menu if user is authenticated #}
  22. {% do navigation_bar.append(
  23. (view_name, view_name, nav_bar_specs[view_name]["title"], nav_bar_specs[view_name]["tooltip"], nav_bar_specs[view_name]["icon"])
  24. ) if current_user.is_authenticated %}
  25. {% endif %}
  26. {% endfor %}
  27. {% if current_user.is_authenticated %}
  28. {% set has_admin_reader_rights = True if (current_user.has_role(ADMIN_ROLE) or current_user.has_role(ADMIN_READER_ROLE) or FLEXMEASURES_MODE == "demo") %}
  29. {% set is_consultant = True if current_user.has_role(CONSULTANT_ROLE) %}
  30. {% if has_admin_reader_rights %}
  31. {% do navigation_bar.append(('assets', 'assets', 'Assets', '', 'list-ul')) %}
  32. {% do navigation_bar.append(('users', 'users', 'Users', '', 'users')) %}
  33. {% do navigation_bar.append(('tasks', 'tasks', 'Tasks', '', 'tasks')) %}
  34. {% endif %}
  35. {% if is_consultant or has_admin_reader_rights %}
  36. {% do navigation_bar.append(('accounts', 'accounts', 'Accounts', '', 'cubes')) %}
  37. {% else %}
  38. {% do navigation_bar.append(("accounts/{}".format(current_user.account.id), 'accounts', 'My Account', '', 'cubes')) %}
  39. {% endif %}
  40. {% do navigation_bar.append(('logged-in-user', 'logged-in-user', '', user_name, 'user')) %}
  41. {% endif %}
  42. {% do navigation_bar.append(('ui/static/documentation/html/index.html', 'docs', '', 'Documentation (new window)', 'question')) if documentation_exists and current_user.is_authenticated %}
  43. {% set active_page = active_page|default('dashboard') -%}
  44. {# Front-end app contents, always include this #}
  45. {% block base %} All your base are belong to us. {% endblock base %}