oedb-backend/oedb/resources/demo/templates/stats.html
2025-09-23 11:26:44 +02:00

76 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stats par type - OpenEventDatabase</title>
<link rel="stylesheet" href="/static/demo_styles.css">
<style>
.container { max-width: 1100px; margin: 0 auto; background: #fff; padding: 16px; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eee; text-align: left; }
th { background: #f9fafb; }
.actions a { margin-right: 8px; }
.map-embed { width: 100%; height: 360px; border: 1px solid #ddd; border-radius: 4px; }
</style>
</head>
<body>
<div class="container">
{% include 'partials/demo_nav.html' %}
<h1>Statistiques par type d'évènement (what)</h1>
<p>Total: <strong>{{ total_events }}</strong> évènements</p>
<table>
<thead>
<tr>
<th>Type (what)</th>
<th>Nombre</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for what, count in counts %}
<tr>
<td>{{ what }}</td>
<td>{{ count }}</td>
<td class="actions">
<a href="/event?what={{ what }}" target="_blank">Voir JSON</a>
<a href="/demo/stats?what={{ what }}#map">Voir sur la carte</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if selected_what %}
<h2 id="map">Carte: {{ selected_what }}</h2>
<link href="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>
<div id="mapDiv" class="map-embed"></div>
<script>
const map = new maplibregl.Map({
container: 'mapDiv',
style: 'https://tiles.openfreemap.org/styles/liberty',
center: [2.3522, 48.8566],
zoom: 4
});
map.addControl(new maplibregl.NavigationControl());
fetch('/event?what={{ selected_what }}&limit=500')
.then(r => r.json())
.then(data => {
if (!data.features || !data.features.length) return;
const bounds = new maplibregl.LngLatBounds();
data.features.forEach(f => {
if (f.geometry && f.geometry.type === 'Point') {
const c = f.geometry.coordinates;
new maplibregl.Marker().setLngLat(c).addTo(map);
bounds.extend(c);
}
});
if (!bounds.isEmpty()) map.fitBounds(bounds, { padding: 40, maxZoom: 12 });
});
</script>
{% endif %}
</div>
</body>
</html>