fix map
This commit is contained in:
parent
79fa989a6d
commit
cba6b94508
23
analytics.py
23
analytics.py
@ -191,15 +191,20 @@ def log_file_access(rel_path, filesize, mime, ip_address, user_agent, device_id,
|
|||||||
folder_yesterday.append({'date_str': yesterday_str, 'rel_path': folder_path})
|
folder_yesterday.append({'date_str': yesterday_str, 'rel_path': folder_path})
|
||||||
|
|
||||||
# Finally, insert the new access at the top of the temp log
|
# Finally, insert the new access at the top of the temp log
|
||||||
|
# Keep existing columns stable; append raw geo data for map use.
|
||||||
file_access_temp.insert(0, [
|
file_access_temp.insert(0, [
|
||||||
iso_ts,
|
iso_ts, # 0 timestamp
|
||||||
rel_path,
|
rel_path, # 1 path
|
||||||
filesize,
|
filesize, # 2 size
|
||||||
mime,
|
mime, # 3 mime
|
||||||
f"{city}, {country}",
|
f"{city}, {country}", # 4 location label
|
||||||
user_agent,
|
user_agent, # 5 UA
|
||||||
device_id,
|
device_id, # 6 device
|
||||||
cached
|
cached, # 7 cached flag
|
||||||
|
city, # 8 city
|
||||||
|
country, # 9 country
|
||||||
|
lat, # 10 latitude
|
||||||
|
lon # 11 longitude
|
||||||
])
|
])
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -814,4 +819,4 @@ if __name__ == "__main__":
|
|||||||
search="2025-06-13 Freitag 16 Uhr",
|
search="2025-06-13 Freitag 16 Uhr",
|
||||||
replacement="2025-06-13 Eröffnungsgottesdienst Freitag 16 Uhr",
|
replacement="2025-06-13 Eröffnungsgottesdienst Freitag 16 Uhr",
|
||||||
dry_run=True
|
dry_run=True
|
||||||
)
|
)
|
||||||
|
|||||||
19
app.py
19
app.py
@ -703,17 +703,22 @@ def handle_request_initial_data():
|
|||||||
|
|
||||||
@socketio.on('request_map_data')
|
@socketio.on('request_map_data')
|
||||||
def handle_request_map_data():
|
def handle_request_map_data():
|
||||||
"""Send initial map data with geographic coordinates"""
|
"""Send initial map data from in-memory log to avoid hitting the DB."""
|
||||||
rows = a.return_file_access_with_geo()
|
rows = a.return_file_access()
|
||||||
connections = []
|
connections = []
|
||||||
for row in rows:
|
for row in rows:
|
||||||
if row[8] and row[9]: # lat and lon exist
|
# lat/lon are appended at indexes 10/11 in analytics.log_file_access
|
||||||
|
lat = row[10] if len(row) > 10 else None
|
||||||
|
lon = row[11] if len(row) > 11 else None
|
||||||
|
city = row[8] if len(row) > 8 else None
|
||||||
|
country = row[9] if len(row) > 9 else None
|
||||||
|
if lat and lon:
|
||||||
connections.append({
|
connections.append({
|
||||||
'timestamp': row[0],
|
'timestamp': row[0],
|
||||||
'city': row[4],
|
'city': city,
|
||||||
'country': row[5],
|
'country': country,
|
||||||
'lat': row[8],
|
'lat': lat,
|
||||||
'lon': row[9]
|
'lon': lon
|
||||||
})
|
})
|
||||||
emit('map_initial_data', {'connections': connections})
|
emit('map_initial_data', {'connections': connections})
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
min-height: 0;
|
||||||
}
|
}
|
||||||
.table-section {
|
.table-section {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
@ -27,7 +28,9 @@
|
|||||||
}
|
}
|
||||||
#map {
|
#map {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
flex: 1;
|
||||||
|
height: auto;
|
||||||
|
min-height: 320px;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
box-shadow: 0 2px 10px rgba(0,0,0,0.2);
|
||||||
}
|
}
|
||||||
@ -155,6 +158,10 @@
|
|||||||
<script>
|
<script>
|
||||||
// Initialize the map centered on Europe
|
// Initialize the map centered on Europe
|
||||||
const map = L.map('map').setView([50.0, 10.0], 5);
|
const map = L.map('map').setView([50.0, 10.0], 5);
|
||||||
|
const refreshMapSize = () => setTimeout(() => map.invalidateSize(), 150);
|
||||||
|
refreshMapSize();
|
||||||
|
window.addEventListener('resize', refreshMapSize);
|
||||||
|
window.addEventListener('orientationchange', refreshMapSize);
|
||||||
|
|
||||||
// Add OpenStreetMap tile layer
|
// Add OpenStreetMap tile layer
|
||||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user