This commit is contained in:
arussac
2025-02-12 08:48:28 +01:00
parent 3d5612bf4a
commit a88678fc3f
5 changed files with 246 additions and 152 deletions

View File

@@ -72,16 +72,27 @@ async function getDataVideoFromApi(id) {
}
}
async function postNewVideo(project_id, measurements_id, name_video, resolution, duration){
async function postNewVideo(project_id, measurements_id, name_video, resolution, duration) {
try {
const response = await $.ajax({
url: api_url.concat(`/videos/`),
method: "POST",
dataType: "json",
contentType: "application/json", // Specify the content type as JSON
data: JSON.stringify({
project_id: project_id,
measurements_id: measurements_id,
name_video: name_video,
resolution: resolution,
duration: duration
})
});
// If the request is successful, store the data in the cache and return it
console.log("Video posted successfully:", response);
return response;
} catch (error) {
console.error("Error fetching data:", error);
console.error("Error posting video:", error);
throw error; // Re-throw the error to handle it outside the function if needed
}
}

View File

@@ -23,3 +23,22 @@ function checkVideoPath(videos, name) {
});
return res;
}
function getMeasurermentsIdsFromForm(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 numerator = parseInt(document.getElementById('numerator').value);
const denominator = parseInt(document.getElementById('denominator').value);
const fraction = numerator / denominator;
const measurementIds = [];
for (let i = first; i <= last; i += fraction) {
measurementIds.push(Math.round(i));
}
return measurementIds;
}
}