diff --git a/js/projet_detail.js b/js/projet_detail.js
index 03d2c2c..7d02485 100644
--- a/js/projet_detail.js
+++ b/js/projet_detail.js
@@ -32,6 +32,22 @@ document.addEventListener("DOMContentLoaded", async () => {
populateTimelapseLogic(start_timelapse, projectId).then( () => {
document.getElementById('show-form-button-camera').addEventListener('click', showFormCamera)
document.getElementById('close-form-button-camera').addEventListener('click', hideFormCamera)
+ if(document.getElementById('commencer') != null){
+ document.getElementById('commencer').addEventListener('click', async () => {
+ 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 frequency = days * 86400 + hours * 3600 + minutes * 60 + seconds;
+ console.log(frequency)
+ await start_timelapse(projectId, frequency)
+ })
+ }
+ if(document.getElementById('stop-camera') != null){
+ document.getElementById('stop-camera').addEventListener('click', async () => {
+ await stopCamera(projectId)
+ })
+ }
}
)
@@ -401,7 +417,11 @@ async function populateTimelapseLogic(placeholder,id) {
placeholder.innerHTML = ``
- } else {
+ } else if (data.status == 1) {
+ placeholder.innerHTML = ``}
+ else {
placeholder.innerHTML = ``
}
}
diff --git a/js/utilities/routes.js b/js/utilities/routes.js
index f9550a4..196c645 100644
--- a/js/utilities/routes.js
+++ b/js/utilities/routes.js
@@ -176,4 +176,44 @@ async function renderVideo(id){
console.error("Error rendering video:", error);
throw error;
}
+}
+
+async function start_timelapse(id,frequency){
+ try {
+ const mydata = JSON.stringify({
+ frequency:frequency
+ });
+ const response = await $.ajax({
+ url: api_url.concat(`/procedure/start/`+id),
+ method: "POST",
+ dataType: "json",
+ contentType: "application/json",
+ data: mydata
+ });
+
+ console.log("data retrieval started:", response);
+ } catch (error) {
+ console.error("Error starting the retrieval:", error);
+ throw error;
+ }
+}
+
+async function stopCamera(id){
+ try {
+ const mydata = JSON.stringify({
+ info:"None"
+ });
+ const response = await $.ajax({
+ url: api_url.concat(`/procedure/stop`+id),
+ method: "POST",
+ dataType: "json",
+ contentType: "application/json",
+ data: mydata
+ });
+
+ console.log("Camera stopped succesfully :", response);
+ } catch (error) {
+ console.error("Error stopping the camera :", error);
+ throw error;
+ }
}
\ No newline at end of file