From f02e3b630e71c6b505a0a57ef6fa600dba855460 Mon Sep 17 00:00:00 2001 From: Hedi Date: Tue, 1 Mar 2022 15:12:41 +0100 Subject: [PATCH 1/3] calendrier : fin + gestion des roles --- .../page-agenda/page-agenda.component.ts | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/app/pages/page-agenda/page-agenda.component.ts b/src/app/pages/page-agenda/page-agenda.component.ts index 1e438ae..94de5dd 100644 --- a/src/app/pages/page-agenda/page-agenda.component.ts +++ b/src/app/pages/page-agenda/page-agenda.component.ts @@ -191,22 +191,28 @@ export class PageAgendaComponent implements AfterViewInit { text: this.rdvSplit(args.e.text()), membre: {id:args.e.data.tags.membre}, team: {id:this.teamId} - } - this.evenementService.updateEvenements(event).subscribe( - { - next: result => { - this.viewChange(); - this.alert={"type":"success", "content":"L'évènement à bien été modifié"}; - this.isShow = true; - }, - error: err => { - this.viewChange(); - this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"}; - this.isShow = true; - }, - complete: () => console.log('DONE!') - } - ); + } + if( (args.e.data.tags.membre == this.userId) || (this.role == 'ROLE_PARENT')){ // mettre role parent en variable + this.evenementService.updateEvenements(event).subscribe( + { + next: result => { + this.viewChange(); + this.alert={"type":"success", "content":"L'évènement à bien été déplacé"}; + this.isShow = true; + }, + error: err => { + this.viewChange(); + this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenement"}; + this.isShow = true; + }, + complete: () => console.log('DONE!') + } + ); + }else{ + this.viewChange(); + this.alert={"type":"danger", "content":"Vous ne pouvez pas déplacé cet évènement !"}; + this.isShow = true; + } } } From 68aae07bb37af3b0e4a77c34788e0a91a72a79b9 Mon Sep 17 00:00:00 2001 From: Hedi Date: Tue, 1 Mar 2022 15:17:34 +0100 Subject: [PATCH 2/3] calendrier : fin + gestion des roles + debug --- src/app/pages/page-agenda/page-agenda.component.html | 6 +++++- src/app/pages/page-agenda/page-agenda.component.ts | 3 ++- src/environments/environment.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/pages/page-agenda/page-agenda.component.html b/src/app/pages/page-agenda/page-agenda.component.html index 295dd85..f667068 100644 --- a/src/app/pages/page-agenda/page-agenda.component.html +++ b/src/app/pages/page-agenda/page-agenda.component.html @@ -57,7 +57,11 @@ (click)="navigateNext($event)" >Next - team : {{ teamId }} - user: {{ userId }} - role: {{ role }} + + + team : {{ teamId }} - user: {{ userId }} - role: {{ role }} + + Date: Tue, 1 Mar 2022 18:37:35 +0100 Subject: [PATCH 3/3] calendrier : fin + gestion des roles + debug --- .../pages/page-agenda/page-agenda.component.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/app/pages/page-agenda/page-agenda.component.ts b/src/app/pages/page-agenda/page-agenda.component.ts index f0679af..d9d86a2 100644 --- a/src/app/pages/page-agenda/page-agenda.component.ts +++ b/src/app/pages/page-agenda/page-agenda.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core'; import { DayPilot, DayPilotCalendarComponent, DayPilotNavigatorComponent } from "@daypilot/daypilot-lite-angular"; import { EvenementService } from 'src/app/services/evenement.service'; import { environment } from 'src/environments/environment'; -import jwt_decode from 'jwt-decode'; +import { TokenService } from 'src/app/services/token.service'; @Component({ selector: 'app-page-agenda', @@ -20,7 +20,7 @@ export class PageAgendaComponent implements AfterViewInit { @ViewChild("navigator") navigator!: DayPilotNavigatorComponent; @ViewChild("calendar") calendar!: DayPilotCalendarComponent; - constructor(private evenementService:EvenementService) { + constructor(private evenementService:EvenementService, private tokenService: TokenService) { this.isShow = false; this.alert = ""; this.debug = environment.debug; @@ -56,15 +56,8 @@ export class PageAgendaComponent implements AfterViewInit { } ngOnInit(): void { - const token = localStorage.getItem(environment.tokenKey); - if(token) { - const decodedToken = jwt_decode(token); - this.userId = decodedToken.userId; - this.teamId = decodedToken.teamId; - this.role = decodedToken.auth[0].authority; - }else{ - // - } + this.userId = this.tokenService.getCurrentMembreId(); + this.teamId = this.tokenService.getCurrentTeamId(); } // petite triche pour eviter la repetition du nom dans le RDV