Prototype HTML pour la page des 'groupes'

This commit is contained in:
xdrm-brackets 2016-07-08 20:28:44 +02:00
parent 3b8705b1c8
commit 4c3dbdd5a7
5 changed files with 59 additions and 22 deletions

View File

@ -176,16 +176,16 @@
/* RENVOIE LA LISTE EXHAUSTIVE DES UTILISATEURS /* RENVOIE LA LISTE EXHAUSTIVE DES GROUPES
* *
* @return utilisateurs<Array> Liste des utilisateurs * @return clusters<Array> Liste des groupes
* *
*/ */
public static function getAll(){ public static function getAll(){
// On recupere les donnees // On recupere les donnees
$users = new Repo('user/getAll', [ $_SESSION['WAREHOUSE']['id'] ]); $clusters = new Repo('cluster/getAll', [ $_SESSION['WAREHOUSE']['id'] ]);
return [ 'users' => $users->answer() ]; return [ 'clusters' => $clusters->answer() ];
} }

View File

@ -235,6 +235,38 @@
/* RENVOIE LA LISTE DES GROUPES D'UN ENTREPOT
*
* @id_warehouse<int> UID de l'entrepot
*
* @return clusters<int> Renvoie la liste des groupes
* Renvoie FALSE si une erreur occure
*
*/
public static function getAll($id_warehouse){
// On ecrit la requete
$request = Database::getPDO()->prepare("SELECT c.*, count(cm.id_cluster_merge) as count
FROM cluster as c, cluster_merge as cm
WHERE cm.id_cluster = c.id_cluster
AND c.id_warehouse = :id_warehouse
GROUP BY c.id_cluster
ORDER BY c.name ASC");
// On execute la requete
$request->execute([
':id_warehouse' => $id_warehouse
]);
// On retourne en supprimant les indices numeriques
return Database::delNumeric( $request->fetchAll() );
}
/* RENVOIE LES MEMBRES D'UN GROUPE DONNE /* RENVOIE LES MEMBRES D'UN GROUPE DONNE
* *

View File

@ -48,13 +48,12 @@
/* [1] VIEW -> Liste des utilisateurs /* [1] VIEW -> Liste des groupes
=========================================================*/ =========================================================*/
$request = new ModuleRequest('userDefault/getAll'); // On utilise la methode 'getAll' du module 'userDefault' $request = new ModuleRequest('clusterDefault/getAll'); // On utilise la methode 'getAll' du module 'groupDefault'
$answer = $request->dispatch(); // On recupere la reponse $answer = $request->dispatch(); // On recupere la reponse
echo "<section data-sublink='view' class='list'>"; echo "<section data-sublink='view' class='list'>";
// echo 'Liste des utilisateurs: <br>';
// si erreur, on affiche l'explicitation // si erreur, on affiche l'explicitation
if( $answer->error != ManagerError::Success ){ if( $answer->error != ManagerError::Success ){
@ -70,24 +69,25 @@
echo "<input type='text' class='searchbar' placeholder='Recherche'>"; echo "<input type='text' class='searchbar' placeholder='Recherche'>";
// Liste des utilisateurs // Liste des utilisateurs
foreach( $answer->get('users') as $user){ // TODO: Récupérer la liste des utilisateurs et machines en implémentant 'clusterDefault/getMembers'
$clusters = new Repo('user/getClusters', array($user['id_user'])); // mettre dans la variable '$members'
$clusters = $clusters->answer();
echo "<article class='inline-box' id='".$user['id_user']."'>"; foreach($answer->get('clusters') as $cluster){
echo "<article class='inline-box' id='".$cluster['id_cluster']."'>";
// Prenom Nom // Prenom Nom
echo "<span class='title'>".$user['firstname']." ".$user['lastname']." <span>#".$user['username']."</span></span>"; echo "<span class='title'>".$cluster['name']."</span></span>";
// Icone vers la suppression // Icone vers la suppression
echo "<span class='link_remove' data-user='".$user['id_user']."'>"; echo "<span class='link_remove' data-cluster='".$cluster['id_cluster']."'>";
echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' ); echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/remove.svg' );
echo "</span>"; echo "</span>";
// Icone vers la modification // Icone vers la modification
echo "<span class='link_edit' data-user='".$user['id_user']."'>"; echo "<span class='link_edit' data-cluster='".$cluster['id_cluster']."'>";
echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' ); echo file_get_contents( __ROOT__.'/src/static/sub-menu-side/edit.svg' );
echo "</span>"; echo "</span>";
@ -98,7 +98,7 @@
echo file_get_contents( __ROOT__.'/src/static/container/card.svg' ); echo file_get_contents( __ROOT__.'/src/static/container/card.svg' );
echo "<span>"; echo "<span>";
echo $user['code']; echo "groupe d". ($cluster['class']==0 ? '\'utilisateurs' : 'e machines');
echo "</span>"; echo "</span>";
echo"</span>"; echo"</span>";
@ -106,8 +106,8 @@
echo "<span class='mail'>"; echo "<span class='mail'>";
echo file_get_contents( __ROOT__.'/src/static/container/mail.svg' ); echo file_get_contents( __ROOT__.'/src/static/container/mail.svg' );
echo "<a href='mailto:".$user['mail']."'><span>"; echo "<a href='mailto:".$cluster['mail']."'><span>";
echo $user['mail']; echo $cluster['count'].' membre(s)';
echo "</span></a>"; echo "</span></a>";
echo"</span>"; echo"</span>";
@ -115,9 +115,11 @@
echo "<span class='groups'>"; echo "<span class='groups'>";
echo file_get_contents( __ROOT__.'/src/static/container/group.svg' ); echo file_get_contents( __ROOT__.'/src/static/container/group.svg' );
if( $clusters != false ) foreach($members as $member)
foreach($clusters as $cluster) if( $member['name'] != $cluster['name'] ) // Si c'est le groupe personnel, on ne l'affiche pas
echo "<span>".$cluster['name']."</span>"; 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"</span>";

View File

@ -115,7 +115,9 @@
if( $clusters != false ) if( $clusters != false )
foreach($clusters as $cluster) 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>".$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 class='add-group' data-machine='".$machine['id_machine']."'>+</span>";
echo"</span>"; echo"</span>";

View File

@ -125,6 +125,7 @@
if( $clusters != false ) if( $clusters != false )
foreach($clusters as $cluster) foreach($clusters as $cluster)
if( $cluster['name'] != $user['username'] ) // 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-user='".$user['id_user']."'></span></span>"; echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-user='".$user['id_user']."'></span></span>";
echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>"; echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>";
echo"</span>"; echo"</span>";