diff --git a/manager/module/userDefault.php b/manager/module/userDefault.php index a844d75..ad38170 100755 --- a/manager/module/userDefault.php +++ b/manager/module/userDefault.php @@ -124,8 +124,7 @@ $link_user = new Repo('user_cluster/unlink', [ $_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/view.php b/manager/view/group/view.php index 20877c9..d80848d 100644 --- a/manager/view/group/view.php +++ b/manager/view/group/view.php @@ -14,26 +14,25 @@ case 'machine': return " @name - + "; break; case 'user': return " @username - + "; break; case 'machine_cluster': return " -
- +
- @name #@name - @icon_remove + @name + @icon_remove - @icon_edit + @icon_edit @icon_type @@ -43,7 +42,7 @@ @icon_group @machines - + + +
"; @@ -52,13 +51,12 @@ case 'user_cluster': return " -
- +
- @name #@name - @icon_remove + @name + @icon_remove - @icon_edit + @icon_edit @icon_type @@ -68,7 +66,7 @@ @icon_group @users - + + +
"; @@ -133,11 +131,12 @@ $USERCLUSTERS[$u]['users'] = View::replaceMultiple( self::template('user'), $members, - [ 'id_cluster' => $cluster['id_user_cluster'] ] + [ 'id_cluster' => 'u'.$cluster['id_user_cluster'] ] ); /* (4) On ajoute les attributs utiles */ - $USERCLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' utilisateur' : count($members).' utilisateurs'; + $USERCLUSTERS[$u]['id_cluster'] = 'u'.$cluster['id_user_cluster']; + $USERCLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' utilisateur' : count($members).' utilisateurs'; $USERCLUSTERS[$u]['icon_type'] = file_get_contents(__ROOT__.'/src/static/menu-side/users.svg'); } @@ -173,11 +172,12 @@ $MACHINECLUSTERS[$u]['machines'] = View::replaceMultiple( self::template('machine'), $members, - [ 'id_cluster' => $cluster['id_machine_cluster'] ] + [ 'id_cluster' => 'm'.$cluster['id_machine_cluster'] ] ); /* (4) On ajoute les attributs utiles */ - $MACHINECLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' machine' : count($members).' machines'; + $MACHINECLUSTERS[$u]['id_cluster'] = 'm'.$cluster['id_machine_cluster']; + $MACHINECLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' machine' : count($members).' machines'; $MACHINECLUSTERS[$u]['icon_type'] = file_get_contents(__ROOT__.'/src/static/menu-side/machines.svg'); } diff --git a/manager/view/machine/groups.php b/manager/view/machine/groups.php index 1d15411..2188a3c 100644 --- a/manager/view/machine/groups.php +++ b/manager/view/machine/groups.php @@ -21,7 +21,7 @@ case 'machine_cluster': return "
- @name #@name + @name @icon_remove diff --git a/manager/view/user/groups.php b/manager/view/user/groups.php index 5414ad6..9079387 100644 --- a/manager/view/user/groups.php +++ b/manager/view/user/groups.php @@ -21,7 +21,7 @@ case 'user_cluster': return "
- @name #@name + @name @icon_remove diff --git a/view/js/groups-min.js b/view/js/groups-min.js index 2c0c579..e21f055 100644 --- a/view/js/groups-min.js +++ b/view/js/groups-min.js @@ -1,24 +1,24 @@ 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(b=0;b article.inline-box[id]");for(c=0;c 1 && !isNaN(pageManager.vars[1]) ){ + if( pageManager.vars.length > 1 && /^[um]\d+$/.test(pageManager.vars[1]) ){ document.location = '#'+pageManager.vars[1]; document.getElementById(pageManager.vars[1]).addClass('selected'); } - /* (1) On recupere tous les liens */ + /* (1) On recupere tous les liens vers des sous-sections */ section.view.link = { edit: document.querySelectorAll(section.view.text + '.link_edit[data-cluster]'), remove: document.querySelectorAll(section.view.text + '.link_remove[data-cluster]') @@ -97,9 +97,11 @@ if( section.view.element != null ){ }, false); + var i; + /* (4) On gere la "redirection" vers la modification */ - for( var i = 0 ; i < section.view.link.edit.length ; i++ ){ + for( i = 0 ; i < section.view.link.edit.length ; i++ ){ section.view.link.edit[i].addEventListener('click', function(e){ pageManager.vars[1] = e.target.getData('cluster'); @@ -110,7 +112,7 @@ if( section.view.element != null ){ } /* (5) On gere la "redirection" vers la suppression */ - for( var i = 0 ; i < section.view.link.remove.length ; i++ ){ + for( i = 0 ; i < section.view.link.remove.length ; i++ ){ section.view.link.remove[i].addEventListener('click', function(e){ pageManager.vars[1] = e.target.getData('cluster'); @@ -121,18 +123,20 @@ if( section.view.element != null ){ } /* (6) On gere la "suppression" d'un groupe */ - for( var i = 0 ; i < section.view.group.rem.length ; i++ ){ + for( i = 0 ; i < section.view.group.rem.length ; i++ ){ section.view.group.rem[i].addEventListener('click', function(e){ - var clusterClass = e.target.parentNode.parentNode.parentNode.children[0].value; + var prefix = e.target.getData('cluster')[0]; + var cluster = e.target.getData('cluster').slice(1); + console.log(e.target); // {1} On rédige la requête // var request = {}; - request.path = (clusterClass==0) ? 'userDefault/unlink' : 'machineDefault/unlink'; - request.id_cluster = e.target.getData('cluster'); + request.path = (prefix=='u') ? 'userDefault/unlink' : 'machineDefault/unlink'; + request.id_cluster = cluster; - if( clusterClass == 0 ) request.id_user = e.target.getData('member'); - else request.id_machine = e.target.getData('member'); + if( prefix == 'u' ) request.id_user = e.target.getData('member'); + else request.id_machine = e.target.getData('member'); // {2} On envoie la requête // api.send(request, function(response){ @@ -151,7 +155,7 @@ if( section.view.element != null ){ } /* (7) On gere la "modification" des membres d'un groupe */ - for( var i = 0 ; i < section.view.group.add.length ; i++ ){ + for( i = 0 ; i < section.view.group.add.length ; i++ ){ section.view.group.add[i].addEventListener('click', function(e){ @@ -701,6 +705,7 @@ if( section.members.element != null && section.members.chooser.element == null ) section.members.element.addEventListener('click', function(e){ /* (0) On récupère les données + initialise les variables */ + var i; var linked = []; var unlinked = []; @@ -710,18 +715,18 @@ if( section.members.element != null && section.members.chooser.element == null ) data = [data]; /* (1) Si on a ajouté des liens */ - for( var i = 0 ; i < data.length ; i++ ) + for( i = 0 ; i < data.length ; i++ ) if( section.members.baseData.indexOf(data[i]) == -1 ) // Si pas dans les données initiales, on ajoute linked.push( data[i] ); /* (2) Si on a supprimé des liens */ - for( var i = 0 ; i < section.members.baseData.length ; i++ ) + for( i = 0 ; i < section.members.baseData.length ; i++ ) if( data.indexOf(section.members.baseData[i]) == -1 ) // Si pas dans les données modifiées, on ajoute unlinked.push( section.members.baseData[i] ); /* (3) Gestion de l'ajout de liens */ - for( var i = 0 ; i < linked.length ; i++ ){ + for( i = 0 ; i < linked.length ; i++ ){ // {1} On rédige la requête // var linkReq = {}; linkReq.path = (section.members.class==0) ? 'userDefault/link' : 'machineDefault/link'; @@ -740,7 +745,7 @@ if( section.members.element != null && section.members.chooser.element == null ) /* (4) Gestion de la suppression de liens */ - for( var i = 0 ; i < unlinked.length ; i++ ){ + for( i = 0 ; i < unlinked.length ; i++ ){ // {1} On rédige la requête // var unlinkReq = {}; unlinkReq.path = (section.members.class==0) ? 'userDefault/unlink' : 'machineDefault/unlink';