mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-10 01:17:42 +01:00
added timeout parameter to notificartion controller for potential later usage in UI
This commit is contained in:
parent
2429ea63d1
commit
4ddc9690ef
1 changed files with 3 additions and 3 deletions
|
@ -49,7 +49,7 @@ class NotificationController:
|
||||||
asyncio.create_task(method(self.cbpi, title, message, type, action ))
|
asyncio.create_task(method(self.cbpi, title, message, type, action ))
|
||||||
|
|
||||||
|
|
||||||
def notify(self, title, message: str, type: NotificationType = NotificationType.INFO, action=[]) -> None:
|
def notify(self, title, message: str, type: NotificationType = NotificationType.INFO, action=[], timeout: int=5000) -> None:
|
||||||
'''
|
'''
|
||||||
This is a convinience method to send notification to the client
|
This is a convinience method to send notification to the client
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ class NotificationController:
|
||||||
|
|
||||||
actions = list(map(lambda item: prepare_action(item), action))
|
actions = list(map(lambda item: prepare_action(item), action))
|
||||||
self.callback_cache[notifcation_id] = action
|
self.callback_cache[notifcation_id] = action
|
||||||
self.cbpi.ws.send(dict(id=notifcation_id, topic="notifiaction", type=type.value, title=title, message=message, action=actions))
|
self.cbpi.ws.send(dict(id=notifcation_id, topic="notifiaction", type=type.value, title=title, message=message, action=actions, timeout=timeout))
|
||||||
data = dict(type=type.value, title=title, message=message, action=actions)
|
data = dict(type=type.value, title=title, message=message, action=actions, timeout=timeout)
|
||||||
self.cbpi.push_update(topic="cbpi/notification", data=data)
|
self.cbpi.push_update(topic="cbpi/notification", data=data)
|
||||||
asyncio.create_task(self._call_listener(title, message, type, action))
|
asyncio.create_task(self._call_listener(title, message, type, action))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue