add event details page, refacto templates

This commit is contained in:
Tykayn 2025-09-26 14:18:14 +02:00 committed by tykayn
parent eb8c42d0c0
commit 6548460478
4 changed files with 191 additions and 125 deletions

View file

@ -0,0 +1,45 @@
{% extends "layout.html" %}
{% block title %}Event {{ id }} - OpenEventDatabase{% endblock %}
{% block css %}
<style>
#map { width:100%; height: 360px; border:1px solid #ddd; border-radius:4px; }
table { width:100%; border-collapse: collapse; margin-top:12px; }
th, td { padding: 6px 8px; border-bottom: 1px solid #eee; text-align:left; }
th { background:#f9fafb; }
</style>
{% endblock %}
{% block header %}Évènement {{ id }}{% endblock %}
{% block content %}
<div id="map"></div>
<table>
<thead><tr><th>Clé</th><th>Valeur</th></tr></thead>
<tbody>
{% for key, value in properties.items()|sort %}
<tr>
<td>{{ key }}</td>
<td>{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% block scripts %}
<script>
const f = JSON.parse('{{ feature_json|safe }}');
const map = new maplibregl.Map({
container: 'map',
style: 'https://tiles.openfreemap.org/styles/liberty',
center: f.geometry && f.geometry.coordinates ? f.geometry.coordinates : [2.3522,48.8566],
zoom: 12
});
map.addControl(new maplibregl.NavigationControl());
if (f.geometry && f.geometry.type === 'Point') {
new maplibregl.Marker().setLngLat(f.geometry.coordinates).addTo(map);
}
</script>
{% endblock %}

View file

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}OpenEventDatabase{% endblock %}</title>
<!-- Common CSS -->
<link rel="stylesheet" href="/static/demo_styles.css">
<!-- Page-specific CSS -->
{% block css %}{% endblock %}
<!-- Common JavaScript libraries -->
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>
<link href="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.css" rel="stylesheet" />
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js"></script>
<!-- Page-specific head content -->
{% block head %}{% endblock %}
</head>
<body>
<div class="container">
<!-- Navigation -->
{% include 'partials/demo_nav.html' %}
<!-- Page header -->
<header>
<h1>{% block header %}OpenEventDatabase{% endblock %}</h1>
</header>
<!-- Main content -->
<main>
{% block content %}{% endblock %}
</main>
<!-- Footer -->
<footer>
<div class="footer-content">
<p>&copy; 2025 OpenEventDatabase - <a href="https://source.cipherbliss.com/tykayn/oedb-backend">Source Code</a></p>
</div>
</footer>
</div>
<!-- Common JavaScript -->
<script src="/static/demo_auth.js"></script>
<!-- Page-specific JavaScript -->
{% block scripts %}{% endblock %}
</body>
</html>

View file

@ -1,76 +1,74 @@
<!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>
{% extends "layout.html" %}
{% 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>
{% block title %}Stats par type - OpenEventDatabase{% endblock %}
{% block css %}
<style>
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>
{% endblock %}
{% block header %}Statistiques par type d'évènement (what){% endblock %}
{% block content %}
<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>
<div id="mapDiv" class="map-embed"></div>
{% endif %}
{% endblock %}
{% block scripts %}
{% if selected_what %}
<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 %}
{% endblock %}