From 4427e6dde0d56268f41e6533e8e26709224b3d1b Mon Sep 17 00:00:00 2001 From: Kerboul Date: Sun, 27 Apr 2025 11:41:58 +0200 Subject: [PATCH] =?UTF-8?q?feat(camera):=20Ajouter=20le=20statut=20'stoppi?= =?UTF-8?q?ng'=20pour=20g=C3=A9rer=20l'arr=C3=AAt=20des=20projets=20et=20m?= =?UTF-8?q?ettre=20=C3=A0=20jour=20la=20documentation=20des=20routes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/config/index.js | 1 + src/controllers/cameraController.js | 5 +++++ src/models/Project.js | 4 ++++ src/routes/cameraRoutes.js | 15 +++++++++++++++ 4 files changed, 25 insertions(+) diff --git a/src/config/index.js b/src/config/index.js index 74c469f..1b1d2ad 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -158,6 +158,7 @@ module.exports = { brouillon: 0, capturing: 1, idle: 2, + stopping: 3 // Projet en cours d'arrêt }, // Statuts pour les vidéos diff --git a/src/controllers/cameraController.js b/src/controllers/cameraController.js index bb9d597..f2d72aa 100644 --- a/src/controllers/cameraController.js +++ b/src/controllers/cameraController.js @@ -73,7 +73,12 @@ class CameraController { * Initie l'arrêt de la procédure de capture */ static stopProcedure = asyncHandler(async (req, res) => { + const { project_id } = req.body; + 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 await Camera.updateCamera(1, { stop_flag: true }); diff --git a/src/models/Project.js b/src/models/Project.js index b7c78f3..cfa7a7d 100644 --- a/src/models/Project.js +++ b/src/models/Project.js @@ -68,6 +68,10 @@ class Project { static updateProjectStatus = wrapDatabaseOperation(async (id, status) => { const query = `UPDATE projects SET status = $1 WHERE id = $2 RETURNING *;`; 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; }); diff --git a/src/routes/cameraRoutes.js b/src/routes/cameraRoutes.js index 71c198b..82c5054 100644 --- a/src/routes/cameraRoutes.js +++ b/src/routes/cameraRoutes.js @@ -49,6 +49,9 @@ router.get('/camera/status', CameraController.getCameraStatus); * type: integer * description: Nombre total d'images à capturer * example: 48 + * status: + * type: integer + * description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping) * required: * - project_id * - interval @@ -99,6 +102,9 @@ router.post('/procedure/start', CameraController.startProcedure); * message: * type: string * 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: * $ref: '#/components/responses/ServerError' */ @@ -123,6 +129,9 @@ router.post('/procedure/stop', CameraController.stopProcedure); * message: * type: string * 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: * $ref: '#/components/responses/ServerError' */ @@ -147,6 +156,9 @@ router.post('/camera/stop', CameraController.confirmStopProcedure); * message: * type: string * example: Caméra en mode maintenance + * status: + * type: integer + * description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping) * 500: * $ref: '#/components/responses/ServerError' */ @@ -171,6 +183,9 @@ router.post('/camera/maintenance', CameraController.activateMaintenance); * message: * type: string * example: Caméra sortie du mode maintenance + * status: + * type: integer + * description: Statut du projet (0: brouillon, 1: capturing, 2: idle, 3: stopping) * 500: * $ref: '#/components/responses/ServerError' */