Save light status (not properly restored yet) and clearer status in timeline when running in a loop
This commit is contained in:
parent
5af386212e
commit
5ca3cffdd9
4 changed files with 12 additions and 3 deletions
|
@ -123,6 +123,7 @@ class CentralCommand(object):
|
|||
status['light_on'] = bool(hv.lightStatus)
|
||||
status['language'] = hv.language_code
|
||||
status['light_id'] = hv.lightId
|
||||
status['available'] = hv.isAvailable()
|
||||
status['msg'] = hv.story.currentMessage.id if hv.story and hv.story.currentMessage else None
|
||||
# status['finished'] = hv.story.isFinished()
|
||||
status['history'] = {} if isSelected is False or not hv.story else hv.story.getLogSummary()
|
||||
|
|
|
@ -1782,6 +1782,7 @@ class Story(object):
|
|||
fn = self.getStateFilename(self.hugvey.lightId)
|
||||
tmpfn = fn + '.tmp'
|
||||
self.stateSave = time.time()
|
||||
self.lightStateSave = self.hugvey.lightStatus
|
||||
with open(tmpfn, 'wb') as fp:
|
||||
pickle.dump(self, fp)
|
||||
# write atomic to disk: flush, close, rename
|
||||
|
@ -1805,9 +1806,11 @@ class Story(object):
|
|||
story = pickle.load(fp)
|
||||
|
||||
story.hugvey = hugvey_state
|
||||
#: :type story: Story
|
||||
story.logger = mainLogger.getChild(f"{story.hugvey.id}").getChild("story")
|
||||
# TODO: this is not really working because it is overridden by the set-status later.
|
||||
story.hugvey.setLightStatus(story.lightStateSave)
|
||||
return story
|
||||
# TODO: take running state etc.
|
||||
|
||||
@classmethod
|
||||
def clearSavedState(cls, hv_id):
|
||||
|
|
|
@ -95,8 +95,9 @@ checkbox.addEventListener('change', (event) => {
|
|||
if(msg['action'] == 'status') {
|
||||
for(let hv of msg['hugveys']){
|
||||
console.log(hv['language'], hv['status']);
|
||||
let evenOdd = parseInt(hv['id'])%2 ? 'odd': 'even'
|
||||
this.dataGroups.update({id: parseInt(hv['id']), content: 'Hugvey #'+hv['id'], className: `status-${hv['status']} lang-${hv['language']} ${evenOdd}`})
|
||||
let evenOdd = parseInt(hv['id'])%2 ? 'odd': 'even';
|
||||
let availableClass = hv['available'] ? 'is-available' : 'is-not-available'
|
||||
this.dataGroups.update({id: parseInt(hv['id']), content: 'Hugvey #'+hv['id'], className: `status-${hv['status']} ${availableClass} lang-${hv['language']} ${evenOdd}`})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,6 +98,10 @@ font-size: 20pt;
|
|||
.status-available{
|
||||
background-color: #660;
|
||||
}
|
||||
.status-running.is-available{
|
||||
/* When running in a loop, Hugvey is listening while available */
|
||||
background-color: #246f6f !important;
|
||||
}
|
||||
.status-running.lang-en-GB{
|
||||
background-color: #02547e;
|
||||
|
||||
|
|
Loading…
Reference in a new issue