diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5850a5c..2ea2f43 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -43,6 +43,7 @@ import localeFr from '@angular/common/locales/fr'; import { CardAvatarComponent } from './components/card-avatar/card-avatar.component'; import { HumeurComponent } from './components/humeur/humeur.component'; import { DeconnexionComponent } from './components/deconnexion/deconnexion.component'; +import { AlertComponent } from './components/alert/alert.component'; registerLocaleData(localeFr) @NgModule({ @@ -82,8 +83,8 @@ registerLocaleData(localeFr) PageUpdateAccountComponent, CardAvatarComponent, DeconnexionComponent, - HumeurComponent - + HumeurComponent, + AlertComponent ], imports: [ BrowserModule, diff --git a/src/app/components/alert/alert.component.html b/src/app/components/alert/alert.component.html new file mode 100644 index 0000000..32e0ec5 --- /dev/null +++ b/src/app/components/alert/alert.component.html @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/src/app/components/alert/alert.component.scss b/src/app/components/alert/alert.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/alert/alert.component.spec.ts b/src/app/components/alert/alert.component.spec.ts new file mode 100644 index 0000000..8e3decb --- /dev/null +++ b/src/app/components/alert/alert.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { AlertComponent } from './alert.component'; + +describe('AlertComponent', () => { + let component: AlertComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ AlertComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AlertComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/alert/alert.component.ts b/src/app/components/alert/alert.component.ts new file mode 100644 index 0000000..84c50f0 --- /dev/null +++ b/src/app/components/alert/alert.component.ts @@ -0,0 +1,20 @@ +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; + +@Component({ + selector: 'app-alert', + templateUrl: './alert.component.html', + styleUrls: ['./alert.component.scss'] +}) +export class AlertComponent implements OnInit { + @Input() alert:any; + @Output() eventClose = new EventEmitter(); + constructor() { } + + ngOnInit(): void { + } + + onClickCloseAlert(){ + //console.log('fermeture from component'); + this.eventClose.emit('true'); + } +} diff --git a/src/app/components/calendrier/calendrier.component.html b/src/app/components/calendrier/calendrier.component.html index b2a5529..911973f 100644 --- a/src/app/components/calendrier/calendrier.component.html +++ b/src/app/components/calendrier/calendrier.component.html @@ -1 +1 @@ -

calendrier works!

+ \ No newline at end of file diff --git a/src/app/components/calendrier/calendrier.component.ts b/src/app/components/calendrier/calendrier.component.ts index 29cc2c8..4edb2ef 100644 --- a/src/app/components/calendrier/calendrier.component.ts +++ b/src/app/components/calendrier/calendrier.component.ts @@ -1,4 +1,7 @@ import { Component, OnInit } from '@angular/core'; +import { DayPilot } from "@daypilot/daypilot-lite-angular"; +import { EvenementService } from 'src/app/services/evenement.service'; +import { TokenService } from 'src/app/services/token.service'; @Component({ selector: 'app-calendrier', @@ -7,9 +10,48 @@ import { Component, OnInit } from '@angular/core'; }) export class CalendrierComponent implements OnInit { - constructor() { } + constructor(private evenementService:EvenementService, private tokenService: TokenService) { } + + get date(): DayPilot.Date { + return this.config.startDate as DayPilot.Date; + } + + set date(value: DayPilot.Date) { + this.config.startDate = value; + } + + events: DayPilot.EventData[] = []; + + config: DayPilot.CalendarConfig = { + viewType: "Day", + timeRangeSelectedHandling: "Disabled", + eventDeleteHandling: "Disabled", + eventMoveHandling: "Disabled", + eventResizeHandling: "Disabled", + eventClickHandling: "Disabled" + } ngOnInit(): void { + const teamId = this.tokenService.getCurrentTeamId(); + this.evenementService.getEvenementsByIdTeam(teamId).subscribe((data: any) => { + Object.keys(data).map((key, index) => { + data[key] = { + barColor:data[key].membre.couleur, + backColor: data[key].membre.couleur, + id: data[key].id, + start: data[key].start, + end: data[key].end, + text: data[key].text.toUpperCase()+'\r('+data[key].membre.prenom+')', + tags : { + membre: data[key].membre.id + } + }; + }); + this.events = data; + console.log(data); + console.log(this.events); + }); + } } diff --git a/src/app/components/signin/signin.component.html b/src/app/components/signin/signin.component.html index 83e4a52..7c782da 100644 --- a/src/app/components/signin/signin.component.html +++ b/src/app/components/signin/signin.component.html @@ -27,10 +27,13 @@ -
+ + + +
diff --git a/src/app/components/signin/signin.component.ts b/src/app/components/signin/signin.component.ts index ff6c04d..cb092a3 100644 --- a/src/app/components/signin/signin.component.ts +++ b/src/app/components/signin/signin.component.ts @@ -44,4 +44,9 @@ export class SigninComponent implements OnInit { this.isShow = true; } } + + onClickCloseAlert(){ + console.log('fermeture'); + this.isShow = ! this.isShow; + } } diff --git a/src/app/pages/page-agenda/page-agenda.component.html b/src/app/pages/page-agenda/page-agenda.component.html index 295dd85..f71faf6 100644 --- a/src/app/pages/page-agenda/page-agenda.component.html +++ b/src/app/pages/page-agenda/page-agenda.component.html @@ -1,7 +1,9 @@ -
+ +
@@ -57,7 +59,11 @@ (click)="navigateNext($event)" >Next - team : {{ teamId }} - user: {{ userId }} - role: {{ role }} + + + team : {{ teamId }} - user: {{ userId }} - role: {{ role }} + + (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(); + this.role = this.tokenService.getRole(); } // petite triche pour eviter la repetition du nom dans le RDV @@ -191,22 +186,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; + } } } diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 90149fd..bd6eab6 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -6,6 +6,7 @@ export const environment = { production: false, apiUrl: 'http://localhost:8088', tokenKey: 'TOKEN-ORGANIZEE', + debug: true, }; /*