diff --git a/lib/microwaveprop_web/components/layouts.ex b/lib/microwaveprop_web/components/layouts.ex index 880a8a54..d08e3faa 100644 --- a/lib/microwaveprop_web/components/layouts.ex +++ b/lib/microwaveprop_web/components/layouts.ex @@ -43,9 +43,9 @@ defmodule MicrowavepropWeb.Layouts do <.link navigate="/map" class="btn btn-ghost btn-sm">Map <.link navigate="/path" class="btn btn-ghost btn-sm">Path <.link navigate="/beacons" class="btn btn-ghost btn-sm">Beacons + <.link navigate="/submit" class="btn btn-ghost btn-sm">Submit <.link navigate="/contacts" class="btn btn-ghost btn-sm">Contacts <.link navigate="/contacts/map" class="btn btn-ghost btn-sm">Contact Map - <.link navigate="/submit" class="btn btn-ghost btn-sm">Submit <.link navigate="/about" class="btn btn-ghost btn-sm">About <.link :if={@current_scope && @current_scope.user && @current_scope.user.is_admin} diff --git a/lib/microwaveprop_web/live/beacon_live/show.ex b/lib/microwaveprop_web/live/beacon_live/show.ex index a0a85183..59bf0bcd 100644 --- a/lib/microwaveprop_web/live/beacon_live/show.ex +++ b/lib/microwaveprop_web/live/beacon_live/show.ex @@ -5,6 +5,7 @@ defmodule MicrowavepropWeb.BeaconLive.Show do alias Microwaveprop.Beacons alias Microwaveprop.Beacons.Beacon alias Microwaveprop.Beacons.RangeEstimate + alias Microwaveprop.Radio.BandResolver @impl true def render(assigns) do @@ -29,6 +30,9 @@ defmodule MicrowavepropWeb.BeaconLive.Show do <.button navigate={~p"/beacons"}> <.icon name="hero-arrow-left" /> + <.button navigate={path_calc_link(@beacon)}> + <.icon name="hero-map" /> Plot path to beacon + <.button :if={admin?(@current_scope)} variant="primary" @@ -211,6 +215,20 @@ defmodule MicrowavepropWeb.BeaconLive.Show do defp format_coord(value) when is_float(value), do: :erlang.float_to_binary(value, decimals: 6) defp format_coord(value), do: to_string(value) + defp path_calc_link(%Beacon{} = beacon) do + base = %{ + "destination" => beacon.grid, + "dst_height_ft" => to_string(beacon.height_ft) + } + + params = maybe_put(base, "band", BandResolver.resolve_as_string(beacon.frequency_mhz)) + + "/path?" <> URI.encode_query(params) + end + + defp maybe_put(map, _key, nil), do: map + defp maybe_put(map, key, value), do: Map.put(map, key, value) + attr :label, :string, required: true slot :inner_block, required: true diff --git a/lib/microwaveprop_web/live/map_live.ex b/lib/microwaveprop_web/live/map_live.ex index c9e22bf3..8d441060 100644 --- a/lib/microwaveprop_web/live/map_live.ex +++ b/lib/microwaveprop_web/live/map_live.ex @@ -474,9 +474,6 @@ defmodule MicrowavepropWeb.MapLive do <.link navigate="/weather" class="btn btn-xs btn-ghost justify-start"> Weather Map - <.link navigate="/algo" class="btn btn-xs btn-ghost justify-start"> - Scoring Algorithm - <.link navigate="/submit" class="btn btn-xs btn-ghost justify-start"> Submit a Contact @@ -486,6 +483,9 @@ defmodule MicrowavepropWeb.MapLive do <.link navigate="/contacts/map" class="btn btn-xs btn-ghost justify-start"> Contact Map + <.link navigate="/algo" class="btn btn-xs btn-ghost justify-start"> + Scoring Algorithm + <.link navigate="/about" class="btn btn-xs btn-ghost justify-start"> About @@ -631,9 +631,6 @@ defmodule MicrowavepropWeb.MapLive do
  • <.link navigate="/weather">Weather Map
  • -
  • - <.link navigate="/algo">Scoring Algorithm -
  • <.link navigate="/submit">Submit a Contact
  • @@ -643,6 +640,9 @@ defmodule MicrowavepropWeb.MapLive do
  • <.link navigate="/contacts/map">Contact Map
  • +
  • + <.link navigate="/algo">Scoring Algorithm +
  • <.link navigate="/about">About
  • diff --git a/lib/microwaveprop_web/live/weather_map_live.ex b/lib/microwaveprop_web/live/weather_map_live.ex index 02192d65..60276e67 100644 --- a/lib/microwaveprop_web/live/weather_map_live.ex +++ b/lib/microwaveprop_web/live/weather_map_live.ex @@ -306,9 +306,6 @@ defmodule MicrowavepropWeb.WeatherMapLive do <.link navigate="/beacons" class="btn btn-xs btn-ghost justify-start"> Beacons - <.link navigate="/algo" class="btn btn-xs btn-ghost justify-start"> - Scoring Algorithm - <.link navigate="/submit" class="btn btn-xs btn-ghost justify-start"> Submit a Contact @@ -318,6 +315,9 @@ defmodule MicrowavepropWeb.WeatherMapLive do <.link navigate="/contacts/map" class="btn btn-xs btn-ghost justify-start"> Contact Map + <.link navigate="/algo" class="btn btn-xs btn-ghost justify-start"> + Scoring Algorithm + <.link navigate="/about" class="btn btn-xs btn-ghost justify-start"> About @@ -426,9 +426,6 @@ defmodule MicrowavepropWeb.WeatherMapLive do
  • <.link navigate="/beacons">Beacons
  • -
  • - <.link navigate="/algo">Scoring Algorithm -
  • <.link navigate="/submit">Submit a Contact
  • @@ -438,6 +435,9 @@ defmodule MicrowavepropWeb.WeatherMapLive do
  • <.link navigate="/contacts/map">Contact Map
  • +
  • + <.link navigate="/algo">Scoring Algorithm +
  • <.link navigate="/about">About