diff --git a/.gitignore b/.gitignore index 7c19e99..7ae447d 100755 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ *.lock /vendor/ /phpunit/coverage -.vscode \ No newline at end of file +.vscode +TODO \ No newline at end of file diff --git a/build/api/module/clusterDefault.php b/build/api/module/clusterDefault.php index 39f0f11..039463a 100755 --- a/build/api/module/clusterDefault.php +++ b/build/api/module/clusterDefault.php @@ -462,14 +462,14 @@ - /* RETOURNE L'E-TREE D'UN GROUPE DE MACHINES + /* RETOURNE LES E-TREES D'UN GROUPE DE MACHINES * * @id_machine_cluster UID du groupe de machine * - * @return e-tree E-tree du groupe de machines + * @return etrees E-trees du groupe de machines * */ - public static function getEtree($params){ + public static function getEtrees($params){ extract($params); @@ -490,7 +490,7 @@ /* [3] On retourne la liste =========================================================*/ - return [ 'etree' => $answer ]; + return [ 'etrees' => $answer ]; } diff --git a/build/api/module/machineDefault.php b/build/api/module/machineDefault.php index 34d444b..99bd2ff 100755 --- a/build/api/module/machineDefault.php +++ b/build/api/module/machineDefault.php @@ -553,6 +553,49 @@ } + /* [6] On envoie les e-tree de la machine + =========================================================*/ + $etrees = []; + + /* (1) On essaie de récupérer les etree de la machine*/ + $mc_req = new Request('machineDefault/getClusters', ['id_machine' => $id_machine]); + + $mc_res = $mc_req->dispatch(); + + /* (2) Si on arrive à récupérer les clusters */ + if( $mc_res->error->get() == Err::Success ){ + + /* (3) Pour chaque cluster, on récupère les e-trees */ + foreach($mc_res->get('clusters') as $cluster){ + + /* (4) On les e-trees du cluster */ + $etree_req = new Request('clusterDefault/getEtrees', [ + 'id_machine_cluster' => $cluster['id_machine_cluster'] + ]); + + $etree_res = $etree_req->dispatch(); + + /* (5) Si erreur, on passe */ + if( $etree_res->error->get() != Err::Success ) + continue; + + /* (6) Sinon -> On entregistre les e-trees */ + foreach($etree_res->get('etrees') as $etree){ + $etree_value = $etree['name'].'-'.$etree['daemon']; + + /* (7) Si pas déja entregistré -> on l'ajoute */ + if( !in_array($etrees, $etree_name) ) + $etrees[] = $etree_name; + } + + + } + + } + + + + /* [N] Retourne les données @@ -561,7 +604,8 @@ 'actions' => $sorted_actions, 'states' => $globalStates, 'chips' => $chips, - 'permissions' => $indexed_permissions + 'permissions' => $indexed_permissions, + 'etrees' => $etrees ]; } diff --git a/build/viewer/view/group/view.php b/build/viewer/view/group/view.php index 66958c7..6959476 100755 --- a/build/viewer/view/group/view.php +++ b/build/viewer/view/group/view.php @@ -61,7 +61,7 @@ })); $twig->addFunction(new \Twig_Function('f_options', function($id_cluster){ - $modReq = new Request('clusterDefault/getEtree', [ + $modReq = new Request('clusterDefault/getEtrees', [ 'id_machine_cluster' => (int) $id_cluster ]); @@ -71,7 +71,7 @@ if( $modRes->error->get() != Err::Success ) return []; - return $modRes->get('etree'); + return $modRes->get('etrees'); })); diff --git a/build/viewer/view/machine/groups.php b/build/viewer/view/machine/groups.php index 0c79c3d..774d82a 100755 --- a/build/viewer/view/machine/groups.php +++ b/build/viewer/view/machine/groups.php @@ -62,7 +62,7 @@ })); $twig->addFunction(new \Twig_Function('f_options', function($id_cluster){ - $modReq = new Request('clusterDefault/getEtree', [ + $modReq = new Request('clusterDefault/getEtrees', [ 'id_machine_cluster' => (int) $id_cluster ]); @@ -72,7 +72,7 @@ if( $modRes->error->get() != Err::Success ) return []; - return $modRes->get('etree'); + return $modRes->get('etrees'); })); diff --git a/config/modules.json b/config/modules.json index 2b7e89c..49b41cf 100755 --- a/config/modules.json +++ b/config/modules.json @@ -516,14 +516,14 @@ } }, - "POST::getEtree": { - "description": "Retourne l'e-tree d'un groupe de machines", + "POST::getEtrees": { + "description": "Retourne les e-trees d'un groupe de machines", "permissions": [["admin"]], "parameters": { "id_machine_cluster": { "description": "UID du groupe de machines", "type": "id" } }, "output": { - "modules": { "description": "E-tree du groupe", "type": "array" } + "etrees": { "description": "E-trees du groupe", "type": "array" } } }