From 3c70acd4ea9ea39ca3c93ff67d3bb23e739ff05d Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 14 Feb 2016 21:58:49 +0100 Subject: [PATCH] - [x] Creation de machine - [x] Creation d'utilisateur --- todo.md | 2 ++ view/js/machines.js | 69 +++++++++++++++++++++++++++++++++++++++++++++ view/js/users.js | 6 +++- view/machines.php | 25 +++++++++++++++- view/users.php | 5 +--- 5 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 view/js/machines.js diff --git a/todo.md b/todo.md index 8e2dc5b..47d37ea 100755 --- a/todo.md +++ b/todo.md @@ -22,6 +22,8 @@ ######## # FAIT # ######## +- [x] Creation de machine +- [x] Creation d'utilisateur - [x] Developpement de l'api cote client - [x] Dev des managers et de l'API et liste des acces - [x] [repo/cluster] getMembers diff --git a/view/js/machines.js b/view/js/machines.js new file mode 100644 index 0000000..df72169 --- /dev/null +++ b/view/js/machines.js @@ -0,0 +1,69 @@ +// On referencie toutes les sections +var section = { + view: { + text: '#CONTAINER > section[data-sublink="view"] ', + element: document.querySelector('#CONTAINER > section[data-sublink="view"]') + }, + + create: { + text: '#CONTAINER > section[data-sublink="create"] ', + element: document.querySelector('#CONTAINER > section[data-sublink="create"]') + } + +}; + + + +/* GESTION DE LA CREATION D'UNE MACHINE +* +*/ +if( section.create.element != null ){ + + // On recupere tous les champs + 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') + } + + // On initialise le gestionnaire des saisies + var createChecker = new inputChecker(); + + + /* (1) Gestion du code RFID */ + createChecker.append( section.create.input.code, format_code, '01-AB-CD-23'); + section.create.input.code.addEventListener('keyup', function(e){ + e.target.value = e.target.value.toUpperCase(); + if( !createChecker.check(e.target) ) + createChecker.correct(e.target, false); + + }, false); + + + /* (n) Gestion de l'envoi du formulaire */ + section.create.input.submit.addEventListener('click', function(e){ + // On annule l'envoi de base (PHP) + e.preventDefault(); + + var request = { + path: 'machineDefault/create', // On veut creer un utilisateur + data: [ + section.create.input.code.value, + section.create.input.name.value + ] + }; + + api.send(request, function(answer){ + if( answer.ModuleError == 0 ) // Tout s'est bien deroule + console.log('Machine cree!'); + else // Erreur + console.error('ModuleError::'+answer.ModuleError); + + }); + + + + }, false); + +} \ No newline at end of file diff --git a/view/js/users.js b/view/js/users.js index 9c927b5..ef2b5cb 100644 --- a/view/js/users.js +++ b/view/js/users.js @@ -65,7 +65,11 @@ if( section.create.element != null ){ }; api.send(request, function(answer){ - console.log(answer); + if( answer.ModuleError == 0 ) // Tout s'est bien deroule + console.log('Utilisateur cree!'); + else // Erreur + console.error('ModuleError::'+answer.ModuleError); + }); diff --git a/view/machines.php b/view/machines.php index 14d9865..c3181a1 100755 --- a/view/machines.php +++ b/view/machines.php @@ -74,7 +74,7 @@ echo "
"; // Prenom Nom - echo "".$machine['name'].""; + echo "#".$machine['name'].""; // Code RFID echo ""; @@ -102,3 +102,26 @@ } echo ''; + + + + + + + + + + + + + /* [2] Creation de machine + =========================================================*/ + echo "
"; + + echo "
"; + echo "
"; + echo "
"; + echo ""; + echo "
"; + + echo '
'; diff --git a/view/users.php b/view/users.php index 463782a..118ce43 100755 --- a/view/users.php +++ b/view/users.php @@ -74,7 +74,7 @@ echo "
"; // Prenom Nom - echo "".$user['username']." (".$user['firstname']." ".$user['lastname'].")"; + echo "".$user['firstname']." ".$user['lastname']." #".$user['username'].""; // Code RFID echo ""; @@ -126,9 +126,6 @@ /* [2] Creation d'utilisateur =========================================================*/ - $request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault' - $answer = $request->dispatch(); // On recupere la reponse - echo "
"; echo "
";