fix delay of submit after enter the PIN

This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-11 18:13:13 -03:00
parent 065b95293a
commit d4a4fe0498
7 changed files with 34 additions and 42 deletions

View File

@ -43,7 +43,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
preconditions.checkArgument(pin); preconditions.checkArgument(pin);
preconditions.checkState($rootScope.iden); preconditions.checkState($rootScope.iden);
preconditions.checkState(_credentials && _credentials.email); preconditions.checkState(_credentials && _credentials.email);
$scope.loading = true; $rootScope.starting = true;
$timeout(function() { $timeout(function() {
$rootScope.$digest(); $rootScope.$digest();
@ -53,10 +53,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
_credentials = null; _credentials = null;
$scope.askForPin = 0; $scope.askForPin = 0;
$rootScope.hasPin = true; $rootScope.hasPin = true;
$scope.loading = null; $rootScope.starting = null;
$scope.createDefaultWallet(); $scope.createDefaultWallet();
}); });
}, 1); }, 100);
}; };
@ -91,13 +91,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
}, 1); }, 1);
}; };
$scope.createDefaultWallet = function() { $scope.createDefaultWallet = function() {
$rootScope.hideNavigation = false; $rootScope.hideNavigation = false;
identityService.createDefaultWallet(function(err) { identityService.createDefaultWallet(function(err) {
$scope.askForPin = 0; $scope.askForPin = 0;
$scope.loading = false;
if (err) { if (err) {
var msg = err.toString(); var msg = err.toString();
@ -106,16 +103,15 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
}); });
}; };
$scope._doCreateProfile = function(emailOrUsername, password, cb) { $scope._doCreateProfile = function(emailOrUsername, password, cb) {
preconditions.checkArgument(_.isString(emailOrUsername)); preconditions.checkArgument(_.isString(emailOrUsername));
preconditions.checkArgument(_.isString(password)); preconditions.checkArgument(_.isString(password));
$rootScope.hideNavigation = false; $rootScope.hideNavigation = false;
$scope.loading = true; $rootScope.starting = true;
identityService.create(emailOrUsername, password, function(err) { identityService.create(emailOrUsername, password, function(err) {
$scope.loading = null; $rootScope.starting = null;
$scope.error = null; $scope.error = null;
if (err) { if (err) {
var msg = err.toString(); var msg = err.toString();

View File

@ -64,20 +64,17 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$rootScope.starting = true; $rootScope.starting = true;
$timeout(function() { $timeout(function() {
$rootScope.$digest();
var credentials = pinService.get(pin, function(err, credentials) { var credentials = pinService.get(pin, function(err, credentials) {
if (err || !credentials) { if (err || !credentials) {
$rootScope.starting = false; $rootScope.starting = null;
$scope.loading = null;
$scope.error = 'Wrong PIN'; $scope.error = 'Wrong PIN';
return; return;
} }
$scope.open(credentials.email, credentials.password); $scope.open(credentials.email, credentials.password);
}); });
},1); },100);
}; };
$scope.openWallets = function() { $scope.openWallets = function() {
preconditions.checkState($rootScope.iden); preconditions.checkState($rootScope.iden);
var iden = $rootScope.iden; var iden = $rootScope.iden;
@ -90,16 +87,18 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
preconditions.checkArgument(pin); preconditions.checkArgument(pin);
preconditions.checkState($rootScope.iden); preconditions.checkState($rootScope.iden);
preconditions.checkState(_credentials && _credentials.email); preconditions.checkState(_credentials && _credentials.email);
$scope.loading = true; $rootScope.starting = true;
pinService.save(pin, _credentials.email, _credentials.password, function(err) { $timeout(function() {
_credentials.password = ''; pinService.save(pin, _credentials.email, _credentials.password, function(err) {
_credentials = null; _credentials.password = '';
$scope.askForPin = 0; _credentials = null;
$rootScope.hasPin = true; $scope.askForPin = 0;
$scope.loading = null; $rootScope.hasPin = true;
$scope.openWallets(); $rootScope.starting = null;
}); $scope.openWallets();
});
},100);
}; };
$scope.openWithCredentials = function(form) { $scope.openWithCredentials = function(form) {
@ -144,7 +143,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.error = 'Unknown error'; $scope.error = 'Unknown error';
} }
$rootScope.starting = false; $rootScope.starting = false;
$scope.loading = null;
$timeout(function(){ $timeout(function(){
$rootScope.$digest(); $rootScope.$digest();
},1) },1)

View File

@ -1,9 +1,9 @@
<div class="createProfile" ng-controller="CreateProfileController" ng-init="init()"> <div class="createProfile" ng-controller="CreateProfileController" ng-init="init()">
<div data-alert ng-show="loading"> <div ng-show="$root.starting">
<div ng-include="'views/includes/loading.html'" ng-init="title = 'Creating profile'"></div> <div ng-include="'views/includes/loading.html'" ng-init="title = 'Creating profile'"></div>
</div> </div>
<div class="large-4 large-centered medium-7 medium-centered columns m20b" ng-show="!loading && !askForPin"> <div class="large-4 large-centered medium-7 medium-centered columns m20b" ng-show="!$root.starting && !askForPin">
<div class="logo-setup hide-for-small-only"> <div class="logo-setup hide-for-small-only">
<img src="img/logo-negative-beta.svg" alt="Copay" width="100"> <img src="img/logo-negative-beta.svg" alt="Copay" width="100">
</div> </div>
@ -167,7 +167,7 @@
</div> </div>
</div> </div>
<button translate type="submit" class="button primary radius expand m0" ng-disabled="passForm.$invalid || loading"> <button translate type="submit" class="button primary radius expand m0" ng-disabled="passForm.$invalid">
Create Profile Create Profile
</button> </button>
@ -184,7 +184,7 @@
</div> </div>
</div> </div>
<div class="large-4 large-centered medium-6 medium-centered columns m20b" ng-show="!loading && askForPin"> <div class="large-4 large-centered medium-6 medium-centered columns m20b" ng-show="!$root.starting && askForPin">
<div class="clipo"> <div class="clipo">
<img src="img/clipo-pin.png" alt="clipo" width="380"> <img src="img/clipo-pin.png" alt="clipo" width="380">
</div> </div>
@ -198,7 +198,7 @@
</span> </span>
</div> </div>
<form name="setPinForm" ng-submit="createPin(setPinForm)" novalidate> <form name="setPinForm" novalidate>
<div class="input" ng-show="askForPin == 1"> <div class="input" ng-show="askForPin == 1">
<input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1"> <input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1">
<i class="icon-locked"></i> <i class="icon-locked"></i>
@ -215,9 +215,8 @@
</a> </a>
</div> </div>
<div class="large-6 medium-6 small-6 columns text-right"> <div class="large-6 medium-6 small-6 columns text-right">
<button translate type="submit" class="button primary radius expand m0" <button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error || loading"> ng-disabled="setPinForm.$invalid || error">
<i class="fi-bitcoin-circle icon-rotate spinner" ng-show="loading"></i>
OK OK
</button> </button>
</div> </div>

View File

@ -36,7 +36,7 @@
</span> </span>
</div> </div>
<form name="setPinForm" ng-model="setPinForm" ng-submit="createPin(setPinForm)" novalidate> <form name="setPinForm" ng-model="setPinForm" novalidate>
<div class="input" ng-show="askForPin == 1"> <div class="input" ng-show="askForPin == 1">
<input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1"> <input id="newpin" type="tel" ng-model="newpin" class="form-control" ng-maxlength="4" ng-minlength="4" maxlength="4" ng-pattern="/^[0-9]{1,4}$/" placeholder="PIN" name="newpin" required show-focus="askForPin == 1">
<i class="icon-locked"></i> <i class="icon-locked"></i>
@ -53,9 +53,8 @@
</a> </a>
</div> </div>
<div class="large-6 medium-6 small-6 columns text-right"> <div class="large-6 medium-6 small-6 columns text-right">
<button translate type="submit" class="button primary radius expand m0" <button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error || loading"> ng-disabled="setPinForm.$invalid || error">
<i class="fi-bitcoin-circle icon-rotate spinner" ng-show="loading"></i>
OK OK
</button> </button>
</div> </div>
@ -92,7 +91,7 @@
</a> </a>
</div> </div>
<div class="large-6 medium-6 small-6 columns text-right"> <div class="large-6 medium-6 small-6 columns text-right">
<button translate type="submit" class="button primary radius expand m0" <button translate ng-click="openWithPin(pinForm.pin.$modelValue)" class="button primary radius expand m0"
ng-disabled="pinForm.$invalid || error"> ng-disabled="pinForm.$invalid || error">
Sign in Sign in
</button> </button>
@ -145,7 +144,7 @@
<i class="icon-locked"></i> <i class="icon-locked"></i>
</div> </div>
<button translate type="submit" class="button primary radius expand m0" ng-disabled="loginForm.$invalid || loading"> <button translate type="submit" class="button primary radius expand m0" ng-disabled="loginForm.$invalid">
Sign in Sign in
</button> </button>
</form> </form>

View File

@ -1,5 +1,5 @@
<div class="import" ng-controller="ImportController"> <div class="import" ng-controller="ImportController">
<div data-alert ng-show="loading"> <div ng-show="loading">
<div ng-include="'views/includes/loading.html'" ng-init="title = importStatus"></div> <div ng-include="'views/includes/loading.html'" ng-init="title = importStatus"></div>
</div> </div>

View File

@ -1,6 +1,6 @@
<div class="import-profile" ng-controller="ImportProfileController"> <div class="import-profile" ng-controller="ImportProfileController">
<div data-alert ng-show="loading"> <div ng-show="loading">
<div ng-include="'views/includes/loading.html'" ng-init="title = importStatus"></div> <div ng-include="'views/includes/loading.html'" ng-init="title = importStatus"></div>
</div> </div>

View File

@ -1,5 +1,5 @@
<div class="join" ng-controller="JoinController"> <div class="join" ng-controller="JoinController">
<div data-alert ng-show="loading"> <div ng-show="loading">
<div ng-include="'views/includes/loading.html'" ng-init="title = 'Connecting to Insight Wallet Server'"></div> <div ng-include="'views/includes/loading.html'" ng-init="title = 'Connecting to Insight Wallet Server'"></div>
</div> </div>