This kind of functionality would first need to be implemented on the server via sessions so that someone with the know-how couldn't still make requests as the person who was previously logged in and active within the application.
Now I want my Angular to perform this task after X minutes of inactivity. Any ideas?
Within Angular you can use the $interval
service to perform a task every n ms. However, there is no simple way of capturing all events that occur within a document, and this is presumably how you would definitively know if a user had walked away from their machine or tabbed out of the application, for example.
A simple alternative would be to watch for mouse movement. Here is that answer adapted to the Angular ecosystem:
[ See it working in a JSFiddle. ]
HTML
<div ng-app>
<div ng-controller="IdleWatch">
<span ng-show="!isIdle()">User not idle</span>
<span ng-show="isIdle()">User idle</span>
</div>
</div>
JavaScript
function IdleWatch ($scope, $interval, $document) {
var int = null;
var callbacks = [];
var idleTime = 0;
$scope.isIdle = function() {
return (idleTime > 0);
};
angular.element($document).bind('mousemove', function(e) {
idleTime = 0;
$interval.cancel(int);
startInterval();
$scope.$apply();
});
function startInterval() {
int = $interval(function() {
idleTime += 3000;
}, 3000);
}
startInterval();
}