up infos habitants sur stats

This commit is contained in:
Tykayn 2025-06-17 16:23:29 +02:00 committed by tykayn
parent 21d4d5b850
commit 918527e15e
16 changed files with 559 additions and 240 deletions

View file

@ -1,4 +1,3 @@
function colorHeadingTable() {
const headers = document.querySelectorAll('th');
@ -21,7 +20,7 @@ function check_validity(e) {
'input[name="commerce_tag_value__contact:email"]',
'input[name="commerce_tag_value__contact:phone"]',
'input[name="commerce_tag_value__contact:website"]',
'commerce_tag_value__contact:mastodon',
'input[name="commerce_tag_value__contact:mastodon"]',
'input[name="commerce_tag_value__address"]',
'input[name="custom_opening_hours"]',
'input[name="commerce_tag_value__contact:street"]',

View file

@ -12,6 +12,18 @@ codes_insee=(
"33063" # Bordeaux
"59350" # Lille
"35238" # Rennes
"75101" # Paris 1er
"75102" # Paris 2e
"75103" # Paris 3e
"75104" # Paris 4e
"75105" # Paris 5e
"75106" # Paris 6e
"75107" # Paris 7e
"75108" # Paris 8e
"75109" # Paris 9e
"75110" # Paris 10e
"75111" # Paris 11e
"75112" # Paris 12e
"75113" # Paris 13e
"75114" # Paris 14e
"75115" # Paris 15e

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250617141249 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE place ADD habitants INT DEFAULT NULL
SQL);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE place DROP habitants
SQL);
}
}

View file

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250617141824 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE stats ADD population INT DEFAULT NULL
SQL);
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql(<<<'SQL'
ALTER TABLE stats DROP population
SQL);
}
}

BIN
public/assets/img/josm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -1,98 +1,68 @@
// Fonction pour gérer la recherche de villes
function setupCitySearch(searchInputId, suggestionListId, onCitySelected) {
const searchInput = document.getElementById(searchInputId);
/**
* Configure la recherche de ville avec autocomplétion
* @param {string} inputId - ID de l'input de recherche
* @param {string} suggestionListId - ID de la liste des suggestions
* @param {Function} onSelect - Callback appelé lors de la sélection d'une ville
*/
export function setupCitySearch(inputId, suggestionListId, onSelect) {
const searchInput = document.getElementById(inputId);
const suggestionList = document.getElementById(suggestionListId);
// Vérifier si les éléments existent avant de continuer
if (!searchInput || !suggestionList) {
console.debug(`Éléments de recherche non trouvés: ${searchInputId}, ${suggestionListId}`);
return;
}
if (!searchInput || !suggestionList) return;
let searchTimeout;
let timeoutId = null;
// Fonction pour nettoyer la liste des suggestions
function clearSuggestions() {
suggestionList.innerHTML = '';
suggestionList.style.display = 'none';
}
searchInput.addEventListener('input', function () {
clearTimeout(timeoutId);
const query = this.value.trim();
// Fonction pour afficher les suggestions
function displaySuggestions(suggestions) {
clearSuggestions();
if (suggestions.length === 0) {
return;
}
suggestions.forEach(suggestion => {
const item = document.createElement('div');
item.className = 'suggestion-item';
item.innerHTML = `
<div class="suggestion-name">${suggestion.display_name}</div>
<div class="suggestion-details">
<span class="suggestion-type">${suggestion.type}</span>
<span class="suggestion-postcode">${suggestion.postcode || ''}</span>
</div>
`;
item.addEventListener('click', () => {
searchInput.value = suggestion.display_name;
clearSuggestions();
if (onCitySelected) {
onCitySelected(suggestion);
}
});
suggestionList.appendChild(item);
});
suggestionList.style.display = 'block';
}
// Fonction pour effectuer la recherche
async function performSearch(query) {
if (!query || query.length < 3) {
if (query.length < 2) {
clearSuggestions();
return;
}
try {
// Recherche avec Nominatim
const response = await fetch(`https://nominatim.openstreetmap.org/search?format=json&q=${encodeURIComponent(query)}&countrycodes=fr&limit=5`);
const data = await response.json();
// Filtrer pour ne garder que les villes
const citySuggestions = data.filter(item =>
item.type === 'city' ||
item.type === 'town' ||
item.type === 'village' ||
item.type === 'administrative'
);
displaySuggestions(citySuggestions);
} catch (error) {
console.error('Erreur lors de la recherche:', error);
clearSuggestions();
}
}
// Gestionnaire d'événements pour l'input
searchInput.addEventListener('input', (e) => {
const query = e.target.value.trim();
// Annuler la recherche précédente
if (searchTimeout) {
clearTimeout(searchTimeout);
}
// Attendre 300ms après la dernière frappe avant de lancer la recherche
searchTimeout = setTimeout(() => {
performSearch(query);
}, 300);
timeoutId = setTimeout(() => performSearch(query), 300);
});
// Fermer la liste des suggestions en cliquant en dehors
document.addEventListener('click', (e) => {
function performSearch(query) {
fetch(`https://geo.api.gouv.fr/communes?nom=${encodeURIComponent(query)}&fields=nom,code,codesPostaux&limit=5`)
.then(response => response.json())
.then(data => {
const citySuggestions = data.map(city => ({
name: city.nom,
postcode: city.codesPostaux[0],
insee: city.code
}));
displaySuggestions(citySuggestions);
})
.catch(error => {
console.error('Erreur lors de la recherche:', error);
clearSuggestions();
});
}
function displaySuggestions(suggestions) {
clearSuggestions();
suggestions.forEach(suggestion => {
const li = document.createElement('li');
li.className = 'list-group-item';
li.textContent = `${suggestion.name} (${suggestion.postcode})`;
li.addEventListener('click', () => {
searchInput.value = suggestion.name;
clearSuggestions();
if (onSelect) onSelect(suggestion);
});
suggestionList.appendChild(li);
});
}
function clearSuggestions() {
suggestionList.innerHTML = '';
}
// Fermer les suggestions en cliquant en dehors
document.addEventListener('click', function (e) {
if (!searchInput.contains(e.target) && !suggestionList.contains(e.target)) {
clearSuggestions();
}
@ -100,17 +70,97 @@ function setupCitySearch(searchInputId, suggestionListId, onCitySelected) {
}
// Fonction pour formater l'URL de labourage
function getLabourerUrl(zipCode) {
/**
* Génère l'URL de labourage pour un code postal donné
* @param {string} zipCode - Le code postal
* @returns {string} L'URL de labourage
*/
export function getLabourerUrl(zipCode) {
return `/admin/labourer/${zipCode}`;
}
// Fonction pour gérer la soumission du formulaire d'ajout de ville
window.handleAddCityFormSubmit = function(event) {
export function handleAddCityFormSubmit(event) {
event.preventDefault();
const form = event.target;
const zipCode = form.querySelector('input[name="zip_code"]').value;
if (zipCode) {
window.location.href = getLabourerUrl(zipCode);
const submitButton = form.querySelector('button[type="submit"]');
const zipCodeInput = form.querySelector('input[name="zip_code"]');
if (!zipCodeInput.value) {
return;
}
};
// Afficher le spinner
submitButton.disabled = true;
const originalContent = submitButton.innerHTML;
submitButton.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Labourer...';
// Rediriger
window.location.href = getLabourerUrl(zipCodeInput.value);
}
/**
* Colore les cellules d'un tableau en fonction des pourcentages
* @param {string} selector - Le sélecteur CSS pour cibler les cellules à colorer
* @param {string} color - La couleur de base en format RGB (ex: '154, 205, 50')
*/
export function colorizePercentageCells(selector, color = '154, 205, 50') {
document.querySelectorAll(selector).forEach(cell => {
const percentage = parseInt(cell.textContent);
if (!isNaN(percentage)) {
const alpha = percentage / 100;
cell.style.backgroundColor = `rgba(${color}, ${alpha})`;
}
});
}
/**
* Colore les cellules d'un tableau avec un gradient relatif à la valeur maximale
* @param {string} selector - Le sélecteur CSS pour cibler les cellules à colorer
* @param {string} color - La couleur de base en format RGB (ex: '154, 205, 50')
*/
export function colorizePercentageCellsRelative(selector, color = '154, 205, 50') {
// Récupérer toutes les cellules
const cells = document.querySelectorAll(selector);
// Trouver la valeur maximale
let maxValue = 0;
cells.forEach(cell => {
const value = parseInt(cell.textContent);
if (!isNaN(value) && value > maxValue) {
maxValue = value;
}
});
// Appliquer le gradient relatif à la valeur max
cells.forEach(cell => {
const value = parseInt(cell.textContent);
if (!isNaN(value)) {
const alpha = value / maxValue; // Ratio relatif au maximum
cell.style.backgroundColor = `rgba(${color}, ${alpha})`;
}
});
}
/**
* Ajuste dynamiquement la taille du texte des éléments list-group-item selon leur nombre
* @param {string} selector - Le sélecteur CSS des éléments à ajuster
* @param {number} [minFont=0.8] - Taille de police minimale en rem
* @param {number} [maxFont=1.2] - Taille de police maximale en rem
*/
export function adjustListGroupFontSize(selector, minFont = 0.8, maxFont = 1.2) {
const items = document.querySelectorAll(selector);
const count = items.length;
let fontSize = maxFont;
if (count > 0) {
// Plus il y a d'items, plus la taille diminue, mais jamais en dessous de minFont
fontSize = Math.max(minFont, maxFont - (count - 5) * 0.05);
}
items.forEach(item => {
item.style.fontSize = fontSize + 'rem';
});
}
function check_validity() {
if (!document.getElementById('editLand')) {
return;
}
// ... suite du code ...
}

View file

@ -131,10 +131,8 @@ final class AdminController extends AbstractController
// Récupérer ou créer les stats pour cette zone
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $zip_code]);
$city = $this->motocultrice->get_city_osm_from_zip_code($zip_code);
if (!$stats) {
$stats = new Stats();
$stats->setZone($zip_code)
->setPlacesCount(0)
@ -144,11 +142,27 @@ final class AdminController extends AbstractController
->setAvecAccessibilite(0)
->setAvecNote(0)
->setCompletionPercent(0);
$this->entityManager->persist($stats);
$this->entityManager->flush();
}
$this->entityManager->persist($stats);
$this->entityManager->flush();
}
$stats->setName($city);
// Récupérer la population via l'API
$population = null;
try {
$apiUrl = 'https://geo.api.gouv.fr/communes/' . $zip_code . '?fields=population';
$response = file_get_contents($apiUrl);
if ($response !== false) {
$data = json_decode($response, true);
if (isset($data['population'])) {
$population = (int)$data['population'];
$stats->setPopulation($population);
}
}
} catch (\Exception $e) {
// Ne rien faire si l'API échoue
}
// Récupérer toutes les données
$places = $this->motocultrice->labourer($zip_code);
$processedCount = 0;

View file

@ -100,6 +100,9 @@ class Place
#[ORM\Column(length: 255, nullable: true)]
private ?string $siret = null;
#[ORM\Column(nullable: true)]
private ?int $habitants = null;
public function getMainTag(): ?string
{
return $this->main_tag;
@ -579,4 +582,16 @@ class Place
return $this;
}
public function getHabitants(): ?int
{
return $this->habitants;
}
public function setHabitants(?int $habitants): static
{
$this->habitants = $habitants;
return $this;
}
}

View file

@ -55,6 +55,10 @@ class Stats
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
// nombre d'habitants dans la zone
#[ORM\Column(type: Types::INTEGER, nullable: true)]
private ?int $population = null;
// calcule le pourcentage de complétion de la zone
public function computeCompletionPercent(): ?int
{
@ -255,6 +259,17 @@ class Stats
return $this;
}
public function getPopulation(): ?int
{
return $this->population;
}
public function setPopulation(?int $population): static
{
$this->population = $population;
return $this;
}
}

View file

@ -37,6 +37,27 @@
</button>
</div>
</div>
{% if stats.population %}
<div class="row mb-3">
<div class="col-md-4 col-12">
<span class="badge bg-info">
<i class="bi bi-people"></i> Population&nbsp;: {{ stats.population|number_format(0, '.', ' ') }}
</span>
</div>
<div class="col-md-4 col-12">
<span class="badge bg-secondary">
<i class="bi bi-shop"></i> 1 lieu pour
{% set ratio = (stats.population and stats.places|length > 0) ? (stats.population / stats.places|length)|round(0, 'ceil') : '?' %}
{{ ratio|number_format(0, '.', ' ') }} habitants
</span>
</div>
<div class="col-md-4 col-12">
<span class="badge bg-success">
<i class="bi bi-pencil-square"></i> {{ stats.getAvecNote() }} / {{ stats.places|length }} commerces avec note
</span>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-3 col-12">
<span class="badge {% if stats.getCompletionPercent() > 85 %}bg-success{% else %}bg-warning{% endif %}">
@ -198,28 +219,52 @@
function calculateCompletion(element) {
let completionCount = 0;
let totalFields = 0;
let missingFields = [];
const fieldsToCheck = [
'name',
'contact:street',
'contact:housenumber',
'opening_hours',
'contact:website',
'contact:phone',
'wheelchair'
{name: 'name', label: 'Nom du commerce'},
{name: 'contact:street', label: 'Rue'},
{name: 'contact:housenumber', label: 'Numéro'},
{name: 'opening_hours', label: 'Horaires d\'ouverture'},
{name: 'contact:website', label: 'Site web'},
{name: 'contact:phone', label: 'Téléphone'},
{name: 'wheelchair', label: 'Accessibilité PMR'}
];
fieldsToCheck.forEach(field => {
totalFields++;
if (element.tags && element.tags[field]) {
if (element.tags && element.tags[field.name]) {
completionCount++;
} else {
missingFields.push(field.label);
}
});
return (completionCount / totalFields) * 100;
return {
percentage: (completionCount / totalFields) * 100,
missingFields: missingFields
};
}
function showMissingFieldsPopup(element) {
const completion = calculateCompletion(element);
if (completion.percentage < 100) {
const popup = new maplibregl.Popup()
.setLngLat(element.geometry.coordinates)
.setHTML(`
<div class="p-2">
<h5>Informations manquantes pour ${element.tags?.name || 'ce commerce'}</h5>
<ul class="list-unstyled">
${completion.missingFields.map(field => `<li><i class="bi bi-x-circle text-danger"></i> ${field}</li>`).join('')}
</ul>
</div>
`);
popup.addTo(map);
}
}
function createPopupContent(element) {
const completion = calculateCompletion(element);
let content = `
<div class="mb-2">
<a class="btn btn-primary" href="/admin/placeType/${element.type}/${element.id}">
@ -231,6 +276,17 @@
</div>
`;
if (completion.percentage < 100) {
content += `
<div class="alert alert-warning mt-2">
<h6>Informations manquantes :</h6>
<ul class="list-unstyled mb-0">
${completion.missingFields.map(field => `<li><i class="bi bi-x-circle text-danger"></i> ${field}</li>`).join('')}
</ul>
</div>
`;
}
content += '<table class="table table-sm">';
// Ajouter tous les tags
@ -250,7 +306,7 @@
elements.forEach(element => {
const completion = calculateCompletion(element);
const bucketIndex = Math.floor(completion / 10);
const bucketIndex = Math.floor(completion.percentage / 10);
buckets[bucketIndex]++;
});
@ -356,7 +412,7 @@
properties: {
id: element.id,
name: element.tags?.name || 'Sans nom',
completion: completion,
completion: completion.percentage,
center: [lon, lat]
},
geometry: {
@ -400,86 +456,33 @@
function updateMarkers() {
// Supprimer tous les marqueurs existants
features.forEach(feature => {
const layerId = `marker-${feature.properties.id}`;
// Supprimer d'abord la couche
if (map.getLayer(layerId)) {
map.removeLayer(layerId);
}
// Puis supprimer la source
if (map.getSource(layerId)) {
map.removeSource(layerId);
}
});
// Supprimer tous les marqueurs en goutte existants
dropMarkers.forEach(marker => marker.remove());
dropMarkers = [];
if (currentMarkerType === 'circle') {
// Afficher les cercles
features.forEach(feature => {
const layerId = `marker-${feature.properties.id}`;
const circle = turf.circle(
feature.properties.center,
5/1000,
{ steps: 64, units: 'kilometers' }
);
features.forEach(feature => {
const el = document.createElement('div');
el.className = 'marker';
el.style.backgroundColor = getCompletionColor(feature.properties.completion);
el.style.width = '15px';
el.style.height = '15px';
el.style.borderRadius = '50%';
el.style.border = '2px solid white';
el.style.cursor = 'pointer';
map.addSource(layerId, {
'type': 'geojson',
'data': circle
});
const marker = new maplibregl.Marker(el)
.setLngLat(feature.geometry.coordinates)
.addTo(map);
map.addLayer({
'id': layerId,
'type': 'fill',
'source': layerId,
'paint': {
'fill-color': getCompletionColor(feature.properties.completion),
'fill-opacity': 0.7
}
});
});
// Ajouter les popups sur les cercles
map.on('click', function(e) {
const clickedFeatures = map.queryRenderedFeatures(e.point, {
layers: features.map(f => `marker-${f.properties.id}`)
});
if (clickedFeatures.length > 0) {
const feature = clickedFeatures[0];
const elementId = feature.layer.id.replace('marker-', '');
const element = overpassData[elementId];
if (element) {
// Créer le contenu de la popup
const popupContent = createPopupContent(element);
new maplibregl.Popup()
.setLngLat(e.lngLat)
.setHTML(popupContent)
.addTo(map);
}
// Ajouter l'événement de clic
el.addEventListener('click', () => {
const element = overpassData[feature.properties.id];
if (element) {
showMissingFieldsPopup(element);
}
});
} else {
// Afficher les marqueurs en goutte
features.forEach(feature => {
const element = overpassData[feature.properties.id];
const popupContent = element ? createPopupContent(element) : `<h1>${feature.properties.name}</h1>`;
const marker = new maplibregl.Marker({
color: getCompletionColor(feature.properties.completion)
})
.setLngLat(feature.properties.center)
.setPopup(new maplibregl.Popup({ offset: 25 })
.setHTML(popupContent))
.addTo(map);
dropMarkers.push(marker);
});
}
dropMarkers.push(marker);
});
}
function draw_circle_containing_all_features(map) {
@ -722,6 +725,40 @@
});
sortTable();
// Initialiser les popovers pour les cellules de complétion
const completionCells = document.querySelectorAll('.completion-cell');
completionCells.forEach(cell => {
new bootstrap.Popover(cell, {
trigger: 'hover',
html: true
});
// Fermer tous les popovers au clic sur une cellule
cell.addEventListener('click', function(e) {
e.stopPropagation();
completionCells.forEach(otherCell => {
if (otherCell !== cell) {
const popover = bootstrap.Popover.getInstance(otherCell);
if (popover) {
popover.hide();
}
}
});
});
});
// Fermer tous les popovers quand on clique ailleurs
document.addEventListener('click', function(e) {
if (!e.target.closest('.completion-cell')) {
completionCells.forEach(cell => {
const popover = bootstrap.Popover.getInstance(cell);
if (popover) {
popover.hide();
}
});
}
});
});
function toggleCompletionInfo() {

View file

@ -10,7 +10,37 @@
{% endif %}
</a>
</td>
<td class="text-right" style="background : rgba(0,255,0,{{ commerce.getCompletionPercentage() / 100 }})">
<td class="text-right completion-cell"
style="background : rgba(0,255,0,{{ commerce.getCompletionPercentage() / 100 }})"
data-bs-toggle="popover"
data-bs-trigger="hover"
data-bs-html="true"
data-bs-content="
<div class='p-2'>
<h6>Informations manquantes :</h6>
<ul class='list-unstyled mb-0'>
{% if not commerce.name %}
<li><i class='bi bi-x-circle text-danger'></i> Nom du commerce</li>
{% endif %}
{% if not commerce.hasAddress() %}
<li><i class='bi bi-x-circle text-danger'></i> Adresse complète</li>
{% endif %}
{% if not commerce.hasOpeningHours() %}
<li><i class='bi bi-x-circle text-danger'></i> Horaires d'ouverture</li>
{% endif %}
{% if not commerce.hasWebsite() %}
<li><i class='bi bi-x-circle text-danger'></i> Site web</li>
{% endif %}
{# {% if not commerce.phone %}
<li><i class='bi bi-x-circle text-danger'></i> Téléphone</li>
{% endif %} #}
{% if not commerce.hasWheelchair() %}
<li><i class='bi bi-x-circle text-danger'></i> Accessibilité PMR</li>
{% endif %}
</ul>
</div>
"
>
{{ commerce.getCompletionPercentage() }}
</td>
<td class="{{ commerce.mainTag ? 'filled' : '' }}">

View file

@ -53,9 +53,21 @@
{% block javascripts %}
{{ parent() }}
<script src='{{ asset('js/maplibre/maplibre-gl.js') }}'></script>
<script src="{{ asset('js/utils.js') }}"></script>
<script>
<script type="module">
import { colorizePercentageCells, setupCitySearch, getLabourerUrl, handleAddCityFormSubmit, colorizePercentageCellsRelative } from '{{ asset('js/utils.js') }}';
document.addEventListener('DOMContentLoaded', function() {
// Initialiser les tooltips Bootstrap
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl)
});
// Colorer les cellules de pourcentage
colorizePercentageCells('td:nth-child(3)');
// colorier selon le nombre de lieux
colorizePercentageCellsRelative('td:nth-child(4)', '154, 205, 50');
const searchInput = document.getElementById('citySearch');
const suggestionList = document.getElementById('citySuggestions');
@ -64,6 +76,30 @@
document.getElementById('selectedZipCode').value = suggestion.postcode;
});
}
// Attacher le submit du formulaire en JS
const labourerForm = document.getElementById('labourerForm');
if (labourerForm) {
labourerForm.addEventListener('submit', handleAddCityFormSubmit);
}
// Gestionnaire pour les boutons de labourage
document.querySelectorAll('.btn-labourer').forEach(button => {
button.addEventListener('click', function(e) {
e.preventDefault();
console.log('submit', this.dataset);
const zipCode = this.dataset.zipCode;
if (!zipCode) return;
// Désactiver le bouton et ajouter le spinner
this.disabled = true;
const originalContent = this.innerHTML;
this.innerHTML = '<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span> Labourer...';
// Rediriger vers l'URL de labourage
window.location.href = getLabourerUrl(zipCode);
});
});
});
</script>
{% endblock %}
@ -77,28 +113,6 @@
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h3 class="card-title">Labourer une ville</h3>
<form id="labourerForm" onsubmit="handleAddCityFormSubmit(event)">
<div class="search-container">
<input type="text"
id="citySearch"
class="form-control"
placeholder="Rechercher une ville..."
autocomplete="off">
<div id="citySuggestions" class="suggestion-list"></div>
</div>
<input type="hidden" name="zip_code" id="selectedZipCode">
<button type="submit" class="btn btn-primary mt-3">Labourer cette ville</button>
</form>
</div>
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<h2>Statistiques par ville</h2>
<div class="table-responsive">
@ -115,12 +129,32 @@
<tbody>
{% for stat in stats %}
<tr>
<td>{{ stat.name }}</td>
<td><a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}" title="Voir les statistiques de cette ville">
{{ stat.name }}
</a></td>
<td>{{ stat.zone }}</td>
<td>{{ stat.completionPercent }}%</td>
<td>{{ stat.places|length }}</td>
<td>
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}" class="btn btn-sm btn-primary">Voir les statistiques</a>
<div class="btn-group" role="group">
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}" class="btn btn-sm btn-primary" title="Voir les statistiques de cette ville">
<i class="bi bi-eye"></i>
</a>
<a href="{{ path('app_admin_labourer', {'zip_code': stat.zone}) }}"
class="btn btn-sm btn-success btn-labourer"
data-zip-code="{{ stat.zone }}"
title="Labourer cette ville"
>
<i class="bi bi-recycle"></i>
</a>
<a href="{{ path('app_admin_delete_by_zone', {'zip_code': stat.zone}) }}"
class="btn btn-sm btn-danger"
onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette zone ?')"
title="Supprimer cette ville"
>
<i class="bi bi-trash"></i>
</a>
</div>
</td>
</tr>
{% endfor %}
@ -129,5 +163,35 @@
</div>
</div>
</div>
<div class="row mt-4">
<div class="col-12">
<div class="card">
<div class="card-body">
<h3 class="card-title">Labourer une ville</h3>
<p class="card-text">
<i class="bi bi-info-circle"
data-bs-toggle="tooltip"
data-bs-placement="right"
data-bs-html="true"
title="<strong>Qu'est-ce que le labourage ?</strong><br><br>Le labourage consiste à rechercher automatiquement tous les commerces et lieux d'intérêt dans une ville sur OpenStreetMap. Cette action permet de :<br><br>- Découvrir les commerces existants<br>- Mesurer leur taux de complétion<br>- Identifier les informations manquantes<br>- Faciliter la mise à jour des données"></i>
Rechercher une ville pour labourer ses commerces
</p>
<form id="labourerForm">
<div class="search-container">
<input type="text"
id="citySearch"
class="form-control"
placeholder="Rechercher une ville..."
autocomplete="off">
<div id="citySuggestions" class="suggestion-list"></div>
</div>
<input type="hidden" name="zip_code" id="selectedZipCode">
<button type="submit" class="btn btn-primary mt-3 btn-labourer">Labourer cette ville</button>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View file

@ -4,7 +4,7 @@
{% block body %}
<div class="container edit-land mt-4">
<div class="container edit-land mt-4" id="editLand">
<div class="card shadow-sm">
<div class="card-body">
@ -15,7 +15,7 @@
{% if commerce_overpass is not empty %}
<form action="{{ path('app_public_submit', {'osm_object_id': commerce_overpass['@attributes'].id, 'version': commerce_overpass['@attributes'].version, 'changesetID': commerce_overpass['@attributes'].changeset }) }}" method="post" class="needs-validation">
<input type="hidden" name="osm_kind" value="{{ osm_kind }}">
{# nom #}
<div class="row g-3 mb-4">
<div class="col-12 col-md-4">
<label for="commerce_tag_value__name" class="form-label">{{'display.keys.name'|trans}}</label>
@ -86,13 +86,10 @@
<hr>
</form>
{% endif %}
</div>
</div>
</div>
<div class="row">
<div class="col-12 mt-4">
<div class="actions-modification mb-4 mx-2">
@ -126,17 +123,20 @@
{{ 'display.by'|trans }}
<a href="https://www.openstreetmap.org/user/{{ commerce_overpass['@attributes'].user }}" >{{ commerce_overpass['@attributes'].user }}</a>
</div>
<div class="lien-OpenStreetMap">
<a href="https://www.openstreetmap.org/{{commerce.osmKind}}/{{ commerce_overpass['@attributes'].id }}" class="btn btn-outline-secondary">
<i class="bi bi-globe"></i> {{ 'display.view_on_osm'|trans }}
{{ asset('img/logo-osm.png') }}
</a>
<button onclick="openInJOSM('{{commerce.osmKind}}', '{{ commerce_overpass['@attributes'].id }}')" class="btn btn-outline-secondary ms-2">
<i class="bi bi-pencil"></i> Éditer dans JOSM
<button onclick="openInJOSM('{{commerce.osmKind}}', '{{ commerce_overpass['@attributes'].id }}')"
title="Ouvrir dans JOSM"
class="btn btn-outline-secondary ms-2">
<i class="bi bi-pencil"></i>
{{ asset('img/josm.png') }}
</button>
<button onclick="openInPanoramax()" class="btn btn-outline-secondary ms-2">
<i class="bi bi-camera"></i> Voir dans Panoramax
<button onclick="openInPanoramax()" title="Ouvrir dans Panoramax" class="btn btn-outline-secondary ms-2">
<i class="bi bi-camera"></i>
{{ asset('img/logo-panoramax.png') }}
</button>
</div>

View file

@ -55,6 +55,14 @@
position: relative;
margin-bottom: 1rem;
}
.list-group-item{
cursor: pointer;
}
.list-group-item:hover{
background-color: #f5f5f5;
color: #000;
}
</style>
{% endblock %}
@ -94,29 +102,24 @@
<div class="row city-list ">
<div class="mt-5">
<h2><i class="bi bi-geo-alt"></i> Villes disponibles</h2>
<p>Visualisez un tableau de bord de la complétion des commerces et autres lieux d'intérêt pour votre ville grâce à OpenStreetMap</p>
<h2><i class="bi bi-geo-alt"></i> Villes disponibles</h2>
<p>Visualisez un tableau de bord de la complétion des commerces et autres lieux d'intérêt pour votre ville grâce à OpenStreetMap</p>
</div>
{% for stat in stats %}
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<div class="d-flex flex-column">
<span class="zone">{{ stat.zone }}</span>
<span class="name">{{ stat.name }}</span>
</div>
<div class="col-md-8">
<div class="list-group">
{% for stat in stats %}
<a href="{{ path('app_admin_stats', {'zip_code': stat.zone}) }}" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
{{ stat.zone }} {{ stat.name }}
<span class="badge bg-primary rounded-pill">{{ stat.placesCount }} commerces</span>
</a>
{% endfor %}
</div>
</div>
<div class="col-md-4">
<div class="card">
<div class="card-body">
Ajoutez votre ville
</div>
</div>
</div>
</div>
<span class="badge bg-primary rounded-pill">{{ stat.placesCount }} lieux</span>
</a>
{% endfor %}
</div>
</div>
<script>
// Créer le formulaire email
@ -223,3 +226,13 @@
</script>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="module">
import { adjustListGroupFontSize } from '{{ asset('js/utils.js') }}';
document.addEventListener('DOMContentLoaded', function() {
adjustListGroupFontSize('.list-group-item');
});
</script>
{% endblock %}