Ajout d'une variable pour avoir le rôle dans le home et le nom et prénom en plus dans le navbar

master
Yanaël GRETTE 4 years ago
parent 253fe14956
commit 5e038cf604
  1. 8
      src/app/home/home.component.html
  2. 8
      src/app/home/home.component.ts
  3. 1
      src/app/modeles/modele-formation.ts
  4. 10
      src/app/nav-menu/nav-menu.component.html
  5. 11
      src/app/nav-menu/nav-menu.component.ts
  6. BIN
      src/assets/img/logo.png

@ -1,6 +1,6 @@
<app-nav-menu></app-nav-menu> <app-nav-menu></app-nav-menu>
<h1> Bonjour</h1> <h1> Bonjour</h1>
<home-assistante *ngIf="this.keycloakService.isUserInRole(role.assistante)"></home-assistante> <home-assistante *ngIf="this.userRole == role.assistante"></home-assistante>
<home-collaborateur *ngIf="this.keycloakService.isUserInRole(role.collaborateur)"></home-collaborateur> <home-collaborateur *ngIf="this.userRole ==role.collaborateur"></home-collaborateur>
<home-commercial *ngIf="this.keycloakService.isUserInRole(role.commercial)"></home-commercial> <home-commercial *ngIf="this.userRole ==role.commercial"></home-commercial>
<home-rh *ngIf="this.keycloakService.isUserInRole(role.rh)"></home-rh> <home-rh *ngIf="this.userRole ==role.rh"></home-rh>

@ -4,6 +4,8 @@ import { KeycloakService } from 'keycloak-angular';
import { Role } from '../utils/roles'; import { Role } from '../utils/roles';
import { environment } from '../../environments/'
@Component({ @Component({
selector: 'app-home', selector: 'app-home',
templateUrl: './home.component.html' templateUrl: './home.component.html'
@ -11,10 +13,12 @@ import { Role } from '../utils/roles';
export class HomeComponent implements OnInit { export class HomeComponent implements OnInit {
role = Role; role = Role;
constructor(public keycloakService : KeycloakService) { userRole : string;
constructor(private keycloakService : KeycloakService) {
let clientId = environment.keycloakConfig.clientId;
this.userRole = this.keycloakService.getKeycloakInstance().resourceAccess[clientId]["roles"][0];
} }
ngOnInit() { ngOnInit() {
} }
} }

@ -10,6 +10,7 @@ export class FormationModel {
duree? : number; duree? : number;
organisme? : string; organisme? : string;
nomFormateur? : string; nomFormateur? : string;
participantsFormation : ParticipationFormationModel[];
}; };

@ -5,14 +5,14 @@
<!--LIEN VERS HOME--> <!--LIEN VERS HOME-->
<button mat-button>Accueil</button> <button mat-button>Accueil</button>
<!--RESTE MENU EN FONCTION DES ROLES--> <!--RESTE MENU EN FONCTION DES ROLES-->
<app-nav-menu-assistante *ngIf="this.keycloakService.isUserInRole(role.assistante)"></app-nav-menu-assistante> <app-nav-menu-assistante *ngIf="this.userRole == role.assistante"></app-nav-menu-assistante>
<app-nav-menu-collaborateur *ngIf="this.keycloakService.isUserInRole(role.collaborateur)"></app-nav-menu-collaborateur> <app-nav-menu-collaborateur *ngIf="this.userRole == role.collaborateur"></app-nav-menu-collaborateur>
<app-nav-menu-commercial *ngIf="this.keycloakService.isUserInRole(role.commercial)"></app-nav-menu-commercial> <app-nav-menu-commercial *ngIf="this.userRole == role.commercial"></app-nav-menu-commercial>
<app-nav-menu-rh *ngIf="this.keycloakService.isUserInRole(role.rh)"></app-nav-menu-rh> <app-nav-menu-rh *ngIf="this.userRole == role.rh"></app-nav-menu-rh>
<!--METTRE QUELQUE CHOSE DE SIMILAIRE A SYGES--> <!--METTRE QUELQUE CHOSE DE SIMILAIRE A SYGES-->
<!--<button mat-button on-click="logout()"> logout </button>--> <!--<button mat-button on-click="logout()"> logout </button>-->
<button mat-button [matMenuTriggerFor]="menuMore"> <button mat-button [matMenuTriggerFor]="menuMore">
<span>{{ keycloakService.getKeycloakInstance().profile.firstName }} {{ keycloakService.getKeycloakInstance().profile.lastName }}</span> <span> {{this.userInfo}}</span>
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
<mat-menu #menuMore="matMenu"> <mat-menu #menuMore="matMenu">

@ -3,6 +3,8 @@ import { KeycloakService } from 'keycloak-angular';
import { Role } from '../utils/roles'; import { Role } from '../utils/roles';
import { environment } from '../../environments/'
@Component({ @Component({
selector: 'app-nav-menu', selector: 'app-nav-menu',
templateUrl: './nav-menu.component.html', templateUrl: './nav-menu.component.html',
@ -10,7 +12,14 @@ import { Role } from '../utils/roles';
export class NavMenuComponent { export class NavMenuComponent {
role = Role; role = Role;
constructor(public keycloakService : KeycloakService){} userRole : string;
userInfo : string;
constructor(private keycloakService : KeycloakService){
let clientId = environment.keycloakConfig.clientId;
this.userRole = this.keycloakService.getKeycloakInstance().resourceAccess[clientId]["roles"][0];
let profil = keycloakService.getKeycloakInstance().profile;
this.userInfo = profil.firstName+" "+profil.lastName;
}
isExpanded = false; isExpanded = false;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Loading…
Cancel
Save