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": "*", "qrcode-decoder-js": "*",
"angular-moment": "~0.7.1", "angular-moment": "~0.7.1",
"socket.io-client": ">=1.0.0", "socket.io-client": ">=1.0.0",
"ng-idle": "*", "ng-idle": "~1.0.2",
"inherits": "~0.0.1", "inherits": "~0.0.1",
"lodash": "~2.4.1", "lodash": "~2.4.1",
"angular-gravatar": "*", "angular-gravatar": "*",

View File

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

View File

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