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 | 195x 85x 85x 85x 85x 84x 85x 85x 2311x 2396x | 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 } from '@angular/common';
import { TwinpadApiService } from '../../services/twinpad-api.service';
@Component({
selector: 'app-header',
imports: [RouterModule, RouterLink, DatePipe],
templateUrl: './header.component.html',
styleUrl: './header.component.scss'
})
export class HeaderComponent implements OnInit, OnDestroy{
locale = inject(LOCALE_ID);
messageService = inject(MessageService);
userAdmin: boolean;
localTimeZone: string;
now: Date;
subscription: Subscription;
constructor(private router: Router, private twinpadApiService: TwinpadApiService){
this.twinpadApiService.getProfile().subscribe({
next: user => {
this.userAdmin = user.is_admin;
},
error: error => {
this.userAdmin = false;
console.log(error);
}
});
}
ngOnInit(){
this.localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
this.updateTime();
this.subscription = interval(100).subscribe(() => this.updateTime());
}
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' });
}
}
|