From f9fa765e3245de03eebb4ebe5b5d2455e1cba873 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 15 Jun 2025 21:32:37 -0500 Subject: [PATCH] add oban tables --- assets/js/app.js | 63 ------ lib/aprs_web/live/map_live/index.ex | 185 +----------------- .../20250616023156_upgrade_oban_to_latest.exs | 14 ++ 3 files changed, 16 insertions(+), 246 deletions(-) create mode 100644 priv/repo/migrations/20250616023156_upgrade_oban_to_latest.exs diff --git a/assets/js/app.js b/assets/js/app.js index 05b7cf3..db57cd4 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -73,26 +73,6 @@ Hooks.APRSMap = { console.log("Map initialized"); - // Handle geolocation requests from server - this.handleEvent("request_geolocation", () => { - if ("geolocation" in navigator) { - navigator.geolocation.getCurrentPosition( - (position) => { - const { latitude, longitude } = position.coords; - console.log("User location:", latitude, longitude); - map.setView([latitude, longitude], 12); - // Notify server of new location - this.pushEvent("set_location", { lat: latitude, lng: longitude }); - }, - (error) => { - console.warn("Geolocation error:", error.message); - }, - ); - } else { - console.warn("Geolocation not available in this browser"); - } - }); - // Add OpenStreetMap tile layer L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", { attribution: @@ -149,12 +129,10 @@ Hooks.APRSMap = { // Store markers to avoid duplicates this.markers = new Map(); this.historicalMarkers = new Map(); - this.packetCount = 0; // Store map instance and initialize state this.map = map; this.mapReady = false; - this.userLocationMarker = null; // Send initial bounds to server this.sendBoundsToServer(); @@ -211,23 +189,6 @@ Hooks.APRSMap = { console.log("Map view updated after delay"); console.log("New map center:", this.map.getCenter()); console.log("New map zoom:", this.map.getZoom()); - - // Add a marker at the user's location - if (this.userLocationMarker) { - this.map.removeLayer(this.userLocationMarker); - } - - this.userLocationMarker = L.marker([lat, lng], { - icon: L.divIcon({ - html: '
', - className: "user-location-marker", - iconSize: [16, 16], - iconAnchor: [8, 8], - }), - }) - .addTo(this.map) - .bindPopup("Your location") - .openPopup(); }, 300); } else { console.error("Invalid coordinates in zoom_to_location event:", data); @@ -312,11 +273,6 @@ Hooks.APRSMap = { } this.markers.clear(); this.historicalMarkers.clear(); - this.packetCount = 0; - const counterElement = document.getElementById("packet-count"); - if (counterElement) { - counterElement.textContent = this.packetCount; - } }, refreshMarkers() { @@ -345,13 +301,6 @@ Hooks.APRSMap = { this.markers.delete(callsign); } }); - - // Update counter - this.packetCount = this.markers.size; - const counterElement = document.getElementById("packet-count"); - if (counterElement) { - counterElement.textContent = this.packetCount; - } }, clearHistoricalMarkers() { @@ -370,10 +319,7 @@ Hooks.APRSMap = { }, removeMarkersOutsideBounds(bounds) { - // Let LiveView handle the packet count // The cluster handles marker visibility automatically - const visibleCount = this.markers.size; - this.pushEvent("update_packet_count", { count: visibleCount }); }, addPacketMarker(packet, isHistorical = false) { @@ -473,15 +419,6 @@ Hooks.APRSMap = { // Store the marker markerCollection.set(markerId, marker); - - // Update packet counter (only for live packets) - if (!isHistorical) { - this.packetCount++; - const counterElement = document.getElementById("packet-count"); - if (counterElement) { - counterElement.textContent = this.packetCount; - } - } } }, diff --git a/lib/aprs_web/live/map_live/index.ex b/lib/aprs_web/live/map_live/index.ex index cbeab74..93c6bdd 100644 --- a/lib/aprs_web/live/map_live/index.ex +++ b/lib/aprs_web/live/map_live/index.ex @@ -22,7 +22,6 @@ defmodule AprsWeb.MapLive.Index do socket = assign(socket, packets: [], - packet_count: 0, page_title: "APRS Map", # Track visible packets by callsign visible_packets: %{}, @@ -117,8 +116,6 @@ defmodule AprsWeb.MapLive.Index do end) |> Map.new() - packet_count = map_size(visible_packets) - # If replay is not active, update the replay packets based on the new bounds socket = if socket.assigns.replay_active do @@ -138,13 +135,7 @@ defmodule AprsWeb.MapLive.Index do socket end - {:noreply, assign(socket, map_bounds: map_bounds, visible_packets: visible_packets, packet_count: packet_count)} - end - - @impl true - def handle_event("update_packet_count", %{"count" => count}, socket) do - # Update packet count from client after markers are removed - {:noreply, assign(socket, packet_count: count)} + {:noreply, assign(socket, map_bounds: map_bounds, visible_packets: visible_packets)} end @impl true @@ -337,13 +328,12 @@ defmodule AprsWeb.MapLive.Index do # Update visible packets tracking visible_packets = Map.put(socket.assigns.visible_packets, callsign_key, sanitized_packet) - packet_count = map_size(visible_packets) # Push the packet to the client-side JavaScript socket = socket |> push_event("new_packet", packet_data) - |> assign(visible_packets: visible_packets, packet_count: packet_count) + |> assign(visible_packets: visible_packets) {:noreply, socket} else @@ -458,18 +448,6 @@ defmodule AprsWeb.MapLive.Index do z-index: 1; } - .map-overlay { - position: absolute; - top: 10px; - right: 10px; - background: rgba(255, 255, 255, 0.9); - padding: 10px 15px; - border-radius: 5px; - box-shadow: 0 2px 5px rgba(0,0,0,0.2); - z-index: 1000; - max-width: 300px; - } - .locate-button { position: absolute; left: 10px; @@ -486,112 +464,6 @@ defmodule AprsWeb.MapLive.Index do background: #f4f4f4; } - .packet-counter { - font-size: 14px; - font-weight: 600; - color: #333; - margin-bottom: 10px; - display: flex; - justify-content: space-between; - align-items: center; - } - - .replay-badge { - background-color: #3498db; - color: white; - padding: 2px 6px; - border-radius: 10px; - font-size: 10px; - font-weight: bold; - animation: pulse 2s infinite; - } - - @keyframes pulse { - 0% { opacity: 0.7; } - 50% { opacity: 1; } - 100% { opacity: 0.7; } - } - - .replay-controls { - margin-top: 10px; - display: flex; - flex-direction: column; - gap: 8px; - } - - .control-buttons { - display: flex; - gap: 8px; - } - - .replay-controls button { - padding: 5px 10px; - border-radius: 4px; - font-size: 12px; - cursor: pointer; - font-weight: 600; - border: none; - flex: 1; - display: flex; - align-items: center; - justify-content: center; - gap: 4px; - } - - .btn-action { - background-color: #3498db; - color: white; - } - - .btn-danger { - background-color: #e74c3c; - color: white; - } - - .btn-secondary { - background-color: #7f8c8d; - color: white; - } - - .icon { - font-weight: bold; - } - - .speed-control { - font-size: 12px; - margin-top: 5px; - } - - .speed-control input { - width: 100%; - margin-top: 5px; - } - - .replay-progress { - font-size: 12px; - margin-top: 5px; - text-align: center; - } - - .progress-bar { - height: 6px; - background-color: #eee; - border-radius: 3px; - overflow: hidden; - margin-bottom: 5px; - } - - .progress-fill { - height: 100%; - background-color: #3498db; - transition: width 0.5s ease-in-out; - } - - .progress-text { - font-size: 10px; - color: #666; - } - .aprs-marker { background: transparent !important; border: none !important; @@ -613,55 +485,6 @@ defmodule AprsWeb.MapLive.Index do > -
-
- {@packet_count} -  packets in view - <%= if @replay_active do %> -
- Replaying historical packets -
- <% end %> -
-
- <%= if @replay_active do %> -
- - -
-
- - -
-
-
-
0, do: @replay_index * 100 / length(@replay_packets), else: 0}%"} - > -
-
-
- {@replay_index} of {length(@replay_packets)} packets -
-
- <% end %> -
-
-