maj
This commit is contained in:
@@ -22,11 +22,18 @@
|
|||||||
<!-- formulaire -->
|
<!-- formulaire -->
|
||||||
<div id="form-container" class="form-container">
|
<div id="form-container" class="form-container">
|
||||||
<div class="form-content">
|
<div class="form-content">
|
||||||
|
<h1>Formulaire</h1>
|
||||||
<form id="my-form">
|
<form id="my-form">
|
||||||
<label for="name">Nom :</label>
|
<label for="name">Nom :</label>
|
||||||
<input type="text" id="name" name="name" required>
|
<input type="text" id="name" name="name" required>
|
||||||
<br><br>
|
<br><br>
|
||||||
<label for="duration">Durée (en secondes) :</label>
|
<label for="resolution">Résolution :</label>
|
||||||
|
<select id="resolution" name="resolution" required>
|
||||||
|
<option value="1920x1080">1920x1080</option>
|
||||||
|
<option value="1280x720">1280x720</option>
|
||||||
|
</select>
|
||||||
|
<br><br>
|
||||||
|
<label for="duration">Durée (en minutes) :</label>
|
||||||
<div class="duration-input">
|
<div class="duration-input">
|
||||||
<button type="button" id="decrement-button">-</button>
|
<button type="button" id="decrement-button">-</button>
|
||||||
<input type="number" id="duration" name="duration" value="0" min="0" required>
|
<input type="number" id="duration" name="duration" value="0" min="0" required>
|
||||||
|
|||||||
@@ -36,9 +36,24 @@ document.getElementById('decrement-button').addEventListener('click', function()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('my-form').addEventListener('submit', function(event) {
|
document.getElementById('my-form').addEventListener('submit', async function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
alert('Nouveau Projet enregistré :\nNom : ' + document.getElementById('name').value + '\nDurée : ' + document.getElementById('duration').value + ' secondes');
|
const data=await getDataProjectVideosFromApi(projectId);
|
||||||
|
const name_video = document.getElementById('name').value
|
||||||
|
const video_duration = document.getElementById('duration').value
|
||||||
|
if(video_duration>0){
|
||||||
|
if(checkVideoPath(data, name_video)){
|
||||||
|
alert('Nouvelle vidéo enregistrée :\nNom : ' + name_video +
|
||||||
|
'\nRésolution : ' + document.getElementById('resolution').value +
|
||||||
|
'\nDurée : ' + video_duration + ' secondes');
|
||||||
|
//project_id, measurement_ids, video_name, resolution, duration, fps, status
|
||||||
|
} else {
|
||||||
|
alert('Le nom : "'+ name_video + '" est déjà pris ! \n' +
|
||||||
|
'veuillez en trouver un autre')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
alert('La durée de la vidéo doit être suppérieur à 0')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById("projets").addEventListener("click", () => {
|
document.getElementById("projets").addEventListener("click", () => {
|
||||||
|
|||||||
@@ -11,34 +11,4 @@ async function PopulateSelect(mySelect,id){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDataProjectVideosFromApi(id) {
|
|
||||||
try {
|
|
||||||
const response = await $.ajax({
|
|
||||||
url: api_url.concat(`/projects/${id}/videos`),
|
|
||||||
method: "GET",
|
|
||||||
dataType: "json",
|
|
||||||
});
|
|
||||||
// If the request is successful, store the data in the cache and return it
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching data:", error);
|
|
||||||
throw error; // Re-throw the error to handle it outside the function if needed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getDataVideoFromApi(id) {
|
|
||||||
try {
|
|
||||||
const response = await $.ajax({
|
|
||||||
url: api_url.concat(`/videos/${id}`),
|
|
||||||
method: "GET",
|
|
||||||
dataType: "json",
|
|
||||||
});
|
|
||||||
// If the request is successful, store the data in the cache and return it
|
|
||||||
return response;
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching data:", error);
|
|
||||||
throw error; // Re-throw the error to handle it outside the function if needed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -42,3 +42,38 @@ function getDataMetrics(projectId){
|
|||||||
return data;
|
return data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function getDataProjectVideosFromApi(id) {
|
||||||
|
try {
|
||||||
|
const response = await $.ajax({
|
||||||
|
url: api_url.concat(`/projects/${id}/videos`),
|
||||||
|
method: "GET",
|
||||||
|
dataType: "json",
|
||||||
|
});
|
||||||
|
// If the request is successful, store the data in the cache and return it
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching data:", error);
|
||||||
|
throw error; // Re-throw the error to handle it outside the function if needed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getDataVideoFromApi(id) {
|
||||||
|
try {
|
||||||
|
const response = await $.ajax({
|
||||||
|
url: api_url.concat(`/videos/${id}`),
|
||||||
|
method: "GET",
|
||||||
|
dataType: "json",
|
||||||
|
});
|
||||||
|
// If the request is successful, store the data in the cache and return it
|
||||||
|
return response;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching data:", error);
|
||||||
|
throw error; // Re-throw the error to handle it outside the function if needed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function postNewVideo(project_id, measurements_id, name_video, resolution, duration, fps, status){
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,3 +13,13 @@ function filterAndSortMeasurementsByIds(measurements, ids) {
|
|||||||
.filter((measurement) => ids.includes(measurement.id))
|
.filter((measurement) => ids.includes(measurement.id))
|
||||||
.sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));
|
.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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user