feat(camera): Ajouter le statut 'stopping' pour gérer l'arrêt des projets et mettre à jour la documentation des routes
All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 9s
All checks were successful
SSH Backend Deploy / ssh-deploy (push) Successful in 9s
This commit is contained in:
@@ -158,6 +158,7 @@ module.exports = {
|
|||||||
brouillon: 0,
|
brouillon: 0,
|
||||||
capturing: 1,
|
capturing: 1,
|
||||||
idle: 2,
|
idle: 2,
|
||||||
|
stopping: 3 // Projet en cours d'arrêt
|
||||||
},
|
},
|
||||||
|
|
||||||
// Statuts pour les vidéos
|
// Statuts pour les vidéos
|
||||||
|
|||||||
@@ -73,7 +73,12 @@ class CameraController {
|
|||||||
* Initie l'arrêt de la procédure de capture
|
* Initie l'arrêt de la procédure de capture
|
||||||
*/
|
*/
|
||||||
static stopProcedure = asyncHandler(async (req, res) => {
|
static stopProcedure = asyncHandler(async (req, res) => {
|
||||||
|
const { project_id } = req.body;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Met à jour le statut du projet en cours d'arrêt
|
||||||
|
await Project.updateProject(project_id, { status: config.projectStatus.stopping });
|
||||||
|
|
||||||
// Marque le drapeau d'arrêt
|
// Marque le drapeau d'arrêt
|
||||||
await Camera.updateCamera(1, { stop_flag: true });
|
await Camera.updateCamera(1, { stop_flag: true });
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ class Project {
|
|||||||
static updateProjectStatus = wrapDatabaseOperation(async (id, status) => {
|
static updateProjectStatus = wrapDatabaseOperation(async (id, status) => {
|
||||||
const query = `UPDATE projects SET status = $1 WHERE id = $2 RETURNING *;`;
|
const query = `UPDATE projects SET status = $1 WHERE id = $2 RETURNING *;`;
|
||||||
const result = await db.query(query, [status, id]);
|
const result = await db.query(query, [status, id]);
|
||||||
|
// Ajout du statut stopping pour les projets en cours d'arrêt
|
||||||
|
if (status === config.projectStatus.stopping) {
|
||||||
|
console.log(`[PROJECT] Projet ${id} mis à jour avec le statut 'stopping'.`);
|
||||||
|
}
|
||||||
return result.rows[0] || null;
|
return result.rows[0] || null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,9 @@ router.get('/camera/status', CameraController.getCameraStatus);
|
|||||||
* type: integer
|
* type: integer
|
||||||
* description: Nombre total d'images à capturer
|
* description: Nombre total d'images à capturer
|
||||||
* example: 48
|
* example: 48
|
||||||
|
* status:
|
||||||
|
* type: integer
|
||||||
|
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
|
||||||
* required:
|
* required:
|
||||||
* - project_id
|
* - project_id
|
||||||
* - interval
|
* - interval
|
||||||
@@ -99,6 +102,9 @@ router.post('/procedure/start', CameraController.startProcedure);
|
|||||||
* message:
|
* message:
|
||||||
* type: string
|
* type: string
|
||||||
* example: Procédure d'arrêt de la caméra initiée avec succès
|
* example: Procédure d'arrêt de la caméra initiée avec succès
|
||||||
|
* status:
|
||||||
|
* type: integer
|
||||||
|
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
|
||||||
* 500:
|
* 500:
|
||||||
* $ref: '#/components/responses/ServerError'
|
* $ref: '#/components/responses/ServerError'
|
||||||
*/
|
*/
|
||||||
@@ -123,6 +129,9 @@ router.post('/procedure/stop', CameraController.stopProcedure);
|
|||||||
* message:
|
* message:
|
||||||
* type: string
|
* type: string
|
||||||
* example: Caméra arrêtée avec succès
|
* example: Caméra arrêtée avec succès
|
||||||
|
* status:
|
||||||
|
* type: integer
|
||||||
|
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
|
||||||
* 500:
|
* 500:
|
||||||
* $ref: '#/components/responses/ServerError'
|
* $ref: '#/components/responses/ServerError'
|
||||||
*/
|
*/
|
||||||
@@ -147,6 +156,9 @@ router.post('/camera/stop', CameraController.confirmStopProcedure);
|
|||||||
* message:
|
* message:
|
||||||
* type: string
|
* type: string
|
||||||
* example: Caméra en mode maintenance
|
* example: Caméra en mode maintenance
|
||||||
|
* status:
|
||||||
|
* type: integer
|
||||||
|
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
|
||||||
* 500:
|
* 500:
|
||||||
* $ref: '#/components/responses/ServerError'
|
* $ref: '#/components/responses/ServerError'
|
||||||
*/
|
*/
|
||||||
@@ -171,6 +183,9 @@ router.post('/camera/maintenance', CameraController.activateMaintenance);
|
|||||||
* message:
|
* message:
|
||||||
* type: string
|
* type: string
|
||||||
* example: Caméra sortie du mode maintenance
|
* example: Caméra sortie du mode maintenance
|
||||||
|
* status:
|
||||||
|
* type: integer
|
||||||
|
* description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping)
|
||||||
* 500:
|
* 500:
|
||||||
* $ref: '#/components/responses/ServerError'
|
* $ref: '#/components/responses/ServerError'
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user