update(map): public club map
All checks were successful
Deploy Production Server / if_merged (pull_request) Successful in 5m26s

This commit is contained in:
Thibaut Valentin 2025-01-20 15:32:13 +01:00
parent 476f2b5233
commit 8ecb9d714f
2 changed files with 8 additions and 33 deletions

View File

@ -15,8 +15,6 @@
<body> <body>
<div id="map" style="width: 100%; height: 95vh"></div> <div id="map" style="width: 100%; height: 95vh"></div>
<div id="club_map_data" style="width: 100%; min-height: 0; background-color: #00000011; padding: 0.5em"></div>
<script src="club-maps.js"></script> <script src="club-maps.js"></script>
</body> </body>
</html> </html>

View File

@ -1,7 +1,4 @@
const div_map = document.getElementById('map'); const api_url = "https://intra.ffsaf.fr";
//const div_info = document.getElementById('club_map_data');
const api_url = "http://localhost:5173";
let map = L.map('map').setView([46.631196, 2.456000], 6); let map = L.map('map').setView([46.631196, 2.456000], 6);
@ -27,8 +24,6 @@ const sortHoraire = (a, b) => {
return a.day - b.day; return a.day - b.day;
} }
//let last_info_show = null;
async function getData() { async function getData() {
const response = await fetch(`${api_url}/api/club/get_map_data`); const response = await fetch(`${api_url}/api/club/get_map_data`);
if (!response.ok) { if (!response.ok) {
@ -37,20 +32,16 @@ async function getData() {
const data = await response.json(); const data = await response.json();
for (const d of data) { for (const d of data) {
console.log(d);
if (d.training_location.length === 0) if (d.training_location.length === 0)
continue; continue;
let icon = null; let icon = null;
if (d.uuid !== null) { if (d.uuid !== null) {
console.log("logo"); const img = await getMeta(`${api_url}/api/club/${d.uuid}/logo`);
const img = await getMeta(`http://localhost:5173/api/club/${d.uuid}/logo`);
let ratio = img.naturalHeight / img.naturalWidth; let ratio = img.naturalHeight / img.naturalWidth;
icon = L.icon({ icon = L.icon({
iconUrl: `http://localhost:5173/api/club/${d.uuid}/logo`, iconUrl: `${api_url}/api/club/${d.uuid}/logo`,
iconSize: [50, 50 * ratio], // size of the icon iconSize: [50, 50 * ratio], // size of the icon
//shadowSize: [50, 64], // size of the shadow //shadowSize: [50, 64], // size of the shadow
@ -61,7 +52,6 @@ async function getData() {
} }
for (const m of d.training_location) { for (const m of d.training_location) {
console.log(m);
let marker; let marker;
if (icon === null) if (icon === null)
marker = L.marker([m.lat, m.lng]); marker = L.marker([m.lat, m.lng]);
@ -89,7 +79,6 @@ async function getData() {
div_info.appendChild(document.createElement("br")); div_info.appendChild(document.createElement("br"));
} else { } else {
for (const m of JSON.parse(d.training_day_time).sort(sortHoraire)) { for (const m of JSON.parse(d.training_day_time).sort(sortHoraire)) {
console.log(m);
let days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"]; let days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"];
div_info.appendChild(document.createTextNode(`${days[m.day]}: ${timeNumberToSting(m.time_start)} - ${timeNumberToSting(m.time_end)}`)); div_info.appendChild(document.createTextNode(`${days[m.day]}: ${timeNumberToSting(m.time_start)} - ${timeNumberToSting(m.time_end)}`));
@ -111,24 +100,12 @@ async function getData() {
} }
marker.bindPopup(div_info.innerHTML); marker.bindPopup(div_info.innerHTML);
//marker.on('click', e => { if (icon !== null){
//console.log("click"); marker.valueOf()._icon.style.backgroundColor = '#FFFFFF';
//if (div_map.style.height !== "95vh" && last_info_show === d.name) { marker.valueOf()._icon.style.borderRadius = '10px';
//div_map.style.height = "95vh"; }
//div_info.style.minHeight = "0";
//div_info.replaceChildren();
//} else {
//div_map.style.height = "80vh";
//div_info.style.minHeight = "15vh";
//div_info.replaceChildren();
//last_info_show = d.name;
//}
//})
} }
} }
} }
getData().then(() => console.log("end loading")); getData().then(() => console.log("end loading"));
console.log("test");