diff --git a/pyscada/hmi/templates/view_overview.html b/pyscada/hmi/templates/view_overview.html index ebfe0408..735df75d 100644 --- a/pyscada/hmi/templates/view_overview.html +++ b/pyscada/hmi/templates/view_overview.html @@ -5,16 +5,21 @@
{% for view in view_list %} {% if view.visible %} + {% if view.link_title %} + {% url 'main-view' view.link_title as link_url %} + {% else %} + {% url 'view-overview-link' view.link_url as link_url %} + {% endif %}
{% if view.logo %} - {{ view.description }} + {{ view.description }} {% else %} -

{{ view.description }}

+

{{ view.description }}

{% endif %}
diff --git a/pyscada/hmi/urls.py b/pyscada/hmi/urls.py index 9f33ef8f..5f0d1aa5 100644 --- a/pyscada/hmi/urls.py +++ b/pyscada/hmi/urls.py @@ -45,4 +45,7 @@ views.get_hidden_config2, name="get-hidden-config2", ), + path( + "/", views.index, name="view-overview-link" + ), # this is used to add special links to the view-overview ] diff --git a/pyscada/hmi/views.py b/pyscada/hmi/views.py index e42429a6..8e47f479 100644 --- a/pyscada/hmi/views.py +++ b/pyscada/hmi/views.py @@ -38,16 +38,60 @@ logger = logging.getLogger(__name__) +class ViewDummy: + def __init__( + self, + title="", + link_title=None, + link_url="", + description="", + url="", + visible=True, + ): + self.title = title + self.link_title = link_title + self.link_url = link_url + self.description = description + + class Logo: + def __init__(self, url): + self.url = url + + def __eq__(self, obj): + return obj == self.url + + def __hash__(self): + return hash(self.url) + + def __bool__(self): + return bool(self.url) + + self.logo = Logo(url=url) + self.visible = visible @login_required -def index(request): +def index(request, link_title=""): if GroupDisplayPermission.objects.count() == 0: view_list = View.objects.all() else: - view_list = get_group_display_permission_list( - View.objects, request.user.groups.all() + view_list = list( + get_group_display_permission_list(View.objects, request.user.groups.all()) ) + if hasattr(settings, "OVERVIEW_ADDITIONAL_LINKS"): + for view_data in settings.OVERVIEW_ADDITIONAL_LINKS: + view = ViewDummy() + view.logo.url = view_data["logo_url"] if "logo_url" in view_data else None + view.title = view_data["title"] if "title" in view_data else "" + view.link_title = ( + view_data["link_title"] if "link_title" in view_data else None + ) + view.link_url = view_data["link_url"] if "link_url" in view_data else "" + view.description = ( + view_data["description"] if "description" in view_data else "" + ) + view_list.append(view) + c = { "user": request.user, "view_list": view_list,