This commit is contained in:
Blandine Bajard 2022-03-02 09:35:39 +01:00
commit 0f27a72de2
12 changed files with 145 additions and 37 deletions

View File

@ -43,6 +43,7 @@ import localeFr from '@angular/common/locales/fr';
import { CardAvatarComponent } from './components/card-avatar/card-avatar.component'; import { CardAvatarComponent } from './components/card-avatar/card-avatar.component';
import { HumeurComponent } from './components/humeur/humeur.component'; import { HumeurComponent } from './components/humeur/humeur.component';
import { DeconnexionComponent } from './components/deconnexion/deconnexion.component'; import { DeconnexionComponent } from './components/deconnexion/deconnexion.component';
import { AlertComponent } from './components/alert/alert.component';
registerLocaleData(localeFr) registerLocaleData(localeFr)
@NgModule({ @NgModule({
@ -82,8 +83,8 @@ registerLocaleData(localeFr)
PageUpdateAccountComponent, PageUpdateAccountComponent,
CardAvatarComponent, CardAvatarComponent,
DeconnexionComponent, DeconnexionComponent,
HumeurComponent HumeurComponent,
AlertComponent
], ],
imports: [ imports: [
BrowserModule, BrowserModule,

View File

@ -0,0 +1,4 @@
<div class="alert alert-{{alert.type}} alert-dismissible fade show" role="alert" style="position:absolute;z-index:9999;top:10px;right:50%;transform: translateX(50%);width:600px; text-align:center;">
{{alert.content}}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" (click)="onClickCloseAlert()"></button>
</div>

View File

@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AlertComponent } from './alert.component';
describe('AlertComponent', () => {
let component: AlertComponent;
let fixture: ComponentFixture<AlertComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AlertComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AlertComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -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<string>();
constructor() { }
ngOnInit(): void {
}
onClickCloseAlert(){
//console.log('fermeture from component');
this.eventClose.emit('true');
}
}

View File

@ -1 +1 @@
<p>calendrier works!</p> <daypilot-calendar [config]="config" [events]="events"></daypilot-calendar>

View File

@ -1,4 +1,7 @@
import { Component, OnInit } from '@angular/core'; 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({ @Component({
selector: 'app-calendrier', selector: 'app-calendrier',
@ -7,9 +10,48 @@ import { Component, OnInit } from '@angular/core';
}) })
export class CalendrierComponent implements OnInit { 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 { 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);
});
} }
} }

View File

@ -27,10 +27,13 @@
<!-- <div *ngIf="errorForm"> <!-- <div *ngIf="errorForm">
<p class="text-danger">Il manque des informations dans le formulaire...</p> <p class="text-danger">Il manque des informations dans le formulaire...</p>
</div> --> </div> -->
<div *ngIf="isShow">
<app-alert *ngIf="isShow" [alert]="alert" (eventClose)="onClickCloseAlert();"></app-alert>
<!-- <div *ngIf="isShow">
<div class="alert alert-{{alert.type}}" role="alert"> <div class="alert alert-{{alert.type}}" role="alert">
{{alert.content}} {{alert.content}}
</div> </div>
</div> </div> -->
</main> </main>
</div> </div>

View File

@ -44,4 +44,9 @@ export class SigninComponent implements OnInit {
this.isShow = true; this.isShow = true;
} }
} }
onClickCloseAlert(){
console.log('fermeture');
this.isShow = ! this.isShow;
}
} }

View File

@ -1,7 +1,9 @@
<app-header></app-header> <app-header></app-header>
<app-side-bar></app-side-bar> <app-side-bar></app-side-bar>
<div <app-alert *ngIf="isShow" [alert]="alert" (eventClose)="onClickCloseAlert();"></app-alert>
<!-- <div
class="alert alert-{{ alert.type }}" class="alert alert-{{ alert.type }}"
role="alert" role="alert"
style="position: absolute; z-index: 999; top: 50%; left: 40%; width: 500px" style="position: absolute; z-index: 999; top: 50%; left: 40%; width: 500px"
@ -18,7 +20,7 @@
> >
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div> -->
<div style="display: flex"> <div style="display: flex">
<div style="width: 150px"> <div style="width: 150px">
@ -57,7 +59,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,9 @@ 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.role = this.tokenService.getRole();
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
@ -191,22 +186,28 @@ export class PageAgendaComponent implements AfterViewInit {
text: this.rdvSplit(args.e.text()), text: this.rdvSplit(args.e.text()),
membre: {id:args.e.data.tags.membre}, membre: {id:args.e.data.tags.membre},
team: {id:this.teamId} team: {id:this.teamId}
} }
this.evenementService.updateEvenements(event).subscribe( 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(); next: result => {
this.alert={"type":"success", "content":"L'évènement à bien été modifié"}; this.viewChange();
this.isShow = true; this.alert={"type":"success", "content":"L'évènement à bien été déplacé"};
}, this.isShow = true;
error: err => { },
this.viewChange(); error: err => {
this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenment"}; this.viewChange();
this.isShow = true; this.alert={"type":"danger", "content":"Problème lors de la modification de l'évenement"};
}, 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:8088', apiUrl: 'http://localhost:8088',
tokenKey: 'TOKEN-ORGANIZEE', tokenKey: 'TOKEN-ORGANIZEE',
debug: true,
}; };
/* /*