Merge pull request #64 from AlineRinquin/calendrier

Calendrier
This commit is contained in:
AlineRinquin 2022-03-01 18:50:01 +01:00 committed by GitHub
commit 4807bfde57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 29 deletions

View File

@ -57,7 +57,11 @@
(click)="navigateNext($event)" (click)="navigateNext($event)"
>Next</a >Next</a
> >
team : {{ teamId }} - user: {{ userId }} - role: {{ role }}
<!-- DEBUT : Pour le debugage -->
<span *ngIf="debug">team : {{ teamId }} - user: {{ userId }} - role: {{ role }}</span>
<!-- FIN : Pour le debugage -->
<span style="float: right" <span style="float: right"
><a ><a
href="#" href="#"

View File

@ -2,7 +2,7 @@ import { Component, OnInit, AfterViewInit, ViewChild } from '@angular/core';
import { DayPilot, DayPilotCalendarComponent, DayPilotNavigatorComponent } from "@daypilot/daypilot-lite-angular"; import { DayPilot, DayPilotCalendarComponent, DayPilotNavigatorComponent } from "@daypilot/daypilot-lite-angular";
import { EvenementService } from 'src/app/services/evenement.service'; import { EvenementService } from 'src/app/services/evenement.service';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import jwt_decode from 'jwt-decode'; import { TokenService } from 'src/app/services/token.service';
@Component({ @Component({
selector: 'app-page-agenda', selector: 'app-page-agenda',
@ -10,7 +10,7 @@ import jwt_decode from 'jwt-decode';
styleUrls: ['./page-agenda.component.scss'] styleUrls: ['./page-agenda.component.scss']
}) })
export class PageAgendaComponent implements AfterViewInit { export class PageAgendaComponent implements AfterViewInit {
debug: boolean;
userId : any; userId : any;
teamId : any; teamId : any;
role:any; role:any;
@ -20,9 +20,10 @@ export class PageAgendaComponent implements AfterViewInit {
@ViewChild("navigator") navigator!: DayPilotNavigatorComponent; @ViewChild("navigator") navigator!: DayPilotNavigatorComponent;
@ViewChild("calendar") calendar!: DayPilotCalendarComponent; @ViewChild("calendar") calendar!: DayPilotCalendarComponent;
constructor(private evenementService:EvenementService) { constructor(private evenementService:EvenementService, private tokenService: TokenService) {
this.isShow = false; this.isShow = false;
this.alert = ""; this.alert = "";
this.debug = environment.debug;
} }
get date(): DayPilot.Date { get date(): DayPilot.Date {
@ -55,15 +56,8 @@ export class PageAgendaComponent implements AfterViewInit {
} }
ngOnInit(): void { ngOnInit(): void {
const token = localStorage.getItem(environment.tokenKey); this.userId = this.tokenService.getCurrentMembreId();
if(token) { this.teamId = this.tokenService.getCurrentTeamId();
const decodedToken = jwt_decode<any>(token);
this.userId = decodedToken.userId;
this.teamId = decodedToken.teamId;
this.role = decodedToken.auth[0].authority;
}else{
//
}
} }
// petite triche pour eviter la repetition du nom dans le RDV // petite triche pour eviter la repetition du nom dans le RDV
@ -192,21 +186,27 @@ export class PageAgendaComponent implements AfterViewInit {
membre: {id:args.e.data.tags.membre}, membre: {id:args.e.data.tags.membre},
team: {id:this.teamId} team: {id:this.teamId}
} }
if( (args.e.data.tags.membre == this.userId) || (this.role == 'ROLE_PARENT')){ // mettre role parent en variable
this.evenementService.updateEvenements(event).subscribe( this.evenementService.updateEvenements(event).subscribe(
{ {
next: result => { next: result => {
this.viewChange(); this.viewChange();
this.alert={"type":"success", "content":"L'évènement à bien été modifié"}; this.alert={"type":"success", "content":"L'évènement à bien été déplacé"};
this.isShow = true; this.isShow = true;
}, },
error: err => { error: err => {
this.viewChange(); this.viewChange();
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"}; this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenement"};
this.isShow = true; this.isShow = true;
}, },
complete: () => console.log('DONE!') complete: () => console.log('DONE!')
} }
); );
}else{
this.viewChange();
this.alert={"type":"danger", "content":"Vous ne pouvez pas déplacé cet évènement !"};
this.isShow = true;
}
} }
} }

View File

@ -6,6 +6,7 @@ export const environment = {
production: false, production: false,
apiUrl: 'http://localhost:8080', apiUrl: 'http://localhost:8080',
tokenKey: 'TOKEN-ORGANIZEE', tokenKey: 'TOKEN-ORGANIZEE',
debug: true,
}; };
/* /*