From 04f5df526066c82e1d39759ee1005eb34043b4f4 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 11 Sep 2026 14:43:33 +0100 Subject: [PATCH] Alerts now displays a "Type" in the table not just the source. Closes #142 --- providers/alert/hamsat.py | 9 +++- static/js/alerts.js | 50 +++++++++++++++++------ templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 +- templates/base.html | 10 ++--- templates/cards/table_columns_alerts.html | 6 +-- templates/conditions.html | 2 +- templates/map.html | 4 +- templates/spots.html | 4 +- templates/status.html | 2 +- 11 files changed, 63 insertions(+), 32 deletions(-) diff --git a/providers/alert/hamsat.py b/providers/alert/hamsat.py index d04302f..6390e2a 100644 --- a/providers/alert/hamsat.py +++ b/providers/alert/hamsat.py @@ -22,11 +22,18 @@ class Hamsat(HTTPAlertProvider): # Iterate through source data for source_alert in http_response.json()["data"]: # Convert to our alert format + freqs_modes = source_alert.get("mode", "") + if "mhz" in source_alert: + if "mhz_direction" in source_alert: + freqs_modes = f"{source_alert['mhz']!s} {source_alert['mhz_direction']}, {freqs_modes}" + else: + freqs_modes = f"{source_alert['mhz']!s}, {freqs_modes}" + alert = Alert( source=self.name, source_id=source_alert["id"], dx_calls=[source_alert["callsign"].upper()], - freqs_modes=f"{source_alert['mhz']!s} {source_alert['mhz_direction']}, {source_alert['mode']}", + freqs_modes=freqs_modes, comment=source_alert["comment"], # Fudge a SIG ref to provide the remaining bits of data we need: the satellite and the operator's grid sig_refs=[ diff --git a/static/js/alerts.js b/static/js/alerts.js index 2c71454..ffd5a0e 100644 --- a/static/js/alerts.js +++ b/static/js/alerts.js @@ -54,7 +54,7 @@ function updateTable() { const showDX = $("#tableShowDX")[0].checked; const showFreqsModes = $("#tableShowFreqsModes")[0].checked; const showComment = $("#tableShowComment")[0].checked; - const showSource = $("#tableShowSource")[0].checked; + const showType = $("#tableShowType")[0].checked; const showRef = $("#tableShowRef")[0].checked; // Populate table with headers @@ -75,8 +75,8 @@ function updateTable() { if (showComment) { table.find('thead tr').append(`Comment`); } - if (showSource) { - table.find('thead tr').append(`Source`); + if (showType) { + table.find('thead tr').append(`Type`); } if (showRef) { table.find('thead tr').append(`Ref.`); @@ -151,7 +151,7 @@ function addAlertRowsToTable(tbody, alerts) { const showDX = $("#tableShowDX")[0].checked; const showFreqsModes = $("#tableShowFreqsModes")[0].checked; const showComment = $("#tableShowComment")[0].checked; - const showSource = $("#tableShowSource")[0].checked; + const showType = $("#tableShowType")[0].checked; const showRef = $("#tableShowRef")[0].checked; // Get times for the alert, and convert to local time if necessary. @@ -232,14 +232,38 @@ function addAlertRowsToTable(tbody, alerts) { if (a["comment"] != null) { commentText = escapeHtml(a["comment"]); } - if (a["url"] != null) { - commentText += ` 🔗`; + + // Format extra text, like URL and attribution + let subComment = a["url"] != null || a["source"] === "NG3K" || a["source"] === "WA7BNM Contest Calendar"; + if (subComment) { + let subCommentText = "" + if (a["url"] != null) { + subCommentText += `More info`; + } + if ((a["source"] === "NG3K" || a["source"] === "WA7BNM Contest Calendar")) { + if (subCommentText !== "") { + subCommentText += " | "; + } + subCommentText += `From ${a["source"]}`; + } + commentText += `
${subCommentText}
`; } - // Sig or fallback to source - let sigSourceText = a["source"]; - if (a["sig"]) { - sigSourceText = a["sig"]; + + // Type, SIG or fallback to source + let sigTypeText = a["source"]; + if (a["alert_type"] === "CONTEST") { + sigTypeText = "Contest"; + } else if (a["alert_type"] === "DXPEDITION") { + sigTypeText = "DXpedition"; + } else if (a["alert_type"] === "SATELLITE") { + sigTypeText = "Satellite"; + } else if (a["alert_type"] === "XOTA") { + if (a["sig"]) { + sigTypeText = a["sig"]; + } else { + sigTypeText = "xOTA"; + } } // Format sig_refs @@ -272,8 +296,8 @@ function addAlertRowsToTable(tbody, alerts) { if (showComment) { $tr.append(`${commentText}`); } - if (showSource) { - $tr.append(` ${sigSourceText}`); + if (showType) { + $tr.append(` ${sigTypeText}`); } if (showRef) { $tr.append(`${sig_refs}`); @@ -290,7 +314,7 @@ function addAlertRowsToTable(tbody, alerts) { } const $td2 = $(""); - if (showSource) { + if (showType) { $td2.append(` `); } if (showRef) { diff --git a/templates/add_spot.html b/templates/add_spot.html index 8819588..183f60d 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 285e769..124d935 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -83,7 +83,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 8c1d613..b40747f 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index abfcfe3..31abd4e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/cards/table_columns_alerts.html b/templates/cards/table_columns_alerts.html index 77c9137..fb07cb6 100644 --- a/templates/cards/table_columns_alerts.html +++ b/templates/cards/table_columns_alerts.html @@ -39,9 +39,9 @@
- - + +
diff --git a/templates/conditions.html b/templates/conditions.html index ffa43a0..34413eb 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 30dcdc3..24383ae 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index c88ab0d..14ec22a 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 29564a5..6d0faf3 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +