chore: update code structure for improved readability and maintainability

This commit is contained in:
2025-04-27 11:48:05 +02:00
parent e776d020a0
commit 81c254289d
6 changed files with 161 additions and 10 deletions

View File

@@ -221,4 +221,30 @@ async function stopCamera(id){
alert("Error stopping the camera :", error);
throw error;
}
}
}
async function manualUpload(imageFile, projectId, timestamp, temperature, humidity) {
try {
// Create FormData to send the file and metadata
const formData = new FormData();
formData.append('image', imageFile);
formData.append('projectId', projectId);
formData.append('timestamp', timestamp);
formData.append('temperature', temperature);
formData.append('humidity', humidity);
const response = await $.ajax({
url: api_url.concat("/camera/upload"),
method: "POST",
data: formData,
processData: false, // Prevents jQuery from converting FormData to string
contentType: false, // Lets browser set the content type with boundary
});
alert("Image uploaded successfully");
return response;
} catch (error) {
alert("Error uploading image: " + error);
throw error;
}
}