I am creating the project using angular. In my project i have used the library ngIdle for when the system goes idle it will give the popup with timer and after that user will logout from the system.
The problem in this when browser goes sleep, then timer is resuming.
https://moribvndvs.github.io/ng2-idle/
Here is the code:
idle.setIdle(5);
// sets a timeout period of 5 seconds. after 10 seconds of inactivity, the user will be considered timed out.
idle.setTimeout(60);
// sets the default interrupts, in this case, things like clicks, scrolls, touches to the document
idle.setInterrupts(DEFAULT_INTERRUPTSOURCES);
idle.onIdleEnd.subscribe(() => this.idleState = 'No longer idle.');
idle.onTimeout.subscribe(() => {
this.idleState = 'Timed out!';
this.timedOut = true;
});
idle.onIdleStart.subscribe(() => this.idleState = 'You\'ve gone idle!');
idle.onTimeoutWarning.subscribe((countdown) => {
this.idleState = 'You will time out in ' + countdown + ' seconds!'
console.log(this.idleState)
}
);
// sets the ping interval to 15 seconds
keepAlive.interval(15);
keepAlive.onPing.subscribe(() => this.lastPing = new Date());
this.reset();
reset() {
// this.idle.setTimeout(false);
this.idle.watch();
this.idleState = 'Started.';
this.timedOut = false;
}
When i put the this.idle.setTimeout(false); in the reset then timer is not initiating.