limitations au ROLE_ENFANT sur page account/ modifier, supprimer et ajouter membre ok
This commit is contained in:
parent
2dd153198e
commit
95d9ab28f0
10 changed files with 56 additions and 15 deletions
|
@ -8,11 +8,13 @@
|
||||||
<h3 class="mt-2 mb-0">{{membre.prenom }} {{membre.nom }}</h3>
|
<h3 class="mt-2 mb-0">{{membre.prenom }} {{membre.nom }}</h3>
|
||||||
<div class="buttons text-center"><button button type="button" class="btn btn-outline-primary px-4"
|
<div class="buttons text-center"><button button type="button" class="btn btn-outline-primary px-4"
|
||||||
routerLink="../modifier-membre/{{membre.id}}"
|
routerLink="../modifier-membre/{{membre.id}}"
|
||||||
routerLinkActive="active-custom">
|
routerLinkActive="active-custom"
|
||||||
|
[hidden]="parent == false">
|
||||||
Modifier
|
Modifier
|
||||||
</button><button button type="button" class="btn btn-primary px-4"
|
</button><button button type="button" class="btn btn-primary px-4"
|
||||||
routerLink="../supprimer-membre/{{membre.id}}"
|
routerLink="../supprimer-membre/{{membre.id}}"
|
||||||
routerLinkActive="active-custom">
|
routerLinkActive="active-custom"
|
||||||
|
[hidden]="parent == false">
|
||||||
Supprimer
|
Supprimer
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
|
import { TokenService } from 'src/app/services/token.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-card-member',
|
selector: 'app-card-member',
|
||||||
|
@ -7,10 +8,24 @@ import { Component, Input, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class CardMemberComponent implements OnInit {
|
export class CardMemberComponent implements OnInit {
|
||||||
@Input() membre: any;
|
@Input() membre: any;
|
||||||
|
parent: boolean;
|
||||||
|
|
||||||
constructor() { }
|
constructor(private tokenService: TokenService) {
|
||||||
|
this.parent = false;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||||
|
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||||
|
const userRole = this.tokenService.getRole();
|
||||||
|
if(userRole == "ROLE_PARENT"){
|
||||||
|
this.parent = true;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
|
}
|
||||||
|
else if(userRole== "ROLE_ENFANT"){
|
||||||
|
this.parent = false;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
//background-color: #c3c3e7;
|
padding-left: 10px;
|
||||||
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
.nav{
|
.nav{
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
|
@ -19,5 +20,9 @@ li {
|
||||||
|
|
||||||
a{
|
a{
|
||||||
color: black;
|
color: black;
|
||||||
|
background-color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
padding: none;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
border-radius: 15px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { Team } from "./team";
|
||||||
|
|
||||||
export interface Membre {
|
export interface Membre {
|
||||||
id: string;
|
id: string;
|
||||||
nom: string;
|
nom: string;
|
||||||
|
@ -7,6 +9,6 @@ export interface Membre {
|
||||||
dateNaissance: Date;
|
dateNaissance: Date;
|
||||||
couleur: string;
|
couleur: string;
|
||||||
passwordConfirm: string;
|
passwordConfirm: string;
|
||||||
// smiley: string;
|
//team: Team;
|
||||||
roleList: string[];
|
roleList: string[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
export interface Team {
|
export interface Team {
|
||||||
|
id: string;
|
||||||
nom : string;
|
nom : string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<app-header></app-header>
|
<app-header></app-header>
|
||||||
<app-side-bar></app-side-bar>
|
<app-side-bar [backgroundColor]="'#7879F1'"></app-side-bar>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-9 offset-2" id="main">
|
<div class="col-9 offset-2" id="main">
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
class="btn btn-primary btn-lg"
|
class="btn btn-primary btn-lg"
|
||||||
routerLink="../ajout-membre"
|
routerLink="../ajout-membre"
|
||||||
routerLinkActive="active-custom"
|
routerLinkActive="active-custom"
|
||||||
|
[hidden]="parent == false"
|
||||||
>
|
>
|
||||||
Ajouter un membre
|
Ajouter un membre
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -37,10 +37,16 @@ export class PageAccountComponent implements OnInit {
|
||||||
this.listMembres = membres;
|
this.listMembres = membres;
|
||||||
});
|
});
|
||||||
|
|
||||||
/***Gestion des limatations en fonction du role (parent ou enfant) */
|
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||||
const roleUser = this.tokenService.getRole();
|
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||||
if(roleUser == "ROLE_PARENT"){
|
const userRole = this.tokenService.getRole();
|
||||||
|
if(userRole == "ROLE_PARENT"){
|
||||||
this.parent = true;
|
this.parent = true;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
|
}
|
||||||
|
else if(userRole== "ROLE_ENFANT"){
|
||||||
|
this.parent = false;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
class="btn btn-primary btn-lg bouton-non"
|
class="btn btn-primary btn-lg bouton-non"
|
||||||
routerLink="/compte"
|
routerLink="/compte"
|
||||||
routerLinkActive="active-custom"
|
routerLinkActive="active-custom"
|
||||||
|
[hidden]="parent == false"
|
||||||
>Non, je ne souhaite pas supprimer ce compte
|
>Non, je ne souhaite pas supprimer ce compte
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-primary btn-lg bouton-oui"
|
class="btn btn-primary btn-lg bouton-oui"
|
||||||
(clickDelete)="onClickDelete()"
|
(clickDelete)="onClickDelete()"
|
||||||
|
[hidden]="parent == false"
|
||||||
>Oui, je souhaite supprimer ce compte
|
>Oui, je souhaite supprimer ce compte
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,10 +9,9 @@ import { TokenService } from 'src/app/services/token.service';
|
||||||
styleUrls: ['./page-delete-member.component.scss']
|
styleUrls: ['./page-delete-member.component.scss']
|
||||||
})
|
})
|
||||||
export class PageDeleteMemberComponent implements OnInit {
|
export class PageDeleteMemberComponent implements OnInit {
|
||||||
@Output() clickDelete = new EventEmitter();
|
|
||||||
parent: boolean;
|
|
||||||
public membreId: any;
|
public membreId: any;
|
||||||
public membreInfos: any;
|
public membreInfos: any;
|
||||||
|
parent: boolean;
|
||||||
|
|
||||||
|
|
||||||
constructor(private membreService: MembreService,
|
constructor(private membreService: MembreService,
|
||||||
|
@ -36,12 +35,17 @@ export class PageDeleteMemberComponent implements OnInit {
|
||||||
console.log(membreInfos.id);
|
console.log(membreInfos.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
const roleUser = this.tokenService.getRole();
|
/** Récupérer le rôle de l'uilisateur connecté pour lui imposer des limitations s'il a un ROLE_ENFANT **/
|
||||||
|
/** Il s'agit de cacher les boutons qui permettent de modifier et supprimer les profils (html)**/
|
||||||
if(roleUser == "ROLE_PARENT"){
|
const userRole = this.tokenService.getRole();
|
||||||
|
if(userRole == "ROLE_PARENT"){
|
||||||
this.parent = true;
|
this.parent = true;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
|
}
|
||||||
|
else if(userRole== "ROLE_ENFANT"){
|
||||||
|
this.parent = false;
|
||||||
|
console.log('Rôle : ' + userRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************** Suppresion d'un membre au click ********************/
|
/********************** Suppresion d'un membre au click ********************/
|
||||||
|
|
|
@ -59,6 +59,7 @@ export class PageSignupComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
public onSubmit(): void {
|
public onSubmit(): void {
|
||||||
|
const teamIdValue = this.signupForm.value[''];
|
||||||
const teamNameValue = this.signupForm.value['teamNameFc'];
|
const teamNameValue = this.signupForm.value['teamNameFc'];
|
||||||
const idValue = this.signupForm.value[''];
|
const idValue = this.signupForm.value[''];
|
||||||
const prenomValue = this.signupForm.value['firstNameFc'];
|
const prenomValue = this.signupForm.value['firstNameFc'];
|
||||||
|
@ -71,6 +72,7 @@ export class PageSignupComponent implements OnInit {
|
||||||
const roleValue = ['ROLE_PARENT'];
|
const roleValue = ['ROLE_PARENT'];
|
||||||
|
|
||||||
const team: Team = {
|
const team: Team = {
|
||||||
|
id : teamIdValue,
|
||||||
nom : teamNameValue,
|
nom : teamNameValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,6 +85,7 @@ export class PageSignupComponent implements OnInit {
|
||||||
couleur: couleurValue,
|
couleur: couleurValue,
|
||||||
dateNaissance: dateNaissanceValue,
|
dateNaissance: dateNaissanceValue,
|
||||||
passwordConfirm: passwordConfirmValue,
|
passwordConfirm: passwordConfirmValue,
|
||||||
|
//team: teamIdValue,
|
||||||
roleList: roleValue,
|
roleList: roleValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue