feat(map): show last-deployed stamp in map sidebar

Deploy stamp was in Layouts.app's nav but the map page uses a custom
full-screen layout that skips the standard nav, so the info wasn't
visible on the page most users land on. Add a compact
"Deployed 2h ago" under the sidebar's data-timestamp/pipeline-status
block with the full UTC time as a tooltip, matching the shape of
Layouts.deploy_stamp.
This commit is contained in:
Graham McIntire 2026-04-18 12:45:59 -05:00
parent 5a14756348
commit 32ce43f04a
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -71,6 +71,8 @@ defmodule MicrowavepropWeb.MapLive do
# wrong viewport and forecast-hour clicks show a small square of
# coverage instead of the full map.
build_ts = Microwaveprop.Application.build_timestamp()
{:ok,
assign(socket,
page_title: "Propagation Prediction Map",
@ -85,10 +87,26 @@ defmodule MicrowavepropWeb.MapLive do
outside_conus: outside_conus?(visitor),
grid_visible: false,
radar_visible: false,
antenna_height_ft: 33
antenna_height_ft: 33,
deploy_iso: Calendar.strftime(build_ts, "%Y-%m-%d %H:%M UTC"),
deploy_ago: format_deploy_ago(build_ts)
)}
end
# Compact relative-time rendering of the build timestamp. Matches the
# format used by Layouts.deploy_stamp/1 so the nav and the map
# sidebar stay consistent.
defp format_deploy_ago(%DateTime{} = dt) do
diff = max(DateTime.diff(DateTime.utc_now(), dt, :second), 0)
cond do
diff < 60 -> "just now"
diff < 3600 -> "#{div(diff, 60)}m ago"
diff < 86_400 -> "#{div(diff, 3600)}h ago"
true -> "#{div(diff, 86_400)}d ago"
end
end
# Prefer the visitor's Cloudflare geolocation when present; fall back to DFW.
defp initial_center(%{"cf_lat" => lat, "cf_lon" => lon}) when is_float(lat) and is_float(lon) do
%{lat: lat, lon: lon}
@ -879,6 +897,13 @@ defmodule MicrowavepropWeb.MapLive do
status={@pipeline_status}
progress={@pipeline_progress}
/>
<div
class="text-[11px] opacity-60 px-1 pt-2 leading-tight"
title={"Last deployed #{@deploy_iso}"}
>
Deployed {@deploy_ago}
</div>
</div>
</div>
</div>