diff --git a/lib/tietopaketti_web/live/dash_live/index.ex b/lib/tietopaketti_web/live/dash_live/index.ex index f1d6e45..dab5990 100644 --- a/lib/tietopaketti_web/live/dash_live/index.ex +++ b/lib/tietopaketti_web/live/dash_live/index.ex @@ -4,7 +4,7 @@ defmodule TietopakettiWeb.DashLive.Index do def mount(_params, _session, socket) do socket = - assign(socket, instance: Application.fetch_env!(:tietopaketti, :instance), sysdata: nil) + assign(socket, instance: Application.fetch_env!(:tietopaketti, :instance), sysdata: nil, counter: 0) if connected?(socket) do Phoenix.PubSub.subscribe(Tietopaketti.PubSub, Tietopaketti.Sysmon.pubsub_topic()) @@ -16,7 +16,7 @@ defmodule TietopakettiWeb.DashLive.Index do def handle_info(msg, socket) def handle_info({Tietopaketti.Sysdata, sysdata}, socket) do - {:noreply, assign(socket, sysdata: sysdata)} + {:noreply, assign(socket, sysdata: sysdata, counter: socket.assigns.counter + 1)} end def handle_info(_msg, socket) do diff --git a/lib/tietopaketti_web/live/dash_live/index.html.heex b/lib/tietopaketti_web/live/dash_live/index.html.heex index 097bd30..5615085 100644 --- a/lib/tietopaketti_web/live/dash_live/index.html.heex +++ b/lib/tietopaketti_web/live/dash_live/index.html.heex @@ -12,6 +12,7 @@ value={cpu} max={100} value-display={"#{Float.round(cpu)} %"} + counter={@counter} /> <% end %> @@ -30,6 +31,7 @@ @sysdata.mem.total_ram, true )}"} + counter={@counter} />