rajah 1 год назад
Родитель
Сommit
7367dd6ab7
35 измененных файлов с 246 добавлено и 148 удалено
  1. 1 1
      angular.json
  2. 20 17
      src/app/app.component.html
  3. 6 6
      src/app/app.component.ts
  4. 9 8
      src/app/app.routes.ts
  5. 1 1
      src/app/composants/categorie-create/categorie-create.component.ts
  6. 0 0
      src/app/composants/home/home.component.css
  7. 15 0
      src/app/composants/home/home.component.html
  8. 29 0
      src/app/composants/home/home.component.ts
  9. 2 2
      src/app/composants/login/login.component.html
  10. 6 10
      src/app/composants/login/login.component.ts
  11. 3 3
      src/app/composants/participant-create/participant-create.component.html
  12. 2 2
      src/app/composants/participant-create/participant-create.component.ts
  13. 3 3
      src/app/composants/participant-details/participant-details.component.html
  14. 2 2
      src/app/composants/participant-details/participant-details.component.ts
  15. 11 11
      src/app/composants/participant-list/participant-list.component.html
  16. 2 2
      src/app/composants/participant-list/participant-list.component.ts
  17. 3 3
      src/app/composants/participant-update/participant-update.component.html
  18. 2 2
      src/app/composants/participant-update/participant-update.component.ts
  19. 2 2
      src/app/composants/production-list/production-list.component.html
  20. 8 2
      src/app/composants/production-list/production-list.component.ts
  21. 2 2
      src/app/composants/variable-create/variable-create.component.ts
  22. 5 0
      src/app/env.ts
  23. 0 28
      src/app/guards/auth.guard.ts
  24. 20 0
      src/app/guarfs/logged.guard.ts
  25. 8 0
      src/app/interfaces/divers.ts
  26. 0 6
      src/app/interfaces/login.ts
  27. 4 6
      src/app/interfaces/participant.ts
  28. 11 0
      src/app/interfaces/user.ts
  29. 43 0
      src/app/services/account.service.ts
  30. 0 25
      src/app/services/auth.service.ts
  31. 2 1
      src/app/services/categorie.service.ts
  32. 18 0
      src/app/services/divers.service.ts
  33. 2 1
      src/app/services/participant.service.ts
  34. 2 1
      src/app/services/production.service.ts
  35. 2 1
      src/app/services/variable.service.ts

+ 1 - 1
angular.json

@@ -5,7 +5,7 @@
   "projects": {
     "demovote-frontend": {
       "projectType": "application",
-      "schematics": { "@schematics/angular": { "component": { "spec": false }, "module": { "spec": false }, "service": { "spec": false } } },
+      "schematics": { "@schematics/angular": { "component": { "skipTests": true, "style": "css" }, "module": { "skipTests": true, "style": "css" }, "service": { "skipTests": true, "style": "css" } } },
       "root": "",
       "sourceRoot": "src",
       "prefix": "app",

+ 20 - 17
src/app/app.component.html

@@ -1,25 +1,28 @@
 <div class="d-flex flex-column flex-shrink-0 bg-body-tertiary" id="sidenav">
   <ul class="nav nav-pills nav-flush flex-column text-center">
-	 	<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_home title="Accueil" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-home" aria-label="Accueil"></i></a></li>
+	 	<li><a href="/home" class="nav-link rounded-0 bg-gradient" #menu_home title="Accueil" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-home" aria-label="Accueil"></i></a></li>
+@if (!this.logged) {
+		<li><a href="/login" class="nav-link rounded-0 bg-gradient" #menu_login title="Login" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-right-to-bracket" aria-label="Login"></i></a></li>
+}
+@if (this.logged) {		
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_account title="Compte" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-user" aria-label="Compte"></i></a></li>
+		<li><a href="/logout" class="nav-link rounded-0 bg-gradient" #menu_logout title="Logout" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-right-from-bracket" aria-label="Logout"></i></a></li>
+}
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_agenda title="Planning" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-clock" aria-label="Planning"></i></a></li>
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_webcams title="Caméras" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-eye" aria-label="Caméras"></i></a></li>
+@if (this.logged) {		
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_chat title="Messagerie" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-comments" aria-label="Messagerie"></i></a></li>
+}
+		<li><a href="/participant-list" class="nav-link rounded-0 bg-gradient" #menu_users title="Participants" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-users" aria-label="Participants"></i></a></li>
 
-		<li><a href="/login" class="nav-link rounded-0 bg-gradient" #menu_login title="Login" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-right-to-bracket" aria-label="Login"></i></a></li>
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_account title="Compte" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-user" aria-label="Compte"></i></a></li>
-		<li><a href="/logout" class="nav-link rounded-0 bg-gradient" #menu_logout title="Logout" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-right-from-bracket" aria-label="Logout"></i></a></li>
+		<li><a href="/categorie-list" class="nav-link rounded-0 bg-gradient" #menu_compos title="Catégories" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-layer-group" aria-label="Catégories"></i></a></li>
+		<li><a href="/production-list" class="nav-link rounded-0 bg-gradient" #menu_prods title="Productions" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-save" aria-label="Productions"></i></a></li>
 
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_agenda title="Planning" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-clock" aria-label="Planning"></i></a></li>
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_webcams title="Caméras" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-eye" aria-label="Caméras"></i></a></li>
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_chat title="Messagerie" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-comments" aria-label="Messagerie"></i></a></li>
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_shows title="Présentations" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-display" aria-label="Présentations"></i></a></li>
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_votes title="Voter" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-vote-yea" aria-label="Voter"></i></a></li>
+		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_results title="Résultats" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-trophy" aria-label="Résultats"></i></a></li>
 
-		<li><a href="/participant-list" class="nav-link rounded-0 bg-gradient" #menu_users title="Participants" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-users" aria-label="Participants"></i></a></li>
-
-		<li><a href="/categorie-list" class="nav-link rounded-0 bg-gradient" #menu_compos title="Catégories" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-layer-group" aria-label="Catégories"></i></a></li>
-		<li><a href="/production-list" class="nav-link rounded-0 bg-gradient" #menu_prods title="Productions" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-save" aria-label="Productions"></i></a></li>
-
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_shows title="Présentations" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-display" aria-label="Présentations"></i></a></li>
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_votes title="Voter" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-vote-yea" aria-label="Voter"></i></a></li>
-		<li><a href="#" class="nav-link rounded-0 bg-gradient" #menu_results title="Résultats" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-trophy" aria-label="Résultats"></i></a></li>
-
-		<li><a href="/variable-list" class="nav-link rounded-0 bg-gradient" #menu_params title="Paramétrages" data-bs-toggle="tooltip" data-bs-placement="right"> <i class="fa-solid fa-sliders-h" aria-label="Paramétrages"></i></a></li>
+		<li><a href="/variable-list" class="nav-link rounded-0 bg-gradient" #menu_params title="Paramétrages" data-bs-toggle="tooltip" data-bs-placement="right"><i class="fa-solid fa-sliders-h" aria-label="Paramétrages"></i></a></li>
 	</ul>
 </div>
 <div id="main">

+ 6 - 6
src/app/app.component.ts

@@ -2,7 +2,7 @@ import { Component, OnInit, ViewChild, ElementRef, Renderer2 } from '@angular/co
 import { RouterOutlet } from '@angular/router';
 import { FormsModule} from '@angular/forms';
 import { Router } from '@angular/router';  
-import { AuthService } from './services/auth.service';  
+import { AccountService } from './services/account.service';  
 
 declare var $: any;
 
@@ -12,6 +12,8 @@ export class AppComponent implements OnInit
 {
   title = 'demovote';
 
+  logged: boolean = false;
+
   @ViewChild('menu_home', {static: false}) menuItemHome!: ElementRef;
   @ViewChild('menu_login', {static: false}) menuItemLogin!: ElementRef;
   @ViewChild('menu_account', {static: false}) menuItemAccount!: ElementRef;
@@ -27,20 +29,18 @@ export class AppComponent implements OnInit
   @ViewChild('menu_results', {static: false}) menuItemResults!: ElementRef;
   @ViewChild('menu_params', {static: false}) menuItemParams!: ElementRef;
 
-  tok!: string | null;  
-
-  constructor(private router: Router, private authService: AuthService, private renderer: Renderer2) { }  
+  constructor(private router: Router, private accountService: AccountService, private renderer: Renderer2) { }  
   
   ngOnInit() 
   {
     $(document).ready(function() { $('[data-bs-toggle="tooltip"]').tooltip();});
 
-    this.tok = localStorage.getItem('token');  
+    this.logged = this.accountService.isLogged();
 	}
 
   logout() 
   {  
-    this.authService.deconnexion();  
+    this.accountService.logout();  
     this.router.navigate(['/']);  
   } 
   

+ 9 - 8
src/app/app.routes.ts

@@ -1,7 +1,8 @@
 import { NgModule } from '@angular/core';
 import { Routes, RouterModule } from '@angular/router';
+import { HomeComponent } from './composants/home/home.component';    
 import { LoginComponent } from './composants/login/login.component';    
-import { AuthGuard } from './guards/auth.guard';    
+//import { LoggedGuard } from './guards/logged.guard';    
 import { VariableListComponent } from './composants/variable-list/variable-list.component';
 import { VariableCreateComponent } from './composants/variable-create/variable-create.component';
 import { VariableDetailsComponent } from './composants/variable-details/variable-details.component';
@@ -21,12 +22,13 @@ import { ProductionUpdateComponent } from './composants/production-update/produc
 import { ProductionUploadComponent } from './composants/production-upload/production-upload.component';
 
 export const routes: Routes = [  
-  {path: '', redirectTo: 'production-list', pathMatch: 'full'},
+  {path: '', redirectTo: 'home', pathMatch: 'full'},
+  {path: 'home', component: HomeComponent},
   {path: 'login', component: LoginComponent},
-  {path: 'variable-list', component: VariableListComponent},
-  {path: 'variable-create', component: VariableCreateComponent},
-  {path: 'variable-details/:numeroVariable', component: VariableDetailsComponent},
-  {path: 'variable-update/:numeroVariable', component: VariableUpdateComponent},
+  {path: 'variable-list', component: VariableListComponent/*, canActivate: [LoggedGuard]*/},
+  {path: 'variable-create', component: VariableCreateComponent/*, canActivate: [LoggedGuard]*/},
+  {path: 'variable-details/:numeroVariable', component: VariableDetailsComponent/*, canActivate: [LoggedGuard]*/},
+  {path: 'variable-update/:numeroVariable', component: VariableUpdateComponent/*, canActivate: [LoggedGuard]*/},
   {path: 'categorie-list', component: CategorieListComponent},
   {path: 'categorie-create', component: CategorieCreateComponent},
   {path: 'categorie-details/:numeroCategorie', component: CategorieDetailsComponent},
@@ -44,8 +46,7 @@ export const routes: Routes = [
 
 @NgModule({
   imports: [RouterModule.forRoot(routes, { onSameUrlNavigation: 'reload' })],                                                                                                                                                                                                                                                                                                          
-  exports: [RouterModule],
-  providers: [AuthGuard]
+  exports: [RouterModule]
 })
 
 export class AppRoutingModule { }

+ 1 - 1
src/app/composants/categorie-create/categorie-create.component.ts

@@ -1,8 +1,8 @@
 import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
+import { Router } from '@angular/router';
 import { AppComponent } from '../../app.component';
 import { Categorie } from '../../interfaces/categorie';
 import { CategorieService } from '../../services/categorie.service';
-import { Router } from '@angular/router';
 import { FormsModule, NgForm } from '@angular/forms'; 
 
 @Component({ selector: 'app-categorie-create', imports: [FormsModule], templateUrl: './categorie-create.component.html', styleUrl: './categorie-create.component.css'})

+ 0 - 0
src/app/composants/home/home.component.css


+ 15 - 0
src/app/composants/home/home.component.html

@@ -0,0 +1,15 @@
+<div class="center" style="min-width: 30rem;">
+
+<p class="fs-2 text-center">Bienvenue @if (this.logged) { {{ this.pseudonyme }} }</p>
+
+@if (this.message) { 
+  @if (this.message.erreur) { <div class="alert alert-danger" role="alert"> {{ this.message.erreur }}</div> } 
+  @if (this.message.alerte) { <div class="alert alert-warning" role="alert"> {{ this.message.alerte }}</div> } 
+  @if (this.message.information) { <div class="alert alert-info" role="alert"> {{ this.message.information }}</div> } 
+  @if (this.message.autre) { <div class="alert alert-light" role="alert"> {{ this.message.autre }}</div> } 
+}
+
+@if (!this.logged) { <div class="alert alert-info" role="alert">Merci de vous <a href="/login">connecter</a> pour accéder à plus de fonctionnalités.</div> }
+
+
+</div>

+ 29 - 0
src/app/composants/home/home.component.ts

@@ -0,0 +1,29 @@
+import { Component, OnInit, AfterViewInit } from '@angular/core';
+import { AppComponent } from '../../app.component';
+import { Message } from '../../interfaces/divers';
+import { AccountService } from '../../services/account.service' 
+import { DiversService } from '../../services/divers.service' 
+
+@Component({ selector: 'app-home', imports: [], templateUrl: './home.component.html', styleUrl: './home.component.css' })
+
+export class HomeComponent implements OnInit, AfterViewInit 
+{
+
+  logged: boolean = false;
+  pseudonyme: string = "";
+  message: Message = new Message();
+  
+  constructor(private diversService: DiversService, private accountService: AccountService, private application: AppComponent) { }
+  
+  ngOnInit() 
+  { 
+    this.logged = this.accountService.isLogged();
+    
+    if (this.logged) { this.pseudonyme = this.accountService.getUsername(); }
+    
+    this.diversService.getMessage().subscribe(data => { this.message = data; });
+  } 
+  
+  ngAfterViewInit() { this.application.menuActivateHome(); }
+
+}

+ 2 - 2
src/app/composants/login/login.component.html

@@ -7,14 +7,14 @@
 			<div class="form-group row">
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Pseudonyme&nbsp;<sup><span class="text-danger">*</span></sup></label>
 				<div class="col-sm-8">
-					<input type="text" class="form-control form-control-sm field-separate" id="userid" name="userid" [(ngModel)]="identifiants.userid" #userRef="ngModel" required [class.is-invalid]="userRef.invalid && userRef.touched">
+					<input type="text" class="form-control form-control-sm field-separate" id="userid" name="userid" [(ngModel)]="identifiants.usr" #userRef="ngModel" required [class.is-invalid]="userRef.invalid && userRef.touched">
 				</div>
 			</div>
 
 			<div class="form-group row">
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Mot de passe&nbsp;<sup><span class="text-danger">*</span></sup></label>
 				<div class="col-sm-8">
-					<input type="password" class="form-control form-control-sm field-separate" id="userpwd" name="userpwd" [(ngModel)]="identifiants.userpwd" #passRef="ngModel" required [class.is-invalid]="passRef.invalid && passRef.touched">
+					<input type="password" class="form-control form-control-sm field-separate" id="userpwd" name="userpwd" [(ngModel)]="identifiants.pwd" #passRef="ngModel" required [class.is-invalid]="passRef.invalid && passRef.touched">
 				</div>
 			</div>
 

+ 6 - 10
src/app/composants/login/login.component.ts

@@ -1,8 +1,8 @@
 import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
 import { Router } from '@angular/router';  
 import { AppComponent } from '../../app.component';
-import { Login } from '../../interfaces/login';  
-import { AuthService } from '../../services/auth.service' 
+import { User } from '../../interfaces/user';  
+import { AccountService } from '../../services/account.service' 
 import { FormsModule, NgForm, NgModel } from '@angular/forms'; 
 
 @Component({ selector: 'app-login', imports: [FormsModule], templateUrl: './login.component.html', styleUrl: './login.component.css' })
@@ -14,11 +14,11 @@ export class LoginComponent implements OnInit, AfterViewInit
   @ViewChild('userRef') userField!: NgModel;
   @ViewChild('passRef') passField!: NgModel;
 
-  identifiants: Login = { userid: "", userpwd: "" }
+  identifiants: User = new User();
  
-  constructor(private router : Router, private authService : AuthService, private application: AppComponent) { }
+  constructor(private router : Router, private accountService : AccountService, private application: AppComponent) { }
   
-  ngOnInit() { this.authService.deconnexion(); } 
+  ngOnInit() { } 
   
   ngAfterViewInit() { this.application.menuActivateLogin(); }
  
@@ -26,11 +26,7 @@ export class LoginComponent implements OnInit, AfterViewInit
   {  
     if (this.loginForm.valid) 
     {
-      this.authService.connexion(this.identifiants);  
-      
-      localStorage.setItem('isConnecte', "true");  
-      localStorage.setItem('token', "from_API_javaspring");  
-      
+      this.accountService.login(this.identifiants);  
       this.router.navigate(['/']);  
     }
   } 

+ 3 - 3
src/app/composants/participant-create/participant-create.component.html

@@ -43,8 +43,8 @@
 
 			<div class="form-group row">
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Délai avant déconnexion</label>
-				<div class="col-sm-8">
-					<input type="text" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion">
+				<div class="col-sm-2">
+					<input type="number" min="5" max="60" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion">
 				</div>
 			</div>
 
@@ -94,7 +94,7 @@
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Status</label>
 				<div class="col-sm-8">
 					<div class="form-group field-separate">
-						<select class="form-select form-select-sm" id="status" name="status" [(ngModel)]="participant.status" required #statusRef="ngModel" [class.is-invalid]="statusRef.invalid && statusRef.touched">
+						<select class="form-select form-select-sm" id="status" name="status" [(ngModel)]="participant.statut" required #statusRef="ngModel" [class.is-invalid]="statusRef.invalid && statusRef.touched">
 							@for (ps of PS; track ps.key) { <option [value]="ps.key">{{ ps.value }}</option> }
 						</select>
 					</div>

+ 2 - 2
src/app/composants/participant-create/participant-create.component.ts

@@ -1,6 +1,6 @@
 import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
-import { Participant, ParticipantEnum, ParticipantStatusList, ParticipantModePaiementList } from '../../interfaces/participant';
 import { AppComponent } from '../../app.component';
+import { Participant, ParticipantEnum, ParticipantStatutList, ParticipantModePaiementList } from '../../interfaces/participant';
 import { ParticipantService } from '../../services/participant.service';
 import { Router } from '@angular/router';
 import { FormsModule, NgForm } from '@angular/forms'; 
@@ -10,7 +10,7 @@ import { FormsModule, NgForm } from '@angular/forms';
 export class ParticipantCreateComponent implements OnInit, AfterViewInit
 {
   
-  PS: ParticipantEnum[] = ParticipantStatusList;
+  PS: ParticipantEnum[] = ParticipantStatutList;
   PMP: ParticipantEnum[] = ParticipantModePaiementList;
 
   @ViewChild('formRef') participantForm!: NgForm;

+ 3 - 3
src/app/composants/participant-details/participant-details.component.html

@@ -56,8 +56,8 @@
 
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Délai avant déconnexion</label>
-			<div class="col-sm-8">
-				<input type="text" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion" disabled>
+			<div class="col-sm-2">
+				<input type="number" min="5" max="60" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion" disabled>
 			</div>
 		</div>
 
@@ -107,7 +107,7 @@
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Status</label>
 			<div class="col-sm-8">
 				<div class="form-group field-separate">
-					<select class="form-select form-select-sm" id="status" name="status" [(ngModel)]="participant.status" disabled>
+					<select class="form-select form-select-sm" id="status" name="status" [(ngModel)]="participant.statut" disabled>
 							@for (ps of PS; track ps.key) { <option [value]="ps.key">{{ ps.value }}</option> }
 					</select>
 				</div>

+ 2 - 2
src/app/composants/participant-details/participant-details.component.ts

@@ -1,7 +1,7 @@
 import { Component, OnInit, AfterViewInit } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
 import { AppComponent } from '../../app.component';
-import { Participant, ParticipantEnum, ParticipantStatusList, ParticipantModePaiementList } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ParticipantStatutList, ParticipantModePaiementList } from '../../interfaces/participant';
 import { ParticipantService } from '../../services/participant.service';
 import { FormsModule } from '@angular/forms'; 
 
@@ -10,7 +10,7 @@ import { FormsModule } from '@angular/forms';
 export class ParticipantDetailsComponent implements OnInit, AfterViewInit 
 {
   
-  PS: ParticipantEnum[] = ParticipantStatusList;
+  PS: ParticipantEnum[] = ParticipantStatutList;
   PMP: ParticipantEnum[] = ParticipantModePaiementList;
  
   numeroParticipant: number = 0;

+ 11 - 11
src/app/composants/participant-list/participant-list.component.html

@@ -14,28 +14,28 @@
 				<tr>
 					<th class="fs-6 label-nobr"><small>Nom</small></th>
 					<th class="fs-6 label-nobr"><small>Pseudonyme</small></th>
-					<th class="fs-6 label-nobr"><small>Arrivé</small></th>
 					<th class="fs-6 label-nobr"><small>Status</small></th>
+					<th class="fs-6 label-nobr"><small>Arrivé</small></th>
 				</tr>
 			</thead>
 			<tbody>
 				@for (participant of participants; track participant.numeroParticipant) {
 				<tr>
-					<td class="label-nobr">{{ participant.nom }}&nbsp;{{ participant.prenom }}&nbsp;&nbsp;</td>
+					<td class="label-nobr"><a (click)="formParticipant(participant.numeroParticipant)" class="link-primary pointeur-souris text-decoration-none">{{ participant.nom }}&nbsp;{{ participant.prenom }}</a>&nbsp;&nbsp;</td>
 					<td class="label-nobr"><a (click)="formParticipant(participant.numeroParticipant)" class="link-primary pointeur-souris text-decoration-none">{{ participant.pseudonyme }}</a>&nbsp;&nbsp;</td>
+					<td>
+					  @if (participant.statut === PS[0].key) { <i class="fa-solid fa-circle-xmark text-danger" title="{{ PS[0].value }}"></i> }
+					  @else if (participant.statut === PS[1].key) { <i class="fa-solid fa-circle-check text-success" title="{{ PS[1].value }}"></i> }  
+					  @else if (participant.statut === PS[2].key) { <i class="fa-solid fa-circle-check text-success" title="{{ PS[2].value }}"></i> }  
+					  @else if (participant.statut === PS[3].key) { <i class="fa-solid fa-circle-check text-success" title="{{ PS[3].value }}"></i> }  
+					  @else if (participant.statut === PS[4].key) { <i class="fa-solid fa-circle-check text-success" title="{{ PS[4].value }}"></i> }  
+					  @else if (participant.statut === PS[5].key) { <i class="fa-solid fa-circle-check text-primary" title="{{ PS[5].value }}"></i> }  
+					  @else if (participant.statut === PS[6].key) { <i class="fa-solid fa-circle-check text-primary" title="{{ PS[6].value }}"></i> } 
+					 </td>
 					<td>
 					  @if (participant.arrived) { <i class="fa-solid fa-circle-check text-success"></i> } 
 					  @else { <i class="fa-solid fa-circle-xmark text-danger"></i> }&nbsp;&nbsp;
 					</td>
-					<td>
-					  @if (participant.status === PS[0].key) { <i class="fa-solid fa-circle-xmark text-danger" title="{{ PS[0].value }}"></i> }
-					  @else if (participant.status === PS[1].key) { <i class="fa-solid fa-circle-xmark text-success" title="{{ PS[1].value }}"></i> }  
-					  @else if (participant.status === PS[2].key) { <i class="fa-solid fa-circle-xmark text-success" title="{{ PS[2].value }}"></i> }  
-					  @else if (participant.status === PS[3].key) { <i class="fa-solid fa-circle-xmark text-success" title="{{ PS[3].value }}"></i> }  
-					  @else if (participant.status === PS[4].key) { <i class="fa-solid fa-circle-xmark text-success" title="{{ PS[4].value }}"></i> }  
-					  @else if (participant.status === PS[5].key) { <i class="fa-solid fa-circle-xmark text-primary" title="{{ PS[5].value }}"></i> }  
-					  @else if (participant.status === PS[6].key) { <i class="fa-solid fa-circle-xmark text-primary" title="{{ PS[6].value }}"></i> } 
-					 </td>
 				</tr>
 				}
 			</tbody>

+ 2 - 2
src/app/composants/participant-list/participant-list.component.ts

@@ -1,7 +1,7 @@
 import { Component, OnInit, AfterViewInit } from '@angular/core';
 import { Router } from '@angular/router';
 import { AppComponent } from '../../app.component';
-import { Participant, ParticipantEnum, ParticipantStatusList } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ParticipantStatutList } from '../../interfaces/participant';
 import { ParticipantService } from '../../services/participant.service';
 
 @Component({ selector: 'app-participant-list', imports: [], templateUrl: './participant-list.component.html', styleUrl: './participant-list.component.css' })
@@ -9,7 +9,7 @@ import { ParticipantService } from '../../services/participant.service';
 export class ParticipantListComponent implements OnInit, AfterViewInit
 {
     
-  PS: ParticipantEnum[] = ParticipantStatusList;
+  PS: ParticipantEnum[] = ParticipantStatutList;
 
   participants: Participant[] = [];
 

+ 3 - 3
src/app/composants/participant-update/participant-update.component.html

@@ -57,8 +57,8 @@
 
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Délai avant déconnexion</label>
-			<div class="col-sm-8">
-				<input type="text" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion">
+			<div class="col-sm-2">
+				<input type="number" min="5" max="60" class="form-control form-control-sm field-separate" id="delaiDeconnexion" name="delaiDeconnexion" [(ngModel)]="participant.delaiDeconnexion">
 			</div>
 		</div>
 
@@ -108,7 +108,7 @@
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr">Status</label>
 			<div class="col-sm-8">
 				<div class="form-group field-separate">
-					<select class="form-select form-select-sm" id="status" name="status" [(ngModel)]="participant.status">
+					<select class="form-select form-select-sm" id="statut" name="statut" [(ngModel)]="participant.statut">
 							@for (ps of PS; track ps.key) { <option [value]="ps.key">{{ ps.value }}</option> }
 					</select>
 				</div>

+ 2 - 2
src/app/composants/participant-update/participant-update.component.ts

@@ -1,7 +1,7 @@
 import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
 import { ActivatedRoute, Router } from '@angular/router';
 import { AppComponent } from '../../app.component';
-import { Participant, ParticipantEnum, ParticipantStatusList, ParticipantModePaiementList } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ParticipantStatutList, ParticipantModePaiementList } from '../../interfaces/participant';
 import { ParticipantService } from '../../services/participant.service';
 import { FormsModule, NgForm } from '@angular/forms'; 
 
@@ -10,7 +10,7 @@ import { FormsModule, NgForm } from '@angular/forms';
 export class ParticipantUpdateComponent implements OnInit, AfterViewInit
 {
   
-  PS: ParticipantEnum[] = ParticipantStatusList;
+  PS: ParticipantEnum[] = ParticipantStatutList;
   PMP: ParticipantEnum[] = ParticipantModePaiementList;
 
   @ViewChild('formRef') participantForm!: NgForm;

+ 2 - 2
src/app/composants/production-list/production-list.component.html

@@ -24,8 +24,8 @@
 				 <small class="text-warning">{{ production.informationsPrivees }}</small>
        </div>
 			<div class="card-footer d-flex justify-content-between">
-			  <i class="fa-solid fa-download text-primary pointeur-souris" title="{{ production.nomArchive }} (v{{ production.numeroVersion }})" (click)="getFile(production.numeroProduction, production.nomArchive)"></i>
-				<i class="fa-solid fa-user-tie pointeur-souris" title="géré par {{ production.nomGestionnaire }}" style="margin-left:7px;"></i>
+			  <i class="fa-solid fa-download text-primary pointeur-souris" (click)="getFile(production.numeroProduction, production.nomArchive)" title="{{ production.nomArchive }} (v{{ production.numeroVersion }})"></i>
+				<i class="fa-solid fa-user-tie text-dark" style="margin-left:7px;" title="géré par {{ production.nomGestionnaire }}"></i>
 			</div>
 		</div>
 	}

+ 8 - 2
src/app/composants/production-list/production-list.component.ts

@@ -16,9 +16,15 @@ export class ProductionListComponent implements OnInit, AfterViewInit
 
   constructor(private productionService: ProductionService, private router: Router, private application: AppComponent) { }
 
-  ngOnInit(): void { this.retreiveDatas(); }
+  ngOnInit(): void 
+  {
+    this.retreiveDatas(); 
+  }
   
-  ngAfterViewInit() { this.application.menuActivateProds(); }
+  ngAfterViewInit() 
+  {
+    this.application.menuActivateProds(); 
+  }
 
   private retreiveDatas() { this.productionService.getListProduction().subscribe(data => { this.productions = data; }); }
 

+ 2 - 2
src/app/composants/variable-create/variable-create.component.ts

@@ -1,8 +1,8 @@
 import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
-import { Variable } from '../../interfaces/variable';
-import { VariableService } from '../../services/variable.service';
 import { AppComponent } from '../../app.component';
 import { Router } from '@angular/router';
+import { Variable } from '../../interfaces/variable';
+import { VariableService } from '../../services/variable.service';
 import { FormsModule, NgForm, NgModel } from '@angular/forms'; 
 
 @Component({ selector: 'app-variable-create', imports: [FormsModule], templateUrl: './variable-create.component.html', styleUrl: './variable-create.component.css' })

+ 5 - 0
src/app/env.ts

@@ -0,0 +1,5 @@
+
+export const Environnement = 
+{
+	apiUrl: 'http://localhost:8080/demovote-api/v1/'
+};

+ 0 - 28
src/app/guards/auth.guard.ts

@@ -1,28 +0,0 @@
-import { Injectable } from '@angular/core';      
-import { ActivatedRouteSnapshot, RouterStateSnapshot, CanActivate, Router } from '@angular/router';      
-import { Observable } from 'rxjs';      
-
-@Injectable({ providedIn: 'root' })
-
-export class AuthGuard implements CanActivate 
-{      
- 
-  constructor(private router: Router) { }
-  
-  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean 
-  {      
-    if (this.isLoggedIn()) { return true; }
-    
-    this.router.navigate(['/']);      
-
-    return false;      
-  }
-  
-  public isLoggedIn(): boolean 
-  {
-    let status = false;      
-    if (localStorage.getItem('isConnecte') == "true") { status = true; } else { status = false; }      
-    return status;      
-  }
-  
-}    

+ 20 - 0
src/app/guarfs/logged.guard.ts

@@ -0,0 +1,20 @@
+import { Injectable } from '@angular/core';
+import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+
+import { AccountService } from '../services/account.service';
+
+@Injectable({ providedIn: 'root' })
+
+export class LoggedGuard implements CanActivate 
+{      
+ 
+  constructor(private router: Router, private accountService: AccountService) {}
+  
+  canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean 
+  {      
+    if (this.accountService.isLogged()) { return true; }
+
+    return false;      
+  }
+   
+}    

+ 8 - 0
src/app/interfaces/divers.ts

@@ -0,0 +1,8 @@
+
+export class Message
+{
+  erreur: string = "";
+  alerte: string = "";
+  information: string = "";
+  autre: string = "";
+}

+ 0 - 6
src/app/interfaces/login.ts

@@ -1,6 +0,0 @@
-
-export class Login 
-{      
-  userid: string = "";    
-  userpwd: string = "";    
-}  

+ 4 - 6
src/app/interfaces/participant.ts

@@ -1,6 +1,6 @@
 export class ParticipantEnum { key!: string; value!: string; }
 
-export const ParticipantStatusList: ParticipantEnum[] = 
+export const ParticipantStatutList: ParticipantEnum[] = 
 [ 
   { key: "EN_ATTENTE", value: "En attente"}, 
   { key: "PAYE_CHEQUE", value: "Payé chèque"}, 
@@ -28,10 +28,8 @@ export class Participant
   nom: string = "";
   prenom: string = "";
   pseudonyme: string = "";
-  groupe: string = "";
   motDePasse: string = "";
-  passwordExpired: boolean = false;
-  dateExpiration: string = "";
+  groupe: string = "";
   delaiDeconnexion: number = 15;
   adresse: string = "";
   codePostal: string = "";
@@ -39,7 +37,7 @@ export class Participant
   pays: string = "";
   numeroTelephone: string = "";
   email: string = "";
-  status: string = "EN_ATTENTE";
+  statut: string = "EN_ATTENTE";
   withMachine: boolean = true;
   commentaire: string = "";
   hereDay1: boolean = false;
@@ -56,7 +54,7 @@ export class Participant
 export class ParticipantShort
 {
   numeroParticipant: number = 0;
+  pseudonyme: string = "";
   nom: string = "";
   prenom: string = "";
-  pseudonyme: string = "";
 }

+ 11 - 0
src/app/interfaces/user.ts

@@ -0,0 +1,11 @@
+
+export class User 
+{
+  usr: string = "";
+  pwd: string = "";
+  token: string = "";
+  id: number = 0;
+  nom: string = "";
+  prenom: string = "";
+  role: number = 0;
+}

+ 43 - 0
src/app/services/account.service.ts

@@ -0,0 +1,43 @@
+import { Injectable } from '@angular/core';
+import { Router } from '@angular/router';
+import { HttpClient } from '@angular/common/http';
+import { BehaviorSubject, Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
+import { Environnement } from '../env';
+import { User } from '../interfaces/user';
+
+@Injectable({ providedIn: 'root' })
+
+export class AccountService 
+{
+
+  private baseURL = Environnement.apiUrl + "account";
+
+  private userSubject: BehaviorSubject<User | null>;
+  
+  public user: Observable<User | null>;
+
+  constructor(private router: Router, private httpClient: HttpClient)
+  {
+    this.userSubject = new BehaviorSubject(JSON.parse(localStorage.getItem('user')!));
+    this.user = this.userSubject.asObservable();
+  }
+
+  public isLogged() { if (this.userSubject.value) { return true; } return false; }
+  public getUsername() { if (this.userSubject.value) { return this.userSubject.value.usr; } return ""; }
+  
+  login(user: User) 
+  {
+    return this.httpClient.post<User>(`${this.baseURL}/login`, user).pipe(map(u => { localStorage.setItem('user', JSON.stringify(u)); this.userSubject.next(u); return u; }));
+  }
+
+  logout() 
+  {
+    localStorage.removeItem('user');
+    this.userSubject.next(null);
+    this.router.navigate(['/']);
+  }
+
+  getListArrives(): Observable<User[]> { return this.httpClient.get<User[]>(`${this.baseURL}/available`); }
+
+}

+ 0 - 25
src/app/services/auth.service.ts

@@ -1,25 +0,0 @@
-import { Injectable } from '@angular/core';
-import { Login } from '../interfaces/login';
-import { HttpClient } from '@angular/common/http'
-
-@Injectable({ providedIn: 'root'})
-
-export class AuthService 
-{
-
-  private baseURL = "http://localhost:8080/demovote-api/v1/variable";
-
-  constructor(private httpClient: HttpClient) { }
- 
-  connexion(identifiants: Login): void
-  {
-    
-  }
-  
-  deconnexion(): void 
-  {
-    localStorage.setItem('isLoggedIn','false');    
-    localStorage.removeItem('token');    
-  }
-  
-}

+ 2 - 1
src/app/services/categorie.service.ts

@@ -1,6 +1,7 @@
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http'
 import { Observable } from 'rxjs';
+import { Environnement } from '../env';
 import { Categorie } from '../interfaces/categorie';
 
 @Injectable({ providedIn: 'root' })
@@ -8,7 +9,7 @@ import { Categorie } from '../interfaces/categorie';
 export class CategorieService 
 {
 
-  private baseURL = "http://localhost:8080/demovote-api/v1/categorie";
+  private baseURL = Environnement.apiUrl + "categorie";
 
   constructor(private httpClient: HttpClient) { }
   

+ 18 - 0
src/app/services/divers.service.ts

@@ -0,0 +1,18 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http'
+import { Observable } from 'rxjs';
+import { Environnement } from '../env';
+import { Message } from '../interfaces/divers';
+
+@Injectable({ providedIn: 'root' })
+
+export class DiversService 
+{
+
+  private baseURL = Environnement.apiUrl + "divers";
+
+  constructor(private httpClient: HttpClient) { }
+  
+  getMessage(): Observable<Message>{ return this.httpClient.get<Message>(`${this.baseURL}/welcome`); }
+  
+}

+ 2 - 1
src/app/services/participant.service.ts

@@ -1,6 +1,7 @@
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http'
 import { Observable } from 'rxjs';
+import { Environnement } from '../env';
 import { Participant, ParticipantShort } from '../interfaces/participant';
 
 @Injectable({ providedIn: 'root' })
@@ -8,7 +9,7 @@ import { Participant, ParticipantShort } from '../interfaces/participant';
 export class ParticipantService 
 {
 
-  private baseURL = "http://localhost:8080/demovote-api/v1/participant";
+  private baseURL = Environnement.apiUrl + "participant";
 
   constructor(private httpClient: HttpClient) { }
   

+ 2 - 1
src/app/services/production.service.ts

@@ -1,6 +1,7 @@
 import { Injectable } from '@angular/core';
 import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http'
 import { Observable } from 'rxjs';
+import { Environnement } from '../env';
 import { Production, ProductionShort, ProductionFile } from '../interfaces/production';
 
 @Injectable({ providedIn: 'root' })
@@ -8,7 +9,7 @@ import { Production, ProductionShort, ProductionFile } from '../interfaces/produ
 export class ProductionService 
 {
 
-  private baseURL = "http://localhost:8080/demovote-api/v1/production";
+  private baseURL = Environnement.apiUrl + "production";
 
   constructor(private httpClient: HttpClient) { }
   

+ 2 - 1
src/app/services/variable.service.ts

@@ -1,6 +1,7 @@
 import { Injectable } from '@angular/core';
 import { HttpClient } from '@angular/common/http'
 import { Observable } from 'rxjs';
+import { Environnement } from '../env';
 import { Variable, VariableType } from '../interfaces/variable';
 
 @Injectable({ providedIn: 'root' })
@@ -8,7 +9,7 @@ import { Variable, VariableType } from '../interfaces/variable';
 export class VariableService 
 {
 
-  private baseURL = "http://localhost:8080/demovote-api/v1/variable";
+  private baseURL = Environnement.apiUrl + "variable";
 
   constructor(private httpClient: HttpClient) { }