Within this HTML code, I am monitoring the page for idle activity. If the user is idle for a certain period of time, an inactivity alert will be displayed and the user will be logged out.
<div *ngIf="environmentData" xmlns="http://java.sun.com/jsf/html" (load)="startTimers()" (mousemove)="resetTimers()" (keypress)="resetTimers()">
In the TypeScript component where these functions are defined, I have set the timeout duration to 10 minutes. However, the alert appears every time there is mouse movement or a key press. Why isn't it waiting for the specified time before showing the alert?
// Start timers.
startTimers() {
console.log("inside start timers method");
console.log("timeout number is " + this.timeoutNow);
this.timeoutTimer = setTimeout(this.showTimeout(), this.timeoutNow);
// window.location.href = this.environmentData.logoutUrl;
}
showTimeout(){
console.log("inside show timeout");
bootbox.alert("You are being timed out due to inactivity!");
}
// Reset timers.
resetTimers() {
console.log("inside reset timers method");
clearTimeout(this.timeoutTimer);
this.startTimers();
}