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:
parent
5a14756348
commit
32ce43f04a
1 changed files with 26 additions and 1 deletions
|
|
@ -71,6 +71,8 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
# wrong viewport and forecast-hour clicks show a small square of
|
# wrong viewport and forecast-hour clicks show a small square of
|
||||||
# coverage instead of the full map.
|
# coverage instead of the full map.
|
||||||
|
|
||||||
|
build_ts = Microwaveprop.Application.build_timestamp()
|
||||||
|
|
||||||
{:ok,
|
{:ok,
|
||||||
assign(socket,
|
assign(socket,
|
||||||
page_title: "Propagation Prediction Map",
|
page_title: "Propagation Prediction Map",
|
||||||
|
|
@ -85,10 +87,26 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
outside_conus: outside_conus?(visitor),
|
outside_conus: outside_conus?(visitor),
|
||||||
grid_visible: false,
|
grid_visible: false,
|
||||||
radar_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
|
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.
|
# 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
|
defp initial_center(%{"cf_lat" => lat, "cf_lon" => lon}) when is_float(lat) and is_float(lon) do
|
||||||
%{lat: lat, lon: lon}
|
%{lat: lat, lon: lon}
|
||||||
|
|
@ -879,6 +897,13 @@ defmodule MicrowavepropWeb.MapLive do
|
||||||
status={@pipeline_status}
|
status={@pipeline_status}
|
||||||
progress={@pipeline_progress}
|
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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue