Gestion de la suppression des groupes personnels lors de la suppression d'entités (user/machine)

This commit is contained in:
xdrm-brackets 2016-07-12 15:16:07 +02:00
parent ea3557ef1d
commit 426002165d
23 changed files with 220 additions and 153 deletions

View File

@ -41,6 +41,7 @@
"getByName",
"getMerge",
"getPersonal",
"getMembers",
"link",

View File

@ -98,6 +98,17 @@
color: inherit;
}
&.selected{
border: 1px solid #7362ff;
transition: box-shadow .2s ease-in-out;
&:hover{
box-shadow: 2px 2px 7px #aaa;
}
}
/* (1) Titre de l'element */
.title{
display: inline-block;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -38,7 +38,7 @@
// stroke: none !important;
// fill: #777 !important;
transition: fill .3s;
transition: fill .3s, stroke .3s;
pointer-events: none;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
DOM={WRAPPER:$("WRAPPER"),HEADER:$("HEADER"),MENUSIDE:$("MENU-SIDE"),CONTAINER:$("CONTAINER")};var pageManager=new pageManagerClass;pageManager.setPage(null,"/view",DOM.CONTAINER,"profile dashboard machines users groups analytics settings".split(" "));var api=new APIClass("/api/");
function navSubMenu(a){var c=document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+pageManager.vars[0]+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#CONTAINER > .sub-menu-side > span[data-sublink="'+a+'"]'):b,b=null==b?document.querySelector("#CONTAINER > .sub-menu-side > span[data-sublink]"):b;if(null==b)return!1;null!=c&&c.remClass("active");a=document.querySelectorAll("#CONTAINER > section[data-sublink].active");for(c=0;c<a.length;c++)a[c].remClass("active");
null!=b&&(b.addClass("active"),a=document.querySelector('#CONTAINER > section[data-sublink="'+b.getData("sublink")+'"]'),null!=a&&a.addClass("active"));if(!b.getData("sublink"))return!1;a=pageManager.vars[0]!=b.getData("sublink");pageManager.vars[0]=b.getData("sublink");a&&pageManager.updateURL()}
function navMenu(a){var c=document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+a+'"]'):b,b=null==b?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]'):b;if(null==b)return!1;null!=c&&c.remClass("active");null!=b&&b.addClass("active");b.getData("link")&&(DOM.HEADER.addClass("loading"),pageManager.setPage(b.getData("link")),
pageManager.activeXHR.addEventListener("loadend",function(){DOM.HEADER.remClass("loading");1<=pageManager.vars.length&&null!=document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);document.querySelector("#CONTAINER > .sub-menu-side").addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},!1)},!1))}navMenu(pageManager.page);
DOM.MENUSIDE.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("link");)a=a.parentNode;a.getData("link")&&navMenu(a.getData("link"))},!1);
function navMenu(a){var c=document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.page+'"]'),b=null,b=a instanceof Element?a:null,b="string"==typeof a?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+a+'"]'):b,b=null==b?document.querySelector('#WRAPPER > #MENU-SIDE > span[data-link="'+pageManager.pagelist[0]+'"]'):b;if(null==b)return!1;null!=c&&c.remClass("active");null!=b&&b.addClass("active");c!=b&&(pageManager.vars=[]);b.getData("link")&&(DOM.HEADER.addClass("loading"),
pageManager.setPage(b.getData("link")),pageManager.activeXHR.addEventListener("loadend",function(){DOM.HEADER.remClass("loading");1<=pageManager.vars.length&&null!=document.querySelector('#CONTAINER > .sub-menu-side > [data-sublink="'+pageManager.vars[0]+'"]')?navSubMenu(pageManager.vars[0]):navSubMenu(null);document.querySelector("#CONTAINER > .sub-menu-side").addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("sublink");)a=a.parentNode;a.getData("sublink")&&navSubMenu(a)},
!1)},!1))}navMenu(pageManager.page);DOM.MENUSIDE.addEventListener("click",function(a){for(a=a.target;a!=document.body&&!a.getData("link");)a=a.parentNode;a.getData("link")&&navMenu(a.getData("link"))},!1);

View File

@ -121,6 +121,11 @@ function navMenu(section){
// Si element, on recupere le data-link
var page = null;
// SI on change de menu, on efface les données URL
if( current != target )
pageManager.vars = [];
// On charge la page si data-link trouve
if( target.getData('link') ){
DOM.HEADER.addClass('loading'); // Animation de chargement

4
js/lib/api-min.js vendored
View File

@ -1,4 +1,4 @@
function APIClass(c){this.target=c}
APIClass.prototype={xhr:[],buffer:null,optionalParams:[],send:function(c,f,g){c.hasOwnProperty("path")||f({ModuleError:4});for(var a=0;a<this.xhr.length;a++)4==this.xhr[a].readyState&&this.xhr.splice(a,1);this.xhr.push(null);a=this.xhr.length-1;this.optionalParams[a]=[];if(3<arguments.length)for(var d=3;d<arguments.length;d++)this.optionalParams[a].push(arguments[d]);this.xhr[a]=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHttpRequest");var e=this;this.xhr[a].onreadystatechange=
function(){if(4==e.xhr[a].readyState)if(e.buffer=e.xhr[a].responseText,console.log("api request",c),-1<[0,200].indexOf(e.xhr[a].status))try{f(JSON.parse(e.xhr[a].responseText),e.optionalParams[a])}catch(b){f({ModuleError:-1,ErrorDescription:"Erreur au niveau de api.js"},e.optionalParams[a]),console.warn(b)}else f({ModuleError:3})};var d=new FormData,b;for(b in c)"path"==b?d.append(b,c[b]):c[b]instanceof File?d.append(b,c[b]):d.append(b,JSON.stringify(c[b]));this.xhr[a].open("POST",this.target,!0);
null!=g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}};
function(){if(4==e.xhr[a].readyState)if(e.buffer=e.xhr[a].responseText,console.log("api request",c),-1<[0,200,417].indexOf(e.xhr[a].status)){var b={ModuleError:-1,ErrorDescription:"Erreur au niveau de api.js"};try{b=JSON.parse(e.xhr[a].responseText)}catch(d){}console.log("api response",b);b.hasOwnProperty("ModuleError")&&0!=b.ModuleError&&console.error("ModuleError::"+b.ModuleError);f(b,e.optionalParams[a])}else f({ModuleError:-2,ModuleDescription:"Erreur au niveau d'AJAX."})};var d=new FormData,
b;for(b in c)"path"==b?d.append(b,c[b]):c[b]instanceof File?d.append(b,c[b]):d.append(b,JSON.stringify(c[b]));this.xhr[a].open("POST",this.target,!0);null!=g&&this.xhr[a].setRequestHeader("Authorization","Digest "+g);this.xhr[a].setRequestHeader("X-Requested-With","XMLHttpRequest");this.xhr[a].send(d)}};

View File

@ -53,30 +53,39 @@ APIClass.prototype = {
// création de l'objet AJAX
if(window.XMLHttpRequest) // IE7+, Firefox, Chrome, Opera, Safari
this.xhr[i] = new XMLHttpRequest();
else // IE5, IE6
this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest');
if(window.XMLHttpRequest) this.xhr[i] = new XMLHttpRequest(); // IE7+, Firefox, Chrome, Opera, Safari
else this.xhr[i] = new ActiveXObject('Microsoft.XMLHttpRequest'); // IE5, IE6
var ptrAPI = this;
this.xhr[i].onreadystatechange = function(){
if( ptrAPI.xhr[i].readyState == 4 ){ // si la requête est terminée
// On met à jour le BUFFER (pour debugger)
ptrAPI.buffer = ptrAPI.xhr[i].responseText;
/* DEBUG : affiche la réponse BRUTE de http://host/api/ */
// console.log('http://host/api/ => '+ptrAPI.xhr[i].responseText);
// console.log( JSON.parse(ptrAPI.xhr[i].responseText) );
console.log('api request', pRequest);
/* si success de requête */
if( [0,200].indexOf(ptrAPI.xhr[i].status) > -1 ){ // si fichier existe et reçu
try{ pHandler( JSON.parse(ptrAPI.xhr[i].responseText), ptrAPI.optionalParams[i]); } // si on peut parser, on envoie
catch(e){ pHandler({ModuleError:-1, ErrorDescription:'Erreur au niveau de api.js'}, ptrAPI.optionalParams[i]); console.warn(e); } // sinon on envoie obj.request = 'corrupted'
if( [0,200,417].indexOf(ptrAPI.xhr[i].status) > -1 ){ // si fichier existe et reçu
var parsedResponse = {ModuleError:-1, ErrorDescription:'Erreur au niveau de api.js'};
// On essaie de parser le json
try{
parsedResponse = JSON.parse(ptrAPI.xhr[i].responseText);
}catch(e){}
// On lance la handler
console.log('api response', parsedResponse);
if( parsedResponse.hasOwnProperty('ModuleError') && parsedResponse.ModuleError != 0 )
console.error('ModuleError::'+parsedResponse.ModuleError);
pHandler(parsedResponse, ptrAPI.optionalParams[i]);
}
/* sinon retourne obj.request = 'unreachable' */
else
pHandler({ModuleError:3});
pHandler({ModuleError:-2, ModuleDescription:'Erreur au niveau d\'AJAX.'});
}
};

View File

@ -1,6 +1,6 @@
function pageManagerClass(){}var ptrPageManagerClass;
pageManagerClass.prototype={depJS:null,depCSS:null,xhr:[],activeXHR:null,page:null,vars:[],path:"",jsPath:"js",cssPath:"css",pagelist:null,container:null,ajax:function(b,c,f,a){for(var d=0;d<this.xhr.length;d++)this.xhr=this.xhr.slice(0,d-1).concat(this.xhr.slice(d,this.xhr.length-1));var e;e=window.XMLHttpRequest?this.xhr.push(new XMLHttpRequest)-1:this.xhr.push(new ActiveXObject("Microsoft.XMLHttpRequest"))-1;this.activeXHR=this.xhr[e];var g=this;this.xhr[e].onreadystatechange=function(){4==g.xhr[e].readyState&&
(-1<[0,200].indexOf(g.xhr[e].status)?c(g.xhr[e].responseText):c())};f="string"==typeof f&&/^POST|GET$/i.test(f)?f.toUpperCase():"POST";a="POST"==f&&"object"==typeof a&&a instanceof FormData?a:null;this.xhr[e].open(f,b,!0);this.xhr[e].send(a);return this},explodeURL:function(b){b=1<=arguments.length?b:document.URL;if(null!=this.pagelist&&/^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?$/i.test(b)){for(var c=RegExp.$2.split("/");""==c[c.length-1];)c.pop();return-1<this.pagelist.indexOf(RegExp.$1)?
(-1<[0,200].indexOf(g.xhr[e].status)?c(g.xhr[e].responseText):c())};f="string"==typeof f&&/^POST|GET$/i.test(f)?f.toUpperCase():"POST";a="POST"==f&&"object"==typeof a&&a instanceof FormData?a:null;this.xhr[e].open(f,b,!0);this.xhr[e].send(a);return this},explodeURL:function(b){b=1<=arguments.length?b:document.URL;if(null!=this.pagelist&&/^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?(?:#(.+))?$/i.test(b)){for(var c=RegExp.$2.split("/");""==c[c.length-1];)c.pop();return-1<this.pagelist.indexOf(RegExp.$1)?
{page:RegExp.$1,"var":c}:null}return null},loadDependencies:function(){"object"==typeof this.depCSS&&this.depCSS instanceof Element&&this.depCSS.parentNode==document.head&&document.head.removeChild(this.depCSS);"object"==typeof this.depJS&&this.depJS instanceof Element&&this.depJS.parentNode==document.head&&document.head.removeChild(this.depJS);ptrPageManagerClass=this;this.ajax(this.path+"/"+this.cssPath+"/"+this.page+".css",function(b){null!=b?(ptrPageManagerClass.depCSS=document.createElement("link"),
ptrPageManagerClass.depCSS.rel="stylesheet",ptrPageManagerClass.depCSS.type="text/css",ptrPageManagerClass.depCSS.href=ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+ptrPageManagerClass.page+".css",document.head.appendChild(ptrPageManagerClass.depCSS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.path+"/"+ptrPageManagerClass.cssPath+"/"+ptrPageManagerClass.page+".css)")});this.ajax(this.path+"/"+this.jsPath+"/"+this.page+".js",function(b){null!=b?(ptrPageManagerClass.depJS=
document.createElement("script"),ptrPageManagerClass.depJS.type="text/javascript",ptrPageManagerClass.depJS.src=ptrPageManagerClass.path+"/"+ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js",document.head.appendChild(ptrPageManagerClass.depJS)):console.warn("[loadDependencies_Error] - ("+ptrPageManagerClass.path+"/"+ptrPageManagerClass.jsPath+"/"+ptrPageManagerClass.page+".js)")})},updateURL:function(){0<this.vars.length?window.history.pushState(this.page,this.page,"/"+this.page+"/"+this.vars.join("/")+

View File

@ -101,7 +101,7 @@ pageManagerClass.prototype = {
explodeURL: function(url_data){
url_data = (arguments.length >= 1) ? url_data : document.URL;
// si pageList est correct et que l'URL correspond à un schéma de page => continue [sinon] return null
if( this.pagelist != null && /^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?$/i.test(url_data) ){
if( this.pagelist != null && /^(?:(?:https?:\/\/)?[^\/]+)\/([a-z0-9_]+)\/?(?:\/((?:.+\/)+)\/?)?(?:#(.+))?$/i.test(url_data) ){
// si la page récupérée dans l'url est dans la liste => renvoi de l'objet [sinon] null
var vars = RegExp.$2.split('/');
while( vars[vars.length-1] == '' ) // on supprime les dernières entrées vides

View File

@ -312,13 +312,42 @@
extract($params);
// On recupere les donnees
$request = new Repo('machine/delete', [
$del_machine = new Repo('machine/delete', [
$_SESSION['WAREHOUSE']['id'],
$id_machine
]);
$answer = $request->answer();
$deleted_machine = $del_machine->answer();
return [ 'status' => $answer ];
if( !$deleted_machine )
return [ 'status' => false ];
/* [2] On récupère le groupe personnel
=========================================================*/
$get_personal_cluster = new Repo('cluster/getPersonal', [
$id_warehouse,
$id_machine,
clusterRepo::MACHINE_CLASS
]);
$personal_cluster = $get_personal_cluster->answer();
// si erreur
if( $personal_cluster === false )
return [ 'status' => false ];
/* [3] On supprime le groupe personnel
=========================================================*/
$del_cluster = new Repo('cluster/delete', [
$id_warehouse,
$personal_cluster['id_cluster']
]);
$deleted = $del_cluster->answer();
return [ 'status' => $deleted ];
}

View File

@ -385,15 +385,44 @@
public static function delete($params){
extract($params);
// On recupere les donnees
$request = new Repo('user/delete', [
/* [1] On supprime l'utilisateur
=========================================================*/
$del_user = new Repo('user/delete', [
$_SESSION['WAREHOUSE']['id'],
$id_user
]);
$answer = $request->answer();
$deleted_user = $del_user->answer();
return [ 'status' => $answer ];
if( !$deleted_user )
return [ 'status' => false ];
/* [2] On récupère le groupe personnel
=========================================================*/
$get_personal_cluster = new Repo('cluster/getPersonal', [
$id_warehouse,
$id_user,
clusterRepo::USER_CLASS
]);
$personal_cluster = $get_personal_cluster->answer();
// si erreur
if( $personal_cluster === false )
return [ 'status' => false ];
/* [3] On supprime le groupe personnel
=========================================================*/
$del_cluster = new Repo('cluster/delete', [
$id_warehouse,
$personal_cluster['id_cluster']
]);
$deleted = $del_cluster->answer();
return [ 'status' => $deleted ];
}

View File

@ -344,6 +344,48 @@
/* RENVOIE LE GROUPE PERSONNEL D'UNE ENTITE
*
* @id_warehouse<int> UID de l'entrepot
* @id_entity<int> UID de l'entité (user/machine)
* @class<int> Classe du groupe (0:user ; 1:machine)
*
* @return cluster<Array> Renvoie le groupe correspondant
* Renvoie FALSE si une erreur occure
*
*/
public static function getPersonal($id_warehouse, $id_entity, $class){
// On ecrit la requete
$request = Database::getPDO()->prepare("SELECT c.*
FROM cluster as c
WHERE c.id_warehouse = :id_warehouse
AND c.personal is not null
AND c.id_entity = :id_entity
AND c.class = :class");
// On execute la requete
$request->execute([
':id_warehouse' => $id_warehouse,
':id_entity' => $id_entity,
':class' => $class
]);
$fetch = $request->fetch();
// Si aucun résultat
if( $fetch == false )
return false;
// On retourne en supprimant les indices numeriques
return Database::delNumeric( $fetch, true );
}
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE
*

View File

@ -235,10 +235,9 @@
':id_warehouse' => $id_warehouse
]);
/* [2] On verifie que l'utilisateur n'existe plus
=========================================================*/
// On retourne l'état
return ( self::getById($id_warehouse, $id_user) === false );
}

View File

@ -43,7 +43,7 @@
id="namedview4184"
showgrid="false"
inkscape:zoom="20.528194"
inkscape:cx="5.9123768"
inkscape:cx="-2.6855544"
inkscape:cy="10.002048"
inkscape:window-x="0"
inkscape:window-y="24"
@ -57,8 +57,8 @@
transform="translate(-212.21429,-536.00508)">
<path
id="stroke-stylisable"
transform="translate(212.21429,536.00508)"
style="fill:none;stroke:#000000;stroke-width:1.20000005;stroke-linecap:round;stroke-miterlimit:4;stroke-dasharray:none"
d="m 222.16311,556.20629 0,-8.72588 c 0,-1.85097 1.49014,-3.34111 3.34112,-3.34111 l 5.59442,0 c 1.85099,0 3.34113,1.49014 3.34113,3.34111 l 0,8.72588 m -3.57785,-16.54671 a 2.5604858,2.5604858 0 0 1 -2.56049,2.56048 2.5604858,2.5604858 0 0 1 -2.56048,-2.56048 2.5604858,2.5604858 0 0 1 2.56048,-2.56049 2.5604858,2.5604858 0 0 1 2.56049,2.56049 z m -6.26011,8.81827 c 0.84653,11.16755 -0.0863,15.6533 3.65368,15.6586 m 3.82066,-15.6586 c -0.84653,11.16755 0.0863,15.6533 -3.65368,15.6586 m -0.13951,-0.0824 0,-7.77436 m 6.28683,3.3775 c 4.15857,0.65353 6.98178,1.92843 6.98178,3.39416 0,2.13166 -5.9713,3.8597 -13.33729,3.8597 -7.36598,0 -13.33729,-1.72804 -13.33729,-3.8597 0,-1.51481 3.01542,-2.8258 7.40393,-3.45769"
inkscape:connector-curvature="0" />
d="m 9.1074219,23.75 c -3.8536982,0.676686 -6.4453125,1.897119 -6.4453125,3.296875 0,2.13166 5.9719106,3.859375 13.3378906,3.859375 7.36599,0 13.337891,-1.727715 13.337891,-3.859375 0,-1.399882 -2.591028,-2.620213 -6.445313,-3.296875 m -6.823898,4.29897 0,-7.77436 m 3.79319,-7.80184 c -0.84653,11.16755 0.0863,15.6533 -3.65368,15.6586 m -3.82066,-15.6586 c 0.84653,11.16755 -0.0863,15.6533 3.65368,15.6586 M 18.64764,3.6545 A 2.5604858,2.5604858 0 0 1 16.08715,6.21498 2.5604858,2.5604858 0 0 1 13.52667,3.6545 2.5604858,2.5604858 0 0 1 16.08715,1.09401 2.5604858,2.5604858 0 0 1 18.64764,3.6545 Z m -8.69882,16.54671 0,-8.72588 c 0,-1.85097 1.49014,-3.34111 3.34112,-3.34111 l 5.59442,0 c 1.85099,0 3.34113,1.49014 3.34113,3.34111 l 0,8.72588" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -56,92 +56,9 @@
echo "<section data-sublink='view' class='list'>";
debug();
$clusterView = new View('group.view', []);
$clusterView->view();
// // si erreur, on affiche l'explicitation
// if( $answer->error != ManagerError::Success ){
// // var_dump( ManagerError::explicit($answer->error) );
//
// echo "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
// }
//
// // Si aucune erreur, on affiche les resultats
// else{
// debug();
//
// // Barre de recherche
// echo "<input type='text' class='searchbar' placeholder='Recherche'>";
//
// foreach($answer->get('clusters') as $cluster){
//
// // Liste des membres
// $get_membersReq = new ModuleRequest('clusterDefault/getMembers', ['id_cluster' => $cluster['id_cluster']] );
// $get_membersRes = $get_membersReq->dispatch();
//
// // Si erreur, valeur par d
// if( $get_membersRes->error != ManagerError::Success )
// $members = [];
// else
// $members = $get_membersRes->get('members');
//
//
//
// echo "<article class='inline-box' id='".$cluster['id_cluster']."'>";
//
// // Prenom Nom
// echo "<span class='title'>".$cluster['name']."</span></span>";
//
//
//
// // Icone vers la suppression
// echo "<span class='link_remove' data-cluster='".$cluster['id_cluster']."'>";
// echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' );
// echo "</span>";
//
// // Icone vers la modification
// echo "<span class='link_edit' data-cluster='".$cluster['id_cluster']."'>";
// echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' );
// echo "</span>";
//
//
//
// // Code RFID
// echo "<span class='code'>";
// echo file_get_contents( __ROOT__.'/src/static/container/card.svg' );
//
// echo "<span>";
// echo "groupe d". ($cluster['class']==0 ? '\'utilisateurs' : 'e machines');
// echo "</span>";
// echo"</span>";
//
// // Adresse email
// echo "<span class='mail'>";
// echo file_get_contents( __ROOT__.'/src/static/container/mail.svg' );
//
// echo "<span>";
// echo count($members).' membre(s)';
// echo "</span>";
// echo"</span>";
//
// // Groupes de la machine
// echo "<span class='groups'>";
// echo file_get_contents( __ROOT__.'/src/static/container/group.svg' );
//
// foreach($members as $member)
// if( $member['name'] != $cluster['name'] ) // Si c'est le groupe personnel, on ne l'affiche pas
// echo "<span>".$member['name']."<span class='rem-member' data-member='".$member['id_member']."' data-cluster='".$cluster['id_cluster']."'></span></span>";
//
// echo "<span class='add-member' data-cluster='".$cluster['id_cluster']."'>+</span>";
// echo"</span>";
//
//
// echo "</article>";
// }
//
// }
echo '</section>';
@ -258,8 +175,10 @@
=========================================================*/
echo "<section data-sublink='filter'>";
echo "<form class='neutral'>";
$userForGroup = new View('group.userChoice', [
'id_cluster' => 206 // groupe "b" de type MACHINE
]);
echo "</form>";
$userForGroup->view();
echo '</section>';

View File

@ -1,11 +1,11 @@
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"]')}};
if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-machine]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-machine]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-machine][data-group]"),add:document.querySelectorAll(section.view.text+".add-group[data-machine]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},
function(a){if(0==a.ModuleError){for(var b=[],c=0;c<a.machines.length;c++)b.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=
0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(b){var a={path:"machineDefault/unlink",id_machine:b.target.getData("machine"),id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},
!1)}
if(null!=section.create.element){section.create.input={name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"machineDefault/create",name:section.create.input.name.value},function(a){0==a.ModuleError?(console.log("Machine cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},
!1)}
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],document.getElementById(pageManager.vars[1]).addClass("selected"));section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-machine]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-machine]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-machine][data-group]"),add:document.querySelectorAll(section.view.text+
".add-group[data-machine]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var b=[],c=0;c<a.machines.length;c++)b.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(b){pageManager.vars[1]=b.target.getData("machine");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(b){var a={path:"machineDefault/unlink",id_machine:b.target.getData("machine"),
id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},!1)}
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"machineDefault/create",name:section.create.input.name.value},function(a){0==a.ModuleError&&(console.log("Machine cree!"),pageManager.vars=["view",a.id_machine],pageManager.refresh(),document.location="",section.create.input.submit.anim("active",
1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(b){var a={id_machine:"",name:"",disable_input:!0};api.send({path:"machineDefault/getById",id_machine:b},function(b){0==b.ModuleError&&(a=b.machine,a.diable_input=!1);section.remove.input.search.id.value=a.id_machine;section.remove.input.name.value=a.name;section.remove.input.submit.disabled=a.disable_input;section.remove.input.search.num.innerHTML=searchindex_remove+1})};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),
num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},name:document.querySelector(section.remove.text+"#remove_name"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastsearch_remove=
null,searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&autofill_remove(pageManager.vars[1]);section.remove.input.search.submit.addEventListener("click",function(b){b.preventDefault();""!=section.remove.input.search.keyword.value&&api.send({path:"machineDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&0<a.machines.length?(section.remove.input.search.submit.anim("active",1E3),lastsearch_remove==a.machines[searchindex_remove].id_machine&&

View File

@ -29,6 +29,12 @@ var section = {
*/
if( section.view.element != null ){
/* (0) On gère le zoom sur un utilisateur via URL */
if( pageManager.vars.length > 1 && !isNaN(pageManager.vars[1]) ){
document.location = '#'+pageManager.vars[1];
document.getElementById(pageManager.vars[1]).addClass('selected');
}
/* (1) On recupere tous les liens */
section.view.link = {
edit: document.querySelectorAll(section.view.text + '.link_edit[data-machine]'),
@ -150,13 +156,9 @@ if( section.create.element != null ){
// On recupere tous les champs
section.create.input = {
name: document.querySelector(section.create.text + '#create_name'),
submit: document.querySelector(section.create.text + '#create_submit')
}
// On initialise le gestionnaire des saisies
var createChecker = new inputChecker();
/* (n) Gestion de l'envoi du formulaire */
section.create.input.submit.addEventListener('click', function(e){
@ -172,9 +174,13 @@ if( section.create.element != null ){
if( answer.ModuleError == 0 ){ // Tout s'est bien deroule
console.log('Machine cree!');
// On redirige sur la machine
pageManager.vars = ['view', answer.id_machine];
pageManager.refresh();
document.location = '';
section.create.input.submit.anim('active', 1500);
}else // Erreur
console.error('ModuleError::'+answer.ModuleError);
}
});

12
view/js/users-min.js vendored
View File

@ -1,9 +1,9 @@
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"]')}};
if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-user][data-group]"),add:document.querySelectorAll(section.view.text+".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},
function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var b=[],c=0;c<a.users.length;c++)b.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");autofill_edit(pageManager.vars[1]);
navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(b){var a={path:"userDefault/unlink",id_user:b.target.getData("user"),id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;
b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},!1)}
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1]);section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-user][data-group]"),add:document.querySelectorAll(section.view.text+".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",
function(b){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var b=[],c=0;c<a.users.length;c++)b.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(b){pageManager.vars[1]=b.target.getData("user");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(b){var a={path:"userDefault/unlink",id_user:b.target.getData("user"),
id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},!1)}
if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),username:document.querySelector(section.create.text+"#create_username"),firstname:document.querySelector(section.create.text+"#create_firstname"),lastname:document.querySelector(section.create.text+"#create_lastname"),mail:document.querySelector(section.create.text+"#create_mail"),password:document.querySelector(section.create.text+"#create_password"),status:document.querySelector(section.create.text+
"#create_status"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(b){b.target.value=b.target.value.toUpperCase();createChecker.check(b.target)||createChecker.correct(b.target,!1)},!1);section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"userDefault/create",code:section.create.input.code.value,
username:section.create.input.username.value,firstname:section.create.input.firstname.value,lastname:section.create.input.lastname.value,mail:section.create.input.mail.value,password:section.create.input.password.value,status:section.create.input.status.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)}
@ -17,5 +17,5 @@ a.lastname;section.edit.input.mail.value=a.mail;section.edit.input.password.valu
"#edit_search_keyword"),id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},code:document.querySelector(section.edit.text+"#edit_code"),username:document.querySelector(section.edit.text+"#edit_username"),firstname:document.querySelector(section.edit.text+"#edit_firstname"),lastname:document.querySelector(section.edit.text+"#edit_lastname"),mail:document.querySelector(section.edit.text+"#edit_mail"),password:document.querySelector(section.edit.text+
"#edit_password"),status:document.querySelector(section.edit.text+"#edit_status"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastsearch_edit=null,searchindex_edit=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&autofill_edit(pageManager.vars[1]);section.edit.input.search.submit.addEventListener("click",function(b){b.preventDefault();""!=section.edit.input.search.keyword.value&&api.send({path:"userDefault/search",keywords:section.edit.input.search.keyword.value},
function(a){0==a.ModuleError&&0<a.users.length?(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=lastsearch_edit==a.users[searchindex_edit].id_user?(searchindex_edit+1)%a.users.length:0,lastsearch_edit=a.users[searchindex_edit].id_user,section.edit.input.search.id.value=lastsearch_edit,section.edit.input.search.sum.innerHTML=a.users.length,autofill_edit(lastsearch_edit)):(section.edit.input.search.sum.innerHTML=0,autofill_edit(null))})},!1);section.edit.input.submit.addEventListener("click",
function(b){b.preventDefault();""!=section.edit.input.search.id.value&&api.send({path:"userDefault/edit",id_user:section.edit.input.search.id.value,code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value,password:section.edit.input.password.value,status:section.edit.input.status.value},function(a){console.log(a);0==a.ModuleError&&1==a.status?(console.log("Utilisateur modifie!"),
section.edit.input.submit.anim("active",1500),autofill_edit(section.edit.input.search.id.value)):console.error("ModuleError::"+a.ModuleError)})},!1)};
function(b){b.preventDefault();""!=section.edit.input.search.id.value&&(b={path:"userDefault/edit",id_user:parseInt(section.edit.input.search.id.value),code:section.edit.input.code.value,username:section.edit.input.username.value,firstname:section.edit.input.firstname.value,lastname:section.edit.input.lastname.value,mail:section.edit.input.mail.value,password:section.edit.input.password.value,status:section.edit.input.status.value},api.send(b,function(a){console.log(a);0==a.ModuleError&&1==a.status?
(console.log("Utilisateur modifie!"),section.edit.input.submit.anim("active",1500),autofill_edit(section.edit.input.search.id.value)):console.error("ModuleError::"+a.ModuleError)}))},!1)};

View File

@ -31,6 +31,14 @@ var section = {
=========================================================*/
if( section.view.element != null ){
/* (0) On gère le zoom sur un utilisateur via URL */
if( pageManager.vars.length > 1 && !isNaN(pageManager.vars[1]) ){
document.location = '#'+pageManager.vars[1];
}
/* (1) On recupere tous les liens */
section.view.link = {
edit: document.querySelectorAll(section.view.text + '.link_edit[data-user]'),
@ -504,7 +512,7 @@ if( section.edit.element != null ){
var request = {
path: 'userDefault/edit', // On veut creer un utilisateur
id_user: section.edit.input.search.id.value,
id_user: parseInt(section.edit.input.search.id.value),
code: section.edit.input.code.value,
username: section.edit.input.username.value,
firstname: section.edit.input.firstname.value,