From 75df9fc66da911d389e1478a0bc848dfcc5683fe Mon Sep 17 00:00:00 2001 From: claude-dev Date: Wed, 4 Mar 2026 22:46:58 +0100 Subject: [PATCH] Fix: Leaflet 'L is not defined' - Integrity-Hashes entfernt + Guard - SRI integrity-Hashes von Leaflet CDN-Links entfernt (verursachen stille Blockierung wenn Hash nicht passt) - renderMap() prueft ob L verfuegbar ist und merkt sich Locations - retryPendingMap() rendert nachtraeglich wenn Leaflet spaeter bereit ist - 2s Retry-Timer nach init() als Fallback Co-Authored-By: Claude Opus 4.6 --- src/static/dashboard.html | 16 ++++++++-------- src/static/js/app.js | 3 +++ src/static/js/components.js | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/static/dashboard.html b/src/static/dashboard.html index f37f117..07b8100 100644 --- a/src/static/dashboard.html +++ b/src/static/dashboard.html @@ -13,10 +13,10 @@ - + - + @@ -558,12 +558,12 @@
- + - - - - - + + + + + diff --git a/src/static/js/app.js b/src/static/js/app.js index 27eee87..bd7eafa 100644 --- a/src/static/js/app.js +++ b/src/static/js/app.js @@ -497,6 +497,9 @@ const App = { await this.selectIncident(id); } } + + // Leaflet-Karte nachladen falls CDN langsam war + setTimeout(() => UI.retryPendingMap(), 2000); }, async loadIncidents() { diff --git a/src/static/js/components.js b/src/static/js/components.js index d3c726a..8127516 100644 --- a/src/static/js/components.js +++ b/src/static/js/components.js @@ -602,12 +602,26 @@ const UI = { _map: null, _mapCluster: null, + _pendingLocations: null, + renderMap(locations) { const container = document.getElementById('map-container'); const emptyEl = document.getElementById('map-empty'); const statsEl = document.getElementById('map-stats'); if (!container) return; + // Leaflet noch nicht geladen? Locations merken und spaeter rendern + if (typeof L === 'undefined') { + this._pendingLocations = locations; + // Statistik trotzdem anzeigen + if (locations && locations.length > 0) { + const totalArticles = locations.reduce((s, l) => s + l.article_count, 0); + if (statsEl) statsEl.textContent = `${locations.length} Orte / ${totalArticles} Artikel`; + if (emptyEl) emptyEl.style.display = 'none'; + } + return; + } + if (!locations || locations.length === 0) { if (emptyEl) emptyEl.style.display = 'flex'; if (statsEl) statsEl.textContent = ''; @@ -723,6 +737,14 @@ const UI = { if (this._map) this._map.invalidateSize(); }, + retryPendingMap() { + if (this._pendingLocations && typeof L !== 'undefined') { + const locs = this._pendingLocations; + this._pendingLocations = null; + this.renderMap(locs); + } + }, + /** * HTML escapen. */