This commit is contained in:
anto
2024-10-24 17:13:14 +02:00
parent bc49332321
commit e07c99e5bb
4 changed files with 68 additions and 27 deletions

View File

@@ -42,6 +42,17 @@ function getDataProjectMetricsFromApi(id) {
});
}
function getDataProjectImagesFromApi(id) {
return $.ajax({
url: api_url.concat(`/image/${id}`),
method: "GET",
dataType: "json",
}).then((data) => {
// If the request is successful, store the data in the cache and return it
return data;
});
}
// Function to send data to API
function sendDataFromApi(datas) {
return $.ajax({

View File

@@ -16,12 +16,29 @@ function display_metrics(metrics_datas) {
table.innerHTML = datas;
}
// function display_metrics(images_datas) {
// // Get data from API and then generate HTML code to display the data in a table
// const table_image = document.getElementById("table-image");
// let datas = `<tr>
// <th>Images</th>
// </tr> `;
// for (let i = 0; i < images_datas.length; i+=3) {
// if(i+2<images_datas.length)
// datas += `<tr>
// <th>${images_datas[i]}</th>
// <th>${images_datas[i+1]}</th>
// <th>${images_datas[i+2]}</th>
// </tr>`;
// }
// table_image.innerHTML = datas;
// }
document.addEventListener("DOMContentLoaded", () => {
const urlParams = new URLSearchParams(window.location.search);
const projectId = urlParams.get("id");
getDataProjectMetricsFromApi(projectId)
.then(project_metrics => {
console.log(project_metrics)
display_metrics(project_metrics);
})
.catch(error => {
@@ -33,5 +50,13 @@ document.addEventListener("DOMContentLoaded", () => {
});
global_project_list=JSON.parse(localStorage.getItem("project_list"));
document.getElementById("name_project").innerHTML=global_project_list[projectId-1].titre;
fetch("https://timelapse.kerboul.me/api/smile")
.then(response => response.blob())
.then(blob => {
const url = URL.createObjectURL(blob);
const imageElement = document.getElementById("my-image");
imageElement.src = url;
});
});