From 6b9df1b0eed032bfec74365eba20546d3cca4ffa Mon Sep 17 00:00:00 2001 From: Kerboul Date: Tue, 11 Feb 2025 20:43:59 +0000 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20de=20la=20gestion=20des=20p?= =?UTF-8?q?rojets=20et=20mise=20=C3=A0=20jour=20des=20chemins=20d'images?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 3 +++ js/projet_detail.js | 13 ++++++++++--- js/utilities/routes.js | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..4c8aa1e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5500 +} \ No newline at end of file diff --git a/js/projet_detail.js b/js/projet_detail.js index 4e06a2d..dc9d1b5 100644 --- a/js/projet_detail.js +++ b/js/projet_detail.js @@ -5,10 +5,17 @@ document.addEventListener("DOMContentLoaded", async () => { const data = await getAllProject(); const DataMetrics = await getDataMetrics(projectId); - document.getElementById("name_project").innerHTML = data[projectId].name; + console.log(projectId); + console.log(data); + + const project = data.find(project => project.id == projectId); + if (project) { + document.getElementById("name_project").innerHTML = project.name; + } else { + console.error("Project not found"); + } const videoSelector = document.getElementById("video_selector"); const numberPicker = document.getElementById('number-picker'); - const resultContainer = document.getElementById('result-container'); const choiceSelect = document.getElementById('choice'); const oneByOneContainer = document.getElementById('one-by-one-container'); const firstLastContainer = document.getElementById('first-last-container'); @@ -164,7 +171,7 @@ function populateImageTable(DataMetrics) { let i = 0; DataMetrics.forEach((measure) => { let imageTD = document.createElement("td"); - imageTD.innerHTML = ``; + imageTD.innerHTML = ``; row.appendChild(imageTD); if ((i + 1) % 3 === 0 && i !== 0) { diff --git a/js/utilities/routes.js b/js/utilities/routes.js index 247fbdc..db46c8e 100644 --- a/js/utilities/routes.js +++ b/js/utilities/routes.js @@ -23,9 +23,8 @@ function getAllProject() { return $.ajax({ url: api_url.concat("/projects"), method: "GET", - dataType: "json", + dataType: "json" }).then((data) => { - // If the request is successful, store the data in the cache and return it return data; }); } @@ -38,6 +37,7 @@ function getDataMetrics(projectId){ }).then((data) => { // If the request is successful, store the data in the cache and return it localStorage.setItem("project_list", JSON.stringify(data)); + console.log(data); return data; }); }