admin.component.ts
806 Bytes
import { Component, OnInit, HostListener, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { InactiveScreenService } from 'src/app/services/inactive-screen/inactive-screen.service';
@Component({
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.scss']
})
export class AdminComponent implements OnInit, OnDestroy {
constructor(
private inactiveScreen: InactiveScreenService,
) { }
ngOnInit() {
this.inactiveScreen.startTimeOutInactividad();
}
ngOnDestroy() {
clearTimeout(this.inactiveScreen.timerReposo);
}
@HostListener('document:click', ['$event'])
eventListener(event: Event) {
clearTimeout(this.inactiveScreen.timerReposo);
this.inactiveScreen.startTimeOutInactividad();
}
}