Init Frontend
This commit is contained in:
10
css/style.css
Normal file
10
css/style.css
Normal file
@@ -0,0 +1,10 @@
|
||||
main {
|
||||
flex: 1 0 auto;
|
||||
}
|
||||
|
||||
|
||||
footer {
|
||||
text-align: center;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
}
|
||||
80
html/projet_detail.html
Normal file
80
html/projet_detail.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Détails</title>
|
||||
<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"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
|
||||
crossorigin="anonymous"
|
||||
/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="section">
|
||||
<div class="buttons-container">
|
||||
<button id="projets" class="btn btn-primary">
|
||||
<span> Mes projets </span>
|
||||
</button>
|
||||
</div>
|
||||
<div id="datas">
|
||||
<h5>
|
||||
Métriques
|
||||
</h5>
|
||||
<h6>
|
||||
Hygrométrie
|
||||
</h6>
|
||||
<h6>
|
||||
température
|
||||
</h6>
|
||||
</div>
|
||||
<div id="video"></div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>© 2024 Timelapse. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script
|
||||
src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<script
|
||||
src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
|
||||
crossorigin="anonymous"
|
||||
></script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.getElementById("projets").addEventListener("click", () => {
|
||||
window.location.href = "projets.html";
|
||||
});
|
||||
});
|
||||
|
||||
const iframeString = `<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>`;
|
||||
|
||||
const tempContainer = document.createElement("div");
|
||||
|
||||
// Set the innerHTML of the temporary container to the iframe string
|
||||
tempContainer.innerHTML = iframeString;
|
||||
|
||||
// Get the first child element of the temporary container (which should be the iframe element)
|
||||
const iframe = tempContainer.firstChild;
|
||||
|
||||
// Add the iframe element to the DOM
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
// Add the video element to the DOM
|
||||
document.body.appendChild(video);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
52
html/projets.html
Normal file
52
html/projets.html
Normal file
@@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Timelapse</title>
|
||||
<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"
|
||||
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">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="section" class="container mt-5">
|
||||
<div class="buttons-container mb-4">
|
||||
<button id="video" class="btn btn-primary"><span>Mes vidéos</span></button>
|
||||
<button id="projet" class="btn btn-primary"><span>Mon projet</span></button>
|
||||
</div>
|
||||
|
||||
<table class="table table-striped" id="table-projects">
|
||||
<thead class="bg-blue-600 text-white">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<footer class="text-center mt-5 py-3">
|
||||
<p>© 2024 Timelapse. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="../js/projets.js"></script>
|
||||
<script>
|
||||
// Redirect to videos.php when the "Mes vidéos" button is clicked
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById("video").addEventListener('click', () => {
|
||||
window.location.href = 'videos.html';
|
||||
});
|
||||
document.getElementById("projet").addEventListener('click', () => {
|
||||
window.location.href = 'projet_detail.html';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
45
html/videos.html
Normal file
45
html/videos.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Vidéos</title>
|
||||
<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"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="section"></div>
|
||||
<div class="buttons-container">
|
||||
<button id="projets" class="btn btn-primary"><span>
|
||||
Mes projets
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<p>© 2024 Timelapse. All rights reserved.</p>
|
||||
</footer>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
|
||||
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous">
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js"
|
||||
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous">
|
||||
</script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"
|
||||
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous">
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.getElementById("projets").addEventListener('click', () => {
|
||||
window.location.href = 'projets.html';
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
86
js/projets.js
Normal file
86
js/projets.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// Global variable for the API URL
|
||||
let api_url = "https://timelapse.kerboul.me/api";
|
||||
|
||||
// Function to display projects in a table
|
||||
function display_projects() {
|
||||
// Get data from API and then generate HTML code to display the data in a table
|
||||
getDataFromApi().then(function (project_list) {
|
||||
const table = document.getElementById("table-projects");
|
||||
let datas = `<tr>
|
||||
<th>Id</th>
|
||||
<th>Name</th>
|
||||
<th>Actions</th>
|
||||
</tr> `;
|
||||
for (let i = 0; i < project_list.rows.length; i++) {
|
||||
datas += `<tr>
|
||||
<th>${project_list.rows[i].id}</th>
|
||||
<th>${project_list.rows[i].name}</th>
|
||||
<th><button class="project_detail btn btn-primary">détails de ${project_list.rows[i].name}</button></th>
|
||||
</tr>`;
|
||||
}
|
||||
table.innerHTML = datas;
|
||||
|
||||
// Select all the buttons with the class button_project
|
||||
const buttons = document.getElementsByClassName("project_detail");
|
||||
// Add an event listener to each button
|
||||
for (let i = 0; i < buttons.length; i++) {
|
||||
buttons[i].addEventListener("click", (event) => {
|
||||
// Send data to API and then navigate to projet_detail.html page
|
||||
deleteDataFromApi(4)
|
||||
window.location.href = "projet_detail.html";
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Function to get data from API
|
||||
function getDataFromApi() {
|
||||
return $.ajax({
|
||||
url: api_url.concat("/itemsdb"), // replace with your API URL
|
||||
method: "GET", // or 'POST', 'PUT', 'DELETE', etc.
|
||||
dataType: "json", // expected data type
|
||||
success: function (data) {
|
||||
// This function is called if the request is successful
|
||||
return data; // log the data to the console
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
// This function is called if the request fails
|
||||
console.error("Error:", textStatus, errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// Function to send data to API
|
||||
function sendDataFromApi(datas) {
|
||||
return $.ajax({
|
||||
url: api_url.concat("/projets"),
|
||||
method: "POST",
|
||||
data: JSON.stringify(datas),
|
||||
contentType: "application/json",
|
||||
success: function (datas) {
|
||||
console.log("successful");
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.error(errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function deleteDataFromApi(id) {
|
||||
return $.ajax({
|
||||
url: api_url.concat("/delete"),
|
||||
method: "POST",
|
||||
data: JSON.stringify({"id":id}),
|
||||
contentType: "application/json",
|
||||
success: function (datas) {
|
||||
console.log("successful");
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
console.error(errorThrown);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Call display_projects() function to display projects
|
||||
display_projects();
|
||||
Reference in New Issue
Block a user