From 9ae7c0d3e49c6638d4010bdab041bb19781713be Mon Sep 17 00:00:00 2001 From: Tykayn Date: Thu, 29 May 2025 15:42:08 +0200 Subject: [PATCH] fix name avec slash, ajout nombre de changesets dans le temps en footer --- assets/app.js | 62 ++++++++++++++++++++++++++++ templates/base.html.twig | 1 + templates/public/dashboard.html.twig | 4 +- 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/assets/app.js b/assets/app.js index 703a3e1..02ae233 100644 --- a/assets/app.js +++ b/assets/app.js @@ -451,5 +451,67 @@ document.addEventListener('DOMContentLoaded', () => { openingHoursFormManager.init(); + + // lister les changesets de l'utilisateur osm-commerces + async function listChangesets() { + // const changesets = await fetch('https://api.openstreetmap.org/api/0.6/changesets?display_name=osm-commerce-fr'); + // Ajouter le header Accept pour demander du JSON + const options = { + headers: { + 'Accept': 'application/json' + } + }; + const changesets = await fetch('https://api.openstreetmap.org/api/0.6/changesets?display_name=osm-commerce-fr', options); + const data = await changesets.json(); + console.log(data.changesets.length); + + // Grouper les changesets par période + const now = new Date(); + const last24h = new Date(now - 24 * 60 * 60 * 1000); + const last7days = new Date(now - 7 * 24 * 60 * 60 * 1000); + const last30days = new Date(now - 30 * 24 * 60 * 60 * 1000); + + const stats = { + last24h: 0, + last7days: 0, + last30days: 0 + }; + + data.changesets.forEach(changeset => { + const changesetDate = new Date(changeset.closed_at); + + if (changesetDate >= last24h) { + stats.last24h++; + } + if (changesetDate >= last7days) { + stats.last7days++; + } + if (changesetDate >= last30days) { + stats.last30days++; + } + }); + + // Afficher les statistiques + const historyDiv = document.getElementById('userChangesHistory'); + if (historyDiv) { + historyDiv.innerHTML = ` +

Changesets créés :

+ + `; + } + } + + // Vérifier si l'élément avec l'ID 'userChangesHistory' existe avant d'appeler la fonction + if (document.getElementById('userChangesHistory')) { + listChangesets(); + } else { + console.log('userChangesHistory non trouvé'); + } + + }); diff --git a/templates/base.html.twig b/templates/base.html.twig index 2ea2361..0feaf2c 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -85,6 +85,7 @@

Sources du logiciel

+
diff --git a/templates/public/dashboard.html.twig b/templates/public/dashboard.html.twig index b43df5c..373a0c1 100644 --- a/templates/public/dashboard.html.twig +++ b/templates/public/dashboard.html.twig @@ -81,7 +81,7 @@ {% for place in places %} {% if place.name %} - {{ place.name }} + {{ place.name }} {% else %} {% endif %} @@ -94,7 +94,7 @@ {% if place.name %} - + {% else %} {% endif %}