diff --git a/bower.json b/bower.json index 719abb2ff..152bf929a 100644 --- a/bower.json +++ b/bower.json @@ -21,7 +21,6 @@ "socket.io-client": ">=1.0.0", "ng-idle": "*", "inherits": "~0.0.1", - "angular-load": "0.2.0", "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/css/src/main.css b/css/src/main.css index dbffed1bd..f1dbfdfa2 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -362,23 +362,22 @@ a:hover { .logo-setup { text-align: center; - padding: 5rem 0 4rem; + padding: 2rem 0; color: #fff; } .box-setup { - margin-bottom: 7rem; + margin-bottom: 1rem; padding: 1.3rem; - border-radius: 2px; - background: #FFFFFF; - -moz-box-shadow: 1px 1px 0px 0px #213140; - box-shadow: 1px 1px 0px 0px #213140; + border-radius: 3px; + background: #fff; } .box-setup-footer { overflow: hidden; + margin-top: 2rem; padding: 1rem 0 0; - border-top: 1px solid #E5E7EA; + border-top: 1px solid #425467; font-size: 12px; } @@ -994,7 +993,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); @@ -1037,8 +1036,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; } @@ -1072,7 +1071,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; } @@ -1421,6 +1420,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;} @@ -1679,6 +1679,102 @@ a.text-warning:hover {color: #FD7262;} /*/////////////////////////////////////////////////*/ +.createProfile .icon-input { + position: absolute; + right: 10px; + top: 11px; +} + +.createProfile .icon-input i { + font-size: 14px; + position: relative; + color: #fff; + margin-right: 14px; + border: none; + box-shadow: none; + top: 2px; +} + +.createProfile .input, .home .input { + box-shadow: 0px 0px 0px 3px #213140, inset 1px 1px 0px 0px rgba(0,0,0,0.05); + border-radius: 3px; +} + +.createProfile h2, .home 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; +} + +.createProfile a.text-gray:hover, .home a.text-gray:hover { + color: #fff; +} + +.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; +} + +.tabs-content>.content { + padding: 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.3rem 0; + font-size: 14px; +} + +.bg-circle { + background: #253547; + border-radius: 100%; + margin: 0 0.5rem 0.3rem 0; + padding: .45rem 0.5rem; + display: inline-block; + text-align: center; + vertical-align: middle; + color: #7A8C9E; + font-size: 30px; + width: 50px; + height: 50px; +} + .session-expired { background: rgba(32,48,64,0.90); width: 100%; @@ -1689,3 +1785,13 @@ a.text-warning:hover {color: #FD7262;} padding-top: 20%; text-align: center; } + +.clipo { + padding: 0 0 2rem; + text-align: center; +} + +.line-none { + border: none; + box-shadow: none; +} \ No newline at end of file diff --git a/css/src/mobile.css b/css/src/mobile.css index 952c0f3e7..2dcf0aed8 100644 --- a/css/src/mobile.css +++ b/css/src/mobile.css @@ -8,7 +8,7 @@ .logo-setup { margin: 0; - padding: 2rem 0; + padding: 1rem 0; } .home, .open, .join, .waiting-copayers, .setup, .import, .settings { @@ -197,6 +197,10 @@ .button, button { padding: 1rem 1.2rem 1.0625rem; } + + .home form { + margin-bottom: 1rem; + } form { margin: 0; diff --git a/img/clipo-signin.png b/img/clipo-signin.png new file mode 100644 index 000000000..169e04022 Binary files /dev/null and b/img/clipo-signin.png differ diff --git a/img/clipo-signup1.png b/img/clipo-signup1.png new file mode 100644 index 000000000..546abf47e Binary files /dev/null and b/img/clipo-signup1.png differ diff --git a/img/clipo-signup2-1.png b/img/clipo-signup2-1.png new file mode 100644 index 000000000..8cc3759d1 Binary files /dev/null and b/img/clipo-signup2-1.png differ diff --git a/img/clipo-signup2.png b/img/clipo-signup2.png new file mode 100644 index 000000000..81eec5561 Binary files /dev/null and b/img/clipo-signup2.png differ diff --git a/img/clipo-signup3.png b/img/clipo-signup3.png new file mode 100644 index 000000000..0a16191cd Binary files /dev/null and b/img/clipo-signup3.png differ diff --git a/js/app.js b/js/app.js index e2ef9e359..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'; @@ -38,12 +39,9 @@ var modules = [ 'copayApp.directives', ]; -if (Object.keys(config.plugins).length) - modules.push('angularLoad'); - - 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 92c3569f8..acf8c86fa 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; @@ -8,6 +8,9 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun identityService.goWalletHome(); $scope.isMobile = isMobile.any(); + $scope.createStep = 'storage'; + $scope.useLocalstorage = false; + pinService.makePinInput($scope, 'newpin', function(newValue) { _firstpin = newValue; $scope.askForPin = 2; @@ -47,10 +50,43 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun }); }; + + $scope.setStep = function(step) { + $scope.error = null; + $scope.createStep = step; + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + $scope.selectStorage = function(storage) { + $scope.useLocalstorage = storage == 'local'; + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + $scope.goToEmail = function() { + $scope.createStep = 'email'; + $scope.useEmail = !$scope.useLocalstorage; + }; + + $scope.setEmailOrUsername = function(form) { + $scope.userOrEmail = $scope.useLocalstorage ? form.username.$modelValue : form.email.$modelValue; + preconditions.checkState($scope.userOrEmail); + + $scope.createStep = 'pass'; + $timeout(function() { + $scope.$digest(); + }, 1); + }; + + + $scope.createDefaultWallet = function() { $rootScope.hideNavigation = false; identityService.createDefaultWallet(function(err) { - $scope.askForPin =0 ; + $scope.askForPin = 0; $scope.loading = false; if (err) { @@ -60,34 +96,24 @@ 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(form.email.$modelValue, form.password.$modelValue, function(err) { - $scope.loading = false; + $scope._doCreateProfile = function(emailOrUsername, password, cb) { + preconditions.checkArgument(_.isString(emailOrUsername)); + preconditions.checkArgument(_.isString(password)); + + $rootScope.hideNavigation = false; + $scope.loading = true; + + identityService.create(emailOrUsername, password, function(err) { + $scope.loading = false; + $scope.error = null; if (err) { var msg = err.toString(); if (msg.indexOf('EEXIST') >= 0 || msg.indexOf('BADC') >= 0) { msg = 'This profile already exists' } - $timeout(function() { - form.email.$setViewValue(''); - form.email.$render(); - form.password.$setViewValue(''); - form.password.$render(); - form.repeatpassword.$setViewValue(''); - form.repeatpassword.$render(); - form.$setPristine(); - $scope.error = msg; - },1); $scope.error = msg; } else { - $scope.error = null; // mobile if ($scope.isMobile) { _credentials = { @@ -99,12 +125,47 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun $timeout(function() { $rootScope.$digest(); }, 1); - return; } else { $scope.createDefaultWallet(); } } + return cb(); }); - } + }; + + + $scope.saveSettings = function(cb) { + var plugins = config.plugins; + + plugins.EncryptedLocalStorage = false; + plugins.EncryptedInsightStorage = false; + + var pluginName = $scope.useLocalstorage ? 'EncryptedLocalStorage' : 'EncryptedInsightStorage'; + plugins[pluginName] = true; + + configService.set({ + plugins: plugins + }, cb); + }; + + + $scope.createProfile = function(form) { + if (form && form.$invalid) { + $scope.error = 'Please enter the required fields'; + return; + } + $scope.saveSettings(function(err) { + $scope._doCreateProfile($scope.userOrEmail, form.password.$modelValue, function(err) { + $timeout(function() { + form.password.$setViewValue(''); + form.password.$render(); + form.repeatpassword.$setViewValue(''); + form.repeatpassword.$render(); + form.$setPristine(); + }, 1); + }); + }); + }; + }); diff --git a/js/controllers/home.js b/js/controllers/home.js index 1c08e4514..e75fe7638 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -4,9 +4,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc var _credentials, _firstpin; - $scope.init = function() { $scope.isMobile = isMobile.any(); + $scope.attempt=0; // This is only for backwards compat, insight api should link to #!/confirmed directly if (getParam('confirmed')) { @@ -28,6 +28,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc pinService.check(function(err, value) { $rootScope.hasPin = value; }); + $scope.usingLocalStorage = config.plugins.EncryptedLocalStorage; }; pinService.makePinInput($scope, 'pin', function(newValue) { @@ -139,8 +140,13 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc copay.logger.warn(err); if ((err.toString() || '').match('PNOTFOUND')) { $scope.error = 'Invalid email or password'; + + if($scope.attempt++>1) { + var storage = $scope.usingLocalStorage ? 'this device storage' : 'cloud storage'; + $scope.error = 'Invalid email or password. You are trying to sign in using ' + storage + '. Change it on settings is necessary.'; + }; + pinService.clear(function() { - copay.logger.debug('PIN erased'); }); } else if ((err.toString() || '').match('Connection')) { $scope.error = 'Could not connect to Insight Server'; @@ -150,7 +156,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/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/controllers/settings.js b/js/controllers/settings.js index 05da4110c..4b2ef366b 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; @@ -18,10 +18,10 @@ angular.module('copayApp.controllers').controller('SettingsController', function } $scope.availableStorages = [{ - name: 'Insight', + name: 'In the cloud (Insight server)', pluginName: 'EncryptedInsightStorage', }, { - name: 'Localstorage', + name: 'In this device (localstorage)', pluginName: 'EncryptedLocalStorage', }, // { @@ -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..f34013165 --- /dev/null +++ b/js/services/configService.js @@ -0,0 +1,38 @@ +'use strict'; + +angular.module('copayApp.services').factory('configService', function(localstorageService, gettextCatalog) { + var root = {}; + + root.set = function(opts, cb) { + + if (opts.logLevel) + copay.logger.setLevel(opts.logLevel); + + if (opts.defaultLanguage) + gettextCatalog.currentLanguage = opts.defaultLanguage; + + 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 = newOpts; + + localstorageService.setItem('config', JSON.stringify(newOpts), 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 2e00efbc1..aa904d9ec 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, @@ -348,7 +348,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 2a86a03c9..76b6361e2 100644 --- a/js/services/pluginManager.js +++ b/js/services/pluginManager.js @@ -1,18 +1,10 @@ 'use strict'; -angular.module('copayApp.services').factory('pluginManager', function(angularLoad) { - var pm = new copay.PluginManager(config); - var scripts = pm.scripts; +angular.module('copayApp.services').factory('pluginManager', function() { + var root = {}; + root.getInstance = function(config){ + return new copay.PluginManager(config); + }; - 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; + return root; }); diff --git a/views/createProfile.html b/views/createProfile.html index 7d04e7bdd..6a40342d6 100644 --- a/views/createProfile.html +++ b/views/createProfile.html @@ -20,13 +20,12 @@ -
+
- Copay + Copay
-
-

Create Profile

+
@@ -35,66 +34,174 @@ {{error|translate}}
-
-
- - - Not valid - - + + + +
+ clipo
-
- - + + + + 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 +
+
+
+ + + + + + +
+
+ clipo +
+
+ clipo
-
- - +

Creating in this device

+

Creating in the cloud

+ +
+ + +
+ +
+ + Not valid +
+
+
+
+
+ +
+ + +
+ + + -
- - - {{'Passwords must match'|translate}} - - + + +
+
+ clipo +
+ +

Creating in this device

+

Creating in the cloud

+
{{userOrEmail}}
+ + +
+ +
-
+
+ +
+ + {{'Passwords must match'|translate}} +
+
+
+
+
- + + - +
-
+

Set up a PIN ?

Enter a 4-digit number for easier access from this device

@@ -125,15 +232,14 @@
-
- +
diff --git a/views/home.html b/views/home.html index 5cd897e3e..eda1bf7b9 100644 --- a/views/home.html +++ b/views/home.html @@ -3,10 +3,18 @@
-
 
-
 
-
 
-
 
+
+
 
+
+
+
 
+
+
+
 
+
+
+
 
+
Accessing your profile...
@@ -14,18 +22,10 @@
- Copay + Copay
-
-
- -
-
- Please sign in to make the payment -
-
@@ -34,45 +34,30 @@

Your email was confimed!

- Please sign in to access your wallets
-
-
- -
- Copay now needs a profile to access wallets. - You can import your current wallets after - creating your profile -

Set up a PIN ?

-

Enter a 4-digit number for easier access from this device

- +

Enter a 4-digit number for easier access from this device

+
-
+
{{error|translate}}
-
+
- +
- +
@@ -83,15 +68,14 @@
-
- - + +
@@ -100,17 +84,14 @@
-
+
{{error|translate}}
- +
@@ -122,41 +103,64 @@
-
-
- +
+ - -
-

Sign in to Copay

+
+
+ clipo +
+

Sign in to Copay

+
+
+ +
+ Copay now needs a profile to access wallets. + You can import your current wallets after + creating your profile +
+
+
+ +
+
+ Please sign in to make the payment +
+
-

- - {{error|translate}} -

-