From d4207a2848de02c14643ee64b25958239ceb8fd7 Mon Sep 17 00:00:00 2001 From: Marat Fayzullin Date: Sat, 16 Sep 2023 17:16:23 -0400 Subject: [PATCH] Clicking on an aircraft message now leads to the map. --- htdocs/lib/MessagePanel.js | 19 ++++++++++++++----- owrx/aircraft.py | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/lib/MessagePanel.js b/htdocs/lib/MessagePanel.js index 6cee4e71..f570ba15 100644 --- a/htdocs/lib/MessagePanel.js +++ b/htdocs/lib/MessagePanel.js @@ -57,9 +57,15 @@ MessagePanel.prototype.scrollToBottom = function() { }; MessagePanel.prototype.linkToMap = function(id, contents = null, attrs = "") { - return '' - + (contents!=null? contents : id) + ''; + if (id) { + return '' + + (contents!=null? contents : id) + ''; + } else if (contents != null) { + return '
' + contents + '
'; + } else { + return ''; + } }; function WsjtMessagePanel(el) { @@ -415,8 +421,11 @@ HfdlMessagePanel.prototype.pushMessage = function(msg) { if (msg.origin) data += ' ↰' + msg.origin; if (msg.destination) data += ' ↳' + msg.destination; - // If no data so far, use message type as data - if (msg.type && !data.length) data = msg.type; + // If no location data in the message, use message type as data + if (!data.length && msg.type) data = msg.type; + + // Make data point to the map + if (data.length && msg.mapid) data = this.linkToMap(msg.mapid, data); // Append report var $b = $(this.el).find('tbody'); diff --git a/owrx/aircraft.py b/owrx/aircraft.py index a5884d74..bd13463f 100644 --- a/owrx/aircraft.py +++ b/owrx/aircraft.py @@ -161,6 +161,8 @@ class AircraftManager(object): if "lat" in item and "lon" in item and "mode" in item: loc = AircraftLocation(item) Map.getSharedInstance().updateLocation(id, loc, item["mode"]) + # Can later use this for linking to the map + data["mapid"] = id # Update input data with computed data for key in ["icao", "aircraft", "flight", "course"]: if key in item: