From 93285662358ed9e569f505e5e777875b535f578a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Wed, 2 Jan 2019 21:24:07 +0100 Subject: [PATCH] Selecting the default light group tab on web panel load if configured --- platypush/backend/http/static/js/light.hue.js | 11 ++++++++++- .../backend/http/templates/plugins/light.hue.html | 13 +++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/platypush/backend/http/static/js/light.hue.js b/platypush/backend/http/static/js/light.hue.js index 7ec0a4d18..65cb7768c 100644 --- a/platypush/backend/http/static/js/light.hue.js +++ b/platypush/backend/http/static/js/light.hue.js @@ -392,6 +392,7 @@ $(document).ready(function() { var $room = $('
') .addClass('room-item') .data('id', room) + .data('name', rooms[room].name) .text(rooms[room].name); var $roomLights = $('
') @@ -471,6 +472,8 @@ $(document).ready(function() { } updateRooms(groups); + }).then(function() { + initBindings(); }); }; @@ -644,11 +647,17 @@ $(document).ready(function() { $animationContainers.hide(); $animationContainer.show(); }); + + if (window.config.light.hue.default_group) { + var $defaultRoomItem = $roomsList.find('.room-item').filter( + (i, r) => $(r).data('name') == window.config.light.hue.default_group); + + $defaultRoomItem.click(); + } }; var init = function() { initUi(); - initBindings(); }; init(); diff --git a/platypush/backend/http/templates/plugins/light.hue.html b/platypush/backend/http/templates/plugins/light.hue.html index 1b395874e..07693d9de 100644 --- a/platypush/backend/http/templates/plugins/light.hue.html +++ b/platypush/backend/http/templates/plugins/light.hue.html @@ -1,6 +1,19 @@ +{% set default_group = configuration['groups'][0] if 'groups' in configuration else None %} + + +
Rooms