From 4bacb52f24587cffe85898d7e9c26f6add957d5b Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 20 Feb 2017 08:21:34 +0100 Subject: [PATCH] Updated machineDefault/getState but [NOT FINISHED] --- build/api/module/historyDefault.php | 2 +- build/api/module/machineDefault.php | 6 ++++++ build/database/repo/history.php | 4 ++-- config/modules.json | 11 +++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/build/api/module/historyDefault.php b/build/api/module/historyDefault.php index 99dd57f..1269812 100755 --- a/build/api/module/historyDefault.php +++ b/build/api/module/historyDefault.php @@ -28,7 +28,7 @@ /* [1] Creation de l'utilisateur =========================================================*/ $create_entry = new Repo('history/create', [ - $id_entry, + $id_user, $id_machine, $id_action, $timestamp diff --git a/build/api/module/machineDefault.php b/build/api/module/machineDefault.php index be8e935..e97c8fa 100755 --- a/build/api/module/machineDefault.php +++ b/build/api/module/machineDefault.php @@ -404,6 +404,12 @@ } + /* (4) STARTED (last state) + ---------------------------------------------------------*/ + if( count($history) > 0 && $history[0]['id_action'] == $action['start'] ) + return [ 'state' => 'started' ]; + + /* (5) DETACHED (no state) ---------------------------------------------------------*/ return [ 'state' => 'detached' ]; diff --git a/build/database/repo/history.php b/build/database/repo/history.php index 05a9d1e..6aad9f0 100755 --- a/build/database/repo/history.php +++ b/build/database/repo/history.php @@ -41,11 +41,11 @@ $check_history = self::getByTimestamp($timestamp); // Si on trouve pas, erreur - if( $check_history === false ) + if( count($check_history) < 1 ) return false; // Sinon, on retourne son id - return $check_history['id_history']; + return $check_history[0]['id_history']; } diff --git a/config/modules.json b/config/modules.json index a1c9f05..71787bd 100755 --- a/config/modules.json +++ b/config/modules.json @@ -510,6 +510,17 @@ }, "historyDefault": { + "POST::create": { + "description": "Retourne l'historique complet", + "permissions": ["warehouse", "admin"], + "parameters": { + "id_machine": { "description": "Machine UID", "type": "id" }, + "id_user": { "description": "User UID", "type": "id" }, + "id_action": { "description": "Action UID", "type": "id" }, + "timestamp": { "description": "timestamp", "type": "id" } + }, + "output": {} + }, "POST::getAll": { "description": "Retourne l'historique complet", "permissions": ["warehouse", "admin"],