From fb935138a177f5608ac7b4bcd8c4893739c5188d Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Mon, 22 Dec 2025 20:44:50 +0000 Subject: [PATCH] Improvements to spot timing display #3 --- core/constants.py | 2 +- webassets/apidocs/openapi.yml | 1 + webassets/js/common.js | 7 ++++--- webassets/js/spots.js | 11 ++++++++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/core/constants.py b/core/constants.py index 9b5bef4..3cfa51b 100644 --- a/core/constants.py +++ b/core/constants.py @@ -36,7 +36,7 @@ SIGS = [ # Modes. Note "DIGI" and "DIGITAL" are also supported but are normalised into "DATA". CW_MODES = ["CW"] PHONE_MODES = ["PHONE", "SSB", "USB", "LSB", "AM", "FM", "DV", "DMR", "DSTAR", "C4FM", "M17"] -DATA_MODES = ["DATA", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "PSK31", "BPSK31", "OLIVIA", "MFSK", "MFSK32", "PKT"] +DATA_MODES = ["DATA", "FT8", "FT4", "RTTY", "SSTV", "JS8", "HELL", "BPSK", "PSK", "PSK31", "BPSK31", "OLIVIA", "MFSK", "MFSK32", "PKT", "MSK144"] ALL_MODES = CW_MODES + PHONE_MODES + DATA_MODES MODE_TYPES = ["CW", "PHONE", "DATA"] diff --git a/webassets/apidocs/openapi.yml b/webassets/apidocs/openapi.yml index 2dde702..c875c83 100644 --- a/webassets/apidocs/openapi.yml +++ b/webassets/apidocs/openapi.yml @@ -841,6 +841,7 @@ components: - MFSK - MFSK32 - PKT + - MSK144 example: SSB ModeType: diff --git a/webassets/js/common.js b/webassets/js/common.js index fa3655d..c7b2623 100644 --- a/webassets/js/common.js +++ b/webassets/js/common.js @@ -117,10 +117,9 @@ function toggleFilterButtons(filterQuery, state) { function updateRefreshDisplay() { if (lastUpdateTime != null) { let secSinceUpdate = moment.duration(moment().diff(lastUpdateTime)).asSeconds(); - let updatingString = " Connected to live spot server."; if (typeof REFRESH_INTERVAL_SEC !== 'undefined' && REFRESH_INTERVAL_SEC != null) { let count = REFRESH_INTERVAL_SEC; - updatingString = "Updating..." + let updatingString = "Updating..." if (secSinceUpdate < REFRESH_INTERVAL_SEC) { count = REFRESH_INTERVAL_SEC - secSinceUpdate; if (count <= 60) { @@ -131,8 +130,10 @@ function updateRefreshDisplay() { updatingString = "Updating in " + number + " minute" + (number != "1" ? "s" : "") + "."; } } + $("#timing-container").html("Last updated at " + lastUpdateTime.format('HH:mm') + " UTC. " + updatingString); + } else { + $("#timing-container").html("Connected to live spot server. Last spot at " + lastUpdateTime.format('HH:mm') + " UTC."); } - $("#timing-container").html("Last updated at " + lastUpdateTime.format('HH:mm') + " UTC. " + updatingString); } } diff --git a/webassets/js/spots.js b/webassets/js/spots.js index 219fbc7..048ea56 100644 --- a/webassets/js/spots.js +++ b/webassets/js/spots.js @@ -30,8 +30,17 @@ function restartSSEConnection() { // Store last updated time lastUpdateTime = moment.utc(); updateRefreshDisplay(); - // Add spot to internal data store + // Get the new spot newSpot = JSON.parse(event.data); + // Awful fudge to ensure new incoming spots at the top of the list don't have timestamps that make them look + // like they belong further down the list. If the spot is older than the latest one we already have, bump its + // time up to match it. This isn't great but since we poll spot providers every 2 minutes anyway, it shouldn't + // be too far wrong. + if (spots.length > 0) { + newSpot["time"] = Math.max(newSpot["time"], Math.max(...spots.map(s => s["time"]))) + } + + // Add spot to internal data store spots.unshift(newSpot); spots = spots.slice(0, -1); // Add spot to table