Skip to content

Commit

Permalink
mise a jour directive
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodolphe_Lassalle committed Jun 11, 2024
1 parent bfc74ad commit 986880b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/components/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class LoginComponent {
});

this.loginVisible = false;
console.log(this.auth.getUserId());
console.log(this.auth.getRole());

this.router.navigate(['/prospect']);
}, error => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@
</span>
} @else {
<div class="flex justify-content-center">
<p-button severity="info" label="Go / NoGo" (click)="validatedBum($event)"
class="p-button-rounded p-button-text">
<p-button severity="info" label="Go/ NoGo" (click)="validatedBum($event)"
class="p-button-rounded p-button-text" *isBum isAdmin>
</p-button>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ export class ListProspectsComponent implements OnInit {
rh: rhValue
};

console.log(newProspect);


this.prospectService.saveProspect(newProspect).subscribe(() => {
this.messageService.add({ severity:'success', summary: 'Success', detail: 'Le prospect est ajouté' });
this.visible = false;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class AuthService {
return typeof window !== 'undefined' ? localStorage.getItem('lastName') : null;
}

getRoles(): string | null {
return typeof window !== 'undefined' ? localStorage.getItem('roles') : null;
getRole(): string | null {
return typeof window !== 'undefined' ? localStorage.getItem('role') : null;
}

getToken(): string | null {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/app/services/auth/identity.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { Injectable } from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Roles } from '@eps/shared/enums/role';
import { AuthService } from './auth.service';

@Injectable({
providedIn: 'root'
})
export class IdentityService {
readonly auth = inject(AuthService);

role = localStorage.getItem('roles');
role = this.auth.getRole();

isAdmin(){
if (this.role !== undefined && this.role !== null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
[text]="true"
severity="secondary "
*ifAdmin />
<p-avatar size="xlarge">
<span class="text-base">{{ user }}</span>
</p-avatar>
</div>
</div>

14 changes: 13 additions & 1 deletion frontend/src/app/shared/components/topbar/topbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { IfAdminDirective } from '@eps/directives/if-admin.directive';
import { MenuItem } from 'primeng/api';
import { ButtonModule } from 'primeng/button';
import { TooltipModule } from 'primeng/tooltip';
import { AuthService } from '@eps/service/auth/auth.service';

@Component({
selector: 'eps-topbar',
Expand All @@ -23,5 +24,16 @@ export class TopbarComponent {
@ViewChild('topbarmenubutton') topbarMenuButton!: ElementRef;
@ViewChild('topbarmenu') menu!: ElementRef;

layoutService = inject(LayoutService);
readonly layoutService = inject(LayoutService);
readonly auth = inject(AuthService);

firstName: string | null = '';
user: string = '';

ngOnInit(): void {
this.firstName = this.auth.getFirstName();
if(this.firstName !== null) {
this.user = this.firstName;
}
}
}

0 comments on commit 986880b

Please sign in to comment.