cesanta / mongoose-wizard

2 stars 1 forks source link

Implement UI auto-refresh heartbeat #24

Closed cpq closed 3 months ago

cpq commented 3 months ago

Add a configuration option - a heartbeat interval. Add a visual "UI freshness" indicator to the toolbar

Adding @dvosully for the implementation feedback

cpq commented 3 months ago

@dvosully the autosync is done.

When device is offline, the toolbar shows red circle and the last sync time:

image

When device is online, a green circle is shown:

image

The sync interval is set in the "sidebar" panel, default is 1 second. When device state changes (a setter function is called which changes attributes), all variables are re-synchronised.

Please feedback

dvosully commented 3 months ago

@cpq I've tested this now. I like the concept and UI, but have a few reservations.

Things I like:

Things I am not yet convinced of:

I don't have a clear idea of how to fix all these things cleanly, and some of the below ideas get complex or may interact badly, but following are some thoughts:

I'll keep thinking about this.

cpq commented 3 months ago

Thanks David!

There is a API function what can trigger refresh independently from any user action:

// Increment device change state counter - trigger UI refresh
void glue_update_state(void);

Currently there is only a single global change counter. We can implement a per-endpoint counter, though that will make both the api above, and processing logic more complex. Esprecially if we want to hide counters of the privileged endpoints from the unprivileged users. Also we can employ websocket to push changes immediately instead of polling, but historically we found that websocket has a toll on both device and a UI.

Note - this change / autorefresh indicator was requested by multiple people . One company even had this as a very strong requirement, cause they had cases with their current implementation, people making changes to the stale UI shutting down the device, or making fatal changes. So for them, having a fresh up-to-date UI is a way higher priority that a user filling setting and having that updated - from the operation safety, they much prefer that rather than showing stale values.

To summarise, the current implementation

We plan to keep the current implementation, and address mentioned issues later, as we see them as a lower priority at this moment.