From 7a80cd08cecf779f5a687c8009216daf8f1ba3ae Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 28 Jan 2019 23:14:12 +0100 Subject: [PATCH] Handling dashboards widget configuration as a list instead of a hash to preserve the order of the widgets --- platypush/backend/http/__init__.py | 15 ++++++++++----- platypush/backend/http/templates/dashboard.html | 10 +++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/platypush/backend/http/__init__.py b/platypush/backend/http/__init__.py index dc7df536d..cc0eb4a8d 100644 --- a/platypush/backend/http/__init__.py +++ b/platypush/backend/http/__init__.py @@ -103,17 +103,22 @@ class HttpBackend(Backend): dashboard: background_image: https://site/image.png widgets: # Each row of the dashboard will have 6 columns - calendar: # Calendar widget + - + widget: calendar # Calendar widget columns: 6 - music: # Music widget + - + widget: music # Music widget columns: 3 - date-time-weather: # Date, time and weather widget + - + widget: date-time-weather # Date, time and weather widget columns: 3 - image-carousel: # Image carousel + - + widget: image-carousel # Image carousel columns: 6 images_path: ~/Dropbox/Photos/carousel # Absolute path (valid as long as it's a subdirectory of one of the available `resource_dirs`) refresh_seconds: 15 - rss-news: # RSS feeds widget + - + widget: rss-news # RSS feeds widget # Requires backend.http.poll to be enabled with some RSS sources and write them to sqlite db columns: 6 limit: 25 diff --git a/platypush/backend/http/templates/dashboard.html b/platypush/backend/http/templates/dashboard.html index 09d7a781a..48a8b2112 100644 --- a/platypush/backend/http/templates/dashboard.html +++ b/platypush/backend/http/templates/dashboard.html @@ -28,7 +28,7 @@ {% endif %} window.config = {{ config | safe }}; - window.widgets = {{ config['widgets'] | safe }}; + window.widgets = {{ config['widgets'] | safe }}.reduce(function(map, w) { map[w.widget] = w; return map }, {}) @@ -44,16 +44,16 @@
{% set used_columns = [0] %} - {% for widget_name, widget in config['widgets'].items() %} + {% for widget in config['widgets'] %} {% if used_columns[0] % 12 == 0 %}
{% endif %}
+ {% print(widget['widget']) %}" + id="{% print(widget['id'] if 'id' in widget else widget['widget']) %}"> {% with properties=widget %} - {% include 'widgets/' + widget_name + '.html' %} + {% include 'widgets/' + widget['widget'] + '.html' %} {% endwith %}