Vue 'machine.view' et 'group.view'
This commit is contained in:
parent
1631bb6406
commit
ea3557ef1d
|
@ -135,11 +135,17 @@
|
|||
|
||||
pointer-events: none;
|
||||
|
||||
path{
|
||||
path#stylisable{
|
||||
fill: #333 !important;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
path#stroke-stylisable{
|
||||
stroke: #333 !important;
|
||||
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -319,12 +325,15 @@
|
|||
input[type=text],
|
||||
input[type=mail],
|
||||
input[type=password],
|
||||
select,
|
||||
&.invalid > input[type=text],
|
||||
&.invalid > input[type=mail],
|
||||
&.invalid > input[type=password],
|
||||
&.invalid > select,
|
||||
input.invalid[type=text],
|
||||
input.invalid[type=mail],
|
||||
input.invalid[type=password]{
|
||||
input.invalid[type=password],
|
||||
select.invalid{
|
||||
display: inline-block;
|
||||
margin: 1em 0;
|
||||
padding: .7em 1em;
|
||||
|
@ -342,13 +351,27 @@
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
select{
|
||||
width: 100%;
|
||||
display: block;
|
||||
background: #fff;
|
||||
|
||||
option{
|
||||
padding: .5em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Champs valides
|
||||
&.valid > input[type=text],
|
||||
&.valid > input[type=mail],
|
||||
&.valid > input[type=password],
|
||||
&.valid > select,
|
||||
input.valid[type=text],
|
||||
input.valid[type=mail],
|
||||
input.valid[type=password]{
|
||||
input.valid[type=password],
|
||||
select.valid{
|
||||
&:focus,
|
||||
&:hover{
|
||||
border-color: $form-valid-color;
|
||||
|
@ -359,9 +382,11 @@
|
|||
&.neutral > input[type=text],
|
||||
&.neutral > input[type=mail],
|
||||
&.neutral > input[type=password],
|
||||
&.neutral > select,
|
||||
input.neutral[type=text],
|
||||
input.neutral[type=mail],
|
||||
input.neutral[type=password]{
|
||||
input.neutral[type=password],
|
||||
select.neutral{
|
||||
&:focus,
|
||||
&:hover{
|
||||
border-color: $form-neutral-color;
|
||||
|
@ -372,6 +397,7 @@
|
|||
&.search > input[type=text],
|
||||
&.search > input[type=mail],
|
||||
&.search > input[type=password],
|
||||
&.search > select,
|
||||
input.search[type=text],
|
||||
input.search[type=mail],
|
||||
input.search[type=password]{
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -101,7 +101,7 @@
|
|||
break;
|
||||
|
||||
case 'alphanumeric':
|
||||
return $checker && is_string($value) && preg_match('/^[\w\.-]+$/i', $value);
|
||||
return $checker && is_string($value) && preg_match('/^[\w\.-]+$/ui', $value);
|
||||
break;
|
||||
|
||||
case 'letters':
|
||||
|
|
|
@ -96,8 +96,8 @@
|
|||
|
||||
/* [2] On vérifie que le template existe
|
||||
=========================================================*/
|
||||
$class = '\\manager\\view\\'.$match[1];
|
||||
$method = $match[2];
|
||||
$class = '\\manager\\view\\'.$match[1].'\\'.$match[2];
|
||||
$method = 'view';
|
||||
|
||||
/* (1) On vérifie que la classe existe */
|
||||
if( !class_exists($class) ){
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
namespace manager\view\group;
|
||||
use \manager\View;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\Authentification;
|
||||
use \manager\ManagerError;
|
||||
|
||||
class view{
|
||||
|
||||
public static function template($type=null){
|
||||
|
||||
switch($type){
|
||||
case 'member': return "
|
||||
<span>
|
||||
@name
|
||||
<span class='rem-member' data-member='@id_member' data-cluster='@id_cluster'></span>
|
||||
</span>";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'cluster': return "
|
||||
<article class='inline-box' id='@id_cluster'>
|
||||
|
||||
<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_edit' data-cluster='@id_cluster'>@icon_edit</span>
|
||||
|
||||
<span class='code'>
|
||||
@icon_type
|
||||
|
||||
<span>@_classtext (@nb_members)</span>
|
||||
</span>
|
||||
|
||||
<span class='groups'>
|
||||
@icon_group
|
||||
@members
|
||||
<span class='add-group' data-cluster='@id_cluster'>+</span>
|
||||
</span>
|
||||
|
||||
</article>";
|
||||
break;
|
||||
|
||||
|
||||
default: return "
|
||||
<input type='text' class='searchbar' placeholder='Recherche'>
|
||||
@clusterlist";
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function view($params){
|
||||
$view = '';
|
||||
|
||||
/* [1] On récupère la liste des utilisateurs
|
||||
=========================================================*/
|
||||
$request = new ModuleRequest('clusterDefault/getAll'); // On utilise la methode 'getAll' du module 'clusterDefault'
|
||||
$answer = $request->dispatch(); // On recupere la reponse
|
||||
|
||||
// si erreur, on affiche l'explicitation
|
||||
if( $answer->error != ManagerError::Success )
|
||||
return "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
|
||||
|
||||
$CLUSTERLIST = $answer->get('clusters');
|
||||
|
||||
|
||||
foreach($CLUSTERLIST as $u=>$cluster){
|
||||
$membersReq = new ModuleRequest('clusterDefault/getMembers', [ 'id_cluster' => $cluster['id_cluster'] ]);
|
||||
$membersRes = $membersReq->dispatch();
|
||||
|
||||
/* (2) Gestion si erreur */
|
||||
if( $membersRes->error == ManagerError::Success ) $members = $membersRes->get('members');
|
||||
else $members = [];
|
||||
|
||||
$CLUSTERLIST[$u]['members'] = View::replaceMultiple(
|
||||
self::template('member'),
|
||||
$members,
|
||||
[ 'id_cluster' => $cluster['id_cluster'] ]
|
||||
);
|
||||
|
||||
|
||||
$CLUSTERLIST[$u]['_classtext'] = ($cluster['class']==0) ? 'utilisateurs' : 'machines';
|
||||
$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' );
|
||||
}
|
||||
|
||||
|
||||
$view_cluster = View::replaceMultiple(
|
||||
self::template('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 ]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace manager\view\machine;
|
||||
use \manager\View;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\Authentification;
|
||||
use \manager\ManagerError;
|
||||
|
||||
class view{
|
||||
|
||||
public static function template($type=null){
|
||||
|
||||
switch($type){
|
||||
case 'cluster': return "
|
||||
<span>
|
||||
@name
|
||||
<span class='rem-group' data-group='@id_cluster' data-machine='@id_machine'></span>
|
||||
</span>";
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case 'machine': return "
|
||||
<article class='inline-box' id='@id_machine'>
|
||||
|
||||
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
|
||||
<span class='link_remove' data-machine='@id_machine'>@icon_remove</span>
|
||||
|
||||
<span class='link_edit' data-machine='@id_machine'>@icon_edit</span>
|
||||
|
||||
<span class='groups'>
|
||||
@icon_group
|
||||
@grouplist
|
||||
<span class='add-group' data-machine='@id_machine'>+</span>
|
||||
</span>
|
||||
|
||||
</article>";
|
||||
break;
|
||||
|
||||
|
||||
default: return "
|
||||
<input type='text' class='searchbar' placeholder='Recherche'>
|
||||
@machinelist";
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static function view($params){
|
||||
$view = '';
|
||||
|
||||
/* [1] On récupère la liste des machines
|
||||
=========================================================*/
|
||||
$request = new ModuleRequest('machineDefault/getAll'); // On utilise la methode 'getAll' du module 'machineDefault'
|
||||
$answer = $request->dispatch(); // On recupere la reponse
|
||||
|
||||
// si erreur, on affiche l'explicitation
|
||||
if( $answer->error != ManagerError::Success )
|
||||
return "<span class='error'>Une erreur est survenue, veuilez contacter le webmaster si cette erreur persiste.</span>";
|
||||
|
||||
$MACHINELIST = $answer->get('machines');
|
||||
|
||||
|
||||
foreach($MACHINELIST as $u=>$machine){
|
||||
$clustersReq = new ModuleRequest('machineDefault/getClusters', [ 'id_machine' => $machine['id_machine'] ]);
|
||||
$clustersRes = $clustersReq->dispatch();
|
||||
|
||||
/* (2) Gestion si erreur */
|
||||
if( $clustersRes->error == ManagerError::Success ) $clusters = $clustersRes->get('clusters');
|
||||
else $clusters = [];
|
||||
|
||||
$MACHINELIST[$u]['grouplist'] = View::replaceMultiple(
|
||||
self::template('cluster'),
|
||||
$clusters,
|
||||
[ 'id_machine' => $machine['id_machine'] ]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$view_machine = View::replaceMultiple(
|
||||
self::template('machine'),
|
||||
$MACHINELIST, [
|
||||
'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_group' => file_get_contents( __ROOT__.'/src/static/container/group.svg' ),
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return View::replaceSingle(self::template(), [ 'machinelist' => $view_machine ]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace manager\view;
|
||||
namespace manager\view\user;
|
||||
use \manager\View;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\Authentification;
|
||||
use \manager\ManagerError;
|
||||
|
||||
class users{
|
||||
class view{
|
||||
|
||||
public static function templateUserlist($type=null){
|
||||
public static function template($type=null){
|
||||
|
||||
switch($type){
|
||||
case 'cluster': return "
|
||||
|
@ -23,7 +23,7 @@
|
|||
case 'user': return "
|
||||
<article class='inline-box' id='@id_user'>
|
||||
|
||||
<span class='title'>@firstname @lastname <span>#@username</span></span>
|
||||
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@firstname @lastname <span>#@username</span></span>
|
||||
<span class='link_remove' data-user='@id_user'>@icon_remove</span>
|
||||
|
||||
<span class='link_edit' data-user='@id_user'>@icon_edit</span>
|
||||
|
@ -59,7 +59,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
public static function userlist($params){
|
||||
public static function view($params){
|
||||
$view = '';
|
||||
|
||||
/* [1] On récupère la liste des utilisateurs
|
||||
|
@ -83,7 +83,7 @@
|
|||
else $clusters = [];
|
||||
|
||||
$USERLIST[$u]['grouplist'] = View::replaceMultiple(
|
||||
self::templateUserlist('cluster'),
|
||||
self::template('cluster'),
|
||||
$clusters,
|
||||
[ 'id_user' => $user['id_user'] ]
|
||||
);
|
||||
|
@ -91,7 +91,7 @@
|
|||
|
||||
|
||||
$view_user = View::replaceMultiple(
|
||||
self::templateUserlist('user'),
|
||||
self::template('user'),
|
||||
$USERLIST, [
|
||||
'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' ),
|
||||
|
@ -104,7 +104,7 @@
|
|||
|
||||
|
||||
|
||||
return View::replaceSingle(self::templateUserlist(), [ 'userlist' => $view_user ]);
|
||||
return View::replaceSingle(self::template(), [ 'userlist' => $view_user ]);
|
||||
}
|
||||
|
||||
|
|
@ -330,8 +330,8 @@
|
|||
}//createWarehouse();
|
||||
|
||||
debug();
|
||||
// $myView = new View('users.userlist', []);
|
||||
// $myView->view();
|
||||
$myView = new View('group.view', []);
|
||||
$myView->view();
|
||||
|
||||
|
||||
?>
|
||||
|
|
178
view/groups.php
178
view/groups.php
|
@ -1,5 +1,6 @@
|
|||
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||
require_once __ROOT__.'/manager/autoloader.php';
|
||||
use \manager\View;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
|
@ -55,87 +56,91 @@
|
|||
|
||||
echo "<section data-sublink='view' class='list'>";
|
||||
|
||||
// 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();
|
||||
$clusterView = new View('group.view', []);
|
||||
$clusterView->view();
|
||||
|
||||
// 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>";
|
||||
}
|
||||
|
||||
}
|
||||
// // 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>';
|
||||
|
||||
|
@ -155,13 +160,14 @@
|
|||
echo "<section data-sublink='create'>";
|
||||
|
||||
echo "<form class='valid'>";
|
||||
echo "<input id='create_code' type='text' placeholder='CO-DE-RF-ID'><br>";
|
||||
echo "<input id='create_username' type='text' placeholder='Username'><br>";
|
||||
echo "<input id='create_firstname' type='text' placeholder='Firstname'><br>";
|
||||
echo "<input id='create_lastname' type='text' placeholder='Lastname'><br>";
|
||||
echo "<input id='create_mail' type='text' placeholder='Mail'><br>";
|
||||
echo "<input id='create_password' type='password' placeholder='Password'><br>";
|
||||
echo "<input id='create_status' type='text' placeholder='Status'><br>";
|
||||
echo "<input id='create_name' type='text' placeholder='Nom'><br>";
|
||||
|
||||
echo "<select id='create_class'>
|
||||
<option value='-' selected disabled>Type de groupe</option>
|
||||
<option value='0'>utilisateurs</option>
|
||||
<option value='1'>machines</option>
|
||||
</select>";
|
||||
|
||||
echo "<button id='create_submit'>Créer</button>";
|
||||
echo "</form>";
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@ if(null!=section.view.element){section.view.link={edit:document.querySelectorAll
|
|||
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={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",code:section.create.input.code.value,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.remove.element){var autofill_remove=function(b){var a=a={id_machine:"",code:"",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.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",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&&(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",id_machine: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",id_machine: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",keywords: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",id_machine:section.edit.input.search.id.value,code:section.edit.input.code.value,name: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)};
|
||||
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.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&&
|
||||
(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",
|
||||
id_machine: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:"",name:"",disable_input:!0};isNaN(b)?section.edit.input.search.num.innerHTML=0:api.send({path:"machineDefault/getById",id_machine: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.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")},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",keywords: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",id_machine:section.edit.input.search.id.value,
|
||||
name: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)};
|
||||
|
|
|
@ -149,7 +149,6 @@ 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')
|
||||
|
@ -159,16 +158,6 @@ if( section.create.element != null ){
|
|||
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)
|
||||
|
@ -176,7 +165,6 @@ if( section.create.element != null ){
|
|||
|
||||
var request = {
|
||||
path: 'machineDefault/create', // On veut creer un utilisateur
|
||||
code: section.create.input.code.value,
|
||||
name: section.create.input.name.value
|
||||
};
|
||||
|
||||
|
@ -219,7 +207,6 @@ if( section.remove.element != null ){
|
|||
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')
|
||||
|
@ -231,10 +218,9 @@ if( section.remove.element != null ){
|
|||
|
||||
/* (2) Gestion de l'auto-remplissage par lien */
|
||||
function autofill_remove(id_machine){
|
||||
// On recupere le code + name de la machine selectionnee
|
||||
var machine_data = machine_data = {
|
||||
// On recupere le name de la machine selectionnee
|
||||
var machine_data = {
|
||||
id_machine: '',
|
||||
code: '',
|
||||
name: '',
|
||||
disable_input: true
|
||||
};
|
||||
|
@ -250,7 +236,6 @@ if( section.remove.element != null ){
|
|||
section.remove.input.search.id.value = machine_data.id_machine;
|
||||
|
||||
// Auto-remplissage du formulaire
|
||||
section.remove.input.code.value = machine_data.code;
|
||||
section.remove.input.name.value = machine_data.name;
|
||||
|
||||
// On gere le caractere "inactif" du submit
|
||||
|
@ -361,7 +346,6 @@ if( section.edit.element != null ){
|
|||
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')
|
||||
|
@ -373,10 +357,9 @@ if( section.edit.element != null ){
|
|||
|
||||
// Gestion de l'auto-remplissage par lien
|
||||
function autofill_edit(id_machine){
|
||||
// On recupere le code + name de la machine selectionnee
|
||||
// On recupere le name de la machine selectionnee
|
||||
var machine_data = {
|
||||
id_machine: '',
|
||||
code: '',
|
||||
name: '',
|
||||
disable_input: true
|
||||
};
|
||||
|
@ -395,7 +378,6 @@ if( section.edit.element != null ){
|
|||
section.edit.input.search.id.value = machine_data.id_machine;
|
||||
|
||||
// Auto-remplissage du formulaire
|
||||
section.edit.input.code.value = machine_data.code;
|
||||
section.edit.input.name.value = machine_data.name;
|
||||
|
||||
// On active ou pas le bouton "Modifier"
|
||||
|
@ -475,7 +457,6 @@ if( section.edit.element != null ){
|
|||
var request = {
|
||||
path: 'machineDefault/edit', // On veut creer une machine
|
||||
id_machine: section.edit.input.search.id.value,
|
||||
code: section.edit.input.code.value,
|
||||
name: section.edit.input.name.value
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||
require_once __ROOT__.'/manager/autoloader.php';
|
||||
use \manager\View;
|
||||
use \manager\ModuleRequest;
|
||||
use \manager\ManagerError;
|
||||
use \manager\Repo;
|
||||
|
@ -49,72 +50,10 @@
|
|||
/* [1] Affichage des machines
|
||||
=========================================================*/
|
||||
debug();
|
||||
$request = new ModuleRequest('machineDefault/getAll'); // On utilise la methode 'getAll' du module 'machineDefault'
|
||||
$answer = $request->dispatch(); // On recupere la reponse
|
||||
|
||||
echo "<section data-sublink='view' class='list'>";
|
||||
// echo 'Liste des utilisateurs: <br>';
|
||||
|
||||
// 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{
|
||||
// Barre de recherche
|
||||
echo "<input type='text' class='searchbar' placeholder='Recherche'>";
|
||||
|
||||
// Liste des machines
|
||||
foreach( $answer->get('machines') as $machine){
|
||||
|
||||
/* (1) On récupère les groupes de la machine */
|
||||
$clustersReq = new ModuleRequest('machineDefault/getClusters', [
|
||||
'id_machine' => $machine['id_machine']
|
||||
]);
|
||||
$clustersRes = $clustersReq->dispatch();
|
||||
|
||||
/* (2) Gestion si erreur */
|
||||
if( $clustersRes->error == ManagerError::Success ) $clusters = $clustersRes->get('clusters');
|
||||
else $clusters = [];
|
||||
|
||||
echo "<article class='inline-box' id='".$machine['id_machine']."'>";
|
||||
// Nom de la machine
|
||||
echo "<span class='title'>#".$machine['name']."</span>";
|
||||
|
||||
|
||||
|
||||
// Icone vers la suppression
|
||||
echo "<span class='link_remove' data-machine='".$machine['id_machine']."'>";
|
||||
echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' );
|
||||
echo "</span>";
|
||||
|
||||
// Icone vers la modification
|
||||
echo "<span class='link_edit' data-machine='".$machine['id_machine']."'>";
|
||||
echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' );
|
||||
echo "</span>";
|
||||
|
||||
|
||||
|
||||
// Groupes de la machine
|
||||
echo "<span class='groups'>";
|
||||
echo file_get_contents( __ROOT__.'/src/static/container/group.svg' );
|
||||
|
||||
if( $clusters != false )
|
||||
foreach($clusters as $cluster)
|
||||
if( $cluster['name'] != $machine['name'] ) // Si c'est le groupe personnel, on ne l'affiche pas
|
||||
echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-machine='".$machine['id_machine']."'></span></span>";
|
||||
|
||||
echo "<span class='add-group' data-machine='".$machine['id_machine']."'>+</span>";
|
||||
echo"</span>";
|
||||
|
||||
|
||||
echo "</article>";
|
||||
}
|
||||
|
||||
}
|
||||
$machineView = new View('machine.view', []);
|
||||
$machineView->view();
|
||||
|
||||
echo '</section>';
|
||||
|
||||
|
@ -134,7 +73,6 @@
|
|||
echo "<section data-sublink='create'>";
|
||||
|
||||
echo "<form class='valid'>";
|
||||
echo "<input id='create_code' type='text' placeholder='Code'><br>";
|
||||
echo "<input id='create_name' type='text' placeholder='Name'><br>";
|
||||
echo "<button id='create_submit'>Créer</button>";
|
||||
echo "</form>";
|
||||
|
@ -165,7 +103,6 @@
|
|||
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='remove_code' type='text' placeholder='CO-DE-RF-ID'><br>";
|
||||
echo "<input id='remove_name' type='text' placeholder='Name'><br>";
|
||||
echo "<button id='remove_submit'>Supprimer</button>";
|
||||
echo "</form>";
|
||||
|
@ -196,7 +133,6 @@
|
|||
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='edit_code' type='text' placeholder='Code'><br>";
|
||||
echo "<input id='edit_name' type='text' placeholder='Name'><br>";
|
||||
echo "<button id='edit_submit' disabled>Modifier</button>";
|
||||
echo "</form>";
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
=========================================================*/
|
||||
echo "<section data-sublink='view' class='list'>";
|
||||
|
||||
$userlist = new View('users.userlist');
|
||||
$userlist = new View('user.view');
|
||||
$userlist->view();
|
||||
|
||||
echo '</section>';
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
<script type='text/javascript' src='/js/lib/reset.js' ></script> <!-- Corrections Javascript natif (ajouts) -->
|
||||
<script type='text/javascript' src='/js/lib/api.js' ></script> <!-- Gestion des transactions avec le serveur -->
|
||||
<script type='text/javascript' src='/js/lib/page-manager.js' ></script> <!-- Gestion réseau/chargement/liens/URL -->
|
||||
<script type='text/javascript' src='/js/lib/form-deflater.js' ></script> <!-- Gestion des formulaires (Object) -->
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
|
Loading…
Reference in New Issue