From 6c7e657f81e8dc836d43cba966ba18d47d88b47c Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Wed, 10 Jul 2019 15:24:02 +0200 Subject: [PATCH] Allow setting the time in the loop fix #64 --- hugvey/central_command.py | 3 +++ hugvey/panopticon.py | 16 ++++++++++++++++ www/css/styles.css | 8 ++++++++ www/index.html | 10 ++++++---- www/js/hugvey_console.js | 5 +++++ www/scss/styles.scss | 11 +++++++++++ 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/hugvey/central_command.py b/hugvey/central_command.py index ed47588..11c6ba8 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -170,6 +170,9 @@ class CentralCommand(object): # status['logbookId'] = selected_id return status + + def setLoopTime(self, secondsAgo: int): + self.timer.setMark('start', time.time() - secondsAgo) def commandHugvey(self, hv_id, msg): """ diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index 047afb3..f8c72aa 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -75,6 +75,8 @@ def getWebSocketHandler(central_command): self.msgChangeLightStatus(msg['hugvey'], bool(msg['light_status'])) elif msg['action'] == 'play_msg': self.msgPlayMsg(msg['hugvey'], msg['msg_id'], msg['reloadStory']) + elif msg['action'] == 'loop_time': + self.msgSetLoopTime(msg['time']) else: # self.send({'alert': 'Unknown request: {}'.format(message)}) logger.warn('Unknown request: {}'.format(message)) @@ -134,6 +136,20 @@ def getWebSocketHandler(central_command): def msgChangeLanguage(self, hv_id, lang_code): central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code}) + + def msgSetLoopTime(self, loop_time): + parts = loop_time.split(":") + if len(parts) == 2: + h, m = parts + s = 0 + elif len(parts) == 3: + h, m, s = parts + else: + logger.critical(f"Invalid time to set: {loop_time}") + return + + seconds = int(h)*3600+int(m)*60+int(s) + central_command.setLoopTime(seconds) def msgChangeLightId(self, hv_id, lightId): central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light', 'light_id': lightId}) diff --git a/www/css/styles.css b/www/css/styles.css index b40cd01..5ce5f40 100644 --- a/www/css/styles.css +++ b/www/css/styles.css @@ -370,3 +370,11 @@ body.showTimeline #toggleTimeline { font-weight: bold; } #variables .name::after { content: " - "; } + +.loop_time { + cursor: pointer; } + +#time_update { + display: none; } + #time_update.visible { + display: block; } diff --git a/www/index.html b/www/index.html index 738a2f0..d8f418f 100644 --- a/www/index.html +++ b/www/index.html @@ -16,10 +16,12 @@
-
-
Timer
-
{{loop_timer}} (up: {{uptime}})
-
+ {{loop_timer}} (up: {{uptime}}) +
+ + +
+