From eb150c7a0f5c2f28a2c460e122e74d23ab2bcba4 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 20 Jul 2016 18:41:24 +0200 Subject: [PATCH] Vues 'groups/membersChoice' et 'groups/groupChoice' --- manager/module/machineDefault.php | 7 ++- manager/module/userDefault.php | 3 +- manager/view/group/groupChoice.php | 65 +++++++++++++++++++++------- manager/view/group/membersChoice.php | 5 ++- view/js/groups-min.js | 11 ++--- view/js/groups.js | 6 +-- 6 files changed, 66 insertions(+), 31 deletions(-) diff --git a/manager/module/machineDefault.php b/manager/module/machineDefault.php index ae186a6..c1e80d4 100755 --- a/manager/module/machineDefault.php +++ b/manager/module/machineDefault.php @@ -74,11 +74,10 @@ extract($params); /* Creation de l'association */ - $link_machine = new Repo('cluster/link', [ + $link_machine = new Repo('machine_cluster/link', [ $_SESSION['WAREHOUSE']['id'], $id_cluster, - $id_machine, - clusterRepo::MACHINE_CLASS + $id_machine ]); /* (1) On retourne l'erreur du repo */ @@ -105,7 +104,7 @@ $link_machine = new Repo('machine_cluster/unlink', [ $_SESSION['WAREHOUSE']['id'], $id_cluster, - $id_machine, + $id_machine ]); /* (1) On retourne l'erreur du repo */ diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index ad38170..95af76b 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -95,8 +95,7 @@ $link_user = new Repo('user_cluster/link', [ $_SESSION['WAREHOUSE']['id'], $id_cluster, - $id_user, - clusterRepo::USER_CLASS + $id_user ]); /* (1) On retourne l'erreur du repo */ diff --git a/manager/view/group/groupChoice.php b/manager/view/group/groupChoice.php index 2c34c14..57a4c73 100644 --- a/manager/view/group/groupChoice.php +++ b/manager/view/group/groupChoice.php @@ -13,7 +13,7 @@ switch($type){ case 'clusterlist': return " - "; + "; break; @@ -39,36 +39,71 @@ - /* [1] On récupére tous les groupes + /* [1] On récupére tous les groupes utilisateur =========================================================*/ /* (1) On récupère les groupe */ - $getClustersRequest = new ModuleRequest('clusterDefault/getAll'); - $getClustersResponse = $getClustersRequest->dispatch(); + $getUserClustersReq = new ModuleRequest('clusterDefault/getAll', [ + 'class' => 0 + ]); + $getUserClusters = $getUserClustersReq->dispatch(); /* (2) Si on ne le trouve pas, on retourne une erreur */ - if( $getClustersResponse->error != ManagerError::Success ) + if( $getUserClusters->error != ManagerError::Success ) return View::$htmlError; /* (3) On récupère les données du groupe */ - $CLUSTERLIST = $getClustersResponse->get('clusters'); + $USERCLUSTERS = $getUserClusters->get('clusters'); - /* (4) On ajoute le type de groupe textuel */ - foreach($CLUSTERLIST as $c=>$cluster) - $CLUSTERLIST[$c]['type'] = ($cluster['class']==clusterRepo::USER_CLASS) ? 'utilisateurs' : 'machines'; + /* (4) On ajoute les données */ + foreach($USERCLUSTERS as $c=>$cluster) + $USERCLUSTERS[$c]['id_cluster'] = $cluster['id_user_cluster']; - - /* [2] On construit la vue des groupes - =========================================================*/ - $cluster_view = View::replaceMultiple( + /* (5) On construit la vue */ + $user_view = View::replaceMultiple( self::template('clusterlist'), - $CLUSTERLIST + $USERCLUSTERS, + [ + 'prefix' => 'u', + 'type' => 'utilisateur' + ] ); + /* [2] On récupére tous les groupes machine + =========================================================*/ + /* (1) On récupère les groupe */ + $getMachineClustersReq = new ModuleRequest('clusterDefault/getAll', [ + 'class' => 1 + ]); + $getMachineClusters = $getMachineClustersReq->dispatch(); + /* (2) Si on ne le trouve pas, on retourne une erreur */ + if( $getMachineClusters->error != ManagerError::Success ) + return View::$htmlError; + + /* (3) On récupère les données du groupe */ + $MACHINECLUSTERS = $getMachineClusters->get('clusters'); + + /* (4) On ajoute les données */ + foreach($MACHINECLUSTERS as $c=>$cluster) + $MACHINECLUSTERS[$c]['id_cluster'] = $cluster['id_machine_cluster']; + + /* (5) On construit la vue */ + $machine_view = View::replaceMultiple( + self::template('clusterlist'), + $MACHINECLUSTERS, + [ + 'prefix' => 'm', + 'type' => 'machine' + ] + ); + + + /* [3] On renvoie la vue globale + =========================================================*/ return View::replaceSingle( self::template(), [ - 'clusters' => $cluster_view + 'clusters' => $user_view.$machine_view ] ); } diff --git a/manager/view/group/membersChoice.php b/manager/view/group/membersChoice.php index 02a4e76..586f310 100644 --- a/manager/view/group/membersChoice.php +++ b/manager/view/group/membersChoice.php @@ -43,9 +43,10 @@ default: return " + Changer de groupe

- - + +
@name diff --git a/view/js/groups-min.js b/view/js/groups-min.js index f10d5a2..a7826fd 100644 --- a/view/js/groups-min.js +++ b/view/js/groups-min.js @@ -1,7 +1,7 @@ var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:document.querySelector('#CONTAINER > section[data-sublink="view"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')},create:{text:'#CONTAINER > section[data-sublink="create"] ',element:document.querySelector('#CONTAINER > section[data-sublink="create"]')},remove:{text:'#CONTAINER > section[data-sublink="remove"] ',element:document.querySelector('#CONTAINER > section[data-sublink="remove"]')}, edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},members:{text:'#CONTAINER > section[data-sublink="members"] ',element:document.querySelector('#CONTAINER > section[data-sublink="members"]'),chooser:{text:'#CONTAINER > section[data-sublink="members"] form#choose-cluster ',element:document.querySelector('#CONTAINER > section[data-sublink="members"] form#choose-cluster')}},permissions:{text:'#CONTAINER > section[data-sublink="permissions"] ', element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}}; -if(null!=section.view.element){1 article.inline-box[id]");for(c=0;c 1 && /^[um]\d+$/.test(pageManager.vars[1]) ){ + if( pageManager.vars.length > 1 && /^(u|m)\d+$/.test(pageManager.vars[1]) ){ document.location = '#'+pageManager.vars[1]; document.getElementById(pageManager.vars[1]).addClass('selected'); } @@ -328,7 +328,7 @@ if( section.remove.element != null ){ } // Gestion automatique au chargement de la page si ID_CLUSTER dans url "/users/remove/:id_cluster:" - if( pageManager.vars.length >= 2 && /^[um]\d+$/.test(pageManager.vars[1]) ){ + if( pageManager.vars.length >= 2 && /^(u|m)\d+$/.test(pageManager.vars[1]) ){ var prefix = pageManager.vars[1][0]; var cluster = pageManager.vars[1].slice(1); @@ -681,7 +681,7 @@ if( section.members.element != null && section.members.chooser.element != null ) var data = section.members.chooser.deflater.deflate()['cluster']; // Vérification du type - if( isNaN(data) ) + if( !/^(u|m)\d+$/.test(data) ) return; /* (2) Redirection */