Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | 195x 85x 85x 85x 85x 85x 85x 84x 85x 85x 2520x 85x 84x 84x 2605x 110x | import { Component, inject, LOCALE_ID, OnDestroy, OnInit } from '@angular/core';
import { Router, RouterModule, RouterLink } from '@angular/router';
import { MessageService } from 'primeng/api';
import { interval, Subscription } from 'rxjs';
import { DatePipe, NgIf } from '@angular/common';
import { TwinpadApiService } from '../../services/twinpad-api.service';
import { AvatarModule } from 'primeng/avatar';
import { StyleService } from '../../services/style.service';
import { User } from '../../models/users';
@Component({
selector: 'app-header',
imports: [RouterModule, RouterLink, DatePipe, AvatarModule, NgIf],
templateUrl: './header.component.html',
styleUrl: './header.component.scss'
})
export class HeaderComponent implements OnInit, OnDestroy{
private router = inject(Router);
private twinpadApiService = inject(TwinpadApiService);
private styleService= inject(StyleService);
locale = inject(LOCALE_ID);
messageService = inject(MessageService);
userAdmin: boolean;
localTimeZone: string;
now: Date;
subscription: Subscription;
user: User;
imagePictureUrl: string;
ngOnInit(){
this.twinpadApiService.getProfile().subscribe({
next: user => {
this.userAdmin = user.is_admin;
},
error: error => {
this.userAdmin = false;
console.log(error);
}
});
this.localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
this.updateTime();
this.subscription = interval(100).subscribe(() => this.updateTime());
this.twinpadApiService.getProfile().subscribe({next: user =>{
this.user = user;
this.imagePictureUrl = this.styleService.getCustomerLogoFromEmail(this.user.email);
}});
}
ngOnDestroy(){
this.subscription?.unsubscribe();
}
private updateTime() {
this.now = new Date();
}
logout(){
this.twinpadApiService.logout();
setTimeout(() => {
this.twinpadApiService.redirectToLogin(this.router);
}, 1500);
this.messageService.add({severity:'success', summary: 'Logout success', detail: 'Successfully logout' });
}
}
|