From b48afb2110a4087515cfd3c6ae88715f3f2ccf01 Mon Sep 17 00:00:00 2001 From: bechi Date: Thu, 4 Dec 2014 19:48:08 -0300 Subject: [PATCH 01/18] add 3 steps funnel --- css/src/main.css | 24 ++++++++++++++----- views/createProfile.html | 52 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/css/src/main.css b/css/src/main.css index e83fc982d..1d9e00e52 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -367,12 +367,10 @@ a:hover { } .box-setup { - margin-bottom: 7rem; - padding: 1.3rem; - border-radius: 2px; - background: #FFFFFF; - -moz-box-shadow: 1px 1px 0px 0px #213140; - box-shadow: 1px 1px 0px 0px #213140; + margin-bottom: 1rem; + padding: 0.3rem; + border-radius: 3px; + background: #fff; } .box-setup-footer { @@ -1644,6 +1642,20 @@ a.text-warning:hover {color: #FD7262;} /*/////////////////////////////////////////////////*/ +.bg-circle { + background: #253547; + border-radius: 100%; + margin: .5rem 1rem 0.5rem 0; + padding: 0.75rem; + display: inline-block; + text-align: center; + vertical-align: middle; + color: #7A8C9E; + font-size: 30px; + width: 60px; + height: 60px; +} + .session-expired { background: rgba(32,48,64,0.90); width: 100%; diff --git a/views/createProfile.html b/views/createProfile.html index 7d04e7bdd..24bd03951 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -26,7 +26,6 @@
-

Create Profile

@@ -35,7 +34,46 @@ {{error|translate}}
-
+ + + + + +
+
+ Access your wallets anywhere +
+
+
+ Backups managed by the server +
+
+
+ Email address confirmation needed +
+
+ +
+
+ Access your wallets anywhere +
+
+
+ Backups managed by the server +
+
+
+ Email address confirmation needed +
+
+
+ +
+ +
+
@@ -45,12 +83,20 @@
+
+
+ +
+ +
+ +
@@ -173,15 +212,14 @@
-
- + From 888842639f8718b8cbb61b1cb27da3db2bd67889 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 5 Dec 2014 09:29:43 -0300 Subject: [PATCH 03/18] update some texts --- views/createProfile.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/views/createProfile.html b/views/createProfile.html index a22211557..d19e01ef5 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -60,22 +60,22 @@ Create in the cloud - +
-
-
-
- Todo1 -
-
+
- Todo2 + Your private keys never leave this device
- Todo3 + No email required +
+
+
+
+ Need to be careful with backups
+ + From 73c80fd6d402d6c03edb5b5cbc67ebae246a113c Mon Sep 17 00:00:00 2001 From: bechi Date: Fri, 5 Dec 2014 11:41:06 -0300 Subject: [PATCH 04/18] first step --- css/src/main.css | 52 ++++++++++++++++++++++++++++++++++++---- views/createProfile.html | 43 +++++++++++++++++++++------------ 2 files changed, 75 insertions(+), 20 deletions(-) diff --git a/css/src/main.css b/css/src/main.css index 1d9e00e52..da4005c3c 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -992,7 +992,7 @@ input[type=date], input[type=datetime-local], input[type=datetime], input[type=e color: #343c43; margin-bottom: 1.3rem; height: 40px; - border-radius: 2px; + border-radius: 3px; background: #F2F5F8; -moz-box-shadow: inset 1px 1px 0px 0px rgba(0,0,0,0.05); box-shadow: inset 1px 1px 0px 0px rgba(0,0,0,0.05); @@ -1035,8 +1035,8 @@ button.primary, .button.primary { background-color: #1ABC9C; color: #fff; - border-radius: 2px; - border-radius: 2px; + border-radius: 3px; + border-radius: 3px; -moz-box-shadow: 1px 1px 0px 0px #16A085; box-shadow: 1px 1px 0px 0px #16A085; } @@ -1070,7 +1070,7 @@ button.warning, .button.warning { background-color: #C0392A; color: #fff; - border-radius: 2px; + border-radius: 3px; -moz-box-shadow: 1px 1px 0px 0px #A02F23; box-shadow: 1px 1px 0px 0px #A02F23; } @@ -1419,6 +1419,7 @@ input.ng-invalid-match, input.ng-invalid-match:focus { } .text-light {font-weight: 100;} +.text-bold {font-weight: 700;} .text-gray {color: #8597A7;} .text-black {color: #2C3E50;} .text-primary {color: #1ABC9C;} @@ -1642,10 +1643,51 @@ a.text-warning:hover {color: #FD7262;} /*/////////////////////////////////////////////////*/ +.tabbable { + border: 2px solid #213140; + border-radius: 3px; + margin-bottom: 1.2rem; +} + +.tabs dd.active a { + color: #fff; + background-color: transparent; +} + +.tabs dd>a { + background: #213140; + text-transform: uppercase; + color: #3E4F5D; + padding: 1rem; + text-align: center; + height: 64px; + font-size: 14px; + line-height: 15px; +} + +.tabs dd>a:hover { + background: #1C2B39; +} + +.tabs dd.active a:hover { + background: transparent; +} + +.tabs-content { + margin-bottom: 0; +} + +.content-item { + border-bottom: 1px solid rgba(32,48,64,0.30); + box-shadow: 0px 1px 0px 0px rgba(121,140,158,0.10); + margin: .5rem 1.3rem; + padding: 0.8rem 0; +} + .bg-circle { background: #253547; border-radius: 100%; - margin: .5rem 1rem 0.5rem 0; + margin: 0 1rem 0.3rem 0; padding: 0.75rem; display: inline-block; text-align: center; diff --git a/views/createProfile.html b/views/createProfile.html index d19e01ef5..ec8dcae57 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -25,7 +25,7 @@ Copay
-
+
@@ -38,52 +38,65 @@
- + + + In the Cloud
+ ( Recommended ) +
-
+
Access your wallets anywhere
-
+
Backups managed by the server
-
+
Email address confirmation needed
- - + + + +
In this Device
+
-
+
Your private keys never leave this device
-
+
No email required
-
+
Need to be careful with backups
- + + + + + + + From 052b913ee08d1b9caf0916cf480e4fdeeee870b8 Mon Sep 17 00:00:00 2001 From: bechi Date: Fri, 5 Dec 2014 13:12:13 -0300 Subject: [PATCH 06/18] input style --- css/src/main.css | 12 +++++++++--- views/createProfile.html | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/css/src/main.css b/css/src/main.css index da4005c3c..78553a103 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -368,15 +368,16 @@ a:hover { .box-setup { margin-bottom: 1rem; - padding: 0.3rem; + padding: 1.3rem; border-radius: 3px; background: #fff; } .box-setup-footer { overflow: hidden; + margin-top: 1.5rem; padding: 1rem 0 0; - border-top: 1px solid #E5E7EA; + border-top: 1px solid #425467; font-size: 12px; } @@ -1643,6 +1644,11 @@ a.text-warning:hover {color: #FD7262;} /*/////////////////////////////////////////////////*/ +.createProfile .input { + border-radius: 3px; + box-shadow: 0px 0px 0px 3px #1A2836, inset 1px 1px 0px 0px rgba(0,0,0,0.05); +} + .tabbable { border: 2px solid #213140; border-radius: 3px; @@ -1681,7 +1687,7 @@ a.text-warning:hover {color: #FD7262;} border-bottom: 1px solid rgba(32,48,64,0.30); box-shadow: 0px 1px 0px 0px rgba(121,140,158,0.10); margin: .5rem 1.3rem; - padding: 0.8rem 0; + padding: 0.3rem 0; } .bg-circle { diff --git a/views/createProfile.html b/views/createProfile.html index e3e9df534..3c454e275 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -22,7 +22,7 @@
- Copay + Copay
@@ -110,7 +110,7 @@
-
+
[x] Creating in this device
From 39af059cee7a72a5d0c7923fd548e78a4bbea812 Mon Sep 17 00:00:00 2001 From: bechi Date: Fri, 5 Dec 2014 14:29:38 -0300 Subject: [PATCH 07/18] add label and styles --- css/src/main.css | 15 +++++++++++++-- views/createProfile.html | 12 ++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/css/src/main.css b/css/src/main.css index 78553a103..1f4c256bb 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -375,7 +375,7 @@ a:hover { .box-setup-footer { overflow: hidden; - margin-top: 1.5rem; + margin-top: 2rem; padding: 1rem 0 0; border-top: 1px solid #425467; font-size: 12px; @@ -1645,8 +1645,19 @@ a.text-warning:hover {color: #FD7262;} /*/////////////////////////////////////////////////*/ .createProfile .input { + box-shadow: 0px 0px 0px 3px #213140, inset 1px 1px 0px 0px rgba(0,0,0,0.05); border-radius: 3px; - box-shadow: 0px 0px 0px 3px #1A2836, inset 1px 1px 0px 0px rgba(0,0,0,0.05); +} + +.createProfile h2 { + font-weight: 700; + font-size: 14px; + color: #A5B2BF; + text-transform: uppercase; + padding-bottom: 0.8rem; + border-bottom: 1px solid #425467; + margin-bottom: 2rem; + text-align: center; } .tabbable { diff --git a/views/createProfile.html b/views/createProfile.html index 3c454e275..3b7024348 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -113,8 +113,8 @@
-
[x] Creating in this device
-
[x] Creating in the cloud
+

Creating in this device

+

Creating in the cloud

- +
@@ -154,9 +154,9 @@ -
[x] Creating in this device
-
[x] Creating in the cloud
-
-> {{userOrEmail}}
+

Creating in this device

+

Creating in the cloud

+
{{userOrEmail}}
From 526bc53a7b2c2df14a42a882fd46ebbc525c9313 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 5 Dec 2014 12:12:51 -0300 Subject: [PATCH 08/18] angularLoad --- bower.json | 3 +-- js/app.js | 4 ---- js/services/pluginManager.js | 14 +------------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index 719abb2ff..29dd38c7f 100644 --- a/bower.json +++ b/bower.json @@ -21,8 +21,7 @@ "socket.io-client": ">=1.0.0", "ng-idle": "*", "inherits": "~0.0.1", - "angular-load": "0.2.0", - "lodash": "~2.4.1", + lodash": "~2.4.1", "angular-gravatar": "*", "angular-touch": "~1.3.0" }, diff --git a/js/app.js b/js/app.js index e2ef9e359..ae8d2cda3 100644 --- a/js/app.js +++ b/js/app.js @@ -38,10 +38,6 @@ var modules = [ 'copayApp.directives', ]; -if (Object.keys(config.plugins).length) - modules.push('angularLoad'); - - var copayApp = window.copayApp = angular.module('copayApp', modules); copayApp.value('defaults', defaults); diff --git a/js/services/pluginManager.js b/js/services/pluginManager.js index 2a86a03c9..5b47b8c35 100644 --- a/js/services/pluginManager.js +++ b/js/services/pluginManager.js @@ -1,18 +1,6 @@ 'use strict'; -angular.module('copayApp.services').factory('pluginManager', function(angularLoad) { +angular.module('copayApp.services').factory('pluginManager', function() { var pm = new copay.PluginManager(config); - var scripts = pm.scripts; - - for(var ii in scripts){ - var src = scripts[ii].src; - - console.log('\tLoading ',src); //TODO - angularLoad.loadScript(src) - .then(scripts[ii].then || null) - .catch(function() { - throw new Error('Loading ' + src); - }) - } return pm; }); From e4f5862576a112891b3f1f404f123de320318403 Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 5 Dec 2014 13:24:46 -0300 Subject: [PATCH 09/18] add configService --- bower.json | 2 +- copay.js | 23 ++++++++++-------- js/controllers/home.js | 5 ++-- js/controllers/settings.js | 44 ++++++++++++++++------------------ js/services/configService.js | 24 +++++++++++++++++++ js/services/identityService.js | 10 ++++---- js/services/pluginManager.js | 8 +++++-- 7 files changed, 73 insertions(+), 43 deletions(-) create mode 100644 js/services/configService.js diff --git a/bower.json b/bower.json index 29dd38c7f..152bf929a 100644 --- a/bower.json +++ b/bower.json @@ -21,7 +21,7 @@ "socket.io-client": ">=1.0.0", "ng-idle": "*", "inherits": "~0.0.1", - lodash": "~2.4.1", + "lodash": "~2.4.1", "angular-gravatar": "*", "angular-touch": "~1.3.0" }, diff --git a/copay.js b/copay.js index bf94a1538..462ad98da 100644 --- a/copay.js +++ b/copay.js @@ -5,19 +5,22 @@ module.exports.TxProposals = require('./js/models/TxProposals'); module.exports.PrivateKey = require('./js/models/PrivateKey'); module.exports.HDPath = require('./js/models/HDPath'); module.exports.HDParams = require('./js/models/HDParams'); -module.exports.crypto = require('./js/util/crypto'); -module.exports.logger = require('./js/util/log'); -module.exports.csv = require('./js/util/csv'); - - -// components -var Async = module.exports.Async = require('./js/models/Async'); -var Insight = module.exports.Insight = require('./js/models/Insight'); -var RateService = module.exports.RateService = require('./js/models/RateService'); - +module.exports.Async = require('./js/models/Async'); +module.exports.Insight = require('./js/models/Insight'); +module.exports.RateService = require('./js/models/RateService'); module.exports.Identity = require('./js/models/Identity'); module.exports.Wallet = require('./js/models/Wallet'); module.exports.Compatibility = require('./js/models/Compatibility'); module.exports.PluginManager = require('./js/models/PluginManager'); + + +module.exports.crypto = require('./js/util/crypto'); +module.exports.logger = require('./js/util/log'); +module.exports.csv = require('./js/util/csv'); + module.exports.version = require('./version').version; module.exports.commitHash = require('./version').commitHash; + + +module.exports.defaultConfig = require('./config'); + diff --git a/js/controllers/home.js b/js/controllers/home.js index 1c08e4514..eb129934c 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -140,7 +140,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc if ((err.toString() || '').match('PNOTFOUND')) { $scope.error = 'Invalid email or password'; pinService.clear(function() { - copay.logger.debug('PIN erased'); }); } else if ((err.toString() || '').match('Connection')) { $scope.error = 'Could not connect to Insight Server'; @@ -150,7 +149,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc $scope.error = 'Unknown error'; } $rootScope.starting = false; - $rootScope.$digest(); + $timeout(function(){ + $rootScope.$digest(); + },1) return; } diff --git a/js/controllers/settings.js b/js/controllers/settings.js index 05da4110c..e2ad33c02 100644 --- a/js/controllers/settings.js +++ b/js/controllers/settings.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $route, $location, $anchorScroll, notification, applicationService, localstorageService) { +angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $route, $location, notification, configService) { $scope.title = 'Settings'; $scope.defaultLanguage = config.defaultLanguage || 'en'; $scope.insightLivenet = config.network.livenet.url; @@ -57,7 +57,6 @@ angular.module('copayApp.controllers').controller('SettingsController', function } } - $scope.save = function() { $scope.insightLivenet = copay.Insight.setCompleteUrl($scope.insightLivenet); $scope.insightTestnet = copay.Insight.setCompleteUrl($scope.insightTestnet); @@ -73,33 +72,32 @@ angular.module('copayApp.controllers').controller('SettingsController', function }, } - var plugins = {}; plugins[$scope.selectedStorage.pluginName] = true; - copay.logger.setLevel($scope.selectedLogLevel.name); - - localstorageService.setItem('config', JSON.stringify({ - network: insightSettings, - version: copay.version, - defaultLanguage: $scope.selectedLanguage.isoCode, - plugins: plugins, - logLevel: $scope.selectedLogLevel.name, - EncryptedInsightStorage: _.extend(config.EncryptedInsightStorage, { - url: insightSettings.livenet.url + '/api/email' - }), - rates: _.extend(config.rates, { - url: insightSettings.livenet.url + '/api/rates' - }), - }), function() { - applicationService.restart(); - }); + configService.set({ + network: insightSettings, + version: copay.version, + defaultLanguage: $scope.selectedLanguage.isoCode, + plugins: plugins, + logLevel: $scope.selectedLogLevel.name, + EncryptedInsightStorage: _.extend(config.EncryptedInsightStorage, { + url: insightSettings.livenet.url + '/api/email' + }), + rates: _.extend(config.rates, { + url: insightSettings.livenet.url + '/api/rates' + }), + }, + function() { + notification.success('Settings saved'); + $location.path('/'); + }); }; - $scope.reset = function() { - localstorageService.removeItem('config', function() { - applicationService.reload(); + configService.reset(function() { + notification.success('Settings reseted'); + $location.path('/'); }); }; diff --git a/js/services/configService.js b/js/services/configService.js new file mode 100644 index 000000000..2d0fef102 --- /dev/null +++ b/js/services/configService.js @@ -0,0 +1,24 @@ +'use strict'; + +angular.module('copayApp.services').factory('configService', function(localstorageService) { + var root = {}; + + root.set = function(opts, cb) { + copay.logger.setLevel(opts.logLevel); + localstorageService.getItem('config', function(err, oldOps) { + + _.defaults(opts, JSON.parse(oldOps)); + + // TODO remove this gloval variable. + config = opts; + localstorageService.setItem('config', JSON.stringify(opts), cb); + }); + }; + + root.reset = function(cb) { + config = copay.defaultConfig; + localstorageService.removeItem('config',cb); + }; + + return root; +}); diff --git a/js/services/identityService.js b/js/services/identityService.js index eda5435f0..8d497be39 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -11,10 +11,10 @@ angular.module('copayApp.services') var root = {}; root.check = function(scope) { copay.Identity.checkIfExistsAny({ - pluginManager: pluginManager, + pluginManager: pluginManager.getInstance(config), }, function(anyProfile) { copay.Wallet.checkIfExistsAny({ - pluginManager: pluginManager, + pluginManager: pluginManager.getInstance(config), }, function(anyWallet) { scope.loading = false; scope.anyProfile = anyProfile ? true : false; @@ -47,7 +47,7 @@ angular.module('copayApp.services') copay.Identity.create({ email: email, password: password, - pluginManager: pluginManager, + pluginManager: pluginManager.getInstance(config), network: config.network, networkName: config.networkName, walletDefaults: config.wallet, @@ -99,7 +99,7 @@ angular.module('copayApp.services') var opts = { email: email, password: password, - pluginManager: pluginManager, + pluginManager: pluginManager.getInstance(config), network: config.network, networkName: config.networkName, walletDefaults: config.wallet, @@ -344,7 +344,7 @@ angular.module('copayApp.services') root.importProfile = function(str, password, cb) { copay.Identity.importFromEncryptedFullJson(str, password, { - pluginManager: pluginManager, + pluginManager: pluginManager.getInstance(config), network: config.network, networkName: config.networkName, walletDefaults: config.wallet, diff --git a/js/services/pluginManager.js b/js/services/pluginManager.js index 5b47b8c35..76b6361e2 100644 --- a/js/services/pluginManager.js +++ b/js/services/pluginManager.js @@ -1,6 +1,10 @@ 'use strict'; angular.module('copayApp.services').factory('pluginManager', function() { - var pm = new copay.PluginManager(config); - return pm; + var root = {}; + root.getInstance = function(config){ + return new copay.PluginManager(config); + }; + + return root; }); From 93b287bedc73bd9defbc0b5713db707f5bf39a9b Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Fri, 5 Dec 2014 14:23:33 -0300 Subject: [PATCH 10/18] now plugins can be read on runtime --- js/app.js | 10 +++--- js/controllers/createProfile.js | 56 ++++++++++++++++++++++----------- js/controllers/homeWallet.js | 6 ++-- js/services/configService.js | 23 ++++++++++---- views/createProfile.html | 13 ++------ 5 files changed, 67 insertions(+), 41 deletions(-) diff --git a/js/app.js b/js/app.js index ae8d2cda3..f93bf2ac1 100644 --- a/js/app.js +++ b/js/app.js @@ -2,16 +2,17 @@ var copay = require('copay'); var _ = require('lodash'); -var config = defaultConfig; var LS = require('../js/plugins/LocalStorage'); var ls = new LS(); -var localConfig; -var defaults = JSON.parse(JSON.stringify(defaultConfig)); - +// TODO move this to configService ! +var config = copay.defaultConfig; ls.getItem('config', function(err, data) { + var localConfig; + try { localConfig = JSON.parse(data); + } catch(e) {}; if (localConfig) { var cmv = copay.version.split('.')[1]; var lmv = localConfig.version ? localConfig.version.split('.')[1] : '-1'; @@ -40,6 +41,7 @@ var modules = [ var copayApp = window.copayApp = angular.module('copayApp', modules); +var defaults = JSON.parse(JSON.stringify(copay.defaultConfig)); copayApp.value('defaults', defaults); copayApp.config(function($sceDelegateProvider) { diff --git a/js/controllers/createProfile.js b/js/controllers/createProfile.js index 6e4981f3d..8d35c8d48 100644 --- a/js/controllers/createProfile.js +++ b/js/controllers/createProfile.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, notification, pluginManager, identityService, pinService, isMobile) { +angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, $timeout, notification, pluginManager, identityService, pinService, isMobile, configService) { var _credentials, _firstpin; @@ -50,7 +50,6 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun }); }; - $scope.selectStorage = function (storage) { $scope.useLocalstorage = storage == 'local'; $timeout(function() { @@ -58,16 +57,10 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun }, 1); }; - $scope.setStorage = function(useLocalstorage) { - console.log('[createProfile.js.53:useLocalstorage:]', useLocalstorage); //TODO + $scope.goToEmail = function() { console.log('[createProfile.js.53:useLocalstorage:]', $scope.useLocalstorage); //TODO - //settingsService.save({...}) $scope.createStep = 'email'; - $scope.useEmail = !useLocalstorage; - $scope.useLocalstorage = useLocalstorage; - $timeout(function() { - $scope.$digest(); - }, 1); + $scope.useEmail = !$scope.useLocalstorage; }; $scope.setEmailOrUsername = function(form) { @@ -97,14 +90,12 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun }); }; - $scope.createProfile = function(form) { - $rootScope.hideNavigation = false; - if (form && form.$invalid) { - $scope.error = 'Please enter the required fields'; - return; - } - $scope.loading = true; - identityService.create( $scope.userOrEmail, form.password.$modelValue, function(err) { + + $scope._doCreateProfile = function(emailOrUsername, password) { + preconditions.checkArgument(_.isString(emailOrUsername)); + preconditions.checkArgument(_.isString(password)); + + identityService.create(emailOrUsername, password, function(err) { $scope.loading = false; if (err) { @@ -141,5 +132,32 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun } } }); - } + }; + + + $scope.createProfile = function(form) { + $rootScope.hideNavigation = false; + if (form && form.$invalid) { + $scope.error = 'Please enter the required fields'; + return; + } + $scope.loading = true; + + var plugins = config.plugins; + + plugins.EncryptedLocalStorage = false; + plugins.EncryptedInsightStorage = false; + + var pluginName = $scope.useLocalstorage ? 'EncryptedLocalStorage' : 'EncryptedInsightStorage'; + + plugins[pluginName] = true; + console.log('[createProfile.js.102:plugins:]', plugins); //TODO + + configService.set({ + plugins: plugins + }, function() { + $scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue); + }); + }; + }); diff --git a/js/controllers/homeWallet.js b/js/controllers/homeWallet.js index 400cc5329..55c4a00bb 100644 --- a/js/controllers/homeWallet.js +++ b/js/controllers/homeWallet.js @@ -64,8 +64,10 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi $scope.$on("$destroy", function() { var w = $rootScope.wallet; - removeWatch(); - w.removeListener('txProposalEvent', _updateTxs); + if (w) { + removeWatch(); + w.removeListener('txProposalEvent', _updateTxs); + }; }); $scope.setAlternativeAmount = function(w, tx, cb) { diff --git a/js/services/configService.js b/js/services/configService.js index 2d0fef102..4278e5215 100644 --- a/js/services/configService.js +++ b/js/services/configService.js @@ -4,20 +4,31 @@ angular.module('copayApp.services').factory('configService', function(localstora var root = {}; root.set = function(opts, cb) { - copay.logger.setLevel(opts.logLevel); - localstorageService.getItem('config', function(err, oldOps) { - _.defaults(opts, JSON.parse(oldOps)); + if (opts.logLevel) + copay.logger.setLevel(opts.logLevel); + + localstorageService.getItem('config', function(err, oldOpsStr) { + + var oldOpts = {}; + + try { + oldOpts = JSON.parse(oldOpsStr); + } catch (e) {}; + + var newOpts = {}; + _.extend(newOpts, copay.defaultConfig, oldOpts, opts); // TODO remove this gloval variable. - config = opts; - localstorageService.setItem('config', JSON.stringify(opts), cb); + config = newOpts; + + localstorageService.setItem('config', JSON.stringify(newOpts), cb); }); }; root.reset = function(cb) { config = copay.defaultConfig; - localstorageService.removeItem('config',cb); + localstorageService.removeItem('config', cb); }; return root; diff --git a/views/createProfile.html b/views/createProfile.html index 3b7024348..82bdd0cde 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -59,7 +59,6 @@ Email address confirmation needed
-
In this Device
@@ -82,17 +81,11 @@
- - - - - -
-
-
- +
+
-

Sign in to Copay

-

- - {{error|translate}} -

+

+ {{error|translate}} +

- +
- +
- -
+
+ * Using this device storage. Change to cloud storage on 'settings'. +
+ + +