From f7d78c0ea67761def4eb8c7869bc2646ccd38738 Mon Sep 17 00:00:00 2001 From: WildSoft Date: Sun, 15 Nov 2026 16:11:27 +0300 Subject: [PATCH] Update public source --- reports/access_points.py | 8 +++++++- reports/access_points_page.py | 3 ++- reports/map_service.py | 11 +++++++++++ reports/search.py | 7 ++----- reports/session_page.py | 8 +++++++- reports/wifi_connections.py | 8 +++++++- 6 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 reports/map_service.py diff --git a/reports/access_points.py b/reports/access_points.py index 64bce14..7b9f271 100644 --- a/reports/access_points.py +++ b/reports/access_points.py @@ -12,6 +12,7 @@ from reports.utils import ( format_datetime as format_report_datetime, ) from reports.map_popups import build_standard_popup +from reports.map_service import get_map_style_url def esc(value): @@ -408,7 +409,7 @@ const map = new maplibregl.Map({ container: "map", style: - "http://127.0.0.1:8080/styles/server-map/style.json", + __MAP_STYLE_URL__, center: [ 30.32, @@ -1181,6 +1182,11 @@ window.setTimeout( marker_js, ) + map_html = map_html.replace( + "__MAP_STYLE_URL__", + json.dumps(get_map_style_url()), + ) + return map_html diff --git a/reports/access_points_page.py b/reports/access_points_page.py index 7ef6d4b..67b04b0 100644 --- a/reports/access_points_page.py +++ b/reports/access_points_page.py @@ -16,6 +16,7 @@ from reports.template import ( page_end, ) from reports.map_popups import build_standard_popup +from reports.map_service import get_map_style_url def esc(value): return html.escape("" if value is None else str(value), quote=True) @@ -932,7 +933,7 @@ def render_map(geojson, context, title): const map = new maplibregl.Map({{ container: "access-point-history-map", - style: "http://127.0.0.1:8080/styles/server-map/style.json", + style: {json.dumps(get_map_style_url())}, center: [30.32, 59.93], zoom: 5 }}); diff --git a/reports/map_service.py b/reports/map_service.py new file mode 100644 index 0000000..2468139 --- /dev/null +++ b/reports/map_service.py @@ -0,0 +1,11 @@ +""" +Centralized map service configuration. +""" + +MAP_STYLE_URL = ( + "http://127.0.0.1:8080/styles/server-map/style.json" +) + + +def get_map_style_url(): + return MAP_STYLE_URL diff --git a/reports/search.py b/reports/search.py index ca6f8fe..5cbd23c 100644 --- a/reports/search.py +++ b/reports/search.py @@ -15,10 +15,7 @@ from reports.utils import ( format_datetime as format_report_datetime, ) from reports.map_popups import build_standard_popup - -MAP_STYLE_URL = ( - "http://127.0.0.1:8080/styles/server-map/style.json" -) +from reports.map_service import get_map_style_url # ============================================================ @@ -2020,7 +2017,7 @@ def render_search_page( ) ).replace( "{map_style}", - MAP_STYLE_URL + json.dumps(get_map_style_url()) ) html += page_end() diff --git a/reports/session_page.py b/reports/session_page.py index bd05aa0..93f7d39 100644 --- a/reports/session_page.py +++ b/reports/session_page.py @@ -39,6 +39,7 @@ from reports.template import ( ReportContext, ) from reports.map_popups import build_standard_popup +from reports.map_service import get_map_style_url # ============================================================ # Helpers @@ -865,7 +866,7 @@ const map = new maplibregl.Map({ style: - "http://127.0.0.1:8080/styles/server-map/style.json", + __MAP_STYLE_URL__, center: [ @@ -2672,6 +2673,11 @@ Session folder: html += page_end() + html = html.replace( + "__MAP_STYLE_URL__", + json.dumps(get_map_style_url()), + ) + return html diff --git a/reports/wifi_connections.py b/reports/wifi_connections.py index 5be6745..5539f0d 100644 --- a/reports/wifi_connections.py +++ b/reports/wifi_connections.py @@ -7,6 +7,7 @@ from reports.access_points import ( load_access_points, ) from reports.map_popups import build_standard_popup +from reports.map_service import get_map_style_url from reports.template import ( ReportContext, card, @@ -216,7 +217,7 @@ const map = new maplibregl.Map({ container: "map", style: - "http://127.0.0.1:8080/styles/server-map/style.json", + __MAP_STYLE_URL__, center: [ 30.32, @@ -671,6 +672,11 @@ window.setTimeout( marker_js, ) + map_html = map_html.replace( + "__MAP_STYLE_URL__", + json.dumps(get_map_style_url()), + ) + return map_html