diff --git a/server/webserver.py b/server/webserver.py index cd9e347..596fd81 100644 --- a/server/webserver.py +++ b/server/webserver.py @@ -138,35 +138,35 @@ class WebServer: match k: case "since": since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC) - spots = [s for s in spots if s.time > since] + spots = [s for s in spots if s.time and s.time > since] case "max_age": max_age = int(query.get(k)) since = datetime.now(pytz.UTC) - timedelta(seconds=max_age) - spots = [s for s in spots if s.time > since] + spots = [s for s in spots if s.time and s.time > since] case "received_since": since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC) - spots = [s for s in spots if s.received_time > since] + spots = [s for s in spots if s.received_time and s.received_time > since] case "source": sources = query.get(k).split(",") - spots = [s for s in spots if s.source in sources] + spots = [s for s in spots if s.source and s.source in sources] case "sig": sigs = query.get(k).split(",") - spots = [s for s in spots if s.sig in sigs] + spots = [s for s in spots if s.sig and s.sig in sigs] case "band": bands = query.get(k).split(",") - spots = [s for s in spots if s.band in bands] + spots = [s for s in spots if s.band and s.band in bands] case "mode": modes = query.get(k).split(",") spots = [s for s in spots if s.mode in modes] case "mode_type": mode_families = query.get(k).split(",") - spots = [s for s in spots if s.mode_type in mode_families] + spots = [s for s in spots if s.mode_type and s.mode_type in mode_families] case "dx_continent": dxconts = query.get(k).split(",") - spots = [s for s in spots if s.dx_continent in dxconts] + spots = [s for s in spots if s.dx_continent and s.dx_continent in dxconts] case "de_continent": deconts = query.get(k).split(",") - spots = [s for s in spots if s.de_continent in deconts] + spots = [s for s in spots if s.de_continent and s.de_continent in deconts] # If we have a "limit" parameter, we apply that last, regardless of where it appeared in the list of keys. if "limit" in query.keys(): spots = spots[:int(query.get("limit"))] @@ -195,7 +195,7 @@ class WebServer: match k: case "received_since": since = datetime.fromtimestamp(int(query.get(k)), pytz.UTC) - alerts = [a for a in alerts if a.received_time > since] + alerts = [a for a in alerts if a.received_time and a.received_time > since] case "max_duration": max_duration = int(query.get(k)) # Check the duration if end_time is provided. If end_time is not provided, assume the activation is @@ -204,13 +204,13 @@ class WebServer: not a.end_time] case "source": sources = query.get(k).split(",") - alerts = [a for a in alerts if a.source in sources] + alerts = [a for a in alerts if a.source and a.source in sources] case "sig": sigs = query.get(k).split(",") - alerts = [a for a in alerts if a.sig in sigs] + alerts = [a for a in alerts if a.sig and a.sig in sigs] case "dx_continent": dxconts = query.get(k).split(",") - alerts = [a for a in alerts if a.dx_continent in dxconts] + alerts = [a for a in alerts if a.dx_continent and a.dx_continent in dxconts] # If we have a "limit" parameter, we apply that last, regardless of where it appeared in the list of keys. if "limit" in query.keys(): alerts = alerts[:int(query.get("limit"))] diff --git a/views/webpage_alerts.tpl b/views/webpage_alerts.tpl index 33b9227..fc5b3ea 100644 --- a/views/webpage_alerts.tpl +++ b/views/webpage_alerts.tpl @@ -7,38 +7,44 @@
- +
Alerts to view: - +
+ + + + + Alerts to view: + +
- +
Spots to view: - +
+ + + + + Spots to view: + +
| Start UTC | `); - table.find('thead tr').append(`End UTC | `); + table.find('thead tr').append(`${useLocalTime ? "Start (Local)" : "Start UTC"} | `); + table.find('thead tr').append(`${useLocalTime ? "End (Local)" : "End UTC"} | `); table.find('thead tr').append(`DX | `); table.find('thead tr').append(`Frequencies & Modes | `); table.find('thead tr').append(`Comment | `); @@ -82,18 +85,31 @@ function addAlertRowsToTable(tbody, alerts) { // Create row let $tr = $('
|---|---|---|---|---|
| UTC | `); + table.find('thead tr').append(`${useLocalTime ? "Local" : "UTC"} | `); table.find('thead tr').append(`DX | `); table.find('thead tr').append(`Frequency | `); table.find('thead tr').append(`Mode | `); @@ -55,8 +58,11 @@ function updateTable() { $tr.addClass("table-faded"); } - // Format a UTC time for display + // Format a UTC or local time for display var time = moment.unix(s["time"]).utc(); + if (useLocalTime) { + time = time.local(); + } var time_formatted = time.format("HH:mm"); // Format DX flag @@ -157,13 +163,13 @@ function loadOptions() { addBandColourCSS(options["bands"]); // Populate the filters panel - $("#settings-container-1").append(generateBandsMultiToggleFilterCard(options["bands"])); - $("#settings-container-2").append(generateMultiToggleFilterCard("DX Continent", "dx_continent", options["continents"])); - $("#settings-container-2").append(generateMultiToggleFilterCard("DE Continent", "de_continent", options["continents"])); - $("#settings-container-2").append(generateMultiToggleFilterCard("Modes", "mode_type", options["mode_types"])); - $("#settings-container-2").append(generateMultiToggleFilterCard("Sources", "source", options["spot_sources"])); + $("#filters-container-1").append(generateBandsMultiToggleFilterCard(options["bands"])); + $("#filters-container-2").append(generateMultiToggleFilterCard("DX Continent", "dx_continent", options["continents"])); + $("#filters-container-2").append(generateMultiToggleFilterCard("DE Continent", "de_continent", options["continents"])); + $("#filters-container-2").append(generateMultiToggleFilterCard("Modes", "mode_type", options["mode_types"])); + $("#filters-container-2").append(generateMultiToggleFilterCard("Sources", "source", options["spot_sources"])); - // Load settings from settings storage + // Load filters from settings storage loadSettings(); // Load spots and set up the timer @@ -217,12 +223,12 @@ function filtersUpdated() { // Set up UI element event listeners, after the document is ready function setUpEventListeners() { - $("#settings-button").click(function() { - $("#settings-area").toggle(); + $("#filters-button").click(function() { + $("#filters-area").toggle(); }); - $("#close-settings-button").click(function() { - $("#settings-button").button("toggle"); - $("#settings-area").hide(); + $("#close-filters-button").click(function() { + $("#filters-button").button("toggle"); + $("#filters-area").hide(); }); }
|---|