From ecec82b6173784bf66f2efaf7c7578de504b6424 Mon Sep 17 00:00:00 2001 From: Ruben van de Ven Date: Fri, 29 Nov 2019 20:51:29 +0100 Subject: [PATCH] Fix #90 - Show future language in panopticon --- hugvey/central_command.py | 15 ++++++++++++++- hugvey/panopticon.py | 5 +---- www/index.html | 4 ++-- www/js/hugvey_console.js | 2 ++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/hugvey/central_command.py b/hugvey/central_command.py index 5bef6db..c42aae8 100644 --- a/hugvey/central_command.py +++ b/hugvey/central_command.py @@ -137,6 +137,8 @@ class CentralCommand(object): with open(lang_filename, 'r') as fp: self.languages[lang['code']] = json.load(fp) + self.future_language = list(self.languages.keys())[0] + def loadLightMap(self): if os.path.exists(self.lightMapFile): with open(self.lightMapFile) as fp: @@ -241,7 +243,8 @@ class CentralCommand(object): 'hugveys': [], 'logbookId': None, 'logbook': [], - 'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange() + 'starts_since_lang_change': self.getHugveyStartsSinceLanguageChange(), + 'future_language': self.future_language, } #use this to test if any threads stay open @@ -272,6 +275,16 @@ class CentralCommand(object): nrOfStarts += 1 return nrOfStarts + def setFutureLanguage(self, lang_code): + """ + Set language for all future hugvey runs (so after a 'finish') + """ + self.timer.setMark('languageChange') + self.future_language = lang_code + for hv_id in self.hugveys: + if self.hugveys[hv_id].eventQueue: + self.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) + def setLoopTime(self, secondsAgo: int): self.timer.setMark('start', time.time() - secondsAgo) diff --git a/hugvey/panopticon.py b/hugvey/panopticon.py index 925ea98..f2a3ed4 100644 --- a/hugvey/panopticon.py +++ b/hugvey/panopticon.py @@ -150,10 +150,7 @@ def getWebSocketHandler(central_command): """ Set language for all future hugvey runs (so after a 'finish') """ - central_command.timer.setMark('languageChange') - for hv_id in central_command.hugveys: - if central_command.hugveys[hv_id].eventQueue: - central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code}) + central_command.setFutureLanguage(lang_code) def msgSetLoopTime(self, loop_time): parts = loop_time.split(":") diff --git a/www/index.html b/www/index.html index 7993027..e40da2d 100644 --- a/www/index.html +++ b/www/index.html @@ -16,13 +16,13 @@
- {{loop_timer}} (up: {{uptime}}) + {{loop_timer}}
- {{starts_since_lang_change}} + {{future_language}}: {{starts_since_lang_change}}
    diff --git a/www/js/hugvey_console.js b/www/js/hugvey_console.js index 6493c2b..e847a3d 100644 --- a/www/js/hugvey_console.js +++ b/www/js/hugvey_console.js @@ -20,6 +20,7 @@ class Panopticon { blockedHugveys: 0, availableHugveys: 0, starts_since_lang_change: 0, + future_language: 0, }, methods: { time_passed: function( hugvey, property ) { @@ -185,6 +186,7 @@ class Panopticon { this.hugveys.logbook = msg['logbook']; this.hugveys.logbookId = msg['logbookId']; this.hugveys.starts_since_lang_change = msg['starts_since_lang_change']; + this.hugveys.future_language = msg['future_language']; if(this.hugveys.selectedId) { this.updateSelectedHugvey(); }