Refactor et correction presque complète du module 'clusterDefault' pour gérer les 2 types de groupes
This commit is contained in:
parent
9404824628
commit
51f39d4d3d
|
@ -383,7 +383,9 @@
|
||||||
"getAll": {
|
"getAll": {
|
||||||
"description": "Liste de tous les groupes",
|
"description": "Liste de tous les groupes",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {},
|
"parameters": {
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" }
|
||||||
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"clusters": { "description": "Liste de tous les groupes.", "type": "array<array<mixed>>" }
|
"clusters": { "description": "Liste de tous les groupes.", "type": "array<array<mixed>>" }
|
||||||
}
|
}
|
||||||
|
@ -393,7 +395,8 @@
|
||||||
"description": "Retourne un groupe spécifique.",
|
"description": "Retourne un groupe spécifique.",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"id_cluster": { "description": "UID du groupe.", "type": "id" }
|
"id_cluster": { "description": "UID du groupe.", "type": "id" },
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" }
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"cluster": { "description": "Données du groupe.", "type": "array<mixed>" }
|
"cluster": { "description": "Données du groupe.", "type": "array<mixed>" }
|
||||||
|
@ -404,7 +407,8 @@
|
||||||
"description": "Retourne un groupe de nom donné.",
|
"description": "Retourne un groupe de nom donné.",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)" }
|
"name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)" },
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" }
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"cluster": { "description": "Données du groupe.", "type": "array<mixed>" }
|
"cluster": { "description": "Données du groupe.", "type": "array<mixed>" }
|
||||||
|
@ -415,7 +419,8 @@
|
||||||
"description": "Retourne les membres d'un groupe.",
|
"description": "Retourne les membres d'un groupe.",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"id_cluster": { "description": "UID du groupe.", "type": "id" }
|
"id_cluster": { "description": "UID du groupe.", "type": "id" },
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" }
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"members": { "description": "Liste des membres du groupe.", "type": "array<array<mixed>>" }
|
"members": { "description": "Liste des membres du groupe.", "type": "array<array<mixed>>" }
|
||||||
|
@ -427,6 +432,7 @@
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"id_cluster": { "description": "UID du groupe.", "type": "id" },
|
"id_cluster": { "description": "UID du groupe.", "type": "id" },
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" },
|
||||||
"name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)", "optional": true }
|
"name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)", "optional": true }
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
|
@ -438,7 +444,8 @@
|
||||||
"description": "Suppression d'un groupe.",
|
"description": "Suppression d'un groupe.",
|
||||||
"permissions": ["warehouse", "admin"],
|
"permissions": ["warehouse", "admin"],
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"id_cluster": { "description": "UID du groupe.", "type": "id" }
|
"id_cluster": { "description": "UID du groupe.", "type": "id" },
|
||||||
|
"class": { "description": "Type de groupe.", "type": "id" }
|
||||||
},
|
},
|
||||||
"output": {
|
"output": {
|
||||||
"status": { "description": "Status de la suppression.", "type": "boolean" }
|
"status": { "description": "Status de la suppression.", "type": "boolean" }
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
public static function create($params){
|
public static function create($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* [2] Creation de l'utilisateur
|
/* [2] Creation du groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_cluster = new Repo('cluster/create', [
|
$repoMethod = ($class==0) ? 'user_cluster/create' : 'machine_cluster/create';
|
||||||
|
|
||||||
|
$create_cluster = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$name,
|
$name
|
||||||
$class
|
|
||||||
]);
|
]);
|
||||||
$id_cluster = $create_cluster->answer();
|
$id_cluster = $create_cluster->answer();
|
||||||
|
|
||||||
|
@ -48,76 +49,21 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* AJOUTE UN UTILISATEUR DONNEE A UN GROUPE DONNE
|
/* RENVOIE UN GROUPE EN FONCTION D'UN MOT CLE
|
||||||
*
|
|
||||||
* @id_cluster<int> UID du groupe
|
|
||||||
* @id_user<int> UID de l'utilisateur
|
|
||||||
*
|
|
||||||
* @return association<int> Renvoie l'UID de l'association cree
|
|
||||||
* Renvoie FALSE si une erreur occure
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function link($params){
|
|
||||||
extract($params);
|
|
||||||
|
|
||||||
/* [1] Creation de l'association
|
|
||||||
=========================================================*/
|
|
||||||
$link_user = new Repo('cluster/link', [
|
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
|
||||||
$id_cluster,
|
|
||||||
$id_user,
|
|
||||||
clusterRepo::USER_CLASS
|
|
||||||
]);
|
|
||||||
|
|
||||||
return [];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RETIRE UNE MACHINE DONNEE A UN GROUPE DONNE
|
|
||||||
*
|
|
||||||
* @id_cluster<int> UID du groupe
|
|
||||||
* @id_user<int> UID de l'utilisateur
|
|
||||||
*
|
|
||||||
* @return association<int> Renvoie l'UID de l'association cree
|
|
||||||
* Renvoie FALSE si une erreur occure
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function unlink($params){
|
|
||||||
extract($params);
|
|
||||||
|
|
||||||
/* [1] Suppression de l'association
|
|
||||||
=========================================================*/
|
|
||||||
$link_user = new Repo('cluster/unlink', [
|
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
|
||||||
$id_cluster,
|
|
||||||
$id_user,
|
|
||||||
clusterRepo::USER_CLASS
|
|
||||||
]);
|
|
||||||
|
|
||||||
return [];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RENVOIE UN UTILISATEUR EN FONCTION D'UN MOT CLE
|
|
||||||
*
|
*
|
||||||
* @keywords<String> Element de recherche
|
* @keywords<String> Element de recherche
|
||||||
|
* @class<int> Type de groupe
|
||||||
*
|
*
|
||||||
* @return users<Array> Retourne la liste des utilisateurs trouves
|
* @return clusters<Array> Retourne la liste des groupes trouves
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function search($params){
|
public static function search($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
$repoMethod = ($class==0) ? 'user_cluster/search' : 'machine_cluster/search';
|
||||||
$cluster = new Repo('cluster/search', [
|
|
||||||
|
// On recupere les donnees des groupes utilisateurs
|
||||||
|
$cluster = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$keywords
|
$keywords
|
||||||
]);
|
]);
|
||||||
|
@ -131,12 +77,19 @@
|
||||||
|
|
||||||
/* RENVOIE LA LISTE EXHAUSTIVE DES GROUPES
|
/* RENVOIE LA LISTE EXHAUSTIVE DES GROUPES
|
||||||
*
|
*
|
||||||
|
* @class<int> Type de groupe
|
||||||
|
*
|
||||||
* @return clusters<Array> Liste des groupes
|
* @return clusters<Array> Liste des groupes
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getAll(){
|
public static function getAll($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
|
$repoMethod = ($class==0) ? 'user_cluster/getAll' : 'machine_cluster/getAll';
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$clusters = new Repo('cluster/getAll', [ $_SESSION['WAREHOUSE']['id'] ]);
|
$clusters = new Repo($repoMethod, [ $_SESSION['WAREHOUSE']['id'] ]);
|
||||||
|
|
||||||
return [ 'clusters' => $clusters->answer() ];
|
return [ 'clusters' => $clusters->answer() ];
|
||||||
}
|
}
|
||||||
|
@ -148,6 +101,7 @@
|
||||||
/* RENVOIE UN GROUPE D'UID DONNE
|
/* RENVOIE UN GROUPE D'UID DONNE
|
||||||
*
|
*
|
||||||
* @id_cluster<int> UID du groupe en question
|
* @id_cluster<int> UID du groupe en question
|
||||||
|
* @class<int> Type de groupe
|
||||||
*
|
*
|
||||||
* @return cluster<Array> Groupe d'UID donne
|
* @return cluster<Array> Groupe d'UID donne
|
||||||
*
|
*
|
||||||
|
@ -155,8 +109,10 @@
|
||||||
public static function getById($params){
|
public static function getById($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
$repoMethod = ($class==0) ? 'user_cluster/getById' : 'machine_cluster/getById';
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('cluster/getById', [
|
$request = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$id_cluster
|
$id_cluster
|
||||||
]);
|
]);
|
||||||
|
@ -174,20 +130,23 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RENVOIE L'UTILISATEURS DE CODE DONNE
|
/* RENVOIE UN GROUPE DE NOM DONNE
|
||||||
*
|
*
|
||||||
* @code<String> Code de l'utilisateur en question
|
* @name<String> Nom du groupe en question
|
||||||
|
* @class<int> Type de groupe
|
||||||
*
|
*
|
||||||
* @return utilisateur<Array> Utilisateur de code donne
|
* @return cluster<Array> Groupe de nom donne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getByCode($params){
|
public static function getByName($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
$repoMethod = ($class==0) ? 'user_cluster/getByName' : 'machine_cluster/getByName';
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/getByCode', [
|
$request = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$code
|
$name
|
||||||
]);
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
|
@ -196,37 +155,7 @@
|
||||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
||||||
|
|
||||||
|
|
||||||
return [ 'user' => $answer ];
|
return [ 'cluster' => $answer ];
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* RENVOIE L'UTILISATEURS D'USERNAME DONNE
|
|
||||||
*
|
|
||||||
* @username<String> Username de l'utilisateur en question
|
|
||||||
*
|
|
||||||
* @return utilisateur<Array> Utilisateur d'username donne
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public static function getByUsername($params){
|
|
||||||
extract($params);
|
|
||||||
|
|
||||||
|
|
||||||
// On recupere les donnees
|
|
||||||
$request = new Repo('user/getByUsername', [
|
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
|
||||||
$username
|
|
||||||
]);
|
|
||||||
$answer = $request->answer();
|
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
|
||||||
if( $answer === false )
|
|
||||||
return [ 'ModuleError' => ManagerError::NoMatchFound ];
|
|
||||||
|
|
||||||
|
|
||||||
return [ 'user' => $answer ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -236,6 +165,7 @@
|
||||||
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE
|
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE
|
||||||
*
|
*
|
||||||
* @id_cluster<int> UID du groupe en question
|
* @id_cluster<int> UID du groupe en question
|
||||||
|
* @class<int> Type du groupe en question
|
||||||
*
|
*
|
||||||
* @return members<Array> Membres du groupe donne
|
* @return members<Array> Membres du groupe donne
|
||||||
*
|
*
|
||||||
|
@ -243,9 +173,10 @@
|
||||||
public static function getMembers($params){
|
public static function getMembers($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
$repoMethod = ($class==0) ? 'user_cluster/getMembers' : 'machine_cluster/getMembers';
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('cluster/getMembers', [
|
$request = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$id_cluster
|
$id_cluster
|
||||||
]);
|
]);
|
||||||
|
@ -263,16 +194,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* MODIFIE UN UTILISATEUR DONNEE
|
/* MODIFIE UN groupe DONNEE
|
||||||
*
|
*
|
||||||
* @id_user<int> UID de l'utilisateur
|
* @id_user<int> UID de l'utilisateur
|
||||||
* @code<String> Code RFID de l'utilisateur
|
* @class<int> Type de groupe
|
||||||
* @username<String> Identifiant l'utilisateur
|
* @name<String> Nouveau nom
|
||||||
* @firstname<String> Prenom de l'utilisateur
|
|
||||||
* @lastcode<String> Nom de l'utilisateur
|
|
||||||
* @mail<String> Adresse email de l'utilisateur
|
|
||||||
* @password<String> Mot de passe de l'utilisateur
|
|
||||||
* @status<String> Status de l'utilisateur
|
|
||||||
*
|
*
|
||||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||||
*
|
*
|
||||||
|
@ -280,6 +206,9 @@
|
||||||
public static function edit($params){
|
public static function edit($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
// TODO:: Gestion de la modification de groupe
|
||||||
|
exit();
|
||||||
|
|
||||||
/* [1] On verifie l'existence de l'utilisateur
|
/* [1] On verifie l'existence de l'utilisateur
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$user_exists = new Repo('user/getById', [
|
$user_exists = new Repo('user/getById', [
|
||||||
|
@ -347,7 +276,8 @@
|
||||||
|
|
||||||
/* SUPPRIME UN UTILISATEUR DONNEE
|
/* SUPPRIME UN UTILISATEUR DONNEE
|
||||||
*
|
*
|
||||||
* @id_user<int> UID de l'utilisateur en question
|
* @id_cluster<int> UID du groupe en question
|
||||||
|
* @class<int> Type de groupe
|
||||||
*
|
*
|
||||||
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
* @return status<Boolean> Retourne si oui ou non tout s'est bien deroule
|
||||||
*
|
*
|
||||||
|
@ -355,11 +285,12 @@
|
||||||
public static function delete($params){
|
public static function delete($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
|
$repoMethod = ($class==0) ? 'user_cluster/delete' : 'machine_cluster/delete';
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('user/delete', [
|
$request = new Repo($repoMethod, [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$id_user
|
$id_cluster
|
||||||
]);
|
]);
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
|
|
|
@ -332,13 +332,13 @@
|
||||||
public static function getMembers($id_warehouse, $id_user_cluster){
|
public static function getMembers($id_warehouse, $id_user_cluster){
|
||||||
/* [1] On recupere la liste des associations
|
/* [1] On recupere la liste des associations
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$get_users = Database::getPDO()->prepare("SELECT m.id_user, m.name
|
$get_users = Database::getPDO()->prepare("SELECT u.*
|
||||||
FROM user_cluster_merge as cm, user_cluster as c, user as m
|
FROM user_cluster_merge as cm, user_cluster as c, user as u
|
||||||
WHERE cm.id_user_cluster = c.id_user_cluster
|
WHERE cm.id_user_cluster = c.id_user_cluster
|
||||||
AND c.id_user_cluster = :id_user_cluster
|
AND c.id_user_cluster = :id_user_cluster
|
||||||
AND c.id_warehouse = :id_warehouse
|
AND c.id_warehouse = :id_warehouse
|
||||||
AND cm.id_user = m.id_user
|
AND cm.id_user = u.id_user
|
||||||
ORDER BY m.name");
|
ORDER BY u.username");
|
||||||
$get_users->execute([
|
$get_users->execute([
|
||||||
':id_warehouse' => $id_warehouse,
|
':id_warehouse' => $id_warehouse,
|
||||||
':id_user_cluster' => $id_user_cluster
|
':id_user_cluster' => $id_user_cluster
|
||||||
|
|
|
@ -11,33 +11,64 @@
|
||||||
public static function template($type=null){
|
public static function template($type=null){
|
||||||
|
|
||||||
switch($type){
|
switch($type){
|
||||||
case 'member': return "
|
case 'machine': return "
|
||||||
<span>
|
<span>
|
||||||
@name
|
@name
|
||||||
<span class='rem-member' data-member='@id_member' data-cluster='@id_cluster'></span>
|
<span class='rem-member' data-member='@id_machine' data-cluster='@id_machine_cluster'></span>
|
||||||
|
</span>";
|
||||||
|
break;
|
||||||
|
case 'user': return "
|
||||||
|
<span>
|
||||||
|
@username
|
||||||
|
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
|
||||||
</span>";
|
</span>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 'cluster': return "
|
case 'machine_cluster': return "
|
||||||
<article class='inline-box' id='@id_cluster'>
|
<article class='inline-box' id='@id_machine_cluster'>
|
||||||
<input type='hidden' value='@class'>
|
<input type='hidden' value='@class'>
|
||||||
|
|
||||||
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
||||||
<span class='link_remove' data-cluster='@id_cluster'>@icon_remove</span>
|
<span class='link_remove' data-cluster='@id_machine_cluster'>@icon_remove</span>
|
||||||
|
|
||||||
<span class='link_edit' data-cluster='@id_cluster'>@icon_edit</span>
|
<span class='link_edit' data-cluster='@id_machine_cluster'>@icon_edit</span>
|
||||||
|
|
||||||
<span class='code'>
|
<span class='code'>
|
||||||
@icon_type
|
@icon_type
|
||||||
<span>@_classtext (@nb_members)</span>
|
<span>machines (@nb_members)</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span class='groups'>
|
<span class='groups'>
|
||||||
@icon_group
|
@icon_group
|
||||||
@members
|
@machines
|
||||||
<span class='add-member' data-cluster='@id_cluster'>+</span>
|
<span class='add-member' data-cluster='@id_machine_cluster'>+</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</article>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
case 'user_cluster': return "
|
||||||
|
<article class='inline-box' id='@id_user_cluster'>
|
||||||
|
<input type='hidden' value='@class'>
|
||||||
|
|
||||||
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
||||||
|
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
|
||||||
|
|
||||||
|
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
|
||||||
|
|
||||||
|
<span class='code'>
|
||||||
|
@icon_type
|
||||||
|
<span>utilisateurs (@nb_members)</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class='groups'>
|
||||||
|
@icon_group
|
||||||
|
@users
|
||||||
|
<span class='add-member' data-cluster='@id_user_cluster'>+</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</article>";
|
</article>";
|
||||||
|
@ -82,7 +113,7 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
$CLUSTERLIST[$u]['_classtext'] = ($cluster['class']==0) ? 'utilisateurs' : 'machines';
|
$CLUSTERLIST[$u]['class'] = (isset($cluster['id_user_cluster'])) ? 0 : 1;
|
||||||
$CLUSTERLIST[$u]['nb_members'] = (count($members)<2) ? count($members).' membre' : count($members).'membres';
|
$CLUSTERLIST[$u]['nb_members'] = (count($members)<2) ? count($members).' membre' : count($members).'membres';
|
||||||
$CLUSTERLIST[$u]['icon_type'] = ($cluster['class']==0) ? file_get_contents( __ROOT__.'/src/static/menu-side/users.svg' ) : file_get_contents( __ROOT__.'/src/static/menu-side/device.svg' );
|
$CLUSTERLIST[$u]['icon_type'] = ($cluster['class']==0) ? file_get_contents( __ROOT__.'/src/static/menu-side/users.svg' ) : file_get_contents( __ROOT__.'/src/static/menu-side/device.svg' );
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\view\user;
|
||||||
|
use \manager\View;
|
||||||
|
use \manager\ModuleRequest;
|
||||||
|
use \manager\Authentification;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
|
||||||
|
class groups{
|
||||||
|
|
||||||
|
public static function template($type=null){
|
||||||
|
|
||||||
|
switch($type){
|
||||||
|
case 'user': return "
|
||||||
|
<span>
|
||||||
|
@username
|
||||||
|
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
|
||||||
|
</span>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case 'user_cluster': return "
|
||||||
|
<article class='inline-box' id='@id_user_cluster'>
|
||||||
|
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
||||||
|
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
|
||||||
|
|
||||||
|
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
|
||||||
|
|
||||||
|
<span class='code'>
|
||||||
|
@icon_type
|
||||||
|
<span>utilisateurs (@count)</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class='groups'>
|
||||||
|
@icon_group
|
||||||
|
@users
|
||||||
|
<span class='add-member' data-cluster='@id_user_cluster'>+</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</article>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default: return "
|
||||||
|
<input type='text' class='searchbar' placeholder='Recherche'>
|
||||||
|
@clusterlist";
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function view($params){
|
||||||
|
debug();
|
||||||
|
$view = '';
|
||||||
|
|
||||||
|
/* [1] On récupère la liste des utilisateurs
|
||||||
|
=========================================================*/
|
||||||
|
$request = new ModuleRequest('clusterDefault/getAll', [
|
||||||
|
'class' => 0
|
||||||
|
]);
|
||||||
|
$answer = $request->dispatch();
|
||||||
|
|
||||||
|
// si erreur, on affiche l'explicitation
|
||||||
|
if( $answer->error != ManagerError::Success )
|
||||||
|
return View::$htmlError;
|
||||||
|
|
||||||
|
$CLUSTERLIST = $answer->get('clusters');
|
||||||
|
|
||||||
|
|
||||||
|
foreach($CLUSTERLIST as $c=>$cluster){
|
||||||
|
$usersReq = new ModuleRequest('clusterDefault/getMembers', [
|
||||||
|
'id_cluster' => $cluster['id_user_cluster'],
|
||||||
|
'class' => 0
|
||||||
|
]);
|
||||||
|
$usersRes = $usersReq->dispatch();
|
||||||
|
|
||||||
|
/* (2) Gestion si erreur */
|
||||||
|
if( $usersRes->error == ManagerError::Success ) $users = $usersRes->get('members');
|
||||||
|
else $users = [];
|
||||||
|
|
||||||
|
$CLUSTERLIST[$c]['count'] = count($users);
|
||||||
|
|
||||||
|
$CLUSTERLIST[$c]['users'] = View::replaceMultiple(
|
||||||
|
self::template('user'),
|
||||||
|
$users,
|
||||||
|
[ 'id_user_cluster' => $cluster['id_user_cluster'] ]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$view_cluster = View::replaceMultiple(
|
||||||
|
self::template('user_cluster'),
|
||||||
|
$CLUSTERLIST, [
|
||||||
|
'icon_remove' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ),
|
||||||
|
'icon_edit' => file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ),
|
||||||
|
'icon_card' => file_get_contents( __ROOT__.'/src/static/container/card.svg' ),
|
||||||
|
'icon_mail' => file_get_contents( __ROOT__.'/src/static/container/mail.svg' ),
|
||||||
|
'icon_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return View::replaceSingle(self::template(), [ 'clusterlist' => $view_cluster ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -224,8 +224,6 @@
|
||||||
locked: false
|
locked: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var SYSTEM = {};
|
|
||||||
|
|
||||||
/* (2) Elements du DOM */
|
/* (2) Elements du DOM */
|
||||||
var mBox = document.getElementById('machine-box');
|
var mBox = document.getElementById('machine-box');
|
||||||
var led = document.getElementById('led');
|
var led = document.getElementById('led');
|
||||||
|
@ -247,20 +245,15 @@
|
||||||
lsi.createDataset('HISTORY.LOG');
|
lsi.createDataset('HISTORY.LOG');
|
||||||
lsi.createDataset('STATES.LOG' );
|
lsi.createDataset('STATES.LOG' );
|
||||||
|
|
||||||
|
|
||||||
/* (4) Récupération des données de fonctionnement */
|
/* (4) Récupération des données de fonctionnement */
|
||||||
var api = new APIClass('/api/');
|
var api = new APIClass('/api/');
|
||||||
|
|
||||||
api.send({path: 'machineDefault/init'}, function(response){
|
api.send({path: 'machineDefault/init'}, function(response){
|
||||||
SYSTEM = {
|
lsi.import('ACTIONS.CNF', response.actions);
|
||||||
action: response.actions,
|
lsi.import('STATES.CNF', response.states);
|
||||||
state: response.states
|
|
||||||
};
|
|
||||||
|
|
||||||
lsi.import('ACTIONS.CNF', SYSTEM.action);
|
|
||||||
lsi.import('STATES.CNF', SYSTEM.state);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/* [1] Fonctions
|
/* [1] Fonctions
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Gestion de mise à jour de la led en fonction de l'état
|
/* (1) Gestion de mise à jour de la led en fonction de l'état
|
||||||
|
@ -349,7 +342,7 @@
|
||||||
|
|
||||||
/* (2) Levé carte
|
/* (2) Levé carte
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
document.body.addEventListener('mouseup', function(e){
|
window.addEventListener('mouseup', function(e){
|
||||||
clearInterval(INTERVAL);
|
clearInterval(INTERVAL);
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
<span>Modification</span>
|
<span>Modification</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span data-sublink='filter' >
|
<span data-sublink='groups' >
|
||||||
<span class='svg'><?php echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/filter.svg' ); ?></span>
|
<span class='svg'><?php echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/filter.svg' ); ?></span>
|
||||||
<span>Filtrer</span>
|
<span>Groupes</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -164,12 +164,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Gestion de filtrage
|
/* [4] Gestion des groupes
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
echo "<section data-sublink='filter'>";
|
echo "<section data-sublink='groups' class='list'>";
|
||||||
|
|
||||||
echo "<form class='neutral'>";
|
$grouplist = new View('user.groups', []);
|
||||||
|
$grouplist->view();
|
||||||
echo "</form>";
|
|
||||||
|
|
||||||
echo '</section>';
|
echo '</section>';
|
||||||
|
|
Loading…
Reference in New Issue