diff --git a/lib/microwaveprop_web/live/user_profile_live.ex b/lib/microwaveprop_web/live/user_profile_live.ex index eb01bc15..84f8949f 100644 --- a/lib/microwaveprop_web/live/user_profile_live.ex +++ b/lib/microwaveprop_web/live/user_profile_live.ex @@ -3,6 +3,7 @@ defmodule MicrowavepropWeb.UserProfileLive do use MicrowavepropWeb, :live_view alias Microwaveprop.Accounts + alias Microwaveprop.BeaconMonitors alias Microwaveprop.Beacons alias Microwaveprop.Beacons.Beacon alias Microwaveprop.Format @@ -23,13 +24,22 @@ defmodule MicrowavepropWeb.UserProfileLive do beacons = Beacons.list_beacons_for_user(user, viewer) involving = Radio.list_contacts_involving_callsign(user.callsign, viewer) + monitors = + if viewer && viewer.id == user.id do + BeaconMonitors.list_monitors_for_user(user) + else + [] + end + {:ok, assign(socket, page_title: user.callsign, profile: user, contacts: contacts, beacons: beacons, - involving: involving + involving: involving, + beacon_monitors: monitors, + is_own_profile: viewer && viewer.id == user.id )} end end @@ -155,6 +165,56 @@ defmodule MicrowavepropWeb.UserProfileLive do +
+
+

Beacon monitors

+

+ Remote monitor stations that report beacon reception data. +

+ + <%= if @beacon_monitors == [] do %> +
+

No monitors registered yet.

+ <.link navigate={~p"/users/settings#beacon-monitors"} class="btn btn-primary btn-sm"> + <.icon name="hero-plus" class="size-4" /> Register a monitor + +
+ <% else %> +
+ + + + + + + + + + + + + + + +
NameTokenLast seen
{monitor.name} + …{String.slice(monitor.token, -8, 8)} + + <%= if monitor.last_seen_at do %> + {Calendar.strftime(monitor.last_seen_at, "%Y-%m-%d %H:%M UTC")} + <% else %> + never + <% end %> +
+
+
+ <.link navigate={~p"/users/settings#beacon-monitors"} class="btn btn-primary btn-sm"> + <.icon name="hero-plus" class="size-4" /> Register another monitor + +
+ <% end %> +
+
+

Contacts {@profile.callsign} is in

diff --git a/test/microwaveprop_web/live/user_profile_live_test.exs b/test/microwaveprop_web/live/user_profile_live_test.exs index d2db90d8..b018ac75 100644 --- a/test/microwaveprop_web/live/user_profile_live_test.exs +++ b/test/microwaveprop_web/live/user_profile_live_test.exs @@ -7,6 +7,7 @@ defmodule MicrowavepropWeb.UserProfileLiveTest do import Phoenix.LiveViewTest alias Microwaveprop.Accounts.User + alias Microwaveprop.BeaconMonitors alias Microwaveprop.Beacons alias Microwaveprop.Radio.Contact alias Microwaveprop.Repo @@ -217,5 +218,52 @@ defmodule MicrowavepropWeb.UserProfileLiveTest do assert html =~ ~r/font-mono[^>]*>\s*W\s*