Merge pull request #3 from matiu/gab1

Refactor profile creation
This commit is contained in:
Gabriel Edgardo Bazán 2015-11-17 15:39:46 -03:00
commit c10bcf0cdb
7 changed files with 72 additions and 95 deletions

View file

@ -1,7 +1,6 @@
<div class="splash content text-center" <div class="splash content text-center"
ng-init="init()"
ng-controller="disclaimerController"> ng-controller="disclaimerController">
<div ng-if="!agreed"> <div>
<div class="row"> <div class="row">
<div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns"> <div class="container-image large-2 medium-2 small-2 medium-centered small-centered large-centered columns">
<img src="img/icon-splash.png" alt="icon" width="100%"> <img src="img/icon-splash.png" alt="icon" width="100%">
@ -15,6 +14,7 @@
<div class="row"> <div class="row">
<div class="scrollArea"> <div class="scrollArea">
<p class="enable_text_select m0"> <p class="enable_text_select m0">
<div class="size-16 text-gray" translate>Terms of Use</div>
<ul> <ul>
<li translate>The software you are about to use functions as a free, open source, and multi-signature digital wallet.</li> <li translate>The software you are about to use functions as a free, open source, and multi-signature digital wallet.</li>
<li translate>The software does not constitute an account where BitPay or other third parties serve as financial intermediaries or custodians of your bitcoin.</li> <li translate>The software does not constitute an account where BitPay or other third parties serve as financial intermediaries or custodians of your bitcoin.</li>
@ -33,21 +33,24 @@
</div> </div>
</div> </div>
</div> </div>
<div class="text-center size-12 text-warning" ng-show="error">
{{(error)|translate}}. <span translate>Retrying...</span>
</div>
<div class="row"> <div class="row">
<p ng-show="lang != 'en'"> <p ng-show="lang != 'en'">
<a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a> <a class="center" ng-click="$root.openExternalLink('https://copay.io/disclaimer')" translate>Official English Disclaimer</a>
</p> </p>
</div> </div>
<div ng-show="!agreed"> <div>
<p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p> <p class="text-gray columns" translate>I affirm that I have read, understood, and agree with these terms.</p>
</div> </div>
<div class="row"> <div class="row">
<div class="text-center size-12 text-warning" ng-show="error">
{{(error)|translate}}. <span translate>Retrying...</span>
</div>
<div class="start-button columns"> <div class="start-button columns">
<button ng-disabled="noProfile" ng-click="create()" class="button black expand round size-12 text-spacing" translate> <button ng-disabled="creatingProfile" ng-click="goHome()" class="button black expand round size-12 text-spacing" translate>
GET STARTED I AGREE. GET STARTED
</button> </button>
</div> </div>
</div> </div>

View file

@ -1107,7 +1107,13 @@ input.ng-invalid-match, input.ng-invalid-match:focus {
.scrollArea ul { .scrollArea ul {
font-size: 0.8rem; font-size: 0.8rem;
text-align: left; text-align: justify;
margin-left: 0;
}
.scrollArea li {
list-style-type:none;
display: inline;
} }
.tabbable { .tabbable {

View file

@ -1,38 +1,37 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('disclaimerController', angular.module('copayApp.controllers').controller('disclaimerController',
function($scope, $timeout, $log, profileService, isCordova, storageService, gettextCatalog, applicationService, uxLanguage, go) { function($scope, $timeout, $log, profileService, isCordova, storageService, gettextCatalog, uxLanguage, go) {
self = this; self = this;
$scope.noProfile = true; $scope.lang = uxLanguage.currentLanguage;
$scope.create = function() { $scope.goHome = function() {
storageService.setCopayDisclaimerFlag(function(err) { go.walletHome();
applicationService.restart();
});
}; };
$scope.init = function(noWallet) { var create = function () {
storageService.getCopayDisclaimerFlag(function(err, val) { $scope.creatingProfile = true;
$scope.lang = uxLanguage.currentLanguage; profileService.create({}, function(err) {
$scope.agreed = val;
if (err) {
if (err == 'EEXISTS')
return go.walletHome();
profileService.create({
noWallet: noWallet
}, function(err) {
if (err && !'EEXIST') {
$log.warn(err); $log.warn(err);
$scope.error = err; $scope.error = err;
$scope.$apply(); $scope.$apply();
$scope.noProfile = true;
$timeout(function() { $timeout(function() {
$scope.init(); $log.warn('Retrying to create profile......');
create();
}, 3000); }, 3000);
} else { } else {
$scope.error = ""; $scope.error = "";
$scope.noProfile = false; $scope.creatingProfile = false;
} }
}); });
});
}; };
// create();
}); });

View file

@ -1295,8 +1295,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$on('Local/NewFocusedWallet', function() { $rootScope.$on('Local/NewFocusedWallet', function() {
self.setFocusedWallet(); self.setFocusedWallet();
self.updateTxHistory(); self.updateTxHistory();
storageService.getCopayDisclaimerFlag(function(err, val) {
if (val) go.walletHome();
storageService.getCleanAndScanAddresses(function(err, walletId) { storageService.getCleanAndScanAddresses(function(err, walletId) {
if (walletId && profileService.walletClients[walletId]) { if (walletId && profileService.walletClients[walletId]) {
$log.debug('Clear last address cache and Scan ', walletId); $log.debug('Clear last address cache and Scan ', walletId);
@ -1307,7 +1305,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
} }
}); });
}); });
});
$rootScope.$on('Local/SetTab', function(event, tab, reset) { $rootScope.$on('Local/SetTab', function(event, tab, reset) {
self.setTab(tab, reset); self.setTab(tab, reset);

View file

@ -75,17 +75,6 @@ angular
// link: http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page?lq=1 // link: http://stackoverflow.com/questions/15606751/angular-changes-urls-to-unsafe-in-extension-page?lq=1
$compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension):|data:image\/)/); $compileProvider.imgSrcSanitizationWhitelist(/^\s*((https?|ftp|file|blob|chrome-extension):|data:image\/)/);
$stateProvider
.state('splash', {
url: '/splash',
needProfile: false,
views: {
'main': {
templateUrl: 'views/splash.html',
}
}
});
$stateProvider $stateProvider
.state('translators', { .state('translators', {
url: '/translators', url: '/translators',
@ -521,9 +510,6 @@ angular
if (err) { if (err) {
if (err.message && err.message.match('NOPROFILE')) { if (err.message && err.message.match('NOPROFILE')) {
$log.debug('No profile... redirecting'); $log.debug('No profile... redirecting');
$state.transitionTo('splash');
} else if (err.message && err.message.match('NONAGREEDDISCLAIMER')) {
$log.debug('Display disclaimer... redirecting');
$state.transitionTo('disclaimer'); $state.transitionTo('disclaimer');
} else { } else {
throw new Error(err); // TODO throw new Error(err); // TODO

View file

@ -134,10 +134,6 @@ angular.module('copayApp.services')
}; };
root.loadAndBindProfile = function(cb) { root.loadAndBindProfile = function(cb) {
storageService.getCopayDisclaimerFlag(function(err, val) {
if (!val) {
return cb(new Error('NONAGREEDDISCLAIMER: Non agreed disclaimer'));
} else {
storageService.getProfile(function(err, profile) { storageService.getProfile(function(err, profile) {
if (err) { if (err) {
$rootScope.$emit('Local/DeviceError', err); $rootScope.$emit('Local/DeviceError', err);
@ -159,8 +155,6 @@ angular.module('copayApp.services')
} }
}); });
}
});
}; };
root._seedWallet = function(opts, cb) { root._seedWallet = function(opts, cb) {

View file

@ -199,14 +199,6 @@ angular.module('copayApp.services')
storage.remove('config', cb); storage.remove('config', cb);
}; };
root.setCopayDisclaimerFlag = function(cb) {
storage.set('agreeDisclaimer', true, cb);
};
root.getCopayDisclaimerFlag = function(cb) {
storage.get('agreeDisclaimer', cb);
};
root.setRemotePrefsStoredFlag = function(cb) { root.setRemotePrefsStoredFlag = function(cb) {
storage.set('remotePrefStored', true, cb); storage.set('remotePrefStored', true, cb);
}; };