à demain

This commit is contained in:
anto
2025-03-09 15:15:23 +01:00
parent 7bbafe906b
commit bfd77bc843
6 changed files with 337 additions and 170 deletions

View File

@@ -257,3 +257,19 @@ footer{
font-size: 18px; font-size: 18px;
text-align: center; text-align: center;
} }
.buttons-container2{
float: left;
width:20%;
}
.frequency-control label {
margin-right: 10px;
}
.frequency-control input[type="number"] {
width: 50px;
text-align: center;
}
.frequency-control button {
margin: 0 5px;
}

View File

@@ -1,40 +1,32 @@
<!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" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
rel="stylesheet" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous" />
href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" <link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet" />
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"
/>
<!-- Select2 CSS --> <!-- Select2 CSS -->
<link <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0/dist/css/select2.min.css" rel="stylesheet" />
href="https://cdn.jsdelivr.net/npm/select2@4.1.0/dist/css/select2.min.css" </head>
rel="stylesheet"
/> <body>
</head>
<body>
<div id="customAlert" class="modal"> <div id="customAlert" class="modal">
<div class="modal-content"> <div class="modal-content">
<p id="alertMessage">This is a custom alert!</p> <p id="alertMessage">This is a custom alert!</p>
<div class="modal-buttons"> <div class="modal-buttons">
<button class="btn btn-danger"id="cancelBtn">Cancel</button> <button class="btn btn-danger" id="cancelBtn">Cancel</button>
<button class="btn btn-primary"id="okBtn">OK</button> <button class="btn btn-primary" id="okBtn">OK</button>
</div> </div>
</div> </div>
</div> </div>
<!-- formulaire --> <!-- formulaire nouveau projet -->
<div id="form-container" class="form-container" style="display: none"> <div id="form-container-project" class="form-container" style="display: none">
<div class="form-content"> <div class="form-content">
<button id="close-form-button" class="close-button">&times;</button> <button id="close-form-button-project" class="close-button">&times;</button>
<h1>Formulaire</h1> <h1>Formulaire</h1>
<div id="my-form"> <div id="my-form">
<label for="name">Nom :</label> <label for="name">Nom :</label>
@@ -49,14 +41,7 @@
<label for="duration">Durée (en secondes) :</label> <label for="duration">Durée (en secondes) :</label>
<div class="duration-input"> <div class="duration-input">
<button type="button" id="decrement-button">-</button> <button type="button" id="decrement-button">-</button>
<input <input type="number" id="duration" name="duration" value="0" min="0" required />
type="number"
id="duration"
name="duration"
value="0"
min="0"
required
/>
<button type="button" id="increment-button">+</button> <button type="button" id="increment-button">+</button>
</div> </div>
<label for="choice">Options :</label> <label for="choice">Options :</label>
@@ -77,13 +62,7 @@
<label for="fraction">Fraction:</label> <label for="fraction">Fraction:</label>
<div class="fraction-input"> <div class="fraction-input">
<span>1/</span> <span>1/</span>
<input <input type="number" id="denominator" name="denominator" value="1" min="1" />
type="number"
id="denominator"
name="denominator"
value="1"
min="1"
/>
</div> </div>
</div> </div>
<div id="one-by-one-container" style="display: none"> <div id="one-by-one-container" style="display: none">
@@ -96,22 +75,53 @@
</div> </div>
</div> </div>
</div> </div>
<!-- Formulaire configuration de la caméra -->
<div id="form-container-camera" class="form-container" style="display: none">
<div class="form-content">
<button id="close-form-button-camera" class="close-button">&times;</button>
<h1>Formulaire</h1>
<div class="frequency-control">
<label for="days">Days:</label>
<button type="button" onclick="decrement('days')">-</button>
<input type="number" id="days" name="days" value="0" min="0" oninput="updateFrequencyText()">
<button type="button" onclick="increment('days')">+</button>
</div>
<div class="frequency-control">
<label for="hours">Hours:</label>
<button type="button" onclick="decrement('hours')">-</button>
<input type="number" id="hours" name="hours" value="0" min="0" oninput="updateFrequencyText()">
<button type="button" onclick="increment('hours')">+</button>
</div>
<div class="frequency-control">
<label for="minutes">Minutes:</label>
<button type="button" onclick="decrement('minutes')">-</button>
<input type="number" id="minutes" name="minutes" value="0" min="0" oninput="updateFrequencyText()">
<button type="button" onclick="increment('minutes')">+</button>
</div>
<div class="frequency-control">
<label for="seconds">Seconds:</label>
<button type="button" onclick="decrement('seconds')">-</button>
<input type="number" id="seconds" name="seconds" value="0" min="0" oninput="updateFrequencyText()">
<button type="button" onclick="increment('seconds')">+</button>
</div>
<span id="frequency-text">une image sera prise toutes les 0 jours 0 heures 0 minutes 0 secondes</span>
<br>
<button id="commencer" class="btn btn-primary">Lancer</button>
</div>
</div>
<!-- page classique --> <!-- page classique -->
<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: 10%"> <div class="buttons-container" style="float: left; width: 10%">
<button class="btn btn-primary" id="projets"> <button class="btn btn-primary" id="projets">
<span> Home </span> <span> Menu Principal</span>
</button> </button>
</div> </div>
<div class="buttons-container" id="delete-placeholder" style="float: left; width: 20%"> <div class="buttons-container buttons-container2 " id="delete-placeholder">
</div> </div>
<h3 <div class="buttons-container buttons-container2" id="start-timelapse"></div>
id="name_project" <h3 id="name_project" class="text-black" style="float: right; width: 50%"></h3>
class="text-black"
style="float: right; width: 50%"
></h3>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@@ -119,7 +129,7 @@
<div id="addVideoHandler"> <div id="addVideoHandler">
<select name="videos" id="video_selector" class="select2"></select> <select name="videos" id="video_selector" class="select2"></select>
<div class="buttons-container"> <div class="buttons-container">
<button class="btn btn-primary" id="show-form-button"> <button class="btn btn-primary" id="show-form-button-camera">
<span> + </span> <span> + </span>
</button> </button>
</div> </div>
@@ -131,10 +141,7 @@
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<div id="content1" class="hiddenTable"> <div id="content1" class="hiddenTable">
<table <table class="table table-striped scrollable sticky-header .thead-dark" id="table-image">
class="table table-striped scrollable sticky-header .thead-dark"
id="table-image"
>
<thead> <thead>
<tr> <tr>
<th colspan="3"> <th colspan="3">
@@ -164,5 +171,6 @@
<script src="../js/utilities/routes.js"></script> <script src="../js/utilities/routes.js"></script>
<script src="../js/utilities/tools.js"></script> <script src="../js/utilities/tools.js"></script>
<script src="../js/projet_detail.js"></script> <script src="../js/projet_detail.js"></script>
</body> </body>
</html> </html>

View File

@@ -17,38 +17,46 @@ document.addEventListener("DOMContentLoaded", async () => {
const oneByOneContainer = document.getElementById('one-by-one-container'); const oneByOneContainer = document.getElementById('one-by-one-container');
const firstLastContainer = document.getElementById('first-last-container'); const firstLastContainer = document.getElementById('first-last-container');
const addNumberButton = document.getElementById('add-number-button'); const addNumberButton = document.getElementById('add-number-button');
const formContainer = document.getElementById('form-container'); const formContainerProject = document.getElementById('form-container-project');
const formContainerCamera = document.getElementById('form-container-camera');
const durationInput = document.getElementById('duration'); const durationInput = document.getElementById('duration');
const tableImage = document.getElementById("content1"); const tableImage = document.getElementById("content1");
const numberBoard = document.getElementById('number-board'); const numberBoard = document.getElementById('number-board');
// Add event listeners for the "Début" and "Fin" input fields // Add event listeners for the "Début" and "Fin" input fields
const firstInput = document.getElementById('first'); const firstInput = document.getElementById('first');
const lastInput = document.getElementById('last'); const lastInput = document.getElementById('last');
const start_timelapse = document.getElementById('start-timelapse')
let selectedNumbers = []; let selectedNumbers = [];
populateTimelapseLogic(start_timelapse, projectId).then( () => {
document.getElementById('show-form-button-camera').addEventListener('click', showFormCamera)
document.getElementById('close-form-button-camera').addEventListener('click', hideFormCamera)
}
)
choiceSelect.addEventListener('change', toggleContainers); choiceSelect.addEventListener('change', toggleContainers);
if (addNumberButton) { if (addNumberButton) {
addNumberButton.addEventListener('click', addSelectedNumber); addNumberButton.addEventListener('click', addSelectedNumber);
} }
videoSelector.addEventListener("change", () => generateViewMetric(projectId)); videoSelector.addEventListener("change", () => generateViewMetric(projectId));
document.getElementById('show-form-button').addEventListener('click', showForm); document.getElementById('show-form-button-camera').addEventListener('click', showFormProject);
document.getElementById('close-form-button').addEventListener('click', hideForm); document.getElementById('close-form-button-project').addEventListener('click', hideFormProject);
document.getElementById('increment-button').addEventListener('click', incrementDuration); document.getElementById('increment-button').addEventListener('click', incrementDuration);
document.getElementById('decrement-button').addEventListener('click', decrementDuration); document.getElementById('decrement-button').addEventListener('click', decrementDuration);
document.getElementById('submit').addEventListener('click', handleFormSubmit); document.getElementById('submit').addEventListener('click', handleFormSubmit);
document.getElementById("projets").addEventListener("click", navigateToProjects); document.getElementById("projets").addEventListener("click", navigateToProjects);
document.getElementById("toggle-view").addEventListener("click", toggleView); document.getElementById("toggle-view").addEventListener("click", toggleView);
firstInput.addEventListener('input', updateRange); firstInput.addEventListener('input', updateRange);
lastInput.addEventListener('input', updateRange); lastInput.addEventListener('input', updateRange);
generateViewMetric(projectId); generateViewMetric(projectId);
PopulateSelect(videoSelector, projectId); PopulateSelect(videoSelector, projectId);
function toggleContainers() { function toggleContainers() {
if (choiceSelect.value === 'oneByOne') { if (choiceSelect.value === 'oneByOne') {
oneByOneContainer.style.display = 'block'; oneByOneContainer.style.display = 'block';
@@ -91,12 +99,19 @@ document.addEventListener("DOMContentLoaded", async () => {
} }
} }
function showForm() { function showFormCamera() {
formContainer.style.display = 'flex'; formContainerCamera.style.display = 'flex';
} }
function hideForm() { function hideFormCamera() {
formContainer.style.display = 'none'; formContainerCamera.style.display = 'none';
}
function showFormProject() {
formContainerProject.style.display = 'flex';
}
function hideFormProject() {
formContainerProject.style.display = 'none';
} }
function incrementDuration() { function incrementDuration() {
durationInput.value = parseInt(durationInput.value) + 1; durationInput.value = parseInt(durationInput.value) + 1;
@@ -131,7 +146,13 @@ document.addEventListener("DOMContentLoaded", async () => {
alert('Nouvelle vidéo enregistrée :\nNom : ' + nameVideo + alert('Nouvelle vidéo enregistrée :\nNom : ' + nameVideo +
'\nRésolution : ' + videoResolution + '\nRésolution : ' + videoResolution +
'\nDurée : ' + videoDuration + ' secondes'); '\nDurée : ' + videoDuration + ' secondes');
}).then(()=>{
getDataProjectVideosFromApi(projectId).then((data)=>{
console.log(data)
renderVideo(idVideo)
}) })
})
} }
function navigateToProjects() { function navigateToProjects() {
@@ -318,3 +339,95 @@ function showConfirmationAlert(videoId) {
customAlert.style.display = 'none'; customAlert.style.display = 'none';
}; };
} }
function convertStringToArray(string) {
const numberStrings = string.replace(/[{}]/g, '').split(',');
// Trim whitespace and convert the string numbers to integers
const numberArray = numberStrings.map(num => parseInt(num.trim(), 10));
return numberArray;
}
function filterAndSortMeasurementsByIds(measurements, ids) {
return measurements
.filter((measurement) => ids.includes(measurement.id))
.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
}
function filterAndSortMeasurementsByNumber(measurements, Numbers) {
// Filter measurements based on their position in the Numbers array
const filteredMeasurements = Numbers.map(index => measurements[index - 1]).filter(measurement => measurement !== undefined);
// Sort the filtered measurements by their timestamp
return filteredMeasurements.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
}
function checkVideoPath(videos, name) {
let res = true;
videos.forEach(video => {
const videoName = video.name;
if(videoName==name)
res=false;
});
return res;
}
function getMeasurementsIdsFromForm(choice, firstInput, lastInput) {
if (choice === 'oneByOne') {
const highlightedButtons = document.querySelectorAll('.number-button.highlight');
return Array.from(highlightedButtons).map(button => parseInt(button.textContent));
} else {
const first = parseInt(firstInput.value);
const last = parseInt(lastInput.value);
const denominator = parseInt(document.getElementById('denominator').value);
const measurementIds = new Set();
measurementIds.add(first); // Always include the first image
// Iterate through the range, adding the step size
for (let i = first + denominator; i <= last; i += denominator) {
measurementIds.add(i);
}
measurementIds.add(last); // Always include the last image
// Convert the Set back to an array and sort it
return Array.from(measurementIds).sort((a, b) => a - b);
}
}
async function populateTimelapseLogic(placeholder,id) {
const data = await getSingleProject(id);
if(data.status == 0){
placeholder.innerHTML = `<button class="btn btn-primary" id="show-form-button-camera">
<span> Configurer la caméra </span>
</button>`
} else {
placeholder.innerHTML = ``
}
}
function increment(id) {
const input = document.getElementById(id);
input.value = parseInt(input.value) + 1;
updateFrequencyText()
}
function decrement(id) {
const input = document.getElementById(id);
if (parseInt(input.value) > 0) {
input.value = parseInt(input.value) - 1;
}
updateFrequencyText()
}
function updateFrequencyText() {
const days = document.getElementById('days').value;
const hours = document.getElementById('hours').value;
const minutes = document.getElementById('minutes').value;
const seconds = document.getElementById('seconds').value;
const frequencyText = `une image sera prise toutes les ${days} jours ${hours} heures ${minutes} minutes ${seconds} secondes`;
document.getElementById('frequency-text').innerHTML = frequencyText;
}

View File

@@ -29,6 +29,16 @@ function getAllProject() {
}); });
} }
function getSingleProject(id) {
return $.ajax({
url: api_url.concat("/projects/"+id),
method: "GET",
dataType: "json"
}).then((data) => {
return data;
});
}
function getDataMetrics(projectId){ function getDataMetrics(projectId){
return $.ajax({ return $.ajax({
url: api_url.concat(`/projects/${projectId}/measurements`), url: api_url.concat(`/projects/${projectId}/measurements`),
@@ -147,3 +157,23 @@ async function deleteVideo(id){
throw error; throw error;
} }
} }
async function renderVideo(id){
try {
const mydata = JSON.stringify({
info:"none"
});
const response = await $.ajax({
url: api_url.concat(`/videos/render/`+id),
method: "POST",
dataType: "json",
contentType: "application/json",
data: mydata
});
console.log("Video rendered successfully:", response);
} catch (error) {
console.error("Error rendering video:", error);
throw error;
}
}