nsg-ethz / autopower

A software suite to conveniently collect, gather, and display power measurement from networking hardware.
MIT License
2 stars 1 forks source link

Provide push message support for Management UI/implement SSE #17

Open UsualSpec opened 3 months ago

UsualSpec commented 3 months ago

During development, I was planning to allow the server to push messages like a successful measurement start, stop, status messages,... to the management UI and then to connected web browsers. The cli.py script already supports this.

Data transmission would happen via server side events using https://flask-sse.readthedocs.io/en/latest/quickstart.html or https://maxhalford.github.io/blog/flask-sse-no-deps/ then the web browser would display a Bootstrap toast if a new message is incoming. The benefit is that a user would directly get messaged if a device changes status. Unfortunately, during this time I did not know about monkey patching, meaning the server would hang as soon as one web browser tries to retrieve new messages from the (no longer implemented) getStatusMessages endpoint. Now this issue is fixed, and server side events could be implemented.

https://github.com/nsg-ethz/autopower/blob/cdb4c9212433088ddd614a17a9a198c33e689427/server/server.py#L555 shows the gRPC method used to retrieve messages from the server.

There even was an implementation attempt I reverted (check git history around Jun 04,2024 in the private repo if you have access).

In general, only having access to the messages sounds like not being that important.

However, allowing SSE in the Management UI is a worthy change and would potentially allow the project to benefit significantly from more interactivity since the server can now directly forward commands to end users:

Implementation may have some hurdles, is not per se trivial but doable.