add inactivity page

This commit is contained in:
Peter Maquiran
2021-08-27 13:39:52 +01:00
parent 6aec4a1d5f
commit 230ea00341
20 changed files with 344 additions and 210 deletions
+35
View File
@@ -0,0 +1,35 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { SessionStore } from '../store/session.service';
@Injectable({
providedIn: 'root'
})
export class InativityService {
constructor(
private router: Router,
) {
var t;
window.onload = resetTimer;
window.onmousemove = resetTimer;
window.onmousedown = resetTimer; // catches touchscreen presses as well
window.ontouchstart = resetTimer; // catches touchscreen swipes as well
window.onclick = resetTimer; // catches touchpad clicks as well
window.onkeydown = resetTimer;
window.addEventListener('scroll', resetTimer, true); // improved; see comments
function userIsNotActive() {
// your function for too long inactivity goes here
SessionStore.setInativity(false)
// alert('go out')
window['inactivity/function']()
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(userIsNotActive, 60000); // time is in milliseconds
}
}
}