phoenixframework / phoenix_live_dashboard

Realtime dashboard with metrics, request logging, plus storage, OS and VM insights

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Update every" value should be remembered across pages

eksperimental opened this issue · comments

Environment

  • Elixir version (elixir -v): 1.11.2
  • Phoenix version (mix deps): 1.5.7
  • Phoenix LiveView version (mix deps): 0.15.3
  • Phoenix Dashboard version (mix deps): 0.4.0
  • Operating system: Linux
  • Browsers you attempted to reproduce this bug on (the more the merrier): Firefox

Actual behavior

Let' s say I change the "update every" value in HOME, and then I switch to another tab. When I came back to home, the value I originally chose is lost

Expected behavior

To remember it. Either globally for all tabs, Or individually per tab

A pull request for this is welcome, probably a hook that stores the value somewhere.

A pull request for this is welcome, probably a hook that stores the value somewhere.

If you give me some guidance on this maybe I can give it a try :)

We did something similar in Livebook. The idea is that you will pass some parameters on connect:

https://github.com/elixir-nx/livebook/blob/main/assets/js/app.js#L47

And those parameters can be read from the cookie:

https://github.com/elixir-nx/livebook/blob/da64f51589eaf41f1c3bdd7ed018c196035ff2aa/assets/js/lib/user.js#L17

And the select dropdown will update the cookie whenever it changes using a Phoenix hook. :)

And in the server you read the current value:

https://github.com/elixir-nx/livebook/blob/5c8e1178001d30902cbf2109c1f51f2dba7d52df/lib/livebook_web/live/user_helpers.ex#L53

Note we will need to do it per page though (i.e. store the value per page but probably all in the same cookie?).