Merge pull request #33 from aprsme/add-last-update-display

Add real-time last update display to map sidebar
This commit is contained in:
Graham McIntire 2025-07-25 14:29:00 -05:00 committed by GitHub
commit a4efe82981
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View file

@ -199,7 +199,10 @@ defmodule AprsmeWeb.MapLive.Index do
# Overlay controls
overlay_callsign: "",
# Slideover state - will be set based on screen size
slideover_open: true
slideover_open: true,
# Track when last update occurred for real-time display in map sidebar
# Updated when packets are processed or map bounds change
last_update_at: DateTime.utc_now()
)
end
@ -1295,6 +1298,31 @@ defmodule AprsmeWeb.MapLive.Index do
/>
</div>
<!-- Last Update -->
<div class="pt-4 border-t border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-sm text-slate-600">
<svg class="w-4 h-4 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"
/>
</svg>
<span class="font-medium">{gettext("Last Update")}</span>
</div>
<div class="text-xs text-slate-500">
<%= if @last_update_at do %>
<div class="font-mono">{time_ago_in_words(@last_update_at)}</div>
<div class="font-mono text-slate-400">
{Calendar.strftime(@last_update_at, "%Y-%m-%d %H:%M UTC")}
</div>
<% else %>
<div class="font-mono text-slate-500">No updates yet</div>
<% end %>
</div>
</div>
<!-- Deployment Information -->
<div class="pt-4 border-t border-slate-200 space-y-3">
<div class="flex items-center space-x-2 text-sm text-slate-600">
@ -1618,6 +1646,8 @@ defmodule AprsmeWeb.MapLive.Index do
socket
|> assign(map_bounds: map_bounds, packet_state: updated_packet_state)
|> assign(needs_initial_historical_load: false)
# Update last update timestamp when map bounds change - this triggers data refresh
|> assign(last_update_at: DateTime.utc_now())
# Load historical packets for the new bounds (now socket.assigns.map_bounds is correct)
Logger.debug("Starting progressive historical loading for new bounds")

View file

@ -38,6 +38,11 @@ defmodule AprsmeWeb.MapLive.PacketProcessor do
# Handle packet visibility logic
socket = handle_packet_visibility(packet, lat, lon, callsign_key, socket)
# Update last update timestamp for real-time display in map sidebar
# This timestamp is shown to users to indicate when data was last refreshed
socket = assign(socket, :last_update_at, DateTime.utc_now())
{:noreply, socket}
end