update bas les couilles

This commit is contained in:
anto
2024-12-10 15:39:04 +01:00
parent c285116a62
commit 5443d1fc72
8 changed files with 453 additions and 408 deletions

View File

@@ -1,26 +1,40 @@
main { main {
flex: 1 0 auto; flex: 1 0 auto;
} }
footer { footer {
text-align: center; text-align: center;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
} }
.row { .row {
margin-top: 20px; margin-top: 20px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.col-md-6 { .col-md-6 {
flex: 0 0 50%; flex: 0 0 50%;
max-width: 50%; max-width: 50%;
} }
.col-md-12 { .col-md-12 {
flex: 0 0 100%; flex: 0 0 100%;
max-width: 100%; max-width: 100%;
} }
.hiddenTable {
max-height: 400px; /* Adjust this value as needed */
overflow-y: hidden;
}
.full-view {
max-height: none;
overflow-y: visible;
}
.sticky-header thead{
position: sticky;
top: 0;
z-index: 1;
}

View File

@@ -1,66 +1,86 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Détails</title> <title>Détails</title>
<link rel="stylesheet" href="../css/style.css" /> <link rel="stylesheet" href="../css/style.css" />
<link <link
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<link <link
href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css"
rel="stylesheet" rel="stylesheet"
/> />
</head> </head>
<body>
<body> <div id="section" class="container mt-5">
<div id="section" class="container mt-5"> <div class="row">
<div class="row"> <div class="col-md-12">
<div class="col-md-12"> <div class="buttons-container" style="float: left; width: 20%">
<div class="buttons-container" style="float: left; width: 20%"> <button id="projets" >
<button id="projets" class="btn btn-primary"> <span> Home </span>
<span> Home </span> </button>
</button> </div>
</div> <h3
<h3 id="name_project" class="text-black" style="float: left; width: 50%"></h3> id="name_project"
</div> class="text-black"
</div> style="float: left; width: 50%"
<div class="row"> ></h3>
<div class="col-md-6"> </div>
<table class="table table-striped" id="table-metrics"> </div>
<thead class="bg-blue-600 text-black"> <div class="row">
<tr> <div class="col-md-6">
<th>date</th> <table class="table table-striped" id="table-metrics">
<th>Hygrométrie</th> <thead>
<th>température</th> <tr>
</tr> <th>date</th>
</thead> <th>Hygrométrie</th>
<tbody></tbody> <th>température</th>
</table> </tr>
</div> </thead>
<div class="col-md-6"> <tbody></tbody>
<table class="table table-striped" id="table-image"> </table>
<thead class="bg-blue-600 text-black"> </div>
<tr> <div class="col-md-6">
<th>images</th> <div id="content1" class="hiddenTable">
</tr> <table
</thead> class="table table-striped scrollable sticky-header"
<tbody></tbody> id="table-image"
</table> >
</div> <thead>
</div> <tr>
</div> <th>
<button id="toggle-view">
<img id="my-image" alt="Description of the image" /> See all images
<footer> </button>
<p>&copy; 2024 Timelapse. All rights reserved.</p> </th>
</footer> <th><button>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> sort images
<script src="../js/globals.js"></script> </button></th>
<script src="../js/projet_detail.js"></script> <th><button>
</body> export images
</html> </button></th>
</tr>
<tr>
<th colspan="3" scope="col">images</th>
</tr>
</thead>
<tbody id="imageSource"></tbody>
</table>
</div>
</div>
</div>
</div>
<footer>
<p>&copy; 2024 Timelapse. All rights reserved.</p>
</footer>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="../js/globals.js"></script>
<script src="../js/projet_detail.js"></script>
</body>
</html>

View File

@@ -1,45 +1,45 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vidéos</title> <title>Vidéos</title>
<link rel="stylesheet" href="../css/style.css"> <link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head> </head>
<body> <body>
<div id="section"></div> <div id="section"></div>
<div class="buttons-container"> <div class="buttons-container">
<button id="projets" class="btn btn-primary"><span> <button id="projets" ><span>
Mes projets Mes projets
</span> </span>
</button> </button>
</div> </div>
</div> </div>
<footer> <footer>
<p>&copy; 2024 Timelapse. All rights reserved.</p> <p>&copy; 2024 Timelapse. All rights reserved.</p>
</footer> </footer>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"> integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" <script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"> integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
</script> </script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"> integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
</script> </script>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
document.getElementById("projets").addEventListener('click', () => { document.getElementById("projets").addEventListener('click', () => {
window.location.href = '../index.html'; window.location.href = '../index.html';
}); });
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@@ -1,50 +1,50 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timelapse</title> <title>Timelapse</title>
<link rel="stylesheet" href="../css/style.css"> <link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
</head> </head>
<body> <body>
<div id="section" class="container mt-5"> <div id="section" class="container mt-5">
<div class="buttons-container mb-4"> <div class="buttons-container mb-4">
<button id="video" class="btn btn-primary"><span>Mes vidéos</span></button> <button id="video" ><span>Mes vidéos</span></button>
<button id="download" class="btn btn-primary"><span>Download App</span></button> <button id="download" ><span>Download App</span></button>
</div> </div>
<table class="table table-striped" id="table-projects"> <table class="table table-striped" id="table-projects">
<thead class="bg-blue-600 text-white"> <thead class="bg-blue-600 text-white">
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Images</th> <th>Images</th>
<th>Actions</th> <th>Actions</th>
</tr> </tr>
</thead> </thead>
<tbody></tbody> <tbody></tbody>
</table> </table>
</div> </div>
<footer class="text-center mt-5 py-3"> <footer class="text-center mt-5 py-3">
<p>&copy; 2024 Timelapse. All rights reserved.</p> <p>&copy; 2024 Timelapse. All rights reserved.</p>
</footer> </footer>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="../js/globals.js"></script> <script src="../js/globals.js"></script>
<script src="../js/index.js"></script> <script src="../js/index.js"></script>
<script> <script>
// Redirect to videos.php when the "Mes vidéos" button is clicked // Redirect to videos.php when the "Mes vidéos" button is clicked
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
document.getElementById("video").addEventListener('click', () => { document.getElementById("video").addEventListener('click', () => {
window.location.href = 'html/videos.html'; window.location.href = 'html/videos.html';
}); });
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@@ -1,85 +1,85 @@
// Global variables // Global variables
let api_url = "https://timelapse.kerboul.me/api"; let api_url = "https://timelapse.kerboul.me/api";
let global_project_list; let global_project_list;
let current_project = ""; let current_project = "";
function formatDate(isoString) { function formatDate(isoString) {
const date = new Date(isoString); const date = new Date(isoString);
const options = { const options = {
year: "numeric", year: "numeric",
month: "long", month: "long",
day: "numeric", day: "numeric",
hour: "numeric", hour: "numeric",
minute: "numeric", minute: "numeric",
second: "numeric", second: "numeric",
timeZoneName: "short", timeZoneName: "short",
}; };
return date.toLocaleString("en-US", options); return date.toLocaleString("en-US", options);
} }
// Function to get data from API // Function to get data from API
function getDataProjectFromApi() { function getDataProjectFromApi() {
return $.ajax({ return $.ajax({
url: api_url.concat("/itemsdb"), url: api_url.concat("/itemsdb"),
method: "GET", method: "GET",
dataType: "json", dataType: "json",
}).then((data) => { }).then((data) => {
// If the request is successful, store the data in the cache and return it // If the request is successful, store the data in the cache and return it
localStorage.setItem("project_list", JSON.stringify(data)); localStorage.setItem("project_list", JSON.stringify(data));
return data; return data;
}); });
} }
function getDataProjectMetricsFromApi(id) { function getDataProjectMetricsFromApi(id) {
return $.ajax({ return $.ajax({
url: api_url.concat(`/metric/${id}`), url: api_url.concat(`/metric/${id}`),
method: "GET", method: "GET",
dataType: "json", dataType: "json",
}).then((data) => { }).then((data) => {
// If the request is successful, store the data in the cache and return it // If the request is successful, store the data in the cache and return it
return data; return data;
}); });
} }
function getDataProjectImagesFromApi(id) { function getDataProjectImagesFromApi(id) {
return $.ajax({ return $.ajax({
url: api_url.concat(`/image/${id}`), url: api_url.concat(`/image/${id}`),
method: "GET", method: "GET",
dataType: "json", dataType: "json",
}).then((data) => { }).then((data) => {
// If the request is successful, store the data in the cache and return it // If the request is successful, store the data in the cache and return it
return data; return data;
}); });
} }
// Function to send data to API // Function to send data to API
function sendDataFromApi(datas) { function sendDataFromApi(datas) {
return $.ajax({ return $.ajax({
url: api_url.concat("/projets"), url: api_url.concat("/projets"),
method: "POST", method: "POST",
data: JSON.stringify(datas), data: JSON.stringify(datas),
contentType: "application/json", contentType: "application/json",
success: function (datas) { success: function (datas) {
console.log("successful"); console.log("successful");
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
console.error(errorThrown); console.error(errorThrown);
}, },
}); });
} }
function deleteDataFromApi(id) { function deleteDataFromApi(id) {
return $.ajax({ return $.ajax({
url: api_url.concat("/delete"), url: api_url.concat("/delete"),
method: "POST", method: "POST",
data: JSON.stringify({ id: id }), data: JSON.stringify({ id: id }),
contentType: "application/json", contentType: "application/json",
success: function (datas) { success: function (datas) {
console.log("successful"); console.log("successful");
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
console.error(errorThrown); console.error(errorThrown);
}, },
}); });
} }

View File

@@ -1,45 +1,45 @@
// Function to display projects in a table // Function to display projects in a table
function display_projects() { function display_projects() {
// Get data from API and then generate HTML code to display the data in a table // Get data from API and then generate HTML code to display the data in a table
const table = document.getElementById("table-projects"); const table = document.getElementById("table-projects");
let datas = `<tr> let datas = `<tr>
<th>Id</th> <th>Id</th>
<th>Name</th> <th>Name</th>
<th>Date</th> <th>Date</th>
<th>Status</th> <th>Status</th>
<th>Actions</th> <th>Actions</th>
</tr> `; </tr> `;
for (let i = 0; i < global_project_list.length; i++) { for (let i = 0; i < global_project_list.length; i++) {
datas += `<tr> datas += `<tr>
<th>${global_project_list[i].id}</th> <th>${global_project_list[i].id}</th>
<th>${global_project_list[i].titre}</th> <th>${global_project_list[i].titre}</th>
<th>${formatDate(global_project_list[i].creation)}</th> <th>${formatDate(global_project_list[i].creation)}</th>
<th>${global_project_list[i].status}</th> <th>${global_project_list[i].status}</th>
<th><button class="project_detail btn btn-primary">détails de ${global_project_list[i].titre}</button></th> <th><button class="project_detail btn btn-primary">détails de ${global_project_list[i].titre}</button></th>
</tr>`; </tr>`;
} }
table.innerHTML = datas; table.innerHTML = datas;
// Select all the buttons with the class button_project // Select all the buttons with the class button_project
const buttons = document.getElementsByClassName("project_detail"); const buttons = document.getElementsByClassName("project_detail");
// Add an event listener to each button // Add an event listener to each button
for (let i = 0; i < buttons.length; i++) { for (let i = 0; i < buttons.length; i++) {
buttons[i].addEventListener("click", (event) => { buttons[i].addEventListener("click", (event) => {
// Send data to API and then navigate to projet_detail.html page // Send data to API and then navigate to projet_detail.html page
window.location.href = `html/projet_detail.html?id=${global_project_list[i].id}`; window.location.href = `html/projet_detail.html?id=${global_project_list[i].id}`;
}); });
buttons[i].addEventListener("onclick", (event) => { buttons[i].addEventListener("onclick", (event) => {
// Send data to API and then navigate to projet_detail.html page // Send data to API and then navigate to projet_detail.html page
current_project=change_current_project(i); current_project=change_current_project(i);
}); });
} }
} }
getDataProjectFromApi() getDataProjectFromApi()
.then(project_list => { .then(project_list => {
global_project_list = project_list; global_project_list = project_list;
// Call the next function here // Call the next function here
display_projects(); display_projects();
}) })
.catch(error => { .catch(error => {
console.error(error); console.error(error);
}); });

View File

@@ -1,62 +1,73 @@
function display_metrics(metrics_datas) { function display_metrics(metrics_datas) {
// Get data from API and then generate HTML code to display the data in a table // Get data from API and then generate HTML code to display the data in a table
const table = document.getElementById("table-metrics"); const table = document.getElementById("table-metrics");
let datas = `<tr> let datas = `
<th>Date</th> <tr><th>Date</th> <th>Température</th> <th>Hygrométrie</th>
<th>Température</th> </tr>`;
<th>Hygrométrie</th> for (let i = 0; i < metrics_datas.length; i++) {
</tr> `; datas += `
for (let i = 0; i < metrics_datas.length; i++) { <tr>
datas += `<tr> <th>${formatDate(metrics_datas[i].date_metrique)}</th>
<th>${formatDate(metrics_datas[i].date_metrique)}</th> <th>${metrics_datas[i].temperature}</th>
<th>${metrics_datas[i].temperature}</th> <th>${metrics_datas[i].hygrometrie}</th>
<th>${metrics_datas[i].hygrometrie}</th> </tr>`;
</tr>`; }
} table.innerHTML = datas;
table.innerHTML = datas; }
}
document.addEventListener("DOMContentLoaded", () => {
// function display_metrics(images_datas) { const urlParams = new URLSearchParams(window.location.search);
// // Get data from API and then generate HTML code to display the data in a table const projectId = urlParams.get("id");
// const table_image = document.getElementById("table-image"); getDataProjectMetricsFromApi(projectId)
// let datas = `<tr> .then((project_metrics) => {
// <th>Images</th> display_metrics(project_metrics);
})
// </tr> `; .catch((error) => {
// for (let i = 0; i < images_datas.length; i+=3) { console.error(error);
// if(i+2<images_datas.length) });
// datas += `<tr> document.getElementById("projets").addEventListener("click", () => {
// <th>${images_datas[i]}</th> window.location.href = "../index.html";
// <th>${images_datas[i+1]}</th> current_project = "";
// <th>${images_datas[i+2]}</th> });
// </tr>`; global_project_list = JSON.parse(localStorage.getItem("project_list"));
// } document.getElementById("name_project").innerHTML =
// table_image.innerHTML = datas; global_project_list[projectId - 1].titre;
// }
fetch("https://timelapse.kerboul.me/api/smile")
document.addEventListener("DOMContentLoaded", () => { .then((response) => response.blob())
const urlParams = new URLSearchParams(window.location.search); .then((blob) => {
const projectId = urlParams.get("id"); const url = URL.createObjectURL(blob);
getDataProjectMetricsFromApi(projectId) let tableBody = document.getElementById("imageSource");
.then(project_metrics => { let row = document.createElement("tr");
display_metrics(project_metrics);
}) for (let i = 0; i < 1500; i++) {
.catch(error => { let imageTD = document.createElement("td");
console.error(error); imageTD.innerHTML = `<img id="${i}" src="${url}" />`;
}); row.appendChild(imageTD);
document.getElementById("projets").addEventListener("click", () => {
window.location.href = "../index.html"; if ((i + 1) % 3 === 0 && i !== 0) {
current_project=""; tableBody.appendChild(row);
}); row = document.createElement("tr"); // Create a new row
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") // Append the last row if there are remaining images
.then(response => response.blob()) if (row.childNodes.length > 0) {
.then(blob => { tableBody.appendChild(row);
const url = URL.createObjectURL(blob); }
const imageElement = document.getElementById("my-image"); });
imageElement.src = url;
}); // Add event listener for the toggle button
}); document.getElementById("toggle-view").addEventListener("click", () => {
const tableImage = document.getElementById("content1");
if (tableImage.classList.contains("hiddenTable")) {
tableImage.classList.remove("hiddenTable");
tableImage.classList.add("full-view");
document.getElementById("toggle-view").innerHTML="See first images"
} else {
tableImage.classList.remove("full-view");
tableImage.classList.add("hiddenTable");
document.getElementById("toggle-view").innerHTML="See all images"
}
});
});

View File

@@ -1,31 +1,31 @@
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
// Fetch data from the API // Fetch data from the API
fetch("https://timelapse.kerboul.me/api/itemsdb") fetch("https://timelapse.kerboul.me/api/itemsdb")
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
// Get the table body element // Get the table body element
const tableBody = document.querySelector("#table-metrics tbody"); const tableBody = document.querySelector("#table-metrics tbody");
// Loop through the data and create a new row for each item // Loop through the data and create a new row for each item
data.forEach(item => { data.forEach(item => {
const row = document.createElement("tr"); const row = document.createElement("tr");
// Create a new cell for each property (metrics, hygrometry, temperature) // Create a new cell for each property (metrics, hygrometry, temperature)
const metricsCell = document.createElement("td"); const metricsCell = document.createElement("td");
metricsCell.textContent = item.metrics; metricsCell.textContent = item.metrics;
row.appendChild(metricsCell); row.appendChild(metricsCell);
const hygrometryCell = document.createElement("td"); const hygrometryCell = document.createElement("td");
hygrometryCell.textContent = item.hygrometry; hygrometryCell.textContent = item.hygrometry;
row.appendChild(hygrometryCell); row.appendChild(hygrometryCell);
const temperatureCell = document.createElement("td"); const temperatureCell = document.createElement("td");
temperatureCell.textContent = item.temperature; temperatureCell.textContent = item.temperature;
row.appendChild(temperatureCell); row.appendChild(temperatureCell);
// Append the row to the table body // Append the row to the table body
tableBody.appendChild(row); tableBody.appendChild(row);
}); });
}) })
.catch(error => console.error(error)); .catch(error => console.error(error));
}); });