show username in header

mazdak/UX-fix-changePassword
Mazdak Gibran 3 weeks ago
parent aa3b22c65f
commit 3ac1eb2bd9

@ -44,14 +44,14 @@
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<div class="d-none d-lg-inline-block me-3"> <div class="d-none d-lg-inline-block me-3">
<label class="text-muted fw-normal mb-0" <label class="text-muted fw-normal mb-0 "
[title]="mismatchedDates" [title]="mismatchedDates"
[style]="{'color': dateColor}" [style]="{'color': dateColor}"
style="font-size: 14px;"> style="font-size: 14px;" >
{{'date' | translate}}: {{date}} {{'date' | translate}}: {{date}}
</label> </label>
</div> </div>
<div class="dropdown d-inline-block profile-dropdown"> <div class="dropdown d-inline-block profile-dropdown">
<button type="button" <button type="button"
class="btn header-item waves-effect p-0 d-flex align-items-center" class="btn header-item waves-effect p-0 d-flex align-items-center"
@ -60,10 +60,10 @@
aria-haspopup="true" aria-haspopup="true"
[attr.aria-expanded]="isDropdownVisible ? 'true' : 'false'"> [attr.aria-expanded]="isDropdownVisible ? 'true' : 'false'">
<img class="rounded-circle header-profile-user" src="assets/images/user-icon.png" alt="user-icon" /> <img class="rounded-circle header-profile-user" src="assets/images/user-icon.png" alt="user-icon" />
<span class="d-none d-xl-inline-block ms-2 text-muted">{{username}}</span> <span class="d-none d-xl-inline-block ms-2 fw-sm">{{username}}</span>
<i class="mdi mdi-chevron-down text-muted d-xl-inline-block font-size-22"></i> <i class="mdi mdi-chevron-down text-muted d-xl-inline-block font-size-22"></i>
</button> </button>
<div class="dropdown-menu dropdown-menu-end" [ngClass]="{'show': isDropdownVisible}"> <div class="dropdown-menu dropdown-menu-end" [ngClass]="{'show': isDropdownVisible}">
<a class="dropdown-item text-danger" (click)="logout()"> <a class="dropdown-item text-danger" (click)="logout()">
<i class="bx bx-power-off font-size-16 align-middle me-1 text-danger"></i> {{ 'logout' | translate }} <i class="bx bx-power-off font-size-16 align-middle me-1 text-danger"></i> {{ 'logout' | translate }}

@ -1,4 +1,4 @@
import { Component, HostListener, Inject, PLATFORM_ID } from '@angular/core'; import { Component, HostListener, Inject, OnInit, PLATFORM_ID } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { SidebarService } from '../../../services/sidebar.service'; import { SidebarService } from '../../../services/sidebar.service';
import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { TranslateModule, TranslateService } from '@ngx-translate/core';
@ -12,7 +12,7 @@ import { AuthenticationService } from '../../../services/authenticate.service';
templateUrl: './header.component.html', templateUrl: './header.component.html',
styleUrl: './header.component.scss' styleUrl: './header.component.scss'
}) })
export class HeaderComponent { export class HeaderComponent implements OnInit{
isDropdownVisible: boolean; isDropdownVisible: boolean;
isVacDropdownVisible: boolean; isVacDropdownVisible: boolean;
isNotificationsVisible: boolean; isNotificationsVisible: boolean;
@ -25,9 +25,9 @@ export class HeaderComponent {
}, },
]; ];
direction: string = 'ltr'; direction: string = 'ltr';
userString; user: any;
user; userObj: any;
username; username : string = '';
mismatchedDates: string = ""; mismatchedDates: string = "";
dateColor = "black"; dateColor = "black";
date: any; date: any;
@ -42,9 +42,6 @@ export class HeaderComponent {
this.isDropdownVisible = false; this.isDropdownVisible = false;
this.isVacDropdownVisible = false; this.isVacDropdownVisible = false;
this.isNotificationsVisible = false; this.isNotificationsVisible = false;
this.userString = this.storageService.getItem('user');
this.user = JSON.parse(this.userString as string);
this.username = this.user?.username;
this.date = new Date().toISOString().split('T')[0]; this.date = new Date().toISOString().split('T')[0];
} }
ngOnInit(): void { ngOnInit(): void {
@ -57,6 +54,8 @@ export class HeaderComponent {
this.storageService.setItem('sidebarState', isCollapsed ? 'expanded' : 'collapsed'); this.storageService.setItem('sidebarState', isCollapsed ? 'expanded' : 'collapsed');
} }
} }
this.userObj = JSON.parse(this.storageService.getItem('user') || '{}');
this.username = this.userObj?.user?.userFullname ?? '';
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {

Loading…
Cancel
Save