display logged-in user
This commit is contained in:
parent
0e76bc7745
commit
ffab44bfc3
6 changed files with 54 additions and 6 deletions
|
|
@ -93,8 +93,21 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="right-container">
|
<div class="right-container">
|
||||||
<p>Good Morning,</p>
|
<p>{{ displayGreeting() }},</p>
|
||||||
<span id="welcome-user">Guest</span>
|
<span id="welcome-user"
|
||||||
|
>{{
|
||||||
|
this.userService.getUserDetails(
|
||||||
|
userService.getCurrentUserId(),
|
||||||
|
"firstName"
|
||||||
|
)
|
||||||
|
}}<br />
|
||||||
|
{{
|
||||||
|
this.userService.getUserDetails(
|
||||||
|
userService.getCurrentUserId(),
|
||||||
|
"lastName"
|
||||||
|
)
|
||||||
|
}}</span
|
||||||
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -163,7 +163,7 @@ section {
|
||||||
|
|
||||||
/*------------- RESPONSIVE -------------*/
|
/*------------- RESPONSIVE -------------*/
|
||||||
|
|
||||||
@media screen and (max-width: 1250px) {
|
@media screen and (max-width: 1500px) {
|
||||||
.right-container {
|
.right-container {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { TaskService } from '../../services/task.service';
|
import { TaskService } from '../../services/task.service';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule, TranslateService } from '@ngx-translate/core';
|
||||||
|
import { UserService } from '../../services/user.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-summary',
|
selector: 'app-summary',
|
||||||
|
|
@ -11,7 +12,11 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||||
styleUrl: './summary.component.scss',
|
styleUrl: './summary.component.scss',
|
||||||
})
|
})
|
||||||
export class SummaryComponent {
|
export class SummaryComponent {
|
||||||
constructor(private taskService: TaskService) {}
|
constructor(
|
||||||
|
private taskService: TaskService,
|
||||||
|
public userService: UserService,
|
||||||
|
private translateService: TranslateService
|
||||||
|
) {}
|
||||||
|
|
||||||
displayNumberOfAllTasks() {
|
displayNumberOfAllTasks() {
|
||||||
return this.taskService.getAllTasks().length;
|
return this.taskService.getAllTasks().length;
|
||||||
|
|
@ -63,4 +68,17 @@ export class SummaryComponent {
|
||||||
var time = month + ' ' + date + ', ' + year;
|
var time = month + ' ' + date + ', ' + year;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayGreeting() {
|
||||||
|
let currentTime = new Date();
|
||||||
|
let localTime = new Date(currentTime.getTime() + 3600000);
|
||||||
|
let currentHour = localTime.getHours();
|
||||||
|
if (currentHour >= 5 && currentHour < 12) {
|
||||||
|
return this.translateService.instant('summary.morning');
|
||||||
|
} else if (currentHour >= 12 && currentHour < 18) {
|
||||||
|
return this.translateService.instant('summary.afternoon');
|
||||||
|
} else {
|
||||||
|
return this.translateService.instant('summary.evening');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,13 @@ export class UserService implements OnDestroy {
|
||||||
return this.allUsers;
|
return this.allUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCurrentUserId() {
|
||||||
|
let currentUser = localStorage.getItem('currentUser');
|
||||||
|
if (currentUser !== null) {
|
||||||
|
return JSON.parse(currentUser)[0].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getUserDetails(userId: string, query: keyof User) {
|
getUserDetails(userId: string, query: keyof User) {
|
||||||
return this.getAllUsers()
|
return this.getAllUsers()
|
||||||
.filter((user) => user.id === userId)
|
.filter((user) => user.id === userId)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,14 @@
|
||||||
<div class="img-language" (click)="toggleLanguage()">
|
<div class="img-language" (click)="toggleLanguage()">
|
||||||
<img src="./../../../../assets/img/header/language.svg" alt="" />
|
<img src="./../../../../assets/img/header/language.svg" alt="" />
|
||||||
</div>
|
</div>
|
||||||
<div class="img-user" (click)="toggleNavbar()">G</div>
|
<div class="img-user" (click)="toggleNavbar()">
|
||||||
|
{{
|
||||||
|
this.userService.getUserDetails(
|
||||||
|
userService.getCurrentUserId(),
|
||||||
|
"initials"
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import { RouterModule } from '@angular/router';
|
||||||
import { NavbarComponent } from '../navbar/navbar.component';
|
import { NavbarComponent } from '../navbar/navbar.component';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { UserService } from '../../../services/user.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
|
|
@ -15,6 +16,8 @@ export class HeaderComponent {
|
||||||
navbarVisible: boolean = false;
|
navbarVisible: boolean = false;
|
||||||
navbarLanguageVisible: boolean = false;
|
navbarLanguageVisible: boolean = false;
|
||||||
|
|
||||||
|
constructor(public userService: UserService) {}
|
||||||
|
|
||||||
toggleNavbar() {
|
toggleNavbar() {
|
||||||
this.navbarVisible = !this.navbarVisible;
|
this.navbarVisible = !this.navbarVisible;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue