From 8527024606b5178aaefb76e8c0a4ce56aafdb94b Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Mon, 7 Mar 2022 16:26:52 +0100 Subject: [PATCH 1/4] nettoyage code --- src/app/models/membre.ts | 3 --- src/app/pages/page-account/page-account.component.html | 2 +- src/app/pages/page-account/page-account.component.ts | 2 -- src/app/pages/page-add-member/page-add-member.component.ts | 1 - .../page-delete-member/page-delete-member.component.ts | 7 +------ .../pages/page-to-do-list/page-to-do-list.component.scss | 2 +- .../page-update-member/page-update-member.component.ts | 2 -- src/app/services/team.service.ts | 2 -- 8 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index a715404..f8fad13 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -1,5 +1,3 @@ -import { Team } from "./team"; - export interface Membre { id: string; nom: string; @@ -9,6 +7,5 @@ export interface Membre { dateNaissance: Date; couleur: string; passwordConfirm: string; - //team: Team; roleList: string[]; } diff --git a/src/app/pages/page-account/page-account.component.html b/src/app/pages/page-account/page-account.component.html index e87ebd6..22e9e59 100644 --- a/src/app/pages/page-account/page-account.component.html +++ b/src/app/pages/page-account/page-account.component.html @@ -24,7 +24,7 @@
- + diff --git a/src/app/pages/page-account/page-account.component.ts b/src/app/pages/page-account/page-account.component.ts index e705c09..8699f62 100644 --- a/src/app/pages/page-account/page-account.component.ts +++ b/src/app/pages/page-account/page-account.component.ts @@ -42,11 +42,9 @@ export class PageAccountComponent implements OnInit { const userRole = this.tokenService.getRole(); if(userRole == "ROLE_PARENT"){ this.parent = true; - console.log('Rôle : ' + userRole); } else if(userRole== "ROLE_ENFANT"){ this.parent = false; - console.log('Rôle : ' + userRole); } } diff --git a/src/app/pages/page-add-member/page-add-member.component.ts b/src/app/pages/page-add-member/page-add-member.component.ts index 5867f19..d5a1543 100644 --- a/src/app/pages/page-add-member/page-add-member.component.ts +++ b/src/app/pages/page-add-member/page-add-member.component.ts @@ -90,7 +90,6 @@ export class PageAddMemberComponent implements OnInit { const mail: Mail = { recipient: emailValue, subject: "Votre mot de passe Organizee", - //message: 'Votre mot de passe' message: `Bonjour ${firstNameValue}!\n Voici vos identifiants de connexion : \n Identifiant : ${emailValue} Mot de passe : ${passwordValue}` diff --git a/src/app/pages/page-delete-member/page-delete-member.component.ts b/src/app/pages/page-delete-member/page-delete-member.component.ts index 47a086d..f512194 100644 --- a/src/app/pages/page-delete-member/page-delete-member.component.ts +++ b/src/app/pages/page-delete-member/page-delete-member.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, OnInit, Output } from '@angular/core'; +import { Component,OnInit} from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { MembreService } from 'src/app/services/membre.service'; import { TokenService } from 'src/app/services/token.service'; @@ -16,7 +16,6 @@ export class PageDeleteMemberComponent implements OnInit { constructor(private membreService: MembreService, private tokenService: TokenService, - private router: Router, private route: ActivatedRoute) { this.membreInfos = ''; this.parent = false; @@ -32,7 +31,6 @@ export class PageDeleteMemberComponent implements OnInit { .getMembreId(this.membreId) .subscribe((membreInfos: any) => { this.membreInfos = membreInfos; - console.log(membreInfos.id); }); /** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/ @@ -40,17 +38,14 @@ export class PageDeleteMemberComponent implements OnInit { const userRole = this.tokenService.getRole(); if(userRole == "ROLE_PARENT"){ this.parent = true; - console.log('Rôle : ' + userRole); } else if(userRole== "ROLE_ENFANT"){ this.parent = false; - console.log('Rôle : ' + userRole); } } /********************** Suppresion d'un membre au click ********************/ onClickDelete(): void { - console.log(this.membreInfos); this.membreService.deleteMembre(this.membreInfos.id).subscribe((resp) => { return resp }); diff --git a/src/app/pages/page-to-do-list/page-to-do-list.component.scss b/src/app/pages/page-to-do-list/page-to-do-list.component.scss index 499b75c..72fe441 100644 --- a/src/app/pages/page-to-do-list/page-to-do-list.component.scss +++ b/src/app/pages/page-to-do-list/page-to-do-list.component.scss @@ -3,7 +3,7 @@ color: #5d5fef; font-size: 30px; margin-left: 240px; - margin-top: 40px; + margin-top: 20px; } .btn { diff --git a/src/app/pages/page-update-member/page-update-member.component.ts b/src/app/pages/page-update-member/page-update-member.component.ts index b7c5c52..cc90005 100644 --- a/src/app/pages/page-update-member/page-update-member.component.ts +++ b/src/app/pages/page-update-member/page-update-member.component.ts @@ -100,8 +100,6 @@ export class PageUpdateMemberComponent implements OnInit { roleList: [roleValue] }; - console.log(membre); - this.membreService.updateMembre(membre)?.subscribe((resp) => { this.router.navigate(['compte']); }); diff --git a/src/app/services/team.service.ts b/src/app/services/team.service.ts index 3e96bab..0de1c80 100644 --- a/src/app/services/team.service.ts +++ b/src/app/services/team.service.ts @@ -32,8 +32,6 @@ export class TeamService { } addTeam(team: Team): Observable { - console.log(team); - return this.http.post(`${this.apiUrl}/teams/add`, team); } From c07b32cad1a057ea3c2e0dc6b5f6a6c1e5fc3479 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Mon, 7 Mar 2022 18:29:53 +0100 Subject: [PATCH 2/4] =?UTF-8?q?avanc=C3=A9es=20signup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/models/membre.ts | 1 + .../page-signup/page-signup.component.ts | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index f8fad13..bda9dd1 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -8,4 +8,5 @@ export interface Membre { couleur: string; passwordConfirm: string; roleList: string[]; + teamId?: string; } diff --git a/src/app/pages/page-signup/page-signup.component.ts b/src/app/pages/page-signup/page-signup.component.ts index f46ce63..8ec6f26 100644 --- a/src/app/pages/page-signup/page-signup.component.ts +++ b/src/app/pages/page-signup/page-signup.component.ts @@ -5,7 +5,7 @@ import { FormGroup, Validators, } from '@angular/forms'; -import { Router, RouterLink } from '@angular/router'; +import { Router} from '@angular/router'; import { Team } from 'src/app/models/team'; import { TeamService } from 'src/app/services/team.service'; import { Membre } from '../../models/membre'; @@ -59,7 +59,7 @@ export class PageSignupComponent implements OnInit { } public onSubmit(): void { - const teamIdValue = this.signupForm.value['']; + let teamIdValue = ''; const teamNameValue = this.signupForm.value['teamNameFc']; const idValue = this.signupForm.value['']; const prenomValue = this.signupForm.value['firstNameFc']; @@ -85,16 +85,20 @@ export class PageSignupComponent implements OnInit { couleur: couleurValue, dateNaissance: dateNaissanceValue, passwordConfirm: passwordConfirmValue, - //team: teamIdValue, + teamId: teamIdValue, roleList: roleValue, }; if (membre.email !== '' && membre.password !== '' && team.nom!== '') { - this.teamService.addTeam(team).subscribe((resp) => { - return resp - }); - this.authService.signup(membre).subscribe((resp) => { - this.router.navigate(['accueil']); + this.teamService.addTeam(team).subscribe((respTeam) => { + teamIdValue = respTeam.id; + console.log(teamIdValue); + this.authService.signup(membre).subscribe((respMembre) => { + this.router.navigate(['accueil']); + console.log(teamIdValue); + return respMembre + }); + }); } else { // affichage erreur From bd9610275dbf37cc18846a8c1cab8d22e7c8a998 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Mon, 7 Mar 2022 20:03:04 +0100 Subject: [PATCH 3/4] modifs --- src/app/models/membre.ts | 4 +++- src/app/pages/page-signup/page-signup.component.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index bda9dd1..11849b0 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -1,3 +1,5 @@ +import { Team } from "./team"; + export interface Membre { id: string; nom: string; @@ -8,5 +10,5 @@ export interface Membre { couleur: string; passwordConfirm: string; roleList: string[]; - teamId?: string; + team?: Team[]; } diff --git a/src/app/pages/page-signup/page-signup.component.ts b/src/app/pages/page-signup/page-signup.component.ts index 8ec6f26..49fc0f8 100644 --- a/src/app/pages/page-signup/page-signup.component.ts +++ b/src/app/pages/page-signup/page-signup.component.ts @@ -85,7 +85,7 @@ export class PageSignupComponent implements OnInit { couleur: couleurValue, dateNaissance: dateNaissanceValue, passwordConfirm: passwordConfirmValue, - teamId: teamIdValue, + team:[teamIdValue, teamNameValue], roleList: roleValue, }; From 841d8fd78cb40a3acf75e274e57e06a377599e26 Mon Sep 17 00:00:00 2001 From: Sana EL HIRI Date: Tue, 8 Mar 2022 13:06:48 +0100 Subject: [PATCH 4/4] signup ok et delete membre ok --- src/app/models/membre.ts | 2 +- .../page-add-member.component.ts | 6 +-- .../page-delete-member.component.html | 2 +- .../page-delete-member.component.ts | 6 ++- .../page-signup/page-signup.component.ts | 38 +++++++++---------- .../page-update-member.component.html | 3 +- src/app/services/membre.service.ts | 2 +- src/environments/environment.ts | 3 +- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/app/models/membre.ts b/src/app/models/membre.ts index 11849b0..970362e 100644 --- a/src/app/models/membre.ts +++ b/src/app/models/membre.ts @@ -10,5 +10,5 @@ export interface Membre { couleur: string; passwordConfirm: string; roleList: string[]; - team?: Team[]; + team?: Team; } diff --git a/src/app/pages/page-add-member/page-add-member.component.ts b/src/app/pages/page-add-member/page-add-member.component.ts index cab3b5d..c9209e1 100644 --- a/src/app/pages/page-add-member/page-add-member.component.ts +++ b/src/app/pages/page-add-member/page-add-member.component.ts @@ -89,11 +89,11 @@ export class PageAddMemberComponent implements OnInit { const mail: Mail = { recipient: emailValue, - subject: "Votre mot de passe Organizee", + subject: "Votre mot de passe provisoire Organizee", message: `Bonjour ${firstNameValue}!\n Voici vos identifiants de connexion : \n Identifiant : ${emailValue} - Mot de passe : ${passwordValue} - Veuillez modifier votre mot de passe à la première connexion : + Mot de passe provisoire : ${passwordValue} + Veuillez modifier votre mot de passe dès la première connexion : http://localhost:4200/password-oublie ` }; diff --git a/src/app/pages/page-delete-member/page-delete-member.component.html b/src/app/pages/page-delete-member/page-delete-member.component.html index da8ade7..ee1f3fb 100644 --- a/src/app/pages/page-delete-member/page-delete-member.component.html +++ b/src/app/pages/page-delete-member/page-delete-member.component.html @@ -23,7 +23,7 @@ id = "bouton-ajout" type="button" class="btn btn-primary btn-lg bouton-oui" - (clickDelete)="onClickDelete()" + (click)="onClickDelete()" [hidden]="parent == false" >Oui, je souhaite supprimer ce compte diff --git a/src/app/pages/page-delete-member/page-delete-member.component.ts b/src/app/pages/page-delete-member/page-delete-member.component.ts index f512194..f923b58 100644 --- a/src/app/pages/page-delete-member/page-delete-member.component.ts +++ b/src/app/pages/page-delete-member/page-delete-member.component.ts @@ -16,6 +16,7 @@ export class PageDeleteMemberComponent implements OnInit { constructor(private membreService: MembreService, private tokenService: TokenService, + private router: Router, private route: ActivatedRoute) { this.membreInfos = ''; this.parent = false; @@ -46,8 +47,9 @@ export class PageDeleteMemberComponent implements OnInit { /********************** Suppresion d'un membre au click ********************/ onClickDelete(): void { - this.membreService.deleteMembre(this.membreInfos.id).subscribe((resp) => { - return resp + console.log("coucou"); + this.membreService.deleteMembre(this.membreInfos).subscribe((resp) => { + this.router.navigate(['compte']); }); } } diff --git a/src/app/pages/page-signup/page-signup.component.ts b/src/app/pages/page-signup/page-signup.component.ts index 49fc0f8..288acfd 100644 --- a/src/app/pages/page-signup/page-signup.component.ts +++ b/src/app/pages/page-signup/page-signup.component.ts @@ -59,7 +59,6 @@ export class PageSignupComponent implements OnInit { } public onSubmit(): void { - let teamIdValue = ''; const teamNameValue = this.signupForm.value['teamNameFc']; const idValue = this.signupForm.value['']; const prenomValue = this.signupForm.value['firstNameFc']; @@ -72,30 +71,31 @@ export class PageSignupComponent implements OnInit { const roleValue = ['ROLE_PARENT']; const team: Team = { - id : teamIdValue, + id : "", nom : teamNameValue, }; - const membre: Membre = { - id: idValue, - nom: nomValue, - prenom: prenomValue, - email: emailValue, - password: passwordValue, - couleur: couleurValue, - dateNaissance: dateNaissanceValue, - passwordConfirm: passwordConfirmValue, - team:[teamIdValue, teamNameValue], - roleList: roleValue, - }; - - if (membre.email !== '' && membre.password !== '' && team.nom!== '') { + if (emailValue !== '' && passwordValue !== '' && team.nom!== '') { + //création Team this.teamService.addTeam(team).subscribe((respTeam) => { - teamIdValue = respTeam.id; - console.log(teamIdValue); + //récupération de l'id auto-généré (respTeam.id) dans l'id team (team.id) + team.id = respTeam.id; + //création objet membre avec l'objet team crée + const membre: Membre = { + id: idValue, + nom: nomValue, + prenom: prenomValue, + email: emailValue, + password: passwordValue, + couleur: couleurValue, + dateNaissance: dateNaissanceValue, + passwordConfirm: passwordConfirmValue, + team: team, + roleList: roleValue, + }; + //création du membre en bdd avec l'objet membre this.authService.signup(membre).subscribe((respMembre) => { this.router.navigate(['accueil']); - console.log(teamIdValue); return respMembre }); diff --git a/src/app/pages/page-update-member/page-update-member.component.html b/src/app/pages/page-update-member/page-update-member.component.html index 5361655..32b822c 100644 --- a/src/app/pages/page-update-member/page-update-member.component.html +++ b/src/app/pages/page-update-member/page-update-member.component.html @@ -80,8 +80,7 @@ placeholder="" name="Role" formControlName="roleFc" - value="{{membreInfos.roleList}}" - [(ngModel)]="membreInfos.roleList" + value="" > diff --git a/src/app/services/membre.service.ts b/src/app/services/membre.service.ts index 5d30104..a69bb6b 100644 --- a/src/app/services/membre.service.ts +++ b/src/app/services/membre.service.ts @@ -46,7 +46,7 @@ export class MembreService { } deleteMembre(membre: Membre): Observable{ - return this.http.delete(`${this.apiUrl}/membres/delete/${membre.id}`); + return this.http.delete(`${this.apiUrl}/membres/delete/${membre.id}`, {responseType: "text"}); } updateMembre(membre: Membre): Observable | void { diff --git a/src/environments/environment.ts b/src/environments/environment.ts index bd6eab6..f6c7117 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -6,7 +6,8 @@ export const environment = { production: false, apiUrl: 'http://localhost:8088', tokenKey: 'TOKEN-ORGANIZEE', - debug: true, + // pour afficher des infos en mode debug + debug: false, }; /*