From 4c1a7729a1dd0d96db79d999ceb598ada41db062 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 5 Jun 2025 15:43:11 +0200 Subject: [PATCH] style dashboard, remove bike parking in places selection --- assets/app.js | 3 +++ assets/styles/app.css | 7 ++++- src/Controller/PublicController.php | 2 ++ src/Service/Motocultrice.php | 38 ++++++++++++++++++---------- templates/public/dashboard.html.twig | 24 ++++++++++++++++++ 5 files changed, 59 insertions(+), 15 deletions(-) diff --git a/assets/app.js b/assets/app.js index 1388037..78f1973 100644 --- a/assets/app.js +++ b/assets/app.js @@ -638,8 +638,11 @@ document.addEventListener('DOMContentLoaded', () => { // Afficher l'indicateur de chargement document.querySelector('#loading_search_insee').classList.remove('d-none'); + const response = await fetch(`https://geo.api.gouv.fr/communes?nom=${query}&fields=nom,code,codesPostaux&limit=10`); const data = await response.json(); + document.querySelector('#loading_search_insee').classList.add('d-none'); + return data.map(commune => ({ label: `${commune.nom} (code insee ${commune.code})`, insee: commune.code, diff --git a/assets/styles/app.css b/assets/styles/app.css index 7c30b98..a4517ac 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -58,8 +58,13 @@ table.js-sort-table th:active { .maplibregl-popup-content { overflow: auto; min-width: 300px; - max-height: 400px; + max-height: 11rem !important; +} +.maplibregl-popup-content table { + width: 100%; + max-height: 300px; + overflow: auto; } .maplibregl-popup-content h1, diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 50a4595..10320df 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -331,6 +331,7 @@ class PublicController extends AbstractController $place->update_place_from_overpass_data($commerce); $this->entityManager->persist($place); $this->entityManager->flush(); + $this->entityManager->clear(); $stats = $place->getStats(); @@ -350,6 +351,7 @@ class PublicController extends AbstractController $this->entityManager->persist($stats); $this->entityManager->persist($place); $this->entityManager->flush(); + $this->entityManager->clear(); return $this->render('public/view.html.twig', [ 'controller_name' => 'PublicController', diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index 5040c4c..9ec2087 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -163,21 +163,31 @@ out center tags;'; $places = []; if (isset($data['elements'])) { - foreach ($data['elements'] as $element) { - if (isset($element['tags'])) { - - $email = ""; - - $places[] = [ - 'id' => $element['id'], - 'type' => $element['type'], - 'name' => $element['tags']['name'] ?? '', - 'email' => $email, - 'lat' => $element['lat'] ?? null, - 'lon' => $element['lon'] ?? null, - 'tags' => $element['tags'] - ]; + $batchSize = 100; // Traiter par lots de 100 éléments + $totalElements = count($data['elements']); + + for ($i = 0; $i < $totalElements; $i += $batchSize) { + $batch = array_slice($data['elements'], $i, $batchSize); + + foreach ($batch as $element) { + if (isset($element['tags'])) { + $email = ""; + + $places[] = [ + 'id' => $element['id'], + 'type' => $element['type'], + 'name' => $element['tags']['name'] ?? '', + 'email' => $email, + 'lat' => $element['lat'] ?? null, + 'lon' => $element['lon'] ?? null, + 'tags' => $element['tags'] + ]; + } } + + // Libérer la mémoire après chaque lot + unset($batch); + gc_collect_cycles(); } } diff --git a/templates/public/dashboard.html.twig b/templates/public/dashboard.html.twig index 2df89b5..6496270 100644 --- a/templates/public/dashboard.html.twig +++ b/templates/public/dashboard.html.twig @@ -217,6 +217,30 @@ out skel qt;`; + {% if totalPages > 1 %} + + {% endif %} +

{{ places_count }} Lieux