à jour
This commit is contained in:
@@ -32,6 +32,22 @@ document.addEventListener("DOMContentLoaded", async () => {
|
|||||||
populateTimelapseLogic(start_timelapse, projectId).then( () => {
|
populateTimelapseLogic(start_timelapse, projectId).then( () => {
|
||||||
document.getElementById('show-form-button-camera').addEventListener('click', showFormCamera)
|
document.getElementById('show-form-button-camera').addEventListener('click', showFormCamera)
|
||||||
document.getElementById('close-form-button-camera').addEventListener('click', hideFormCamera)
|
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 = `<button class="btn btn-primary" id="show-form-button-camera">
|
placeholder.innerHTML = `<button class="btn btn-primary" id="show-form-button-camera">
|
||||||
<span> Configurer la caméra </span>
|
<span> Configurer la caméra </span>
|
||||||
</button>`
|
</button>`
|
||||||
} else {
|
} else if (data.status == 1) {
|
||||||
|
placeholder.innerHTML = `<button class="btn btn-danger" id="stop-camera">
|
||||||
|
<span> Stopper la prise d'images </span>
|
||||||
|
</button>`}
|
||||||
|
else {
|
||||||
placeholder.innerHTML = ``
|
placeholder.innerHTML = ``
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,4 +176,44 @@ async function renderVideo(id){
|
|||||||
console.error("Error rendering video:", error);
|
console.error("Error rendering video:", error);
|
||||||
throw 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user