Correction et adaptation du module 'machineDefault' + Correction recherche instantannée pour 'machine' et 'user'
This commit is contained in:
parent
f5e116f7f2
commit
24709ad97c
|
@ -1,27 +1,5 @@
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
"machineDefault" :[
|
|
||||||
"create",
|
|
||||||
|
|
||||||
"link",
|
|
||||||
"unlink",
|
|
||||||
|
|
||||||
"search",
|
|
||||||
|
|
||||||
"getAll",
|
|
||||||
"getById",
|
|
||||||
"getByCode",
|
|
||||||
"getByName",
|
|
||||||
|
|
||||||
"getClusters",
|
|
||||||
|
|
||||||
"edit",
|
|
||||||
|
|
||||||
"delete"
|
|
||||||
],
|
|
||||||
|
|
||||||
|
|
||||||
"module": {
|
"module": {
|
||||||
"method": {
|
"method": {
|
||||||
"description": "Test de l'API",
|
"description": "Test de l'API",
|
||||||
|
@ -29,35 +7,6 @@
|
||||||
"parameters": {}
|
"parameters": {}
|
||||||
},
|
},
|
||||||
|
|
||||||
"phpunitParams": {
|
|
||||||
"description": "Méthode utile à phpunit pour le test des paramètres.",
|
|
||||||
"permissions": [],
|
|
||||||
"parameters": {
|
|
||||||
"p1": { "description": "Texte", "type": "text" },
|
|
||||||
"p2": { "description": "Entier positif", "type": "id" }
|
|
||||||
},
|
|
||||||
"output": {
|
|
||||||
"receivedArguments": { "description": "Liste des arguments reçus par la méthode", "type": "array<mixed>" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"phpunitOptionalParams": {
|
|
||||||
"description": "Méthode utile à phpunit pour le test des paramètres optionnels.",
|
|
||||||
"permissions": [],
|
|
||||||
"parameters": {
|
|
||||||
"p1": { "description": "Texte", "type": "text" },
|
|
||||||
"p2": { "description": "Texte", "type": "text", "optional": false },
|
|
||||||
"p3": { "description": "Entier positif (optionnel)", "type": "id", "optional": true }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
"phpunitPermissions": {
|
|
||||||
"description": "Méthode utile à phpunit pour le test des permissions.",
|
|
||||||
"permissions": ["a", "b"],
|
|
||||||
"parameters": {}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
"markdown": {
|
"markdown": {
|
||||||
"description": "Retourne une description en markdown des différents modules de l'API",
|
"description": "Retourne une description en markdown des différents modules de l'API",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
|
@ -65,7 +14,6 @@
|
||||||
"parameters": {}
|
"parameters": {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
"apiBlueprint": {
|
"apiBlueprint": {
|
||||||
"description": "Retourne une documentation de l'API au format API Blueprint.",
|
"description": "Retourne une documentation de l'API au format API Blueprint.",
|
||||||
"permissions": [],
|
"permissions": [],
|
||||||
|
@ -111,13 +59,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"userDefault": {
|
"userDefault": {
|
||||||
|
|
||||||
"create": {
|
"create": {
|
||||||
|
@ -253,7 +194,129 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
"machineDefault": {
|
||||||
|
"create": {
|
||||||
|
"description": "Création d'une nouvelle machine.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"code": { "description": "Code RFID de la machine.", "type": "rfid" },
|
||||||
|
"name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" },
|
||||||
|
"id_cluster": { "description": "UID du groupe de la machine.", "type": "id" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"link": {
|
||||||
|
"description": "Ajout d'une machine à un groupe.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" },
|
||||||
|
"id_cluster": { "description": "UID du groupe de la machine.", "type": "id" }
|
||||||
|
},
|
||||||
|
"output": {}
|
||||||
|
},
|
||||||
|
|
||||||
|
"unlink": {
|
||||||
|
"description": "Retrait d'une machine d'un groupe.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" },
|
||||||
|
"id_cluster": { "description": "UID du groupe de la machine.", "type": "id" }
|
||||||
|
},
|
||||||
|
"output": {}
|
||||||
|
},
|
||||||
|
|
||||||
|
"search": {
|
||||||
|
"description": "Recherche une machine par mots-clés.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"keywords": { "description": "Mots-clés de recherche de machine", "type": "text" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"machines": { "description": "Liste des machines correspondant à la recherche.", "type": "array<array<mixed>>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"getAll": {
|
||||||
|
"description": "Retourne la liste de toutes les machines.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {},
|
||||||
|
"output": {
|
||||||
|
"machines": { "description": "Liste de toutes les machines.", "type": "array<array<mixed>>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"getById": {
|
||||||
|
"description": "Retourne les données d'une machine.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"machine": { "description": "Données de la machine.", "type": "array<mixed>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"getByCode": {
|
||||||
|
"description": "Retourne les données d'une machine de code RFID donné.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"code": { "description": "Code RFID de la machine.", "type": "rfid" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"machine": { "description": "Données de la machine.", "type": "array<mixed>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"getByName": {
|
||||||
|
"description": "Retourne les données d'une machine de nom donné.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"machine": { "description": "Données de la machine.", "type": "array<mixed>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"getClusters": {
|
||||||
|
"description": "Retourne les groupes d'une machine.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"clusters": { "description": "Liste des groupes de la machine.", "type": "array<array<mixed>>" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"edit": {
|
||||||
|
"description": "Modifie les attributs d'une machine.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" },
|
||||||
|
"code": { "description": "Code RFID de la machine.", "type": "rfid", "optional": true },
|
||||||
|
"name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)", "optional": true }
|
||||||
|
},
|
||||||
|
"output": {}
|
||||||
|
},
|
||||||
|
|
||||||
|
"delete": {
|
||||||
|
"description": "Supprime une machine.",
|
||||||
|
"permissions": [],
|
||||||
|
"parameters": {
|
||||||
|
"id_machine": { "description": "UID de la machine.", "type": "id" }
|
||||||
|
},
|
||||||
|
"output": {
|
||||||
|
"status": { "description": "Status de la suppression.", "type": "boolean" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,7 +228,7 @@
|
||||||
// On verifie le type pour chaque element
|
// On verifie le type pour chaque element
|
||||||
foreach($value as $element)
|
foreach($value as $element)
|
||||||
// Si erreur dans au moins 1 element, on retourne que c'est incorrect
|
// Si erreur dans au moins 1 element, on retourne que c'est incorrect
|
||||||
if( !self::check($elements_type, $element) )
|
if( !self::check($elements_type, trim($element) ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Si aucune erreur, on retourne que tout est bon
|
// Si aucune erreur, on retourne que tout est bon
|
||||||
|
@ -270,7 +270,6 @@
|
||||||
|
|
||||||
case 'alphanumeric':
|
case 'alphanumeric':
|
||||||
case 'user.username':
|
case 'user.username':
|
||||||
case 'machine.name':
|
|
||||||
case 'group.name':
|
case 'group.name':
|
||||||
return $checker && is_string($value) && preg_match('/^[\w-]+$/i', $value);
|
return $checker && is_string($value) && preg_match('/^[\w-]+$/i', $value);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -18,20 +18,10 @@
|
||||||
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
* @return status<Boolean> Retourne si oui ou non, tout s'est bien passe
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function create($code=null, $name=null){
|
public static function create($params){
|
||||||
/* [1] Normalisation + verification des donnees
|
extract($params);
|
||||||
=========================================================*/
|
|
||||||
$correct_param = Database::check('machine.code', $code);
|
|
||||||
$correct_param = $correct_param && Database::check('machine.name', $name);
|
|
||||||
|
|
||||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
/* [1] Creation de la machine
|
||||||
if( !$correct_param )
|
|
||||||
return array('ModuleError' => ManagerError::ParamError);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [2] Creation de la machine
|
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_machine = new Repo('machine/create', array($code, $name) );
|
$create_machine = new Repo('machine/create', array($code, $name) );
|
||||||
$id_machine = $create_machine->answer();
|
$id_machine = $create_machine->answer();
|
||||||
|
@ -43,7 +33,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] Creation du groupe de meme nom que la machine
|
/* [2] Creation du groupe de meme nom que la machine
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$create_group = new Repo('cluster/create', array($name) );
|
$create_group = new Repo('cluster/create', array($name) );
|
||||||
$id_group = $create_group->answer();
|
$id_group = $create_group->answer();
|
||||||
|
@ -55,7 +45,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Association au groupe
|
/* [3] Association au groupe
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$assoc_goup = new Repo('cluster/link', array($id_group, $id_machine, clusterRepo::MACHINE_CLASS));
|
$assoc_goup = new Repo('cluster/link', array($id_group, $id_machine, clusterRepo::MACHINE_CLASS));
|
||||||
$id_assoc = $assoc_goup->answer();
|
$id_assoc = $assoc_goup->answer();
|
||||||
|
@ -66,7 +56,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [5] Gestion du retour
|
/* [4] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return array(
|
return array(
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
|
@ -88,21 +78,13 @@
|
||||||
* Renvoie FALSE si une erreur occure
|
* Renvoie FALSE si une erreur occure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function link($id_cluster, $id_machine){
|
public static function link($params){
|
||||||
/* [1] Normalisation + verification des donnees
|
extract($params);
|
||||||
=========================================================*/
|
|
||||||
$correct_param = Database::check('auto_increment_id', $id_cluster);
|
|
||||||
$correct_param = $correct_param && Database::check('auto_increment_id', $id_machine);
|
|
||||||
|
|
||||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
/* Creation de l'association */
|
||||||
if( !$correct_param )
|
|
||||||
return array('ModuleError' => ManagerError::ParamError);
|
|
||||||
|
|
||||||
/* [2] Creation de l'association
|
|
||||||
=========================================================*/
|
|
||||||
$link_machine = new Repo('cluster/link', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
$link_machine = new Repo('cluster/link', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
||||||
|
|
||||||
return $link_machine;
|
return array();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,21 +101,13 @@
|
||||||
* Renvoie FALSE si une erreur occure
|
* Renvoie FALSE si une erreur occure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function unlink($id_cluster, $id_machine){
|
public static function unlink($params){
|
||||||
/* [1] Normalisation + verification des donnees
|
extract($params);
|
||||||
=========================================================*/
|
|
||||||
$correct_param = Database::check('auto_increment_id', $id_cluster);
|
|
||||||
$correct_param = $correct_param && Database::check('auto_increment_id', $id_machine);
|
|
||||||
|
|
||||||
// Si les parametres ne sont pas corrects, on retourne une erreur
|
/* Suppression de l'association */
|
||||||
if( !$correct_param )
|
|
||||||
return array('ModuleError' => ManagerError::ParamError);
|
|
||||||
|
|
||||||
/* [2] Suppression de l'association
|
|
||||||
=========================================================*/
|
|
||||||
$link_machine = new Repo('cluster/unlink', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
$link_machine = new Repo('cluster/unlink', array($id_cluster, $id_machine, clusterRepo::MACHINE_CLASS));
|
||||||
|
|
||||||
return $link_machine;
|
return array();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,14 +117,16 @@
|
||||||
|
|
||||||
/* RENVOIE UNE MACHINE EN FONCTION D'UN MOT CLE
|
/* RENVOIE UNE MACHINE EN FONCTION D'UN MOT CLE
|
||||||
*
|
*
|
||||||
* @keyword<String> Element de recherche
|
* @keywords<String> Element de recherche
|
||||||
*
|
*
|
||||||
* @return machines<Array> Retourne la liste des machines trouvees
|
* @return machines<Array> Retourne la liste des machines trouvees
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function search($keyword){
|
public static function search($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$machine = new Repo('machine/search', array($keyword));
|
$machine = new Repo('machine/search', array($keywords));
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'machines' => $machine->answer()
|
'machines' => $machine->answer()
|
||||||
|
@ -186,14 +162,16 @@
|
||||||
* @return machine<Array> Machine d'UID donne
|
* @return machine<Array> Machine d'UID donne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getById($id_machine){
|
public static function getById($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getById', array($id_machine));
|
$request = new Repo('machine/getById', array($id_machine));
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -212,14 +190,45 @@
|
||||||
* @return machine<Array> Machine de code donne
|
* @return machine<Array> Machine de code donne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getByCode($code){
|
public static function getByCode($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getByCode', array($code));
|
$request = new Repo('machine/getByCode', array($code));
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||||
|
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'machine' => $answer
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RENVOIE LA MACHINE DE NAME DONNE
|
||||||
|
*
|
||||||
|
* @name<String> Name de l'utilisateur en question
|
||||||
|
*
|
||||||
|
* @return machine<Array> Machine de name donne
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function getByName($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
|
|
||||||
|
// On recupere les donnees
|
||||||
|
$request = new Repo('machine/getByName', array($name));
|
||||||
|
$answer = $request->answer();
|
||||||
|
|
||||||
|
// Si aucun resultat, on retourne une erreur
|
||||||
|
if( $answer === false )
|
||||||
|
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -238,14 +247,16 @@
|
||||||
* @return clusters<Array> Groupes de la machine donne
|
* @return clusters<Array> Groupes de la machine donne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getClusters($id_machine){
|
public static function getClusters($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/getClusters', array($id_machine));
|
$request = new Repo('machine/getClusters', array($id_machine));
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
||||||
// Si aucun resultat, on retourne une erreur
|
// Si aucun resultat, on retourne une erreur
|
||||||
if( $answer === false )
|
if( $answer === false )
|
||||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
return array( 'ModuleError' => ManagerError::NoMatchFound );
|
||||||
|
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
|
@ -266,10 +277,8 @@
|
||||||
* @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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function edit($id_machine=null, $code=null, $name=null){
|
public static function edit($params){
|
||||||
// Si @id_machine n'est pas au bon format, on retourne une erreur
|
extract($params);
|
||||||
if( !Database::check('auto_increment_id', $id_machine) )
|
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
|
||||||
|
|
||||||
|
|
||||||
/* [1] On verifie l'existence de la machine
|
/* [1] On verifie l'existence de la machine
|
||||||
|
@ -279,7 +288,7 @@
|
||||||
|
|
||||||
// Si on a recupere aucune machine, on retourne une erreur
|
// Si on a recupere aucune machine, on retourne une erreur
|
||||||
if( !is_array($machine_data) )
|
if( !is_array($machine_data) )
|
||||||
return array('ModuleError' => ManagerError::ModuleError);
|
return array('ModuleError' => ManagerError::NoMatchFound);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -289,8 +298,8 @@
|
||||||
|
|
||||||
/* (1) Verification des parametres (si correct et different)*/
|
/* (1) Verification des parametres (si correct et different)*/
|
||||||
$correct_param = array(
|
$correct_param = array(
|
||||||
'code' => Database::check('machine.code', $code ) && $machine_data['code'] != $code,
|
'code' => !is_null($code) && $machine_data['code'] != $code,
|
||||||
'name' => Database::check('machine.name', $name ) && $machine_data['name'] != $name
|
'name' => !is_null($name) && $machine_data['name'] != $name
|
||||||
);
|
);
|
||||||
|
|
||||||
/* (2) Gestion des parametres optionnels */
|
/* (2) Gestion des parametres optionnels */
|
||||||
|
@ -325,7 +334,9 @@
|
||||||
* @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
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function delete($id_machine){
|
public static function delete($params){
|
||||||
|
extract($params);
|
||||||
|
|
||||||
// On recupere les donnees
|
// On recupere les donnees
|
||||||
$request = new Repo('machine/delete', array($id_machine));
|
$request = new Repo('machine/delete', array($id_machine));
|
||||||
$answer = $request->answer();
|
$answer = $request->answer();
|
||||||
|
|
|
@ -0,0 +1,277 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\module;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\ResourceDispatcher;
|
||||||
|
|
||||||
|
class module{
|
||||||
|
|
||||||
|
/* PERMET DE TESTER L'API
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function method(){
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'ModuleError' => ManagerError::Success,
|
||||||
|
'ReceivedArguments' => func_get_args()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RENVOIE UNE DESCRIPTION EN MARKDOWN DES MODULES DE L'API
|
||||||
|
*
|
||||||
|
* @return markdown<String> Description des modules
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function markdown(){
|
||||||
|
/* [1] Récupération de la configuration
|
||||||
|
=========================================================*/
|
||||||
|
// On récupère le fichier et on le parse
|
||||||
|
$modules = json_decode( ResourceDispatcher::getResource('f/json/modules/conf'), true );
|
||||||
|
|
||||||
|
// Gestion de l'erreur de parsage
|
||||||
|
if( $modules == null )
|
||||||
|
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||||
|
|
||||||
|
/* [2] Mise en forme de la liste des modules
|
||||||
|
=========================================================*/
|
||||||
|
$markdown = "## Module List\n";
|
||||||
|
|
||||||
|
foreach($modules as $moduleName=>$moduleData)
|
||||||
|
$markdown .= "- $moduleName\n";
|
||||||
|
|
||||||
|
/* [3] Mise en forme des méthodes des modules
|
||||||
|
=========================================================*/
|
||||||
|
$markdown .= "----\n## Method List & Description\n";
|
||||||
|
|
||||||
|
$count = 1;
|
||||||
|
foreach($modules as $moduleName=>$moduleData){
|
||||||
|
$markdown .= "### $count - '$moduleName' methods\n";
|
||||||
|
|
||||||
|
foreach($moduleData as $methodName=>$methodData)
|
||||||
|
$markdown .= "`$methodName` - ".$methodData['description']."\n";
|
||||||
|
|
||||||
|
$markdown .= "----\n";
|
||||||
|
|
||||||
|
$count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [n] Gestion du retour
|
||||||
|
=========================================================*/
|
||||||
|
return array(
|
||||||
|
'ModuleError' => ManagerError::Success,
|
||||||
|
'headers' => array(
|
||||||
|
'Content-Type' => 'text/markdown; charset=utf-8',
|
||||||
|
'Content-Transfer-Encoding' => 'binary',
|
||||||
|
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
'Expires' => '0'
|
||||||
|
),
|
||||||
|
'body' => $markdown
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* RENVOIE UNE DOC API_BLUEPRINT DE L'API
|
||||||
|
*
|
||||||
|
* @return apiBlueprint<String> Description des modules au format API Blueprint
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function apiBlueprint(){
|
||||||
|
/* [0] Récupération de la configuration
|
||||||
|
=========================================================*/
|
||||||
|
// On récupère le fichier et on le parse
|
||||||
|
$modules = json_decode( ResourceDispatcher::getResource('f/json/modules/conf'), true );
|
||||||
|
|
||||||
|
// Gestion de l'erreur de parsage
|
||||||
|
if( $modules == null )
|
||||||
|
return array( 'ModuleError' => ManagerError::ParsingFailed );
|
||||||
|
|
||||||
|
|
||||||
|
/* [1] Début du fichier custom
|
||||||
|
=========================================================*/
|
||||||
|
$content = "FORMAT: 1A\n";
|
||||||
|
$content .= "HOST: https://socioview.xdrm.io/api/\n\n";
|
||||||
|
|
||||||
|
$content .= "# NxTIC API\n";
|
||||||
|
$content .= "API de la plateforme d'étude **NxTIC**, cette documentation présentera toutes les méthodes accessibles depuis la plateforme elle-même et depuis un logiciel tiers.\n";
|
||||||
|
$content .= "La plateforme **NxTIC** est une plateforme d'étude sociale développé par Adrien Marquès _(xdrm-brackets)_ pour un laboratoire de sociologie du _CNRS_.\n";
|
||||||
|
$content .= "Elle a pour objectif l'acquisition, la visualisation et l'extraction de données relationnelles.\n";
|
||||||
|
$content .= "> Cette plateforme est temporairement hébergée sur https://socioview.xdrm.io/.\n\n";
|
||||||
|
|
||||||
|
$content .= "## Structure et fonctionnement\n";
|
||||||
|
$content .= "Le fonctionnement est basé sur une délégation à 2 niveaux : des __modules__ contenant des __méthodes__.\n\n";
|
||||||
|
|
||||||
|
$content .= "***\n\n";
|
||||||
|
|
||||||
|
$content .= "### Paramètres\n";
|
||||||
|
$content .= "Tous les paramètres doivent être envoyés en `multipart/form-data`.\n\n";
|
||||||
|
|
||||||
|
$content .= "1. Chacun formatté en `json` \n";
|
||||||
|
$content .= "2. Portant le `nom` défini dans la documentation \n";
|
||||||
|
$content .= "3. L'ordre n'a pas d'importance \n";
|
||||||
|
$content .= "4. Respectant le `type` défini dans la documentation (cf. [Types](#introduction/types-de-donnees)) \n\n";
|
||||||
|
|
||||||
|
$content .= "> **Note:** Les `paramètres URI` ne correspondent pas aux paramètres URI. \n";
|
||||||
|
$content .= "Ils servent à expliciter les paramètres et leurs types, et correspondent aux variables notées `{nomVar}` dans le corps de la requête.\n\n";
|
||||||
|
|
||||||
|
$content .= "### Réponses\n\n";
|
||||||
|
|
||||||
|
$content .= "#### A. Les réponses seront formattées en json et contiendront:\n\n";
|
||||||
|
|
||||||
|
$content .= "1. `ModuleError` - Le code de l'erreur \n";
|
||||||
|
$content .= "2. `ErrorDescription` - La description de l'erreur\n\n";
|
||||||
|
|
||||||
|
$content .= "****\n\n";
|
||||||
|
|
||||||
|
$content .= "#### B. Codes `HTTP` et leur signification.\n\n";
|
||||||
|
|
||||||
|
$content .= "|Status|Code HTTP|\n";
|
||||||
|
$content .= "|---|---|\n";
|
||||||
|
$content .= "|OK|`200` - Success|\n";
|
||||||
|
$content .= "|Erreur|`417` - Erreur quelconque|\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
$content .= "## Types de données\n\n";
|
||||||
|
|
||||||
|
$content .= "### Types Simples \n";
|
||||||
|
$content .= "|Type|Exemple|Description|\n";
|
||||||
|
$content .= "|---|---|---|\n";
|
||||||
|
$content .= "|`mixed`|`[9,\"a\"]`, `\"a\"`|Type quelconque (peut être simple ou composé)|\n";
|
||||||
|
$content .= "|`id`|`10`, `\"23\"`|Nombre entier positif compris entre `0` et `2147483647`|\n";
|
||||||
|
$content .= "|`text`|`\"Hello!\"`|Chaine de caractères de longueur quelconque (peut être vide)|\n";
|
||||||
|
$content .= "|`mail`|`\"a.b@c.def\"`|Adresse mail avec une syntaxe valide|\n";
|
||||||
|
$content .= "|`number`|`0102030405`|Numéro de téléphone valide suivant les formats : `06`, `+336`, `+33 6`|\n";
|
||||||
|
$content .= "|`array`|`[1, 3]`|Tableau quelconque non vide|\n";
|
||||||
|
$content .= "|`boolean`|`true`, `false`|Booléen|\n";
|
||||||
|
$content .= "|`varchar(a,b)`|`\"Hello!\"`|Chaine de caractères de taille comprise entre `a` et `b` (inclus)|\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
$content .= "### Type composé : array\n\n";
|
||||||
|
|
||||||
|
$content .= "|Type|Sous-Type|Description|\n";
|
||||||
|
$content .= "|---|---|---|\n";
|
||||||
|
$content .= "|`array<mixed>`|`mixed`|Tableau contenant uniquement des données de type `mixed`|\n";
|
||||||
|
$content .= "|`array<id>`|`id`|Tableau contenant uniquement des données de type `id`|\n";
|
||||||
|
$content .= "|`array<text>`|`text`|Tableau contenant uniquement des données de type `text`|\n";
|
||||||
|
$content .= "|`array<mail>`|`mail`|Tableau contenant uniquement des données de type `mail`|\n";
|
||||||
|
$content .= "|`array<number>`|`number`|Tableau contenant uniquement des données de type `number`|\n";
|
||||||
|
$content .= "|`array<array>`|`array`|Tableau contenant uniquement des données de type `array`|\n";
|
||||||
|
$content .= "|`array<boolean>`|`boolean`|Tableau contenant uniquement des données de type `boolean`|\n";
|
||||||
|
$content .= "|`array<varchar(a,b)>`|`varchar(a,b)`|Tableau contenant uniquement des données de type `varchar(a,b)`|\n\n";
|
||||||
|
|
||||||
|
$content .= "> **Note:** Il est possible de chainer le type `array` autant de fois que nécessaire. \n";
|
||||||
|
$content .= "**Ex.:** `array<array<id>>` - Soit un tableau contenant des tableaux contenant exclusivement des données de type `id`.\n";
|
||||||
|
|
||||||
|
$content .= "\n\n\n\n\n";
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] Pour chaque module
|
||||||
|
=========================================================*/
|
||||||
|
foreach($modules as $module=>$methods){
|
||||||
|
|
||||||
|
$content .= "## $module [/$module] \n\n";
|
||||||
|
|
||||||
|
/* [3] Pour chaque méthode
|
||||||
|
=========================================================*/
|
||||||
|
foreach($methods as $methName=>$method){
|
||||||
|
|
||||||
|
/* (1) Description */
|
||||||
|
$content .= "### $methName [POST /$module/$methName]\n\n";
|
||||||
|
$content .= $method['description']."\n";
|
||||||
|
if( count($method['permissions']) > 0)
|
||||||
|
$content .= '> Permissions `'.implode('``', $method['permissions'])."`\n\n";
|
||||||
|
|
||||||
|
// Liste des paramètres
|
||||||
|
if( isset($method['parameters']) && count($method['parameters']) > 0 ){
|
||||||
|
// On explicite tous les paramètres
|
||||||
|
$content .= "+ Parameters\n\n";
|
||||||
|
foreach($method['parameters'] as $argName=>$argument){
|
||||||
|
$optional = isset($argument['optional']) && $argument['optional'] === true;
|
||||||
|
$content .= " + $argName (${argument['type']}, ".( $optional ? 'optional' : 'required' ).") - ${argument['description']}\n";
|
||||||
|
}
|
||||||
|
$content .= "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (2) Requête */
|
||||||
|
$content .= "+ Request (multipart/form-data; boundary=xxxBOUNDARYxxx)\n\n";
|
||||||
|
|
||||||
|
// Header
|
||||||
|
$content .= " + Headers\n\n";
|
||||||
|
$content .= " Authorization: Digest {yourAccessToken}\n";
|
||||||
|
$content .= " Cache-Control: no-cache\n";
|
||||||
|
|
||||||
|
if( isset($method['parameters']) && count($method['parameters']) > 0 ){
|
||||||
|
|
||||||
|
// Body
|
||||||
|
$content .= " + Body\n\n";
|
||||||
|
foreach($method['parameters'] as $argName=>$argument){
|
||||||
|
|
||||||
|
$content .= " --xxxBOUNDARYxxx\n";
|
||||||
|
$content .= " Content-Disposition: form-data; name=\"$argName\"\n";
|
||||||
|
$content .= " Content-Type: application/json\n\n";
|
||||||
|
$content .= " {".$argName."}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$content .= " --xxxBOUNDARYxxx--\n";
|
||||||
|
|
||||||
|
// Schema
|
||||||
|
$content .= " + Schema\n\n";
|
||||||
|
$content .= " {\n";
|
||||||
|
foreach($method['parameters'] as $argName=>$argData)
|
||||||
|
$content .= " \"$argName\": @$argName\n";
|
||||||
|
$content .= " }\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* (3) Réponse */
|
||||||
|
$content .= "\n+ Response 200 (application/json)\n\n";
|
||||||
|
if( isset($method['output']) && count($method['output']) > 0 ){
|
||||||
|
|
||||||
|
// Body
|
||||||
|
$content .= " + Body\n\n";
|
||||||
|
$content .= " {\n";
|
||||||
|
foreach($method['output'] as $outName=>$outData)
|
||||||
|
$content .= " \"$outName\": @$outName\n";
|
||||||
|
$content .= " }\n";
|
||||||
|
|
||||||
|
// Schema
|
||||||
|
$content .= " + Schema\n\n";
|
||||||
|
$content .= " {\n";
|
||||||
|
foreach($method['output'] as $outName=>$outData)
|
||||||
|
$content .= " \"$outName\": @$outName\n";
|
||||||
|
$content .= " }\n";
|
||||||
|
|
||||||
|
// On explicite tous les paramètres
|
||||||
|
$content .= " + Attributes (object)\n\n";
|
||||||
|
foreach($method['output'] as $outName=>$outData)
|
||||||
|
$content .= " + $outName (${outData['type']}) - ${outData['description']}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$content .= "\n\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'ModuleError' => ManagerError::Success,
|
||||||
|
'headers' => array(
|
||||||
|
'Content-Type' => 'application/octet-stream; charset=utf-8',
|
||||||
|
'Content-Transfer-Encoding' => 'binary',
|
||||||
|
'Content-Disposition' => 'attachment; filename=NxTIC.apib',
|
||||||
|
'Pragma' => 'no-cache',
|
||||||
|
'Expires' => '0'
|
||||||
|
),
|
||||||
|
'body' => $content
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -269,7 +269,7 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$edit_machine = Database::getPDO()->prepare("UPDATE machine
|
$edit_machine = Database::getPDO()->prepare("UPDATE machine
|
||||||
SET code = :code,
|
SET code = :code,
|
||||||
name = :name
|
name = :name
|
||||||
WHERE id_machine = :id_machine");
|
WHERE id_machine = :id_machine");
|
||||||
$edit_machine->execute(array(
|
$edit_machine->execute(array(
|
||||||
':code' => $code,
|
':code' => $code,
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
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.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)}
|
||||||
|
if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),name:document.querySelector(section.create.text+"#create_name"),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:"machineDefault/create",data:[section.create.input.code.value,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.remove.element){var autofill_remove=function(b){var a=a={id_machine:"",code:"",name:"",disable_input:!0};api.send({path:"machineDefault/getById",data:[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.code.value=a.code;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")},code:document.querySelector(section.remove.text+"#remove_code"),
|
||||||
|
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",data:[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&&(searchindex_remove=(searchindex_remove+1)%a.machines.length),lastsearch_remove=a.machines[searchindex_remove].id_machine,section.remove.input.search.id.value=lastsearch_remove,section.remove.input.search.sum.innerHTML=a.machines.length,autofill_remove(lastsearch_remove)):(section.remove.input.search.sum.innerHTML=0,autofill_remove(null))})},
|
||||||
|
!1);section.remove.input.submit.addEventListener("click",function(b){b.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"machineDefault/delete",data:[section.remove.input.search.id.value]},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine supprimee!"),section.remove.input.submit.anim("active",1500),autofill_remove(null)):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||||
|
if(null!=section.edit.element){var autofill_edit=function(b){var a={id_machine:"",code:"",name:"",disable_input:!0};isNaN(b)?section.edit.input.search.num.innerHTML=0:api.send({path:"machineDefault/getById",data:[b]},function(b){0==b.ModuleError&&(a=b.machine,a.disable_input=!1);section.edit.input.search.id.value=a.id_machine;section.edit.input.code.value=a.code;section.edit.input.name.value=a.name;section.edit.input.submit.disabled=a.disable_input;section.edit.input.search.num.innerHTML=searchindex_edit+
|
||||||
|
1})};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#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"),name:document.querySelector(section.edit.text+
|
||||||
|
"#edit_name"),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:"machineDefault/search",data:[section.edit.input.search.keyword.value]},function(a){0==a.ModuleError&&0<a.machines.length?(section.edit.input.search.submit.anim("active",
|
||||||
|
1E3),searchindex_edit=lastsearch_edit==a.machines[searchindex_edit].id_machine?(searchindex_edit+1)%a.machines.length:0,lastsearch_edit=a.machines[searchindex_edit].id_machine,section.edit.input.search.id.value=lastsearch_edit,section.edit.input.search.sum.innerHTML=a.machines.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:"machineDefault/edit",data:[section.edit.input.search.id.value,section.edit.input.code.value,section.edit.input.name.value]},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine modifiee!"),section.edit.input.submit.anim("active",1500),autofill_edit(section.edit.input.search.id.value)):console.error("ModuleError::"+a.ModuleError)})},!1)};
|
|
@ -41,7 +41,7 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'machineDefault/search',
|
path: 'machineDefault/search',
|
||||||
data: [section.view.searchbar.value]
|
keywords: section.view.searchbar.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// On envoie la requete
|
// On envoie la requete
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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"]')},
|
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"]')}};
|
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.searchbar.addEventListener("keyup",function(b){api.send({path:"userDefault/search",data:[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+
|
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.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]);
|
"> 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)}
|
navSubMenu("remove")},!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"),
|
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"),
|
||||||
|
|
|
@ -43,7 +43,7 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
var search = {
|
var search = {
|
||||||
path: 'userDefault/search',
|
path: 'userDefault/search',
|
||||||
data: [section.view.searchbar.value]
|
keywords: section.view.searchbar.value
|
||||||
};
|
};
|
||||||
|
|
||||||
// On envoie la requete
|
// On envoie la requete
|
||||||
|
|
Loading…
Reference in New Issue