arrondi completion sur ville

This commit is contained in:
Tykayn 2025-08-12 12:01:49 +02:00 committed by tykayn
parent 1659864efb
commit b9f57e48b5

View file

@ -5,43 +5,52 @@
{% block stylesheets %}
{{ parent() }}
<link href='{{ asset('js/maplibre/maplibre-gl.css') }}' rel='stylesheet' />
<link href='{{ asset('css/city-sidebar.css') }}' rel='stylesheet' />
<link href='{{ asset('js/maplibre/maplibre-gl.css') }}' rel='stylesheet'/>
<link href='{{ asset('css/city-sidebar.css') }}' rel='stylesheet'/>
<style>
.completion-circle {
fill-opacity: 0.6;
stroke: #fff;
stroke-width: 3;
}
#distribution_completion {
height: 300px;
margin: 20px 0;
}
.completion-info {
margin-bottom: 2rem;
}
.osm-modification-info {
font-size: 0.85rem;
line-height: 1.3;
}
.osm-modification-info .text-muted {
font-size: 0.75rem;
}
.osm-modification-info a {
text-decoration: none;
color: #0d6efd;
}
.osm-modification-info a:hover {
text-decoration: underline;
}
.osm-freshness-info {
font-size: 0.95rem;
line-height: 1.4;
}
.osm-freshness-info .alert {
border-left: 4px solid #0dcaf0;
background-color: #f8f9fa;
}
.completion-badge {
display: inline-block;
width: 18px;
@ -51,14 +60,17 @@
border: 2px solid #fff;
box-shadow: 0 0 2px #888;
}
.completion-low {
background: #b2dfdb;
border-color: #009688;
}
.completion-medium {
background: #81c784;
border-color: #388e3c;
}
.completion-high {
background: #388e3c;
border-color: #1b5e20;
@ -70,7 +82,7 @@
.compact-theme-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}
.theme-title a {
@ -87,27 +99,33 @@
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
.theme-row-scroll {
overflow-x: auto;
white-space: nowrap;
padding-bottom: 0.5rem;
}
.theme-row-scroll .col-auto {
display: inline-block;
float: none;
}
.theme-row-scroll .compact-theme-card {
display: inline-block;
vertical-align: top;
margin-right: 8px;
}
.tab-content {
margin-top: 1.5rem;
}
.table-theme th, .table-theme td {
vertical-align: middle;
font-size: 0.95em;
}
.table-theme th {
background: #f8f9fa;
}
@ -116,7 +134,7 @@
{% block body %}
<div class="container-fluid">
<div class="container-fluid">
<div class="row">
<!-- Sidebar de navigation -->
<div class="col-12">
@ -175,16 +193,17 @@
{% if stats.dateLabourageDone %}
<div class="alert alert-info">
Dernier labourage : {{ include('admin/_labourage_time_ago.html.twig', { date: stats.dateLabourageDone }) }}
Dernier labourage
: {{ include('admin/_labourage_time_ago.html.twig', { date: stats.dateLabourageDone }) }}
</div>
{% endif %}
{% endif %}
<div class="row">
<div id="followups">
{% set overpass_type_queries = {
{% set overpass_type_queries = {
'fire_hydrant': 'nwr["emergency"="fire_hydrant"](area.searchArea);',
'charging_station': 'nwr["amenity"="charging_station"](area.searchArea);',
'bicycle_parking' : 'nwr["amenity"="bicycle_parking"](area.searchArea);',
@ -199,30 +218,37 @@
'police': 'nwr["amenity"="police"](area.searchArea);',
'drinking_water' : 'nwr["amenity"="drinking_water"](area.searchArea);',
'healthcare': 'nwr["healthcare"](area.searchArea);nwr["amenity"="doctors"](area.searchArea);nwr["amenity"="pharmacy"](area.searchArea);nwr["amenity"="hospital"](area.searchArea);nwr["amenity"="clinic"](area.searchArea);nwr["amenity"="social_facility"](area.searchArea);'
} %}
} %}
{% set theme_groups = {
{% set theme_groups = {
'emergency': ['fire_hydrant', 'defibrillator'],
'transport': ['bus_stop', 'charging_station', 'bicycle_parking'],
'healthcare': ['healthcare', 'laboratory', 'drinking_water'],
'education': ['school'],
'security': ['police', 'camera'],
'infrastructure': ['toilets', 'recycling', 'substation']
} %}
} %}
<div class="row mb-4" id="themes">
<div class="row mb-4" id="themes">
<div class="col-12">
<h2 class="section-anchor">Thèmes</h2>
<ul class="nav nav-tabs" id="themeTabs" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="tab-table" data-bs-toggle="tab" data-bs-target="#tabTableContent" type="button" role="tab" aria-controls="tabTableContent" aria-selected="true">Tableau</button>
<button class="nav-link active" id="tab-table" data-bs-toggle="tab"
data-bs-target="#tabTableContent" type="button" role="tab"
aria-controls="tabTableContent" aria-selected="true">Tableau
</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="tab-cards" data-bs-toggle="tab" data-bs-target="#tabCardsContent" type="button" role="tab" aria-controls="tabCardsContent" aria-selected="false">Cartes</button>
<button class="nav-link" id="tab-cards" data-bs-toggle="tab"
data-bs-target="#tabCardsContent" type="button" role="tab"
aria-controls="tabCardsContent" aria-selected="false">Cartes
</button>
</li>
</ul>
<div class="tab-content" id="themeTabsContent">
<div class="tab-pane fade show active" id="tabTableContent" role="tabpanel" aria-labelledby="tab-table">
<div class="tab-pane fade show active" id="tabTableContent" role="tabpanel"
aria-labelledby="tab-table">
<table class="table table-theme">
<thead>
<tr>
@ -268,7 +294,9 @@
{{ followup_labels[type]|default(type|capitalize) }}
</td>
<td>{{ count is not null ? count : '?' }}</td>
<td><span class="completion-badge {{ completion_class }}"></span> {{ completion is not null ? completion ~ '%' : '?' }}</td>
<td>
<span class="completion-badge {{ completion_class }}"></span> {{ completion is not null ? completion ~ '%' : '?' }}
</td>
<td>
{% if progression7Days[type] is defined %}
{% set countDelta = progression7Days[type].count %}
@ -288,7 +316,10 @@
{% endif %}
</td>
<td>
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" target="_blank" class="btn btn-sm btn-outline-primary" title="Voir le graphique">
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}"
target="_blank"
class="btn btn-sm btn-outline-primary"
title="Voir le graphique">
<i class="bi bi-graph-up"></i>
</a>
</td>
@ -298,7 +329,8 @@
</tbody>
</table>
</div>
<div class="tab-pane fade" id="tabCardsContent" role="tabpanel" aria-labelledby="tab-cards">
<div class="tab-pane fade" id="tabCardsContent" role="tabpanel"
aria-labelledby="tab-cards">
{% set all_types = followup_labels|keys %}
<div class="row">
{% for type in all_types %}
@ -316,26 +348,37 @@
{% endif %}
{% endif %}
<div class="col-auto">
<div class="card shadow-sm text-center compact-theme-card" style="min-width: 120px; max-width: 140px;">
<div class="card shadow-sm text-center compact-theme-card"
style="min-width: 120px; max-width: 140px;">
<div class="card-body p-2">
<div class="d-flex align-items-center justify-content-between mb-1">
<span class="completion-badge {{ completion_class }}"></span>
<i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-4"></i>
</div>
<div class="theme-title mb-1">
<a href="https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="fw-bold text-decoration-none text-dark small" title="Voir le JSON Overpass">
<a href="https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}"
target="_blank"
class="fw-bold text-decoration-none text-dark small"
title="Voir le JSON Overpass">
{{ followup_labels[type]|default(type|capitalize) }}
</a>
</div>
<div class="theme-stats small">
<span title="Nombre">{{ data and data.count is defined ? data.count.getMeasure() : '?' }}</span> |
<span title="Complétion">{{ completion is not null ? completion : '?' }}%</span>
<span title="Nombre">{{ data and data.count is defined ? data.count.getMeasure() : '?' }}</span>
|
<span title="Complétion">{{ completion is not null ? completion|round(1) : '?' }}%</span>
</div>
<div class="theme-actions mt-1">
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" target="_blank" class="btn btn-sm btn-outline-primary btn-sm" title="Voir le graphique">
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}"
target="_blank"
class="btn btn-sm btn-outline-primary btn-sm"
title="Voir le graphique">
<i class="bi bi-graph-up"></i>
</a>
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="btn btn-sm btn-outline-dark btn-sm ms-1" title="Ouvrir dans JOSM">
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}"
target="_blank"
class="btn btn-sm btn-outline-dark btn-sm ms-1"
title="Ouvrir dans JOSM">
<i class="bi bi-box-arrow-up-right"></i> JOSM
</a>
</div>
@ -348,7 +391,12 @@
{% for type in all_types %}
<div class="col-md-4 col-12 mb-2">
<span class="fw-bold">{{ followup_labels[type]|default(type|capitalize) }}</span>
<button class="btn btn-link p-0 ms-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapse-tags-{{ type }}" aria-expanded="false" aria-controls="collapse-tags-{{ type }}" title="Voir les critères de complétion">
<button class="btn btn-link p-0 ms-1" type="button"
data-bs-toggle="collapse"
data-bs-target="#collapse-tags-{{ type }}"
aria-expanded="false"
aria-controls="collapse-tags-{{ type }}"
title="Voir les critères de complétion">
<i class="bi bi-question-circle"></i>
</button>
<div class="collapse mt-2" id="collapse-tags-{{ type }}">
@ -358,7 +406,8 @@
{% for tag in completion_tags[type] ?? [] %}
<li><code>{{ tag }}</code></li>
{% else %}
<li><span class="text-muted">Aucun critère défini</span></li>
<li><span class="text-muted">Aucun critère défini</span>
</li>
{% endfor %}
</ul>
</div>
@ -369,7 +418,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3 col-12">
@ -380,7 +429,7 @@
</div>
<div class="col-md-3 col-12">
<span class="badge bg-primary">
<i class="bi bi-building"></i> {{ stats.places | length}}
<i class="bi bi-building"></i> {{ stats.places | length }}
</span>lieux dans la zone.
</div>
<div class="col-md-3 col-12">
@ -417,7 +466,6 @@
</div>
<div id="carte" class="section-anchor">
<h2>Carte</h2>
<div id="maploader">
@ -445,16 +493,19 @@
<h2>Graphiques</h2>
<div class="row">
<div class="col-md-6 col-12">
<canvas id="repartition_tags" width="600" height="400" style="max-width:100%; margin: 20px 0;"></canvas>
<canvas id="repartition_tags" width="600" height="400"
style="max-width:100%; margin: 20px 0;"></canvas>
</div>
<div class="col-md-6 col-12">
<div class="card">
<div class="card-header">
<i class="bi bi-calendar-event"></i> Fréquence des mises à jour par trimestre pour {{stats.name}}
<i class="bi bi-calendar-event"></i> Fréquence des mises à jour par
trimestre pour {{ stats.name }}
</div>
<div class="card-body">
<canvas id="modificationsByQuarterChart" style="min-height: 250px; width: 100%;"></canvas>
<canvas id="modificationsByQuarterChart"
style="min-height: 250px; width: 100%;"></canvas>
</div>
</div>
</div>
@ -473,15 +524,18 @@
<div class="row" id="lieux">
<div class="col-md-6 col-12">
<h1 class="card-title p-4 section-anchor">Tableau des {{ stats.places |length }} lieux</h1>
<h1 class="card-title p-4 section-anchor">Tableau des {{ stats.places |length }}
lieux</h1>
</div>
<div class="col-md-6 col-12">
<div class="btn-group mt-4" role="group">
<a href="{{ path('app_admin_export_overpass_csv', {'insee_code': stats.zone}) }}" class="btn btn-primary">
<a href="{{ path('app_admin_export_overpass_csv', {'insee_code': stats.zone}) }}"
class="btn btn-primary">
<i class="bi bi-filetype-csv"></i>
Export Overpass CSV
</a>
<a href="{{ path('app_admin_export_table_csv', {'insee_code': stats.zone}) }}" class="btn btn-success">
<a href="{{ path('app_admin_export_table_csv', {'insee_code': stats.zone}) }}"
class="btn btn-success">
<i class="bi bi-table"></i>
Export Tableau CSV
</a>
@ -489,8 +543,9 @@
</div>
</div>
<div id="table_container" class="table-container" >
<table id="stats-table" class="table table-bordered table-striped table-hover table-responsive table-sort">
<div id="table_container" class="table-container">
<table id="stats-table"
class="table table-bordered table-striped table-hover table-responsive table-sort">
{% include 'admin/stats/table-head.html.twig' %}
<tbody>
{% for commerce in stats.places %}
@ -508,7 +563,7 @@
<h2>Podium des contributeurs OSM de cette ville</h2>
</div>
<div class="card-body">
<div class="table-container" >
<div class="table-container">
<table class="table table-striped table-bordered mt-4" style="max-width:800px">
<thead class="table-dark">
@ -526,7 +581,7 @@
<tr>
<th scope="row">{{ loop.index }}</th>
<td>
<a href="https://www.openstreetmap.org/user/{{ row.osm_user|e('url') }}" >
<a href="https://www.openstreetmap.org/user/{{ row.osm_user|e('url') }}">
{{ row.osm_user }}
</a>
</td>
@ -554,7 +609,9 @@
</td>
</tr>
{% else %}
<tr><td colspan="6">Aucun contributeur trouvé pour cette ville.</td></tr>
<tr>
<td colspan="6">Aucun contributeur trouvé pour cette ville.</td>
</tr>
{% endfor %}
</tbody>
</table>
@ -605,8 +662,8 @@
</div>
</div>
<!-- Espace de dump JSON -->
<div id="ctc-json-dump-container" class="mt-4" style="display:none;">
<!-- Espace de dump JSON -->
<div id="ctc-json-dump-container" class="mt-4" style="display:none;">
<div class="card">
<div class="card-header p-2">
<i class="bi bi-file-earmark-code"></i> Dump du JSON récupéré
@ -615,7 +672,7 @@
<pre id="ctc-json-dump" style="max-height:400px;overflow:auto;"></pre>
</div>
</div>
</div>
</div>
<div class="mt-3 ctc-tests">
<div class="card ctc-tests">
@ -646,11 +703,11 @@
</div>
</div>
<div id="ctc-json-error" class="alert alert-danger mt-4" style="display:none;"></div>
<div id="ctc-json-error" class="alert alert-danger mt-4" style="display:none;"></div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
@ -658,7 +715,7 @@
{{ parent() }}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const geojsonData = {{ geojson|raw }};
const map_token = "{{ maptiler_token }}";
// Liste des tags attendus pour la complétion des lieux
@ -680,23 +737,27 @@
// Correction : toujours un tableau
f.properties.missing_tags = Array.isArray(f.properties.missing_tags) ? f.properties.missing_tags : (f.properties.missing_tags ? [f.properties.missing_tags] : []);
});
// Fonction de couleur dégradée
function lerpColor(a, b, t) {
const ah = a.replace('#', '');
const bh = b.replace('#', '');
const ar = parseInt(ah.substring(0,2), 16), ag = parseInt(ah.substring(2,4), 16), ab = parseInt(ah.substring(4,6), 16);
const br = parseInt(bh.substring(0,2), 16), bg = parseInt(bh.substring(2,4), 16), bb = parseInt(bh.substring(4,6), 16);
const rr = Math.round(ar + (br-ar)*t);
const rg = Math.round(ag + (bg-ag)*t);
const rb = Math.round(ab + (bb-ab)*t);
return '#' + rr.toString(16).padStart(2,'0') + rg.toString(16).padStart(2,'0') + rb.toString(16).padStart(2,'0');
const ar = parseInt(ah.substring(0, 2), 16), ag = parseInt(ah.substring(2, 4), 16),
ab = parseInt(ah.substring(4, 6), 16);
const br = parseInt(bh.substring(0, 2), 16), bg = parseInt(bh.substring(2, 4), 16),
bb = parseInt(bh.substring(4, 6), 16);
const rr = Math.round(ar + (br - ar) * t);
const rg = Math.round(ag + (bg - ag) * t);
const rb = Math.round(ab + (bb - ab) * t);
return '#' + rr.toString(16).padStart(2, '0') + rg.toString(16).padStart(2, '0') + rb.toString(16).padStart(2, '0');
}
let map;
let map_is_loaded = false;
let currentMode = 'drop';
// Fonction pour mettre à jour le style des marqueurs
window.updateMarkers = function(mode) {
window.updateMarkers = function (mode) {
currentMode = mode;
// Mettre à jour l'état visuel des boutons
document.getElementById('circleMarkersBtn').classList.toggle('active', mode === 'circle');
@ -762,7 +823,7 @@
zoom: 14
});
window.mapInstance = map;
map.on('load', function() {
map.on('load', function () {
map_is_loaded = true;
document.getElementById('maploader').style.display = 'none';
@ -811,18 +872,18 @@
window.updateMarkers('drop');
// Listeners boutons
document.getElementById('circleMarkersBtn').addEventListener('click', function() {
document.getElementById('circleMarkersBtn').addEventListener('click', function () {
window.updateMarkers('circle');
});
document.getElementById('dropMarkersBtn').addEventListener('click', function() {
document.getElementById('dropMarkersBtn').addEventListener('click', function () {
window.updateMarkers('drop');
});
// Popups et clusters (inchangé)
map.on('click', 'clusters', function(e) {
const features = map.queryRenderedFeatures(e.point, { layers: ['clusters'] });
map.on('click', 'clusters', function (e) {
const features = map.queryRenderedFeatures(e.point, {layers: ['clusters']});
const clusterId = features[0].properties.cluster_id;
map.getSource('places').getClusterExpansionZoom(clusterId, function(err, zoom) {
map.getSource('places').getClusterExpansionZoom(clusterId, function (err, zoom) {
if (err) return;
map.easeTo({
center: features[0].geometry.coordinates,
@ -831,7 +892,7 @@
});
});
map.on('click', 'unclustered-point', function(e) {
map.on('click', 'unclustered-point', function (e) {
const coordinates = e.features[0].geometry.coordinates.slice();
const properties = e.features[0].properties;
@ -856,10 +917,10 @@
.addTo(map);
});
map.on('mouseenter', 'clusters', function() {
map.on('mouseenter', 'clusters', function () {
map.getCanvas().style.cursor = 'pointer';
});
map.on('mouseleave', 'clusters', function() {
map.on('mouseleave', 'clusters', function () {
map.getCanvas().style.cursor = '';
});
});
@ -877,7 +938,8 @@
const place_nodes = [];
const place_ways = [];
const place_relations = [];
const places = {{ geojson|raw }}.features;
const places = {{ geojson|raw }}.
features;
places.forEach(place => {
if (
place.properties.getOsmKind() === 'node'
@ -898,7 +960,13 @@
(place_relations.length > 0 ? 'relation(id:' + place_relations.join(',') + ');\n' : '') +
'(._;>;);\nout meta;';
const url = 'http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data=' + encodeURIComponent(overpass_josm_query);
openInJOSM(map, map_is_loaded, [{osm_id: place_nodes.join(','), osm_type: 'node'}, {osm_id: place_ways.join(','), osm_type: 'way'}, {osm_id: place_relations.join(','), osm_type: 'relation'}], url);
openInJOSM(map, map_is_loaded, [{
osm_id: place_nodes.join(','),
osm_type: 'node'
}, {osm_id: place_ways.join(','), osm_type: 'way'}, {
osm_id: place_relations.join(','),
osm_type: 'relation'
}], url);
});
}
@ -923,12 +991,12 @@
options: {
responsive: true,
plugins: {
legend: { display: false },
title: { display: true, text: 'Fréquence des mises à jour par trimestre' }
legend: {display: false},
title: {display: true, text: 'Fréquence des mises à jour par trimestre'}
},
scales: {
y: { beginAtZero: true, title: { display: true, text: 'Nombre de lieux' } },
x: { title: { display: true, text: 'Trimestre' } }
y: {beginAtZero: true, title: {display: true, text: 'Nombre de lieux'}},
x: {title: {display: true, text: 'Trimestre'}}
}
}
@ -939,7 +1007,8 @@
// Créer un graphique de la répartition des tags
const tagsCount = {};
const places = {{ geojson|raw }}.features;
const places = {{ geojson|raw }}.
features;
places.forEach(place => {
const mainTag = place.properties.main_tag;
@ -951,15 +1020,15 @@
const sortedTags = Object.entries(tagsCount).sort(([, a], [, b]) => b - a);
const labels = sortedTags.map(item => item[0]);
const data = sortedTags.map(item => item[1]);
const container_tags= document.getElementById('repartition_tags');
const container_tags = document.getElementById('repartition_tags');
console.log('répartition', tagsCount, container_tags)
if(!container_tags){
if (!container_tags) {
console.log('pas de container_tags', container_tags)
return;
}
const ctx = container_tags.getContext ? container_tags.getContext('2d') : null;
if(ctx){
if (ctx) {
new Chart(ctx, {
type: 'doughnut',
data: {
@ -1020,11 +1089,11 @@
return parseInt(a.split('-')[0]) - parseInt(b.split('-')[0]);
});
const completionValues = completionLabels.map(label => completionDistribution[label]);
const dc = document.getElementById('distribution_completion');
const dc = document.getElementById('distribution_completion');
if(dc){
if (dc) {
const completionCtx = dc.getContext ? dc.getContext('2d') : null;
if(!completionCtx){
if (!completionCtx) {
console.log('pas de completionCtx');
} else {
new Chart(completionCtx, {
@ -1058,26 +1127,26 @@ if(dc){
}
});
}
} else {
} else {
console.log('pas de distribution_completion');
}
}
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const trigger = document.querySelector('.completion-hover-trigger');
const content = document.getElementById('completionInfoContent');
const icon = document.getElementById('completionInfoIcon');
if (trigger && content) {
trigger.addEventListener('mouseenter', function() {
trigger.addEventListener('mouseenter', function () {
content.style.display = 'block';
if (icon) {
icon.classList.remove('bi-chevron-down');
icon.classList.add('bi-chevron-up');
}
});
trigger.addEventListener('mouseleave', function() {
trigger.addEventListener('mouseleave', function () {
content.style.display = 'none';
if (icon) {
icon.classList.remove('bi-chevron-up');
@ -1085,10 +1154,10 @@ if(dc){
}
});
// Pour garder la popup ouverte si la souris va sur la popup
content.addEventListener('mouseenter', function() {
content.addEventListener('mouseenter', function () {
content.style.display = 'block';
});
content.addEventListener('mouseleave', function() {
content.addEventListener('mouseleave', function () {
content.style.display = 'none';
if (icon) {
icon.classList.remove('bi-chevron-up');
@ -1099,9 +1168,9 @@ if(dc){
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const btn = document.getElementById('btn-geolocate');
btn && btn.addEventListener('click', function() {
btn && btn.addEventListener('click', function () {
console.log('[GEOLOC] Bouton cliqué');
if (!navigator.geolocation) {
alert('La géolocalisation n\'est pas supportée par ce navigateur.');
@ -1110,7 +1179,7 @@ if(dc){
}
btn.disabled = true;
btn.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Localisation...';
navigator.geolocation.getCurrentPosition(function(pos) {
navigator.geolocation.getCurrentPosition(function (pos) {
const lat = pos.coords.latitude;
const lon = pos.coords.longitude;
console.log('[GEOLOC] Position obtenue', lat, lon);
@ -1122,13 +1191,18 @@ if(dc){
if (window._geoMarkerSource) window.mapInstance.removeSource('geo-marker');
window.mapInstance.addSource('geo-marker', {
type: 'geojson',
data: { type: 'Feature', geometry: { type: 'Point', coordinates: [lon, lat] } }
data: {type: 'Feature', geometry: {type: 'Point', coordinates: [lon, lat]}}
});
window.mapInstance.addLayer({
id: 'geo-marker',
type: 'circle',
source: 'geo-marker',
paint: { 'circle-radius': 10, 'circle-color': '#007bff', 'circle-stroke-width': 2, 'circle-stroke-color': '#fff' }
paint: {
'circle-radius': 10,
'circle-color': '#007bff',
'circle-stroke-width': 2,
'circle-stroke-color': '#fff'
}
});
window._geoMarker = true;
window._geoMarkerSource = true;
@ -1137,7 +1211,7 @@ if(dc){
}
btn.disabled = false;
btn.innerHTML = '<i class="bi bi-geo-alt"></i> Me localiser';
}, function(err) {
}, function (err) {
alert('Impossible de vous localiser : ' + err.message);
console.error('[GEOLOC] Erreur de géolocalisation', err);
btn.disabled = false;
@ -1147,22 +1221,22 @@ if(dc){
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const btn = document.getElementById('ctc-json-test-btn');
const select = document.getElementById('ctc-json-select');
const dumpContainer = document.getElementById('ctc-json-dump-container');
const dump = document.getElementById('ctc-json-dump');
const error = document.getElementById('ctc-json-error');
if(btn && select) {
btn.addEventListener('click', function() {
if (btn && select) {
btn.addEventListener('click', function () {
const url = select.value;
dumpContainer.style.display = 'none';
error.style.display = 'none';
dump.textContent = '';
if(!url) return;
if (!url) return;
fetch(url)
.then(r => {
if(!r.ok) throw new Error('Erreur HTTP ' + r.status);
if (!r.ok) throw new Error('Erreur HTTP ' + r.status);
return r.json();
})
.then(data => {
@ -1178,17 +1252,17 @@ if(dc){
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.addEventListener('DOMContentLoaded', function () {
const ctcCompletionSeries = {{ ctc_completion_series|json_encode|raw }};
console.log('ctcCompletionSeries',ctcCompletionSeries)
console.log('ctcCompletionSeries', ctcCompletionSeries)
// Exemple d'intégration dans un graphique Chart.js :
// Pour chaque type, ajouter une série CTC si elle existe
Object.keys(ctcCompletionSeries).forEach(function(type) {
const data = ctcCompletionSeries[type].map(pt => ({ x: pt.date, y: pt.value }));
Object.keys(ctcCompletionSeries).forEach(function (type) {
const data = ctcCompletionSeries[type].map(pt => ({x: pt.date, y: pt.value}));
// Ajoute la série au graphique correspondant (ex: name_count, hours_count...)
// À adapter selon l'ID du canvas et la structure du graphique
const canvasId = type.replace('_count','') + 'Chart';
const canvasId = type.replace('_count', '') + 'Chart';
const canvas = document.getElementById(canvasId);
if (!canvas) return;
// On suppose que le graphique existe déjà, on ajoute la série CTC
@ -1200,7 +1274,7 @@ if(dc){
backgroundColor: 'rgba(255,165,0,0.1)',
fill: false,
yAxisID: 'y',
borderDash: [5,3],
borderDash: [5, 3],
datalabels: {
display: false
}