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)"
>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"
><a
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 { 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',
@ -10,7 +10,7 @@ import jwt_decode from 'jwt-decode';
styleUrls: ['./page-agenda.component.scss']
})
export class PageAgendaComponent implements AfterViewInit {
debug: boolean;
userId : any;
teamId : any;
role:any;
@ -20,9 +20,10 @@ 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;
}
get date(): DayPilot.Date {
@ -55,15 +56,8 @@ export class PageAgendaComponent implements AfterViewInit {
}
ngOnInit(): void {
const token = localStorage.getItem(environment.tokenKey);
if(token) {
const decodedToken = jwt_decode<any>(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
@ -192,21 +186,27 @@ export class PageAgendaComponent implements AfterViewInit {
membre: {id:args.e.data.tags.membre},
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(
{
next: result => {
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;
},
error: err => {
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;
},
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,
apiUrl: 'http://localhost:8080',
tokenKey: 'TOKEN-ORGANIZEE',
debug: true,
};
/*