Bladeren bron

dev en cours

rajah 11 maanden geleden
bovenliggende
commit
7539fc8fa0

+ 14 - 1
src/app/composants/account-details/account-details.component.html

@@ -21,6 +21,19 @@
 			</div>
 		</div>
 
+		<div class="form-group row">
+			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></label>
+			<div class="col-sm-8">
+				<div class="form-group field-separate">
+					<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role" disabled>
+						<option [value]="this.profils[0].key">{{ this.profils[0].value }}</option>
+						<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
+						<option [value]="this.profils[2].key" selected>{{ this.profils[2].value }}</option>
+					</select>
+				</div>
+			</div>
+		</div>
+
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Nom</span></label>
 			<div class="col-sm-8">
@@ -52,7 +65,7 @@
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Mot de passe</span></label>
 			<div class="col-sm-8">
-				<input type="password" class="form-control form-control-sm field-separate" id="motDePasse" name="motDePasse" [(ngModel)]="participant.motDePasse" disabled>
+				<button type="button" (click)="updateMotDePasse()" class="btn bg-gradient btn-primary btn-sm field-separate"><i class="fa-solid fa-key"></i>&nbsp;<span i18n>Modifier</span></button>
 			</div>
 		</div>
 

+ 15 - 3
src/app/composants/account-details/account-details.component.ts

@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
 import { FormsModule } from '@angular/forms';
 
 import { MenuComponent } from '../menu/menu.component';
-import { Participant } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ProfilList } from '../../interfaces/participant';
 import { AccountService } from '../../services/account.service'
 import { Journees } from '../../interfaces/divers';
 import { DiversService } from '../../services/divers.service'
@@ -13,14 +13,24 @@ import { DiversService } from '../../services/divers.service'
 export class AccountDetailsComponent implements OnInit, AfterViewInit
 {
 
+  profil: string = "";
+  profils: ParticipantEnum[] = ProfilList;
+
   journees: Journees = new Journees();
 
   participant: Participant = new Participant();
 
-  constructor(private diversService: DiversService, private accountService : AccountService, private router: Router, private menu: MenuComponent) { }
+  constructor(
+    private diversService: DiversService,
+    private accountService : AccountService,
+    private router: Router,
+    private menu: MenuComponent
+  ) { }
 
   ngOnInit()
   {
+    this.profil = this.accountService.getRole();
+
     this.journees = new Journees();
     this.diversService.getJournees().subscribe(data => { this.journees = data; });
 
@@ -32,6 +42,8 @@ export class AccountDetailsComponent implements OnInit, AfterViewInit
 
   updateProfil() { this.router.navigate(['/account-update']); }
 
-  goToHome(){ this.router.navigate(['/'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
+  updateMotDePasse() { this.router.navigate(['/account-password']); }
+
+  goToHome() { this.router.navigate(['/'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
 
 }

+ 0 - 0
src/app/composants/account-password/account-password.component.css


+ 1 - 0
src/app/composants/account-password/account-password.component.html

@@ -0,0 +1 @@
+<p>account-password works!</p>

+ 11 - 0
src/app/composants/account-password/account-password.component.ts

@@ -0,0 +1,11 @@
+import { Component } from '@angular/core';
+
+@Component({
+  selector: 'app-account-password',
+  imports: [],
+  templateUrl: './account-password.component.html',
+  styleUrl: './account-password.component.css'
+})
+export class AccountPasswordComponent {
+
+}

+ 13 - 7
src/app/composants/account-update/account-update.component.html

@@ -22,6 +22,19 @@
 			</div>
 		</div>
 
+		<div class="form-group row">
+			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></label>
+			<div class="col-sm-8">
+				<div class="form-group field-separate">
+					<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role" disabled>
+						<option [value]="this.profils[0].key">{{ this.profils[0].value }}</option>
+						<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
+						<option [value]="this.profils[2].key" selected>{{ this.profils[2].value }}</option>
+					</select>
+				</div>
+			</div>
+		</div>
+
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Nom</span>&nbsp;<sup><span class="text-danger">*</span></sup></label>
 			<div class="col-sm-8">
@@ -50,13 +63,6 @@
 			</div>
 		</div>
 
-		<div class="form-group row">
-			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Mot de passe</span></label>
-			<div class="col-sm-8">
-				<input type="password" class="form-control form-control-sm field-separate" id="motDePasse" name="motDePasse" [(ngModel)]="participant.motDePasse">
-			</div>
-		</div>
-
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Adresse</span></label>
 			<div class="col-sm-8">

+ 13 - 3
src/app/composants/account-update/account-update.component.ts

@@ -3,7 +3,7 @@ import { Router } from '@angular/router';
 import { FormsModule, NgForm } from '@angular/forms';
 
 import { MenuComponent } from '../menu/menu.component';
-import { Participant } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ProfilList } from '../../interfaces/participant';
 import { AccountService } from '../../services/account.service'
 import { Journees } from '../../interfaces/divers';
 import { DiversService } from '../../services/divers.service'
@@ -13,16 +13,26 @@ import { DiversService } from '../../services/divers.service'
 export class AccountUpdateComponent implements OnInit, AfterViewInit
 {
 
+  profil: string = "";
+  profils: ParticipantEnum[] = ProfilList;
+
   @ViewChild('formRef') participantForm!: NgForm;
 
   journees: Journees = new Journees();
 
   participant: Participant = new Participant();
 
-  constructor(private diversService: DiversService, private accountService : AccountService, private router: Router, private menu: MenuComponent) { }
+  constructor(
+    private diversService: DiversService,
+    private accountService : AccountService,
+    private router: Router,
+    private menu: MenuComponent
+  ) { }
 
   ngOnInit()
   {
+    this.profil = this.accountService.getRole();
+
     this.journees = new Journees();
     this.diversService.getJournees().subscribe(data => { this.journees = data; });
 
@@ -34,6 +44,6 @@ export class AccountUpdateComponent implements OnInit, AfterViewInit
 
   updateConfirmed() { if (this.participantForm.valid) { this.accountService.updateProfil(this.participant).subscribe(); this.goToHome(); } }
 
-  goToHome(){ this.router.navigate(['/'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
+  goToHome() { this.router.navigate(['/'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
 
 }

+ 1 - 0
src/app/composants/login/login.component.html

@@ -17,6 +17,7 @@
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Pseudonyme</span>&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" #userid id="userid" name="userid" [(ngModel)]="identifiants.username" #userRef="ngModel" required [class.is-invalid]="userRef.invalid && userRef.touched" autofocus>
+					<div class="form-text field-separate"><span i18n>Indiquez celui fourni lors de l'inscription, s'il est commun à d'autres participants, merci de contacter l'administrateur.</span></div>
 				</div>
 			</div>
 

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

@@ -13,7 +13,7 @@
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></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.role" required #statusRef="ngModel">
+						<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role">
 							<option [value]="this.profils[0].key">{{ this.profils[0].value }}</option>
 							<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
 							<option [value]="this.profils[2].key" selected>{{ this.profils[2].value }}</option>
@@ -26,7 +26,7 @@
 				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></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.role" required #statusRef="ngModel">
+						<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role">
 							<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
 							<option [value]="this.profils[2].key">{{ this.profils[2].value }}</option>
 						</select>
@@ -63,9 +63,9 @@
 			</div>
 
 			<div class="form-group row">
-				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Mot de passe</span></label>
+				<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Mot de passe</span>&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="motDePasse" name="motDePasse" [(ngModel)]="participant.motDePasse">
+					<input type="password" class="form-control form-control-sm field-separate" id="motDePasse" name="motDePasse" [(ngModel)]="participant.motDePasse" #mdpRef="ngModel" required [class.is-invalid]="mdpRef.invalid && mdpRef.touched">
 				</div>
 			</div>
 

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

@@ -48,6 +48,6 @@ export class ParticipantCreateComponent implements OnInit, AfterViewInit
 
   addParticipant() { if (this.participantForm.valid) { this.saveParticipant(); } }
 
-  goToListParticipant() {this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
+  goToListParticipant() { this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
 
 }

+ 13 - 0
src/app/composants/participant-details/participant-details.component.html

@@ -20,6 +20,19 @@
 				<input type="text" class="form-control form-control-sm field-separate" id="dateModification" name="dateModification" [(ngModel)]="participant.dateModification" disabled>
 			</div>
 		</div>
+		
+		<div class="form-group row">
+			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></label>
+			<div class="col-sm-8">
+				<div class="form-group field-separate">
+					<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role" disabled>
+						<option [value]="this.profils[0].key">{{ this.profils[0].value }}</option>
+						<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
+						<option [value]="this.profils[2].key" selected>{{ this.profils[2].value }}</option>
+					</select>
+				</div>
+			</div>
+		</div>
 
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Nom</span></label>

+ 16 - 3
src/app/composants/participant-details/participant-details.component.ts

@@ -3,16 +3,20 @@ import { ActivatedRoute, Router } from '@angular/router';
 import { FormsModule } from '@angular/forms';
 
 import { MenuComponent } from '../menu/menu.component';
-import { Participant, ParticipantEnum, ParticipantStatutList, ParticipantModePaiementList } from '../../interfaces/participant';
+import { Participant, ParticipantEnum, ProfilList, ParticipantStatutList, ParticipantModePaiementList } from '../../interfaces/participant';
 import { ParticipantService } from '../../services/participant.service';
 import { Journees } from '../../interfaces/divers';
 import { DiversService } from '../../services/divers.service'
+import { AccountService } from '../../services/account.service';
 
 @Component({ selector: 'app-participant-details', imports: [FormsModule, MenuComponent], templateUrl: './participant-details.component.html', styleUrl: './participant-details.component.css' })
 
 export class ParticipantDetailsComponent implements OnInit, AfterViewInit
 {
 
+  profil: string = "";
+  profils: ParticipantEnum[] = ProfilList;
+
   journees: Journees = new Journees();
 
   PS: ParticipantEnum[] = ParticipantStatutList;
@@ -21,10 +25,19 @@ export class ParticipantDetailsComponent implements OnInit, AfterViewInit
   numeroParticipant: number = 0;
   participant: Participant = new Participant();
 
-  constructor(private diversService: DiversService, private participantService: ParticipantService, private route: ActivatedRoute, private router: Router, private menu: MenuComponent) { }
+  constructor(
+    private diversService: DiversService,
+    private participantService: ParticipantService,
+    private route: ActivatedRoute,
+    private router: Router,
+    private menu: MenuComponent,
+    private accountService: AccountService
+  ) { }
 
   ngOnInit()
   {
+    this.profil = this.accountService.getRole();
+
     this.journees = new Journees();
     this.diversService.getJournees().subscribe(data => { this.journees = data; });
 
@@ -37,6 +50,6 @@ export class ParticipantDetailsComponent implements OnInit, AfterViewInit
 
   updateParticipant(id: number) { this.router.navigate(['/participant-update', id]); }
 
-  goToListParticipant(){ this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
+  goToListParticipant() { this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
 
 }

+ 28 - 0
src/app/composants/participant-update/participant-update.component.html

@@ -22,6 +22,33 @@
 			</div>
 		</div>
 
+@if (this.profil === "ADMIN") {
+		<div class="form-group row">
+			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></label>
+			<div class="col-sm-8">
+				<div class="form-group field-separate">
+					<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role">
+						<option [value]="this.profils[0].key">{{ this.profils[0].value }}</option>
+						<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
+						<option [value]="this.profils[2].key" selected>{{ this.profils[2].value }}</option>
+					</select>
+				</div>
+			</div>
+		</div>
+} @else if (this.profil === "ORGA") {
+		<div class="form-group row">
+			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Profil</span></label>
+			<div class="col-sm-8">
+				<div class="form-group field-separate">
+					<select class="form-select form-select-sm" id="role" name="role" [(ngModel)]="participant.role">
+						<option [value]="this.profils[1].key">{{ this.profils[1].value }}</option>
+						<option [value]="this.profils[2].key">{{ this.profils[2].value }}</option>
+					</select>
+				</div>
+			</div>
+		</div>
+}
+
 		<div class="form-group row">
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Nom</span>&nbsp;<sup><span class="text-danger">*</span></sup></label>
 			<div class="col-sm-8">
@@ -54,6 +81,7 @@
 			<label class="col-sm-4 col-form-label col-form-label-sm label-nobr"><span i18n>Mot de passe</span></label>
 			<div class="col-sm-8">
 				<input type="password" class="form-control form-control-sm field-separate" id="motDePasse" name="motDePasse" [(ngModel)]="participant.motDePasse">
+				<div class="form-text field-separate"><span i18n>Laisser ce champ vide si vous ne voulez pas changer le mot de passe actuel.</span></div>
 			</div>
 		</div>
 

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

@@ -14,7 +14,7 @@ import { AccountService } from '../../services/account.service';
 export class ParticipantUpdateComponent implements OnInit, AfterViewInit
 {
 
-  private profil: string = "";
+  profil: string = "";
   profils: ParticipantEnum[] = ProfilList;
 
   journees: Journees = new Journees();
@@ -53,6 +53,6 @@ export class ParticipantUpdateComponent implements OnInit, AfterViewInit
 
   deleteConfirmed() { this.participantService.deleteParticipant(this.numeroParticipant).subscribe(); this.goToListParticipant(); }
 
-  goToListParticipant(){ this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
+  goToListParticipant() { this.router.navigate(['/participant-list'], { queryParams: { 'refresh': this.menu.getRandomInteger(1, 100000) } }); }
 
 }