From 8cbe6cf03bbbdc6751d1980618d981bf5d4c1592 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 18 Jul 2016 11:03:17 +0200 Subject: [PATCH] =?UTF-8?q?Gestion=20du=20module=20'machineDefault/init'?= =?UTF-8?q?=20pour=20envoyer=20les=20donn=C3=A9es=20du=20syst=C3=A8me=20d'?= =?UTF-8?q?une=20machine?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/modules.json | 2 +- config/repositories.json | 10 +++++----- manager/module/machineDefault.php | 28 +++++++++++++++++++++++++++- manager/repo/state.php | 17 +++++++++++++++++ test/client/interface.php | 12 +++++++++++- 5 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 manager/repo/state.php diff --git a/config/modules.json b/config/modules.json index ec92faf..52cbd4e 100755 --- a/config/modules.json +++ b/config/modules.json @@ -239,7 +239,7 @@ "init": { "description": "Données d'initialisation d'une machine.", - "permissions": ["warehouse"], + "permissions": [], "parameters": {}, "output": { "data": { "description": "Données d'initialisation.", "type": "array" } diff --git a/config/repositories.json b/config/repositories.json index 0b9df17..af268ef 100755 --- a/config/repositories.json +++ b/config/repositories.json @@ -61,12 +61,12 @@ ], "action": [ - "getById", - "removePermission", - "getAll", - "getById", - "getByIdTarget" + "getById" + ], + + "state": [ + "getAll" ], "permission": [ diff --git a/manager/module/machineDefault.php b/manager/module/machineDefault.php index ec4e2c4..879606d 100755 --- a/manager/module/machineDefault.php +++ b/manager/module/machineDefault.php @@ -365,9 +365,35 @@ + /* ENVOI DES DONNEES D'INITIALISATION DU SYSTEME DES MACHINES + * + * @return data Données d'initialisation du système + * + */ + public static function init($params){ + extract($params); + + /* [1] On récupére la liste des actions + =========================================================*/ + $actionsReq = new Repo('action/getAll'); + $actions = ($actionsReq->error==0) ? $actionsReq->answer() : []; + + /* [2] On récupère la liste des états + =========================================================*/ + $statesReq = new Repo('state/getAll'); + $states = ($statesReq->error==0) ? $statesReq->answer() : []; + + + /* [3] Retorne les données + =========================================================*/ + return [ + 'actions' => $actions, + 'states' => $states + ]; + + } - diff --git a/manager/repo/state.php b/manager/repo/state.php new file mode 100644 index 0000000..133906f --- /dev/null +++ b/manager/repo/state.php @@ -0,0 +1,17 @@ + diff --git a/test/client/interface.php b/test/client/interface.php index 1ee9171..5e0025c 100644 --- a/test/client/interface.php +++ b/test/client/interface.php @@ -165,6 +165,8 @@
+
+
@@ -191,6 +193,8 @@ locked: false }; + var SYSTEM = {}; + /* (2) Elements du DOM */ var mBox = document.getElementById('machine-box'); var led = document.getElementById('led'); @@ -207,7 +211,13 @@ /* (4) Récupération des données de fonctionnement */ var api = new APIClass('/api/'); - + api.send({path: 'machineDefault/init'}, function(response){ + console.log(response); + SYSTEM = { + action: response.actions, + state: response.states + }; + }); /* [1] Fonctions =========================================================*/