diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index d43e8ef..b4b104e 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -7,7 +7,6 @@ import { PageAgendaComponent } from './pages/page-agenda/page-agenda.component'; import { PageAjoutContactComponent } from './pages/page-ajout-contact/page-ajout-contact.component'; import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component'; import { PageDashboardComponent } from './pages/page-dashboard/page-dashboard.component'; -import { PageDeleteAccountComponent } from './pages/page-delete-account/page-delete-account.component'; import { PageDeleteMemberComponent } from './pages/page-delete-member/page-delete-member.component'; import { PageForgotPasswordComponent } from './pages/page-forgot-password/page-forgot-password.component'; import { PageMenuSemaineComponent } from './pages/page-menu-semaine/page-menu-semaine.component'; @@ -17,11 +16,11 @@ import { PageRepertoireComponent } from './pages/page-repertoire/page-repertoire import { PageResetPasswordComponent } from './pages/page-reset-password/page-reset-password.component'; import { PageSignupComponent } from './pages/page-signup/page-signup.component'; import { PageToDoListComponent } from './pages/page-to-do-list/page-to-do-list.component'; -import { PageUpdateAccountComponent } from './pages/page-update-account/page-update-account.component'; import { PageUpdateMemberComponent } from './pages/page-update-member/page-update-member.component'; import { PageSupportComponent } from './pages/page-support/page-support.component'; import { FooterComponent } from './components/footer/footer.component'; import { AuthGuard } from './auth.guard'; +import { PageAjoutEvenementsComponent } from './pages/page-ajout-evenements/page-ajout-evenements.component'; const routes: Routes = [ { path: '', redirectTo: 'accueil', pathMatch: 'full' }, @@ -32,7 +31,6 @@ const routes: Routes = [ { path: 'agenda', canActivate: [AuthGuard], component: PageAgendaComponent }, { path: 'tableau-de-bord', canActivate: [AuthGuard], component: PageDashboardComponent }, { path: 'supprimer-membre', canActivate: [AuthGuard], component: PageDeleteMemberComponent }, - { path: 'supprimer-compte', canActivate: [AuthGuard], component: PageDeleteAccountComponent }, { path: 'password-oublie', component: PageForgotPasswordComponent }, { path: 'menu', canActivate: [AuthGuard], component: PageMenuSemaineComponent }, { path: 'repertoire', canActivate: [AuthGuard], component: PageRepertoireComponent }, @@ -40,11 +38,11 @@ const routes: Routes = [ { path: 'creation-compte', component: PageSignupComponent }, { path: 'page-support', component: PageSupportComponent}, { path: 'to-do-list', canActivate: [AuthGuard], component: PageToDoListComponent }, - { path: 'modifier-membre', canActivate: [AuthGuard], component: PageUpdateMemberComponent }, - { path: 'modifier-compte', canActivate: [AuthGuard], component: PageUpdateAccountComponent }, + { path: 'modifier-membre/:id', canActivate: [AuthGuard], component: PageUpdateMemberComponent }, { path: 'ajouter-contact', canActivate: [AuthGuard], component: PageAjoutContactComponent }, { path: 'creation-team', canActivate: [AuthGuard], component: PageCreationTeamComponent }, { path: 'footer', component: FooterComponent}, + { path: 'ajout-evenement', canActivate: [AuthGuard], component: PageAjoutEvenementsComponent }, { path: '**', component: PageNotFoundComponent }, ]; diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2ea2f43..31e7e57 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -23,10 +23,8 @@ import { MeteoComponent } from './components/meteo/meteo.component'; import { CalendrierComponent } from './components/calendrier/calendrier.component'; import { CardMemberComponent } from './components/card-member/card-member.component'; import { ToDoListComponent } from './components/to-do-list/to-do-list.component'; -import { TacheComponent } from './components/tache/tache.component'; import { CardMenuComponent } from './components/card-menu/card-menu.component'; import { FicheContactComponent } from './components/fiche-contact/fiche-contact.component'; -import { PaginationComponent } from './components/pagination/pagination.component'; import { CreneauComponent } from './components/creneau/creneau.component'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http'; @@ -35,8 +33,6 @@ import { PageModifierContactComponent } from './pages/page-modifier-contact/page import { PageCreationTeamComponent } from './pages/page-creation-team/page-creation-team.component'; import { AutofocusFixModule } from 'ngx-autofocus-fix'; import { FooterComponent } from './components/footer/footer.component'; -import { PageDeleteAccountComponent } from './pages/page-delete-account/page-delete-account.component'; -import { PageUpdateAccountComponent } from './pages/page-update-account/page-update-account.component'; import { DayPilot, DayPilotModule } from "@daypilot/daypilot-lite-angular"; import { registerLocaleData } from '@angular/common'; import localeFr from '@angular/common/locales/fr'; @@ -44,6 +40,7 @@ import { CardAvatarComponent } from './components/card-avatar/card-avatar.compon import { HumeurComponent } from './components/humeur/humeur.component'; import { DeconnexionComponent } from './components/deconnexion/deconnexion.component'; import { AlertComponent } from './components/alert/alert.component'; +import { PageAjoutEvenementsComponent } from './pages/page-ajout-evenements/page-ajout-evenements.component'; registerLocaleData(localeFr) @NgModule({ @@ -70,21 +67,18 @@ registerLocaleData(localeFr) CalendrierComponent, CardMemberComponent, ToDoListComponent, - TacheComponent, CardMenuComponent, FicheContactComponent, - PaginationComponent, CreneauComponent, PageAjoutContactComponent, PageModifierContactComponent, PageCreationTeamComponent, FooterComponent, - PageDeleteAccountComponent, - PageUpdateAccountComponent, CardAvatarComponent, DeconnexionComponent, HumeurComponent, - AlertComponent + AlertComponent, + PageAjoutEvenementsComponent ], imports: [ BrowserModule, diff --git a/src/app/auth.guard.ts b/src/app/auth.guard.ts index c457e30..f15980b 100644 --- a/src/app/auth.guard.ts +++ b/src/app/auth.guard.ts @@ -19,6 +19,7 @@ export class AuthGuard implements CanActivate { this.tokenKey = environment.tokenKey; } + //s'il n'y a pas de token, le user ne peut pas naviguer sur les url où cette option est activée canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot @@ -35,20 +36,17 @@ export class AuthGuard implements CanActivate { console.log('decodedToken : ', decodedToken); if (decodedToken.exp) { - console.log("Date d'exp decodedToken : ", decodedToken.exp); const dateExp = new Date(decodedToken.exp * 1000); if (new Date() >= dateExp) { - // le token a expiré, je n'autorise pas l'accès + // le token a expiré, je n'autorise pas l'accès et je redirige pour connexion this.router.navigate(['accueil']); return false; } } - - console.log("C'est ok ! "); return true; } else { console.log('You shall not pass !!!!'); - this.router.navigate(['accueil']); // redirection de notre utilisateur vers une url de notre application (dans notre code TS) + this.router.navigate(['accueil']); return false; } } diff --git a/src/app/components/card-avatar/card-avatar.component.html b/src/app/components/card-avatar/card-avatar.component.html index 4591621..d6969cb 100644 --- a/src/app/components/card-avatar/card-avatar.component.html +++ b/src/app/components/card-avatar/card-avatar.component.html @@ -1,13 +1,12 @@ -
-
-
-
- -
-
-

{{membre.prenom }} {{membre.nom }}

-
-
-
+
+ +
+
+
-
+ +
+
{{membre.prenom }} {{membre.nom }}
+
+ +
\ No newline at end of file diff --git a/src/app/components/card-avatar/card-avatar.component.scss b/src/app/components/card-avatar/card-avatar.component.scss index 91c7e56..86d9570 100644 --- a/src/app/components/card-avatar/card-avatar.component.scss +++ b/src/app/components/card-avatar/card-avatar.component.scss @@ -3,18 +3,14 @@ height: 60px; margin: 0 auto; background: black; - } -.card { - min-height: 8px; - border: none; - overflow: hidden; - border-radius: 8px; - justify-content: center; +.card-title{ + text-align: center; } - -h3 { - font-size: small; -} +.avatar{ + width: 150px; + height: 170px; + border-radius: 20px; +} \ No newline at end of file diff --git a/src/app/components/card-member/card-member.component.html b/src/app/components/card-member/card-member.component.html index f5c02f7..d6eb7af 100644 --- a/src/app/components/card-member/card-member.component.html +++ b/src/app/components/card-member/card-member.component.html @@ -7,7 +7,7 @@

{{membre.prenom }} {{membre.nom }}

+
-
- -
+ + + + + +
+ +
+
+ diff --git a/src/app/pages/page-account/page-account.component.scss b/src/app/pages/page-account/page-account.component.scss index d8b4580..790a2af 100644 --- a/src/app/pages/page-account/page-account.component.scss +++ b/src/app/pages/page-account/page-account.component.scss @@ -1,3 +1,29 @@ button{ margin-bottom: 5px; } + +#main{ + margin-top: 20px; +} + +ng-container{ + display: flex; +} + +#bouton-ajout { + margin-top: 5px; + border: 1px solid #7879F1 !important; + background-color: #7879F1; + color: #fff; + height: 50px; + width: 250px; +} + +#bouton-ajout:hover { + margin-top: 5px; + border: 1px solid #191933 !important; + background-color: #191933; + color: #fff; + height: 50px; + width: 250px; +} diff --git a/src/app/pages/page-account/page-account.component.ts b/src/app/pages/page-account/page-account.component.ts index 19a8af8..0814759 100644 --- a/src/app/pages/page-account/page-account.component.ts +++ b/src/app/pages/page-account/page-account.component.ts @@ -1,5 +1,9 @@ import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; import { MembreService } from 'src/app/services/membre.service'; +import { TeamService } from 'src/app/services/team.service'; +import { TokenService } from 'src/app/services/token.service'; + @Component({ @@ -9,16 +13,28 @@ import { MembreService } from 'src/app/services/membre.service'; }) export class PageAccountComponent implements OnInit { public listMembres: any[]; + currentUser: any; + currentTeam: any; - constructor(private membreService: MembreService) { + constructor(private membreService: MembreService, + private teamService: TeamService, + private tokenService: TokenService, + private router: Router) { this.listMembres = []; } ngOnInit(): void { + /** Récuperer la team du membre connecté **/ + this.teamService.getTeamById()?.subscribe((team) => { + this.currentTeam = team; + }); + /** Récuperer le membre connecté **/ + this.membreService.getMembreId(this.tokenService.getCurrentMembreId()).subscribe((user) => { + this.currentUser = user; + }); + /** Récuperer la liste des membres de la team **/ this.membreService.getMembresByTeamId()?.subscribe((membres: any[]) => { - console.log(membres); this.listMembres = membres; - - }); + }); } } diff --git a/src/app/pages/page-accueil/page-accueil.component.ts b/src/app/pages/page-accueil/page-accueil.component.ts index 490000a..9bfb412 100644 --- a/src/app/pages/page-accueil/page-accueil.component.ts +++ b/src/app/pages/page-accueil/page-accueil.component.ts @@ -10,7 +10,7 @@ import { TokenService } from 'src/app/services/token.service'; }) export class PageAccueilComponent implements OnInit { - constructor(private http: HttpClient, private router: Router, private tokenService: TokenService) { + constructor(private http: HttpClient, private router: Router, private tokenService: TokenService) { } diff --git a/src/app/pages/page-add-member/page-add-member.component.html b/src/app/pages/page-add-member/page-add-member.component.html index c7d87a6..5731f66 100644 --- a/src/app/pages/page-add-member/page-add-member.component.html +++ b/src/app/pages/page-add-member/page-add-member.component.html @@ -1,12 +1,12 @@ - +
-
+

Ajouter un nouveau membre à {{currentTeam.nom}}

-
+
+
- +
- +
-
+
Date de naissance
@@ -92,20 +93,7 @@ !addMemberForm.controls['emailFc'].valid }" /> - -
-
- - +
- +
Confirmez le mot de passe
+
+ + +
+
diff --git a/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts b/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts index 1076f68..34f9d99 100644 --- a/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts +++ b/src/app/pages/page-ajout-contact/page-ajout-contact.component.ts @@ -63,7 +63,7 @@ export class PageAjoutContactComponent implements OnInit { email: emailValue, dateNaissance: dateNaissanceValue, adresse: adresseValue, - team: { id: teamId }, // changer l'id quand la personne est logé => recuperer l'id de la team du membre + team: { id: teamId }, }; if (contact.nom !== '') { diff --git a/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.html b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.html new file mode 100644 index 0000000..4c68aa6 --- /dev/null +++ b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.html @@ -0,0 +1,78 @@ + + +
+
+ +
+
+

Ajouter un évènement à l'agenda

+
+
+ +
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+ + Annuler + +
+
+
+
+ \ No newline at end of file diff --git a/src/app/components/pagination/pagination.component.scss b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.scss similarity index 100% rename from src/app/components/pagination/pagination.component.scss rename to src/app/pages/page-ajout-evenements/page-ajout-evenements.component.scss diff --git a/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.spec.ts b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.spec.ts new file mode 100644 index 0000000..e28926a --- /dev/null +++ b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageAjoutEvenementsComponent } from './page-ajout-evenements.component'; + +describe('PageAjoutEvenementsComponent', () => { + let component: PageAjoutEvenementsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageAjoutEvenementsComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PageAjoutEvenementsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.ts b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.ts new file mode 100644 index 0000000..3d06070 --- /dev/null +++ b/src/app/pages/page-ajout-evenements/page-ajout-evenements.component.ts @@ -0,0 +1,71 @@ +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { Router } from '@angular/router'; +import { EvenementService } from 'src/app/services/evenement.service'; +import { TokenService } from 'src/app/services/token.service'; + +@Component({ + selector: 'app-page-ajout-evenements', + templateUrl: './page-ajout-evenements.component.html', + styleUrls: ['./page-ajout-evenements.component.scss'] +}) +export class PageAjoutEvenementsComponent implements OnInit { + public eventForm: FormGroup; + public userId : any; + public teamId : any; + public isShow: boolean; + public alert:any; + + constructor(private evenementService:EvenementService, private tokenService: TokenService, private router: Router,) { + this.eventForm = new FormGroup({}); + this.isShow = false; + this.alert = ""; + } + + ngOnInit(): void { + this.userId = this.tokenService.getCurrentMembreId(); + this.teamId = this.tokenService.getCurrentTeamId(); + + this.eventForm = new FormGroup({ + startDateFc : new FormControl(''), + startHourFc : new FormControl(''), + endDateFc : new FormControl(''), + endHourFc : new FormControl(''), + textFc : new FormControl('', [ Validators.required]) + }) + } + + public onSubmit(): void { + const startDateValue = this.eventForm.value['startDateFc']; + const startHourValue = this.eventForm.value['startHourFc']; + const endDateValue = this.eventForm.value['endDateFc']; + const endHourValue = this.eventForm.value['endHourFc']; + const textValue = this.eventForm.value['textFc']; + + const event = { + start: startDateValue+'T'+startHourValue+':00', + end: endDateValue+'T'+endHourValue+':00', + text: textValue, + id:"", + membre: {id:this.userId}, + team: {id:this.teamId} + } + + this.evenementService.addEvenements(event).subscribe({ + next: result => { + this.alert={"type":"success", "content":"L'évènement à été correctement ajouté au calendrier"}; + this.isShow = true; + }, + error: err => { + this.alert={"type":"danger", "content":"Problème lors de l'ajout de l'évenment"}; + this.isShow = true; + }, + complete: () => { + console.log('DONE!'); + this.router.navigate(['agenda']); + } + }); + + } + +} diff --git a/src/app/pages/page-dashboard/page-dashboard.component.html b/src/app/pages/page-dashboard/page-dashboard.component.html index 95545c6..6d627bb 100644 --- a/src/app/pages/page-dashboard/page-dashboard.component.html +++ b/src/app/pages/page-dashboard/page-dashboard.component.html @@ -2,30 +2,37 @@
-
-

Bienvenue {{ conectedUser.prenom }}!!

-
-
-
- -
-
- A venir +
+ +
+

Bienvenue {{ conectedUser.prenom }}!!

-
-
-
+
+ +
+
+ +
+
+ +
+ A venir +
+
-
-
- +
+
    +
  • + +
  • +
-
+
diff --git a/src/app/pages/page-dashboard/page-dashboard.component.scss b/src/app/pages/page-dashboard/page-dashboard.component.scss index d2d8bff..ba266b3 100644 --- a/src/app/pages/page-dashboard/page-dashboard.component.scss +++ b/src/app/pages/page-dashboard/page-dashboard.component.scss @@ -11,40 +11,9 @@ } .container { - display: flex; - padding: 20px; - -} - -button{ - margin-bottom: 5px; -} - -.calendrier{ - align-content: flex-end; -} - -#boxFour{ - height: 150px; - margin-top: -99px; - width: fit-content; -} - -#boxThree{ - margin-top: -85px; - height: 150px; - width: fit-content; -} - -#boxTwo{ - margin-top: 50px; - margin-left: 150px; - height: 50%; - width: fit-content; +margin-left:200px; } .avatar{ - margin-top: -50px; - justify-content: space-between; - margin: 0; + margin:O; } \ No newline at end of file diff --git a/src/app/pages/page-delete-account/page-delete-account.component.html b/src/app/pages/page-delete-account/page-delete-account.component.html deleted file mode 100644 index 18e56eb..0000000 --- a/src/app/pages/page-delete-account/page-delete-account.component.html +++ /dev/null @@ -1,12 +0,0 @@ - -
-
- -
-
-

Supprimer votre compte

-
- -
-
-
diff --git a/src/app/pages/page-delete-account/page-delete-account.component.scss b/src/app/pages/page-delete-account/page-delete-account.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/page-delete-account/page-delete-account.component.spec.ts b/src/app/pages/page-delete-account/page-delete-account.component.spec.ts deleted file mode 100644 index 1515cf6..0000000 --- a/src/app/pages/page-delete-account/page-delete-account.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PageDeleteAccountComponent } from './page-delete-account.component'; - -describe('PageDeleteAccountComponent', () => { - let component: PageDeleteAccountComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ PageDeleteAccountComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PageDeleteAccountComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/page-delete-account/page-delete-account.component.ts b/src/app/pages/page-delete-account/page-delete-account.component.ts deleted file mode 100644 index 0388cf0..0000000 --- a/src/app/pages/page-delete-account/page-delete-account.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-page-delete-account', - templateUrl: './page-delete-account.component.html', - styleUrls: ['./page-delete-account.component.scss'] -}) -export class PageDeleteAccountComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} diff --git a/src/app/pages/page-forgot-password/page-forgot-password.component.ts b/src/app/pages/page-forgot-password/page-forgot-password.component.ts index 1368394..821250f 100644 --- a/src/app/pages/page-forgot-password/page-forgot-password.component.ts +++ b/src/app/pages/page-forgot-password/page-forgot-password.component.ts @@ -1,16 +1,11 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { AuthService } from '../../services/auth.service'; -import { - FormBuilder, - FormControl, - FormGroup, - Validators, -} from '@angular/forms'; import { Membre } from 'src/app/models/membre'; import { MailService } from 'src/app/services/mail.service'; import { Mail } from 'src/app/models/mail'; + @Component({ selector: 'app-page-forgot-password', templateUrl: './page-forgot-password.component.html', @@ -20,7 +15,7 @@ export class PageForgotPasswordComponent implements OnInit { alert : any; isShow : boolean; - + constructor(private authService: AuthService, private router: Router, private mailService: MailService,) { this.alert = ""; this.isShow = false; @@ -30,6 +25,7 @@ export class PageForgotPasswordComponent implements OnInit { public onSubmit(submittedForm: any): void { const membre: Membre = { + id: "", nom: "", prenom: "", dateNaissance: new Date(), @@ -41,9 +37,7 @@ export class PageForgotPasswordComponent implements OnInit { }; console.log(membre); - // this.authService.forgotPassword(membre).subscribe((resp) => { - // console.log('----'+resp) - // }); + this.authService.forgotPassword(membre).subscribe( { @@ -65,12 +59,12 @@ export class PageForgotPasswordComponent implements OnInit { }) }, error: err => { - this.alert={"type":"danger", "content":"Le mail a merdé, ou il n'y a personne ds la bdd !"}; + this.alert={"type":"danger", "content":"Votre email est erroné"}; this.isShow = true; }, complete: () => console.log('DONE!') } - ); + ); diff --git a/src/app/pages/page-menu-semaine/page-menu-semaine.component.html b/src/app/pages/page-menu-semaine/page-menu-semaine.component.html index d5690f8..f6245e9 100644 --- a/src/app/pages/page-menu-semaine/page-menu-semaine.component.html +++ b/src/app/pages/page-menu-semaine/page-menu-semaine.component.html @@ -11,3 +11,4 @@
+ diff --git a/src/app/pages/page-modifier-contact/page-modifier-contact.component.html b/src/app/pages/page-modifier-contact/page-modifier-contact.component.html index f518f82..9832a9c 100644 --- a/src/app/pages/page-modifier-contact/page-modifier-contact.component.html +++ b/src/app/pages/page-modifier-contact/page-modifier-contact.component.html @@ -1,7 +1,7 @@
- +
@@ -11,7 +11,8 @@
+ formControlName="couleurFc" value= "{{ listContactInfo.couleur }}" + [(ngModel)]="listContactInfo.couleur">
@@ -20,10 +21,10 @@ id="floatingInputlastName" placeholder="" name="lastName" - formControlName="lastNameFc" value= "{{ listContactInfo.nom }}"> + formControlName="lastNameFc" value= "{{ listContactInfo.nom }}" + [(ngModel)]="listContactInfo.nom"> -
+ formControlName="firstNameFc" value= "{{ listContactInfo.prenom }}" + [(ngModel)]="listContactInfo.prenom"> -
+ formControlName="telephoneFc" value= "{{ listContactInfo.telephone }}" + [(ngModel)]="listContactInfo.telephone"> -
+ formControlName="emailFc" value= "{{ listContactInfo.email }}" + [(ngModel)]="listContactInfo.email">
-
+ formControlName="dateNaissanceFc" + value= "{{ listContactInfo.dateNaissance }}" + [(ngModel)]="listContactInfo.dateNaissance">
-
+ formControlName="adresseFc" value= "{{ listContactInfo.adresse }}" + [(ngModel)]="listContactInfo.adresse">
+ >Valider
+
\ No newline at end of file diff --git a/src/app/pages/page-repertoire/page-repertoire.component.html b/src/app/pages/page-repertoire/page-repertoire.component.html index d390bff..6f48ea9 100644 --- a/src/app/pages/page-repertoire/page-repertoire.component.html +++ b/src/app/pages/page-repertoire/page-repertoire.component.html @@ -2,10 +2,10 @@
- +
-
+
+ +
diff --git a/src/app/pages/page-repertoire/page-repertoire.component.scss b/src/app/pages/page-repertoire/page-repertoire.component.scss index 3d44188..3f3f6b7 100644 --- a/src/app/pages/page-repertoire/page-repertoire.component.scss +++ b/src/app/pages/page-repertoire/page-repertoire.component.scss @@ -31,4 +31,8 @@ .h4 { color: black; font-weight: bold; +} + +.pointer{ + cursor: pointer; } \ No newline at end of file diff --git a/src/app/pages/page-reset-password/page-reset-password.component.ts b/src/app/pages/page-reset-password/page-reset-password.component.ts index fea1a14..6e31529 100644 --- a/src/app/pages/page-reset-password/page-reset-password.component.ts +++ b/src/app/pages/page-reset-password/page-reset-password.component.ts @@ -36,16 +36,6 @@ export class PageResetPasswordComponent implements OnInit { ); } - // public onSubmit(submittedForm: any): void { - // console.log(submittedForm.form.value); - // const password = submittedForm.form.value['password']; - // console.log(email); - // this.authService.resetPassword(email, password).subscribe((resp: any) => { - // window.alert("Votre mot de passe est bien ré-initialisé !") - // this.router.navigate(['accueil']); - - // }); - // } public onSubmit(): void { console.log('value : ', this.resetForm.value); @@ -54,6 +44,7 @@ export class PageResetPasswordComponent implements OnInit { const passwordConfirmValue = this.resetForm.value['passwordConfirmFc']; const membre: Membre = { + id: "", nom: "", prenom: "", dateNaissance: new Date(), diff --git a/src/app/pages/page-signup/page-signup.component.html b/src/app/pages/page-signup/page-signup.component.html index c41025d..7d2a6ca 100644 --- a/src/app/pages/page-signup/page-signup.component.html +++ b/src/app/pages/page-signup/page-signup.component.html @@ -4,10 +4,30 @@
-
- -
+
+ +
+
+ + +
- +
- +
- +
- +
- +
- +
+ + diff --git a/src/app/pages/page-to-do-list/page-to-do-list.component.ts b/src/app/pages/page-to-do-list/page-to-do-list.component.ts index b9732e8..a850dda 100644 --- a/src/app/pages/page-to-do-list/page-to-do-list.component.ts +++ b/src/app/pages/page-to-do-list/page-to-do-list.component.ts @@ -21,6 +21,7 @@ export class PageToDoListComponent implements OnInit { } ngOnInit(): void { + //récupère les todoLists existantes en fonctoin de l'id de la team en utilisant le service this.TodoService.getToDoListByTeamId()?.subscribe((listTodos: any) => { console.log(listTodos); this.listTodos = listTodos; @@ -28,23 +29,21 @@ export class PageToDoListComponent implements OnInit { this.idTodo = 0; }); } - //Ajouter une todo List + + //Ajouter une todo List si l'input n'est pas vide addTodoByTeamId() { const todoList: ToDoList = { nom: this.todoListTitle, taches: [], id: 0, }; - this.TodoService.addTodoByTeamId(todoList)?.subscribe((resp) => { - console.log(todoList); - window.location.reload(); - }); - } - - deleteTodo(id: number): void { - window.alert('La to-do-List a bien été supprimé!'); - this.TodoService.deleteTodoById(id).subscribe((resp) => { - window.location.reload(); - }); + if (this.todoListTitle != '') { + this.TodoService.addTodoByTeamId(todoList)?.subscribe((resp) => { + console.log(todoList); + window.location.reload(); //rafraîchit l'aperçu + }); + }else{ + window.alert('Il faut saisir du texte'); // sinon msg d'erreur + } } } diff --git a/src/app/pages/page-update-account/page-update-account.component.html b/src/app/pages/page-update-account/page-update-account.component.html deleted file mode 100644 index 2c307c2..0000000 --- a/src/app/pages/page-update-account/page-update-account.component.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
-
- -
-
-

Modifier votre compte

-
-
-
diff --git a/src/app/pages/page-update-account/page-update-account.component.scss b/src/app/pages/page-update-account/page-update-account.component.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/app/pages/page-update-account/page-update-account.component.spec.ts b/src/app/pages/page-update-account/page-update-account.component.spec.ts deleted file mode 100644 index d65402a..0000000 --- a/src/app/pages/page-update-account/page-update-account.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { PageUpdateAccountComponent } from './page-update-account.component'; - -describe('PageUpdateAccountComponent', () => { - let component: PageUpdateAccountComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ PageUpdateAccountComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PageUpdateAccountComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/app/pages/page-update-account/page-update-account.component.ts b/src/app/pages/page-update-account/page-update-account.component.ts deleted file mode 100644 index 4fcb39b..0000000 --- a/src/app/pages/page-update-account/page-update-account.component.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Component, OnInit } from '@angular/core'; - -@Component({ - selector: 'app-page-update-account', - templateUrl: './page-update-account.component.html', - styleUrls: ['./page-update-account.component.scss'] -}) -export class PageUpdateAccountComponent implements OnInit { - - constructor() { } - - ngOnInit(): void { - } - -} 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 764bae0..3d9a20b 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 @@ -1,11 +1,112 @@ - -
-
- -
-
-

Modifier ce membre

-
+ +
+
+
+

Modifier profil

+
+ +
+ +
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
diff --git a/src/app/pages/page-update-member/page-update-member.component.scss b/src/app/pages/page-update-member/page-update-member.component.scss index e69de29..b66b171 100644 --- a/src/app/pages/page-update-member/page-update-member.component.scss +++ b/src/app/pages/page-update-member/page-update-member.component.scss @@ -0,0 +1,80 @@ +.login-form { + height: 100vh; + padding-top: 40px; + background-color: #f5f5f5; +} + h1{ + color: rgba(0, 0, 0, 0.658); + font-size: 34px; + margin-top: 20px; + } + +.form-updateMember { + width: 100%; + max-width: 330px; + padding: 15px; + margin-top: 50px; + margin-left: auto; + margin-right: auto; + border: solid 1px; + border-radius: 10px; + background-color: #fcddec; + border-color: #ef5da8; +} + +.form-updateMember .checkbox { + font-weight: 400; +} + +.form-updateMember .form-floating:focus-within { + z-index: 2; +} + +.form-updateMember input[type="email"] { + margin-bottom: 10px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-updateMember input[type="color"] { + border: none; + margin-bottom: 10px; + margin-top: -70px; + margin-left: 100px; + border-radius: 50%; + width: 100px; + height: 100px; +} + +.form-updateMember input[type="color"]::-webkit-color-swatch { + border: none; + margin-top: -15px; + border-radius: 80%; + width: 80px; + height: 80px; +} + +.form-updateMember input[type="text"] { + margin-bottom: 10px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-updateMember input[type="date"] { + margin-bottom: 10px; + border-bottom-right-radius: 0; + border-bottom-left-radius: 0; +} + +.form-updateMember input[type="password"] { + margin-bottom: 10px; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.btn-outline-success { + margin-top: 10px; + background-color: #ffff; + color: #ef5da8 !important; + border-color: #ef5da8 !important; +} 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 be0f66e..e97f81a 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 @@ -1,4 +1,8 @@ import { Component, OnInit } from '@angular/core'; +import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import { ActivatedRoute, Router } from '@angular/router'; +import { Membre } from 'src/app/models/membre'; +import { MembreService } from 'src/app/services/membre.service'; @Component({ selector: 'app-page-update-member', @@ -6,10 +10,121 @@ import { Component, OnInit } from '@angular/core'; styleUrls: ['./page-update-member.component.scss'] }) export class PageUpdateMemberComponent implements OnInit { + public updateMembreForm: FormGroup; + public membreData: FormGroup; + public membreInfos: any; + public membreId: any; - constructor() { } + + constructor(private membreService: MembreService, + private router: Router, + private fb: FormBuilder, + private route: ActivatedRoute) { + this.updateMembreForm = new FormGroup({}); + this.membreData = this.initForm(); + this.membreInfos = ''; + } ngOnInit(): void { + /** Pour récuperer l'id du membre à modifier **/ + this.membreId = this.route.snapshot.paramMap.get('id'); + + /** Appel Api **/ + this.membreService + .getMembreId(this.membreId) + .subscribe((membreInfos: any) => { + this.membreInfos = membreInfos; + }); + + /** group est déprécié mais pas d'autres solutions sinon revoir la fonction confirmeValidator **/ + this.updateMembreForm = this.fb.group( + { + firstNameFc: new FormControl('', [Validators.required]), + lastNameFc: new FormControl('', [Validators.required]), + dateNaissanceFc: new FormControl('', [Validators.required]), + roleFc: new FormControl('', []), + couleurFc: new FormControl('', []), + emailFc: new FormControl('', [ + Validators.email, + Validators.required, + Validators.pattern(/^([\w\.\-_]+)?\w+@[\w-_]+(\.\w+){1,}/gim), + ]), + passwordFc: new FormControl('', [ + Validators.minLength(8), + ]), + passwordConfirmFc: new FormControl('', [ + Validators.minLength(8), + ]), + }, + { + validator: this.ConfirmedValidator('passwordFc', 'passwordConfirmFc'), + } + )}; + + /** Méthode qui initialise les champs du formulaire avec les infos de la BDD **/ + private initForm(membre?: Membre): FormGroup { + + return this.fb.group({ + nom:[membre ? membre.nom : ''], + prenom: [membre ? membre.prenom : ''], + email: [membre ? membre.email : ''], + password: [membre ? membre.password : ''], + couleur: [membre ? membre.couleur : ''], + dateNaissance: [membre ? membre.dateNaissance : ''], + passwordConfirm: [membre ? membre.passwordConfirm : ''], + roleList: [membre ? membre.roleList : ['']], + }); } + + /** Méthode qui envoie les champs modifiés pour mise à jour **/ + public onSubmit(): void { + const firstNameValue = this.updateMembreForm.value['firstNameFc']; + const lastNameValue = this.updateMembreForm.value['lastNameFc']; + const emailValue = this.updateMembreForm.value['emailFc']; + const passwordValue = this.updateMembreForm.value['passwordFc']; + const dateNaissanceValue = this.updateMembreForm.value['dateNaissanceFc']; + const couleurValue = this.updateMembreForm.value['couleurFc']; + const passwordConfirmValue = this.updateMembreForm.value['passwordConfirmFc']; + const roleValue = this.updateMembreForm.value['roleFc']; + + const membre: Membre = { + id: this.membreId, + nom: lastNameValue, + prenom: firstNameValue, + email: emailValue, + password: passwordValue, + dateNaissance: dateNaissanceValue, + couleur: couleurValue, + passwordConfirm: passwordConfirmValue, + roleList: [roleValue] + }; + + console.log(membre); + + this.membreService.updateMembre(membre)?.subscribe((resp) => { + //this.router.navigate(['compte']); + }); + } + + + + /** Méthode pour compare le mot de passe et la confirmation de mot de passe **/ + ConfirmedValidator(controlName: string, matchingControlName: string) { + return (formGroup: FormGroup) => { + const control = formGroup.controls[controlName]; + const matchingControl = formGroup.controls[matchingControlName]; + if ( + matchingControl.errors && + !matchingControl.errors['confirmedValidator'] + ) { + return; + } + if (control.value !== matchingControl.value) { + matchingControl.setErrors({ confirmedValidator: true }); + } else { + matchingControl.setErrors(null); + } + }; + } } diff --git a/src/app/services/auth.interceptor.ts b/src/app/services/auth.interceptor.ts index a5b418e..c0a87ce 100644 --- a/src/app/services/auth.interceptor.ts +++ b/src/app/services/auth.interceptor.ts @@ -14,7 +14,6 @@ export class AuthInterceptor implements HttpInterceptor { constructor(private tokenService: TokenService) {} intercept(request: HttpRequest, next: HttpHandler): Observable> { - console.log('Coucou je suis le videur ! '); const token = this.tokenService.getToken(); if(token) { diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 52d1ddd..6b599ad 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -19,6 +19,7 @@ export class AuthService { this.tokenKey = environment.tokenKey; } + //methode pour s'inscrire - on passe l'objet en entier signup(membre: Membre): Observable { console.log(membre); @@ -26,17 +27,15 @@ export class AuthService { } - +//methode pour se connecter - on passe id et pwd signin(email: string, password: string): Observable { const body = { email: email, password: password, }; - console.log('Mon body : ', body); return this.http.post(`${this.apiUrl}/membres/sign-in`, body).pipe( map((x: any) => { - console.log('Service : ', x.token); localStorage.setItem(this.tokenKey, x.token); return x; // permet de renvoyer la réponse à l'initiateur (page Signin) après le traitement du map }) @@ -44,10 +43,12 @@ export class AuthService { } + //permet d'envoyer un mail à l'utilisateur pour qu'il change son pwd forgotPassword(membre: Membre): Observable { return this.http.post(`${this.apiUrl}/membres/forgot-password`, membre, {responseType: "text"}); } + //permet à l'utilisateur de changer son pwd resetPassword(membre: Membre, uuid:string): Observable { console.log('--'+uuid+' / '+membre); return this.http.put(`${this.apiUrl}/membres/reset-password/${uuid}`, membre); diff --git a/src/app/services/membre.service.ts b/src/app/services/membre.service.ts index 98d19a0..38d2567 100644 --- a/src/app/services/membre.service.ts +++ b/src/app/services/membre.service.ts @@ -49,7 +49,12 @@ export class MembreService { return this.http.delete(`${this.apiUrl}/membres/delete/1`); } - updateMembre(membre: Membre): Observable { - return this.http.put(`${this.apiUrl}/membres/update/1`, membre); - } + updateMembre(membre: Membre): Observable | void { + const teamId = this.tokenService.getCurrentTeamId(); + if (teamId){ + return this.http.put(`${this.apiUrl}/membres/update/${teamId}/${membre.id}`, membre); + }else { + this.router.navigate(['accueil']); + } +} } diff --git a/src/app/services/menus.service.ts b/src/app/services/menus.service.ts index 846f68b..5d528f2 100644 --- a/src/app/services/menus.service.ts +++ b/src/app/services/menus.service.ts @@ -19,7 +19,7 @@ apiUrl: string; this.apiUrl = environment.apiUrl; } - //on affiche les menus d'une team + //on affiche les menus d'une team - on récupère l'id de la team dans le token getMenu(): Observable | void { const teamId = this.tokenService.getCurrentTeamId(); if (teamId){ @@ -33,6 +33,7 @@ apiUrl: string; return this.http.get(`${this.apiUrl}/menus/` + id); } + //permet d'ajouter un menu et de lui attribuer l'id de la bonne team addMenu(menu: Menu): Observable | void { console.log(menu); const teamId = this.tokenService.getCurrentTeamId(); @@ -44,11 +45,12 @@ apiUrl: string; } + //suppression d'un menu deleteMenu(id:number): Observable { return this.http.delete(`${this.apiUrl}/menus/delete/${id}`, {responseType:"text"}); } - +//modification d'un menu - avec id du menu et id de la team updateMenu(menu: Menu, id:number): Observable | void { const teamId = this.tokenService.getCurrentTeamId(); if (teamId){ diff --git a/src/app/services/todo.service.ts b/src/app/services/todo.service.ts index 6528ebb..31e14f1 100644 --- a/src/app/services/todo.service.ts +++ b/src/app/services/todo.service.ts @@ -18,37 +18,46 @@ export class TodoService { this.apiUrl = environment.apiUrl; } + //recupère les todolistexistantes en BDD par le tokenService en fonction de l'iD de la team getToDoListByTeamId(): Observable | void { const teamId = this.tokenService.getCurrentTeamId(); return this.http.get(`${this.apiUrl}/todolist/team/${teamId}`); } + //supprime les taches par l'id dela tache dans la todoList deleteTacheById(idTache: any): Observable { return this.http.delete(`${this.apiUrl}/taches/delete/${idTache}`, { responseType: 'text', }); } + //ajoute une tache avec auto-incrémentation de l'id dans la todolist addTache(newtache: Tache, idTodoList: number): Observable { // console.log(newtache); return this.http.post(`${this.apiUrl}/taches/add/${idTodoList}`, newtache); } + // modifie une tâche par son id updateTache(tache: Tache): Observable { - console.log(tache); + // console.log(tache); return this.http.put(`${this.apiUrl}/taches/update/1`, tache); } + + //ajoute ne todoList sur une team (par son id) via le token addTodoByTeamId(newtodoList: TodoList): Observable { const teamId = this.tokenService.getCurrentTeamId(); console.log(newtodoList + 'newtodoList'); return this.http.post(`${this.apiUrl}/todolist/add/${teamId}`, newtodoList); } + //suprime une todoList en fonction de son id deleteTodoById(idTodo: any): Observable { return this.http.delete(`${this.apiUrl}/todolist/delete/${idTodo}`, { responseType: 'text', }); } + + //modfie une todoList par son id updateTodo(todoList: TodoList): Observable { console.log(todoList); return this.http.put(`${this.apiUrl}/todolist/update/666`, todoList); diff --git a/src/app/services/token.service.ts b/src/app/services/token.service.ts index 378e3a6..a4f61c5 100644 --- a/src/app/services/token.service.ts +++ b/src/app/services/token.service.ts @@ -11,6 +11,7 @@ tokenKey = environment.tokenKey; constructor() { } + //récupère le token public getToken(): string | null { const token = localStorage.getItem(this.tokenKey); if(token) { @@ -20,17 +21,18 @@ tokenKey = environment.tokenKey; } } + //supprime le token public eraseToken(): string | null { const token = localStorage.getItem(this.tokenKey); if(token) { - localStorage.removeItem(this.tokenKey); - return token; + localStorage.removeItem(this.tokenKey); //.clear() supprime tous les token du localStorage ! + return token; //utiliser remove() }else { return null; } } - +//recupère l'id du membre stocké dans le token public getCurrentMembreId(): number | null { const token = this.getToken(); if(token) { @@ -42,6 +44,7 @@ tokenKey = environment.tokenKey; } } + //recupère l'id de la team stocké dans le token public getCurrentTeamId(): number | null { const token = this.getToken(); if(token){ @@ -55,6 +58,7 @@ return null; } + //recupère le role du membre stocké dans le token public getRole(): string | null { const token = this.getToken(); if(token){ diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 63d46e1..bd6eab6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -4,7 +4,7 @@ export const environment = { production: false, - apiUrl: 'http://localhost:8080', + apiUrl: 'http://localhost:8088', tokenKey: 'TOKEN-ORGANIZEE', debug: true, };