{gettext("APRS Station")}

{@callsign} <%= if @packet do %> <% {symbol_table, symbol_code} = AprsmeWeb.AprsSymbol.extract_from_packet(@packet) %> <% display_symbol = if symbol_table && String.match?(symbol_table, ~r/^[A-Z0-9]$/), do: symbol_table, else: "#{AprsmeWeb.AprsSymbol.normalize_symbol_table(symbol_table)}#{AprsmeWeb.AprsSymbol.normalize_symbol_code(symbol_code)}" %>
{render_symbol_html(@packet)}
<% end %>
<.link navigate={~p"/packets/#{@callsign}"} class="btn btn-outline btn-sm"> {gettext("View packets")} <%= if @has_weather_packets do %> <.link navigate={~p"/weather/#{@callsign}"} class="btn btn-primary btn-sm"> {gettext("Weather charts")} <% end %>
<%= if @packet do %>

{gettext("Position Information")}

{gettext("Location")}
{@packet.lat || ""}, {@packet.lon || ""}
<%= if @packet.lat && @packet.lon do %>
{gettext("Grid Square")}
<%= case Gridsquare.encode(@packet.lon, @packet.lat) do %> <% %Gridsquare.EncodeResult{grid_reference: grid_ref} -> %> {grid_ref} <% _ -> %> - <% end %>
<% end %>
{gettext("Last Activity")}
<%= if @packet.received_at do %>
{AprsmeWeb.TimeHelpers.time_ago_in_words(@packet.received_at)}
{Calendar.strftime(@packet.received_at, "%Y-%m-%d %H:%M:%S UTC")}
<% else %> {gettext("Unknown")} <% end %>
<%= if @packet.altitude do %>
{gettext("Altitude")}
{@packet.altitude} ft
<% end %> <%= if @packet.course do %>
{gettext("Course")}
{@packet.course}°
<% end %> <%= if @packet.speed do %>
{gettext("Speed")}
{@packet.speed} MPH
<% end %> <%= if @packet.comment do %>
{gettext("Comment")}
<%= if is_binary(@packet.comment) do %> {Aprsme.EncodingUtils.sanitize_string(@packet.comment)} <% else %> {@packet.comment} <% end %>
<% end %> <%= if @packet.phg_power || @packet.phg_height || @packet.phg_gain do %>
{gettext("PHG (Power-Height-Gain)")}
<%= if @packet.phg_power do %>
{gettext("Power:")} {@packet.phg_power} W
<% end %> <%= if @packet.phg_height do %>
{gettext("HAAT:")} {@packet.phg_height} ft
<% end %> <%= if @packet.phg_gain do %>
{gettext("Gain:")} {@packet.phg_gain} dBi
<% end %> <%= if @packet.phg_directivity do %>
{gettext("Dir:")} <%= if @packet.phg_directivity == 0 or @packet.phg_directivity == 360 do %> {gettext("Omni")} <% else %> {@packet.phg_directivity}° <% end %>
<% end %>
<% end %>
<%= if @packet && @packet.lat && @packet.lon do %>
<% {symbol_table, symbol_code} = AprsmeWeb.AprsSymbol.extract_from_packet(@packet) %> <% symbol_html = AprsmeWeb.AprsSymbol.render_marker_html(symbol_table, symbol_code, @callsign, 32) %> <.info_map id="station-location-map" lat={Aprsme.EncodingUtils.to_float(@packet.lat)} lon={Aprsme.EncodingUtils.to_float(@packet.lon)} callsign={@callsign} symbol_html={symbol_html} height="100%" zoom={12} />
<% end %>

{gettext("Device Information")}

{gettext("Device")}
<%= if @packet.device_model || @packet.device_vendor do %> {[ @packet.device_model, @packet.device_vendor, @packet.device_contact ] |> Enum.reject(&is_nil/1) |> Enum.join(" ")} <%= if @packet.device_class do %> ({@packet.device_class}) <% end %> <% else %> {@packet.device_identifier || gettext("Unknown")} <% end %>
{gettext("Path")}
<% path_elements = parse_path_with_links(@packet.path) %> <%= for {{type, content, display}, index} <- Enum.with_index(path_elements) do %> <%= case type do %> <% :link -> %> <.link navigate={~p"/info/#{content}"} class="link link-primary"> {display} <% :text -> %> {content} <% end %> <%= if index < length(path_elements) - 1 do %> , <% end %> <% end %>
<%= if @packet.path && @packet.path != "" do %>
{gettext("Decoded Path")}
{decode_aprs_path(@packet.path)}
<% end %>
{gettext("Raw Packet")}
<%= if is_binary(@packet.raw_packet) do %> {Aprsme.EncodingUtils.sanitize_string(@packet.raw_packet)} <% else %> {@packet.raw_packet || ""} <% end %>
<%= if length(@other_ssids) > 0 do %>

{gettext("Other SSIDs")}

<%= for ssid_info <- @other_ssids do %> <% end %>
{gettext("Callsign")} {gettext("Distance & Direction")} {gettext("Last Heard")}
<.link navigate={~p"/info/#{ssid_info.callsign}"} class="link link-primary"> {ssid_info.callsign} <%= if ssid_info.packet do %> <% {symbol_table, symbol_code} = AprsmeWeb.AprsSymbol.extract_from_packet(ssid_info.packet) %> <% display_symbol = if symbol_table && String.match?(symbol_table, ~r/^[A-Z0-9]$/), do: symbol_table, else: "#{AprsmeWeb.AprsSymbol.normalize_symbol_table(symbol_table)}#{AprsmeWeb.AprsSymbol.normalize_symbol_code(symbol_code)}" %>
{render_symbol_html(ssid_info.packet)}
<% end %>
<%= if ssid_info.packet && ssid_info.packet.lat && ssid_info.packet.lon && @packet && @packet.lat && @packet.lon do %> <% dist = haversine( @packet.lat, @packet.lon, ssid_info.packet.lat, ssid_info.packet.lon ) %> <% course = calculate_course( @packet.lat, @packet.lon, ssid_info.packet.lat, ssid_info.packet.lon ) %> <% locale = Map.get(assigns, :locale, "en") %> {format_distance(dist, locale)} @ {Float.round(course, 0)}° <% else %> - <% end %> <%= if ssid_info.last_heard && ssid_info.last_heard.timestamp do %> {ssid_info.last_heard.time_ago} <% else %> {gettext("Unknown")} <% end %>
<% else %>
<% end %>

{gettext("Stations Near Current Position")}

<%= for neighbor <- @neighbors do %> <% end %>
{gettext("Callsign")} {gettext("Distance & Course")} {gettext("Last Heard")}
<.link navigate={~p"/info/#{neighbor.callsign}"} class="link link-primary"> {neighbor.callsign} <%= if neighbor.packet do %> <% {symbol_table, symbol_code} = AprsmeWeb.AprsSymbol.extract_from_packet(neighbor.packet) %> <% display_symbol = if symbol_table && String.match?(symbol_table, ~r/^[A-Z0-9]$/), do: symbol_table, else: "#{AprsmeWeb.AprsSymbol.normalize_symbol_table(symbol_table)}#{AprsmeWeb.AprsSymbol.normalize_symbol_code(symbol_code)}" %>
{render_symbol_html(neighbor.packet)}
<% end %>
<%= if neighbor.course do %> {neighbor.distance || ""} @ {Float.round(neighbor.course, 0)}° <% else %> {neighbor.distance || ""} <% end %> <%= if neighbor.last_heard do %>
{neighbor.last_heard.time_ago}
{neighbor.last_heard.formatted}
<% else %> {gettext("Unknown")} <% end %>
<%= if length(@heard_by_stations) > 0 do %>

{gettext("Stations which heard %{callsign} directly on radio", callsign: @callsign )}

<%= for station <- @heard_by_stations do %> <% end %>
{gettext("Callsign")} {gettext("First Heard")} {gettext("Last Heard")} {gettext("Packets")} {gettext("Longest Path")}
<.link navigate={~p"/info/#{station.digipeater}"} class="link link-primary"> {station.digipeater} <%= if station.first_heard do %>
{Calendar.strftime(station.first_heard, "%Y-%m-%d %H:%M")}
<% else %> - <% end %>
<%= if station.last_heard do %>
{AprsmeWeb.TimeHelpers.time_ago_in_words(station.last_heard)}
{Calendar.strftime(station.last_heard, "%Y-%m-%d %H:%M")}
<% else %> - <% end %>
{station.packet_count} <%= if station.longest_distance do %> {station.longest_distance} <%= if station.longest_path_time do %>
{Calendar.strftime(station.longest_path_time, "%Y-%m-%d %H:%M")}
<% end %> <% else %> - <% end %>
<% end %> <%= if length(@stations_heard_by) > 0 do %>

{gettext("Stations heard directly by %{callsign}", callsign: @callsign )}

<%= for station <- @stations_heard_by do %> <% end %>
{gettext("Callsign")} {gettext("First Heard")} {gettext("Last Heard")} {gettext("Packets")} {gettext("Longest Path")}
<.link navigate={~p"/info/#{station.station}"} class="link link-primary"> {station.station} <%= if station.first_heard do %>
{Calendar.strftime(station.first_heard, "%Y-%m-%d %H:%M")}
<% else %> - <% end %>
<%= if station.last_heard do %>
{AprsmeWeb.TimeHelpers.time_ago_in_words(station.last_heard)}
{Calendar.strftime(station.last_heard, "%Y-%m-%d %H:%M")}
<% else %> - <% end %>
{station.packet_count} <%= if station.longest_distance do %> {station.longest_distance} <%= if station.longest_path_time do %>
{Calendar.strftime(station.longest_path_time, "%Y-%m-%d %H:%M")}
<% end %> <% else %> - <% end %>
<% end %> <% else %>

{gettext("No data available")}

{gettext("No recent packet data available for this callsign.")}

<% end %>