Merge pull request #2461 from cmgustavo/bug/ng-idle-module01

Updates ng-idle module
This commit is contained in:
Matias Alejo Garcia 2015-03-30 18:39:29 -03:00
commit dec9c9fcf5
3 changed files with 14 additions and 13 deletions

View File

@ -19,7 +19,7 @@
"qrcode-decoder-js": "*",
"angular-moment": "~0.7.1",
"socket.io-client": ">=1.0.0",
"ng-idle": "*",
"ng-idle": "~1.0.2",
"inherits": "~0.0.1",
"lodash": "~2.4.1",
"angular-gravatar": "*",

View File

@ -45,22 +45,23 @@ angular.module('copayApp.controllers').controller('HeadController', function($sc
$scope.init = function() {
if (!$rootScope.wallet) return;
$scope.$on('$idleStart', function() {});
$scope.$on('$idleWarn', function(a, countdown) {
$scope.$on('IdleStart', function() {});
$scope.$on('IdleWarn', function(a, countdown) {
$rootScope.countdown = countdown;
$rootScope.sessionExpired = true;
$rootScope.$apply();
});
$scope.$on('$idleEnd', function() {
$scope.$on('IdleEnd', function() {
$timeout(function() {
$rootScope.sessionExpired = null;
}, 500);
});
$scope.$on('$idleTimeout', function() {
$scope.$on('IdleTimeout', function() {
$rootScope.sessionExpired = null;
$scope.signout();
notification.warning('Session closed', 'Session closed because a long time of inactivity');
});
$scope.$on('$keepalive', function() {
$scope.$on('Keepalive', function() {
if ($rootScope.wallet) {
$rootScope.wallet.keepAlive();
}

View File

@ -129,17 +129,17 @@ angular
//Setting HTML5 Location Mode
angular
.module('copayApp')
.config(function($locationProvider, $idleProvider, $keepaliveProvider) {
.config(function($locationProvider, IdleProvider, KeepaliveProvider) {
$locationProvider
.html5Mode(false)
.hashPrefix('!');
// IDLE timeout
var timeout = config.wallet.idleDurationMin * 60 || 300;
$idleProvider.idleDuration(timeout); // in seconds
$idleProvider.warningDuration(40); // in seconds
$keepaliveProvider.interval(30); // in seconds
IdleProvider.idle(timeout); // in seconds
IdleProvider.timeout(40); // in seconds
KeepaliveProvider.interval(30); // in seconds
})
.run(function($rootScope, $location, $idle, gettextCatalog, uriHandler, isCordova, amMoment) {
.run(function($rootScope, $location, Idle, gettextCatalog, uriHandler, isCordova, amMoment) {
var userLang, androidLang;
@ -156,7 +156,7 @@ angular
// Register URI handler, not for mobileApp
if (!isCordova) {
$idle.watch();
Idle.watch();
uriHandler.register();
}
@ -167,7 +167,7 @@ angular
}
if (!$rootScope.iden && next.logged) {
$idle.unwatch();
Idle.unwatch();
$location.path('/');
}
if ($rootScope.wallet && !$rootScope.wallet.isComplete() && next.walletShouldBeComplete) {