Skip to content

Commit a025356

Browse files
author
Jeppe Elkjær Jørgensen
committed
IOT-500 fix and add username + icon
1 parent 8c2ee5a commit a025356

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/app/navbar/global-admin/global-admin.component.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<mat-expansion-panel class="mb-5">
1+
<div *ngIf="user">
2+
<fa-icon [icon]="faUser" class="navbar-icon" style="margin-right: 1em; margin-left: 1em;"></fa-icon> {{user.name}}
3+
</div>
4+
<mat-expansion-panel class="mb-5" *ngIf="isGlobalAdmin">
25
<mat-expansion-panel-header>
36
<mat-panel-title class="nav-item py-2">
47
<p class="nav-item ml-2">Global Administrator</p>

src/app/navbar/global-admin/global-admin.component.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { faGlobe, faUsers, faIdBadge, faSitemap } from '@fortawesome/free-solid-svg-icons';
2+
import { PermissionType } from '@app/admin/permission/permission.model';
3+
import { UserResponse } from '@app/admin/users/user.model';
4+
import { AuthService } from '@app/auth/auth.service';
5+
import { faGlobe, faUsers, faIdBadge, faSitemap, faUser } from '@fortawesome/free-solid-svg-icons';
36

47
@Component({
58
selector: 'app-global-admin',
@@ -11,9 +14,24 @@ export class GlobalAdminComponent implements OnInit {
1114
faUsers = faUsers;
1215
faIdBadge = faIdBadge;
1316
faSitemap = faSitemap;
14-
constructor() { }
17+
faUser = faUser;
18+
19+
public user: UserResponse;
20+
public isGlobalAdmin = false;
21+
22+
constructor(private authService: AuthService) { }
1523

1624
ngOnInit(): void {
25+
this.authService.me()
26+
.subscribe(
27+
(response) => {
28+
this.user = response.user;
29+
this.findGlobalAdminPermission(response.user);
30+
});
31+
}
32+
33+
findGlobalAdminPermission(user: UserResponse) {
34+
this.isGlobalAdmin = this.user.permissions.some(x => x.type === PermissionType.GlobalAdmin);
1735
}
1836

1937
}

0 commit comments

Comments
 (0)