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

View File

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

View File

@ -1,9 +1,9 @@
<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>
<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">
<img src="img/logo-negative-beta.svg" alt="Copay" width="100">
</div>
@ -167,7 +167,7 @@
</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
</button>
@ -184,7 +184,7 @@
</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">
<img src="img/clipo-pin.png" alt="clipo" width="380">
</div>
@ -198,7 +198,7 @@
</span>
</div>
<form name="setPinForm" ng-submit="createPin(setPinForm)" novalidate>
<form name="setPinForm" novalidate>
<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">
<i class="icon-locked"></i>
@ -215,9 +215,8 @@
</a>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<button translate type="submit" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error || loading">
<i class="fi-bitcoin-circle icon-rotate spinner" ng-show="loading"></i>
<button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error">
OK
</button>
</div>

View File

@ -36,7 +36,7 @@
</span>
</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">
<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>
@ -53,9 +53,8 @@
</a>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<button translate type="submit" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error || loading">
<i class="fi-bitcoin-circle icon-rotate spinner" ng-show="loading"></i>
<button translate ng-click="createPin(setPinForm.repeatpin.$modelValue)" class="button primary radius expand m0"
ng-disabled="setPinForm.$invalid || error">
OK
</button>
</div>
@ -92,7 +91,7 @@
</a>
</div>
<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">
Sign in
</button>
@ -145,7 +144,7 @@
<i class="icon-locked"></i>
</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
</button>
</form>

View File

@ -1,5 +1,5 @@
<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>

View File

@ -1,6 +1,6 @@
<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>

View File

@ -1,5 +1,5 @@
<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>