mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 10:24:26 +01:00
doorlockd.py: move emit status to Logic class
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
93a34b7755
commit
a6e117ffd9
@ -183,8 +183,18 @@ class Logic:
|
|||||||
|
|
||||||
def request(self, state, credentials):
|
def request(self, state, credentials):
|
||||||
err = self._request(state, credentials)
|
err = self._request(state, credentials)
|
||||||
|
self.emit_status(err)
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
def emit_status(self, message=None):
|
||||||
|
led = self.state.to_img()
|
||||||
|
if message is None:
|
||||||
|
message = self.state.to_html()
|
||||||
|
else:
|
||||||
|
message = message.to_html()
|
||||||
|
|
||||||
|
socketio.emit('status', {'led': led, 'message': message})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
return self.door_handler.state
|
return self.door_handler.state
|
||||||
@ -210,19 +220,9 @@ class AuthenticationForm(FlaskForm):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def emit_status(message=None):
|
|
||||||
led = logic.state.to_img()
|
|
||||||
if message is None:
|
|
||||||
message = logic.state.to_html()
|
|
||||||
else:
|
|
||||||
message = message.to_html()
|
|
||||||
|
|
||||||
socketio.emit('status', {'led': led, 'message': message})
|
|
||||||
|
|
||||||
|
|
||||||
@socketio.on('connect')
|
@socketio.on('connect')
|
||||||
def on_connect():
|
def on_connect():
|
||||||
emit_status()
|
logic.emit_status()
|
||||||
|
|
||||||
|
|
||||||
@webapp.route('/display')
|
@webapp.route('/display')
|
||||||
@ -252,8 +252,6 @@ def home():
|
|||||||
# Don't trust python, zero credentials
|
# Don't trust python, zero credentials
|
||||||
user = password = credentials = None
|
user = password = credentials = None
|
||||||
|
|
||||||
emit_status(response)
|
|
||||||
|
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
authentication_form=authentication_form,
|
authentication_form=authentication_form,
|
||||||
response=response,
|
response=response,
|
||||||
|
Loading…
Reference in New Issue
Block a user