Change language for all available

This commit is contained in:
Ruben van de Ven 2019-11-11 12:45:08 +01:00
parent 10f856a439
commit 0418091ac0
6 changed files with 94 additions and 7 deletions

View file

@ -502,7 +502,7 @@ class HugveyState(object):
def isAvailable(self): def isAvailable(self):
if self.command.config['story']['loop']: if self.command.config['story']['loop']:
if self.status == self.STATE_RUNNING and self.story: if (self.status == self.STATE_RUNNING or self.status == self.STATE_PAUSE) and self.story:
if self.story.currentMessage: if self.story.currentMessage:
if self.story.currentMessage.id == self.story.startMessage.id: if self.story.currentMessage.id == self.story.startMessage.id:
return True return True
@ -639,6 +639,9 @@ class HugveyState(object):
if event['event'] == 'change_language': if event['event'] == 'change_language':
self.setLanguage(event['lang_code']) self.setLanguage(event['lang_code'])
if event['event'] == 'change_language_if_available':
if self.isAvailable() or self.status == self.STATE_BLOCKED:
self.setLanguage(event['lang_code'])
if event['event'] == 'change_light': if event['event'] == 'change_light':
self.setLightId(event['light_id']) self.setLightId(event['light_id'])
if event['event'] == 'change_light_status': if event['event'] == 'change_light_status':

View file

@ -69,6 +69,8 @@ def getWebSocketHandler(central_command):
self.msgFinish(msg['hugvey']) self.msgFinish(msg['hugvey'])
elif msg['action'] == 'change_language': elif msg['action'] == 'change_language':
self.msgChangeLanguage(msg['hugvey'], msg['lang_code']) self.msgChangeLanguage(msg['hugvey'], msg['lang_code'])
elif msg['action'] == 'change_language_for_available':
self.msgChangeLanguageForAllAvailableHugveys(msg['lang_code'])
elif msg['action'] == 'change_light': elif msg['action'] == 'change_light':
self.msgChangeLightId(msg['hugvey'], int(msg['light_id'])) self.msgChangeLightId(msg['hugvey'], int(msg['light_id']))
elif msg['action'] == 'change_light_status': elif msg['action'] == 'change_light_status':
@ -137,6 +139,10 @@ def getWebSocketHandler(central_command):
def msgChangeLanguage(self, hv_id, lang_code): def msgChangeLanguage(self, hv_id, lang_code):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code}) central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code})
def msgChangeLanguageForAllAvailableHugveys(self, lang_code):
for hv_id in central_command.hugveys:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code})
def msgSetLoopTime(self, loop_time): def msgSetLoopTime(self, loop_time):
parts = loop_time.split(":") parts = loop_time.split(":")
if len(parts) == 2: if len(parts) == 2:

View file

@ -1,3 +1,19 @@
@-webkit-keyframes sk-scaleout {
0% {
-webkit-transform: scale(0); }
100% {
-webkit-transform: scale(1);
opacity: 0; } }
@keyframes sk-scaleout {
0% {
-webkit-transform: scale(0);
transform: scale(0); }
100% {
-webkit-transform: scale(1);
transform: scale(1);
opacity: 0; } }
body { body {
font-family: "Noto Sans", sans-serif; font-family: "Noto Sans", sans-serif;
margin: 0; margin: 0;
@ -67,9 +83,23 @@ img.icon {
height: 200px; height: 200px;
border: solid 1px; border: solid 1px;
box-sizing: border-box; box-sizing: border-box;
position: relative; } position: relative;
padding: 5px; }
#status > div#overview { #status > div#overview {
width: 100% / 3; } width: calc(100% / 3 * 2); }
#status > div#overview #languages {
color: #ccc;
list-style: none;
padding: 0; }
#status > div#overview #languages .loading:after {
display: inline-block;
content: '';
width: 15px;
height: 15px;
background-color: white;
border-radius: 100%;
-webkit-animation: sk-scaleout 1.0s infinite ease-in-out;
animation: sk-scaleout 1.0s infinite ease-in-out; }
#status .counts dd, #status .counts dt { #status .counts dd, #status .counts dt {
display: inline-block; display: inline-block;
width: 30px; width: 30px;

View file

@ -25,9 +25,12 @@
<ul id='languages'> <ul id='languages'>
<li v-for="lang in languages" :title="lang.file" <li v-for="lang in languages" :title="lang.file"
:id="'lang-' + lang.code" class="btn lang--btn" :id="'lang-' + lang.code">
@click="loadNarrative(lang.code, lang.file)"><span <span :class="['flag-icon', lang.code]"></span>
:class="['flag-icon', lang.code]"></span> {{lang.code}}</li> {{lang.code}}:
<span class='edit btn lang--btn' @click="loadNarrative(lang.code, lang.file)">Edit</span>
<span :id="'change-lang-' + lang.code" class='switch btn lang--btn' @click="changeLanguageForAvailable(lang.code)">Switch free</span>
</li>
</ul> </ul>
</div> </div>

View file

@ -35,6 +35,13 @@ class Panopticon {
return panopticon.loadNarrative( code, file ); return panopticon.loadNarrative( code, file );
} }
}, },
changeLanguageForAvailable: function(code){
console.log('TODO: set loader icon for 3 sec', this);
panopticon.send( { action: 'change_language_for_available', lang_code: code } );
let el = document.getElementById("change-lang-"+code);
el.classList.add('loading');
setTimeout(function(){el.classList.remove('loading');}, 3000);
},
block: function(hv) { block: function(hv) {
hv.status = "loading"; hv.status = "loading";
return panopticon.block(hv.id); return panopticon.block(hv.id);

View file

@ -1,6 +1,26 @@
$status_width: 380px; $status_width: 380px;
$status_width_open: 860px; $status_width_open: 860px;
@-webkit-keyframes sk-scaleout {
0% { -webkit-transform: scale(0) }
100% {
-webkit-transform: scale(1.0);
opacity: 0;
}
}
@keyframes sk-scaleout {
0% {
-webkit-transform: scale(0);
transform: scale(0);
} 100% {
-webkit-transform: scale(1.0);
transform: scale(1.0);
opacity: 0;
}
}
body{ body{
font-family: "Noto Sans", sans-serif; font-family: "Noto Sans", sans-serif;
margin: 0; margin: 0;
@ -94,9 +114,27 @@ img.icon{
border: solid 1px; border: solid 1px;
box-sizing: border-box; box-sizing: border-box;
position: relative; position: relative;
padding: 5px;
&#overview{ &#overview{
width: 100% / 3; width: calc(100% / 3 * 2);
#languages{
color:#ccc;
list-style: none;padding:0;
.loading:after {
display:inline-block;
content: '';
width: 15px;
height: 15px;
background-color: white;
border-radius: 100%;
-webkit-animation: sk-scaleout 1.0s infinite ease-in-out;
animation: sk-scaleout 1.0s infinite ease-in-out;
}
}
} }
} }