graph détaillé, listing clés courantes

This commit is contained in:
Tykayn 2025-07-12 14:28:00 +02:00 committed by tykayn
parent b771aea541
commit 9eb08073d0
7 changed files with 213 additions and 48 deletions

View file

@ -26,13 +26,15 @@
<thead>
<tr>
<th>Thème</th>
<th>Évolution du nombre</th>
<th>Évolution de la complétion</th>
<th>Évolution 7j</th>
<th>Évolution 30j</th>
<th>Évolution 6 mois</th>
</tr>
</thead>
<tbody>
{% for type, diff in latest_diffs %}
{% if diff.count_diff is not null and diff.count_diff != 0 %}
{% set has_period_change = (diff.count_diff_7j != 0 or diff.count_diff_30j != 0 or diff.count_diff_6mois != 0) %}
{% if has_period_change %}
{% set has_change = true %}
<tr>
<td>
@ -41,28 +43,73 @@
</a>
</td>
<td>
{% if diff.count_diff > 0 %}
{% if diff.count_diff_7j > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% else %}
<i class="bi bi-arrow-down text-danger"></i>
{% endif %}
{{ diff.count_diff > 0 ? '+' ~ diff.count_diff : diff.count_diff }} objets
</td>
<td>
{% if diff.completion_diff > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.completion_diff < 0 %}
{% elseif diff.count_diff_7j < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.completion_diff > 0 ? '+' ~ diff.completion_diff : diff.completion_diff }}%
{{ diff.count_diff_7j > 0 ? '+' ~ diff.count_diff_7j : diff.count_diff_7j }} objets
<br>
<span class="small text-muted">Complétion :
{% if diff.completion_diff_7j > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.completion_diff_7j < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.completion_diff_7j > 0 ? '+' ~ diff.completion_diff_7j : diff.completion_diff_7j }}%
</span>
</td>
<td>
{% if diff.count_diff_30j > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.count_diff_30j < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.count_diff_30j > 0 ? '+' ~ diff.count_diff_30j : diff.count_diff_30j }} objets
<br>
<span class="small text-muted">Complétion :
{% if diff.completion_diff_30j > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.completion_diff_30j < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.completion_diff_30j > 0 ? '+' ~ diff.completion_diff_30j : diff.completion_diff_30j }}%
</span>
</td>
<td>
{% if diff.count_diff_6mois > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.count_diff_6mois < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.count_diff_6mois > 0 ? '+' ~ diff.count_diff_6mois : diff.count_diff_6mois }} objets
<br>
<span class="small text-muted">Complétion :
{% if diff.completion_diff_6mois > 0 %}
<i class="bi bi-arrow-up text-success"></i>
{% elseif diff.completion_diff_6mois < 0 %}
<i class="bi bi-arrow-down text-danger"></i>
{% else %}
<i class="bi bi-arrow-right text-secondary"></i>
{% endif %}
{{ diff.completion_diff_6mois > 0 ? '+' ~ diff.completion_diff_6mois : diff.completion_diff_6mois }}%
</span>
</td>
</tr>
{% endif %}
{% endfor %}
{% if not has_change %}
<tr><td colspan="3" class="text-muted">Aucun changement significatif cette semaine.</td></tr>
<tr><td colspan="4" class="text-muted">Aucun changement significatif cette semaine.</td></tr>
{% endif %}
</tbody>
</table>

View file

@ -101,6 +101,23 @@
.btn-josm {
margin-bottom: 1rem;
}
/* Bouton flottant suggestion desktop */
.suggestion-float-btn {
position: fixed;
bottom: 32px;
right: 32px;
z-index: 1000;
box-shadow: 0 2px 8px rgba(0,0,0,0.15);
display: none;
}
@media (min-width: 768px) {
.suggestion-float-btn { display: block; }
.suggestion-footer-btn { display: none !important; }
}
@media (max-width: 767.98px) {
.suggestion-float-btn { display: none !important; }
.suggestion-footer-btn { display: block; width: 100%; margin: 0; border-radius: 0; }
}
</style>
{% endblock %}
@ -167,6 +184,9 @@
<a href="{{ path('admin_street_completion', {'insee_code': stats.zone}) }}" class="btn btn-outline-success">
<i class="bi bi-signpost"></i> Complétion des rues
</a>
<a href="https://forum.openstreetmap.fr/t/osm-mon-commerce/34403/11" class="btn btn-outline-info ms-auto d-none d-md-inline-block suggestion-float-btn" target="_blank" rel="noopener">
<i class="bi bi-chat-dots"></i> Faire une suggestion
</a>
</div>
{% if josm_url %}
@ -254,6 +274,29 @@
</div>
{% endif %}
</div>
<div class="card mt-5">
<div class="card-header">
<i class="bi bi-tags"></i> Statistiques des tags utilisés dans les objets trouvés
</div>
<div class="card-body p-2">
<div id="tags-stats-block">
<table class="table table-sm table-bordered mb-0" id="tags-stats-table" style="max-width:600px;">
<thead>
<tr>
<th>Tag</th>
<th>Nombre d'occurrences</th>
</tr>
</thead>
<tbody>
<tr><td colspan="2" class="text-muted">Chargement...</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<a href="https://forum.openstreetmap.fr/t/osm-mon-commerce/34403/11" class="btn btn-info suggestion-footer-btn mt-4 mb-2" target="_blank" rel="noopener" style="display:none;">
<i class="bi bi-chat-dots"></i> Faire une suggestion
</a>
{% endblock %}
{% block javascripts %}
@ -329,6 +372,8 @@
.then(data => {
if (!data.elements || data.elements.length === 0) {
document.getElementById('themeMap').innerHTML = '<div class="alert alert-warning">Aucun objet trouvé via Overpass pour ce thème.</div>';
// Vider le tableau des tags
document.querySelector('#tags-stats-table tbody').innerHTML = '<tr><td colspan="2" class="text-muted">Aucun objet trouvé</td></tr>';
return;
}
// Centrage carte
@ -401,6 +446,25 @@
.setPopup(new maplibregl.Popup({ offset: 18 }).setHTML(popupHtml))
.addTo(mapInstance);
});
// --- Statistiques des tags ---
const tagCounts = {};
data.elements.forEach(e => {
if (e.tags) {
Object.entries(e.tags).forEach(([k, v]) => {
if (!tagCounts[k]) tagCounts[k] = 0;
tagCounts[k]++;
});
}
});
const tbody = document.querySelector('#tags-stats-table tbody');
if (Object.keys(tagCounts).length === 0) {
tbody.innerHTML = '<tr><td colspan="2" class="text-muted">Aucun tag trouvé</td></tr>';
} else {
tbody.innerHTML = Object.entries(tagCounts)
.sort((a, b) => b[1] - a[1])
.map(([k, v]) => `<tr><td><code>${k}</code></td><td>${v}</td></tr>`)
.join('');
}
})
.catch(err => {
document.getElementById('themeMap').innerHTML = '<div class="alert alert-danger">Erreur lors de la requête Overpass : ' + err + '</div>';

View file

@ -11,13 +11,9 @@
<a href="{{ path('app_public_index') }}" class="btn btn-secondary">
<i class="bi bi-arrow-left"></i> Retour à l'accueil
</a>
</div>
</div>
<div class="card">
<div class="card-header">
<h3><i class="bi bi-geo-alt"></i> Labourage d'une nouvelle ville</h3>
<p class="mb-0">Entrez le code INSEE de votre ville pour l'ajouter à notre base de données</p>
</div>
<div class="card-body">
{% include 'public/labourage-form.html.twig' %}
</div>

View file

@ -151,8 +151,6 @@
<p class="text-muted">Aucun lieu modifié dans les 6 derniers mois.</p>
{% endif %}
</div>
</div>
<script src="{{ asset('js/table-sortable.js') }}"></script>
<script>document.querySelectorAll('table.table-sort').forEach(t => window.TableSortable && TableSortable.initTable(t));</script>
</div>
</div>
{% endblock %}