mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-06-20 01:44:42 +02:00
fix name avec slash, ajout nombre de changesets dans le temps en footer
This commit is contained in:
parent
90760c93f8
commit
9ae7c0d3e4
3 changed files with 65 additions and 2 deletions
|
@ -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 = `
|
||||
<p>Changesets créés :</p>
|
||||
<ul>
|
||||
<li>Dernières 24h : ${stats.last24h}</li>
|
||||
<li>7 derniers jours : ${stats.last7days}</li>
|
||||
<li>30 derniers jours : ${stats.last30days}</li>
|
||||
</ul>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
// 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é');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<p class="mb-0">
|
||||
<a href="https://www.openstreetmap.org/copyright">Sources du logiciel</a>
|
||||
</p>
|
||||
<div id="userChangesHistory"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
{% for place in places %}
|
||||
<tr>
|
||||
<td>{% if place.name %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name, 'uuid': place.uuidForUrl}) }}">{{ place.name }}</a>
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name|url_encode, 'uuid': place.uuidForUrl}) }}">{{ place.name }}</a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': '?', 'uuid': place.uuidForUrl}) }}"><i class="bi bi-question-circle"></i></a>
|
||||
{% endif %} </td>
|
||||
|
@ -94,7 +94,7 @@
|
|||
<a href="https://www.openstreetmap.org/{{place.osmKind}}/{{ place.osmId }}" target="_blank"><i class="bi bi-globe"></i></a>
|
||||
|
||||
{% if place.name %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name, 'uuid': place.uuidForUrl}) }}"><i class="bi bi-pencil"></i></a>
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': place.name|url_encode, 'uuid': place.uuidForUrl}) }}"><i class="bi bi-pencil"></i></a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_public_edit', {'zipcode': place.zipCode, 'name': '?', 'uuid': place.uuidForUrl}) }}"><i class="bi bi-pencil"></i></a>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue