Fix #90 - Show future language in panopticon

This commit is contained in:
Ruben van de Ven 2019-11-29 20:51:29 +01:00
parent cc1d33c831
commit ecec82b617
4 changed files with 19 additions and 7 deletions

View file

@ -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)

View file

@ -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(":")

View file

@ -16,13 +16,13 @@
<div id="interface" class='showStatus'>
<div id='status'>
<div id='overview'>
<span class="loop_time" onclick="document.getElementById('time_update').classList.toggle('visible')">{{loop_timer}}</span> (up: {{uptime}})
<span class="loop_time" title="uptime: {{uptime}}" onclick="document.getElementById('time_update').classList.toggle('visible')">{{loop_timer}}</span>
<div id='time_update'>
<input type="text" value="00:00:00" name="loop_time_value" id="loop_time_value" />
<input type="button" onclick="panopticon.change_loop_time(document.getElementById('loop_time_value').value)" value="set time">
</div>
<span title="Conversations started since last language change">{{starts_since_lang_change}}</span>
<span title="Conversations started since last language change">{{future_language}}: {{starts_since_lang_change}}</span>
<ul id='languages'>

View file

@ -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();
}