admin.component.ts
800 Bytes
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
import { Component, OnInit, HostListener } from '@angular/core';
import { Router } from '@angular/router';
@Component({
selector: 'app-admin',
templateUrl: './admin.component.html',
styleUrls: ['./admin.component.scss']
})
export class AdminComponent implements OnInit {
timerReposo: any;
constructor(
private router: Router,
) { }
ngOnInit() {
this.startTimeOutInactividad();
}
@HostListener('document:click', ['$event'])
documentClick(event: MouseEvent) {
if (event) {
this.restartTimer();
}
}
restartTimer() {
clearTimeout(this.timerReposo);
this.startTimeOutInactividad();
}
startTimeOutInactividad() {
this.timerReposo = setTimeout(() => {
this.router.navigate(['cancelar-compra']);
}, 90000);
}
}