From 25c76aea20f123f25db1d32cda6cc1101206a6fc Mon Sep 17 00:00:00 2001 From: Alix JEUDI--LEMOINE Date: Thu, 29 May 2025 15:23:53 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20WIP:=20user=20list=20route?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/users/users.component.css | 0 src/app/components/users/users.component.html | 24 ++++++++++++ src/app/components/users/users.component.ts | 37 +++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 src/app/components/users/users.component.css create mode 100644 src/app/components/users/users.component.html create mode 100644 src/app/components/users/users.component.ts diff --git a/src/app/components/users/users.component.css b/src/app/components/users/users.component.css new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/users/users.component.html b/src/app/components/users/users.component.html new file mode 100644 index 0000000..a274c46 --- /dev/null +++ b/src/app/components/users/users.component.html @@ -0,0 +1,24 @@ +
+

Gestion des utilisateurs

+ +
+ + + + + + + + + + + + + +
Nom d'utilisateurStatut
{{ user.username }} + + {{ user.is_admin ? 'Administrateur' : 'Utilisateur' }} + +
+
+
\ No newline at end of file diff --git a/src/app/components/users/users.component.ts b/src/app/components/users/users.component.ts new file mode 100644 index 0000000..0d5285a --- /dev/null +++ b/src/app/components/users/users.component.ts @@ -0,0 +1,37 @@ +import { Component, OnInit } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { HttpClient } from '@angular/common/http'; +import { environment } from '../../../environment'; + +interface User { + _id: string; + username: string; + is_admin: boolean; +} + +@Component({ + selector: 'app-users', + templateUrl: './users.component.html', + styleUrls: ['./users.component.css'], + imports: [CommonModule] +}) +export class UsersComponent implements OnInit { + users: User[] = []; + + constructor(private http: HttpClient) {} + + ngOnInit(): void { + this.loadUsers(); + } + + private loadUsers(): void { + this.http.get(`${environment.apiURL}/admin/users`).subscribe( + users => { + this.users = users; + }, + error => { + console.error('Erreur lors du chargement des utilisateurs:', error); + } + ); + } +} \ No newline at end of file