From 7835694fb233c6170a68bc4c3711529191825aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 1 Sep 2016 12:10:08 -0300 Subject: [PATCH 1/5] import with Qr in onboarding --- public/views/onboarding/welcome.html | 2 +- src/js/controllers/import.js | 4 ++-- src/js/controllers/onboarding/welcomeController.js | 6 ++++++ src/js/routes.js | 7 +++++-- src/sass/views/onboarding/onboard-welcome.scss | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/public/views/onboarding/welcome.html b/public/views/onboarding/welcome.html index 8e44f87aa..20dd432b6 100644 --- a/public/views/onboarding/welcome.html +++ b/public/views/onboarding/welcome.html @@ -1,6 +1,6 @@ - +
diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index c1fbaf111..55fcb5645 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -36,7 +36,6 @@ angular.module('copayApp.controllers').controller('importController', $scope.processWalletInfo = function(code) { if (!code) return; - $scope.importErr = false; var parsedCode = code.split('|'); @@ -407,5 +406,6 @@ angular.module('copayApp.controllers').controller('importController', }; updateSeedSourceSelect(); - $scope.setSeedSource('new'); + $scope.setSeedSource(); + if ($stateParams.code) $scope.processWalletInfo($stateParams.code); }); diff --git a/src/js/controllers/onboarding/welcomeController.js b/src/js/controllers/onboarding/welcomeController.js index f217639ad..213a28bc5 100644 --- a/src/js/controllers/onboarding/welcomeController.js +++ b/src/js/controllers/onboarding/welcomeController.js @@ -2,6 +2,12 @@ angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) { + $scope.goImport = function(code) { + $state.go('tabs.import', { + code: code + }); + }; + $scope.createProfile = function() { $log.debug('Creating profile'); profileService.createProfile(function(err) { diff --git a/src/js/routes.js b/src/js/routes.js index d580f3f4d..15ed20d90 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -270,12 +270,15 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr }) .state('tabs.import', { url: '/import/:fromOnboarding', -// abstract: true, + // abstract: true, views: { 'tab-home': { templateUrl: 'views/import.html' }, - } + }, + params: { + code: null + }, }) .state('tabs.import.phrase', { url: '/tab-import-phrase', diff --git a/src/sass/views/onboarding/onboard-welcome.scss b/src/sass/views/onboarding/onboard-welcome.scss index 2e9c19e01..8e40facd9 100644 --- a/src/sass/views/onboarding/onboard-welcome.scss +++ b/src/sass/views/onboarding/onboard-welcome.scss @@ -5,6 +5,7 @@ background-size: contain; background-repeat-y: no-repeat; #shopping-24 { + content: url("../img/onboarding-welcome-shopping24.png"); position: absolute; top: 2%; right: 5%; From d25a5dfb1b88021202081c7b13df380ba0d7231b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 1 Sep 2016 12:14:21 -0300 Subject: [PATCH 2/5] adding from onboarding state param --- src/js/controllers/onboarding/welcomeController.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/controllers/onboarding/welcomeController.js b/src/js/controllers/onboarding/welcomeController.js index 213a28bc5..921086c98 100644 --- a/src/js/controllers/onboarding/welcomeController.js +++ b/src/js/controllers/onboarding/welcomeController.js @@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('welcomeController', function( $scope.goImport = function(code) { $state.go('tabs.import', { + fromOnboarding: true, code: code }); }; From 657c2b830ce60cd88462a89e38de4cf5060d951f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 1 Sep 2016 15:21:18 -0300 Subject: [PATCH 3/5] remove main tabs from import view in onboarding flow --- public/views/import.html | 36 +++++++++++++------ public/views/onboarding/welcome.html | 2 +- .../onboarding/welcomeController.js | 2 +- src/js/controllers/tabsController.js | 36 +++++++++++-------- src/js/routes.js | 36 +++++++++++++++++++ 5 files changed, 85 insertions(+), 27 deletions(-) diff --git a/public/views/import.html b/public/views/import.html index 79d347ebd..17e6187aa 100644 --- a/public/views/import.html +++ b/public/views/import.html @@ -1,17 +1,33 @@ - + - - - +
+ + + - - - + + + - - - + + + +
+ +
+ + + + + + + + + + + +
diff --git a/public/views/onboarding/welcome.html b/public/views/onboarding/welcome.html index 20dd432b6..05459b33d 100644 --- a/public/views/onboarding/welcome.html +++ b/public/views/onboarding/welcome.html @@ -14,7 +14,7 @@
- +
diff --git a/src/js/controllers/onboarding/welcomeController.js b/src/js/controllers/onboarding/welcomeController.js index 921086c98..f08a5b5eb 100644 --- a/src/js/controllers/onboarding/welcomeController.js +++ b/src/js/controllers/onboarding/welcomeController.js @@ -3,7 +3,7 @@ angular.module('copayApp.controllers').controller('welcomeController', function($scope, $state, $timeout, $log, $ionicPopup, profileService) { $scope.goImport = function(code) { - $state.go('tabs.import', { + $state.go('onboarding.import.phrase', { fromOnboarding: true, code: code }); diff --git a/src/js/controllers/tabsController.js b/src/js/controllers/tabsController.js index b9114db36..ccd1b1e88 100644 --- a/src/js/controllers/tabsController.js +++ b/src/js/controllers/tabsController.js @@ -1,21 +1,27 @@ - 'use strict'; -angular.module('copayApp.controllers').controller('tabsController', function($log, $scope, $ionicModal, incomingData) { +angular.module('copayApp.controllers').controller('tabsController', function($log, $scope, $stateParams, $ionicModal, $timeout, incomingData) { - $scope.onScan = function(data) { -console.log('[tabsController.js.6:data:]',data); //TODO - if (!incomingData.redir(data)) { - $ionicPopup.alert({ - title: 'Invalid data', - }); - } + $scope.onScan = function(data) { + if (!incomingData.redir(data)) { + $ionicPopup.alert({ + title: 'Invalid data', + }); } + } - $scope.setScanFn = function(scanFn) { - $scope.scan = function() { - $log.debug('Scanning...'); - scanFn(); - }; + $scope.setScanFn = function(scanFn) { + $scope.scan = function() { + $log.debug('Scanning...'); + scanFn(); }; - }); + }; + + $scope.importInit = function() { + $scope.fromOnboarding = $stateParams.fromOnboarding; + $timeout(function() { + $scope.$apply(); + }, 1); + } + +}); diff --git a/src/js/routes.js b/src/js/routes.js index 15ed20d90..e70269936 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -631,6 +631,42 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } } }) + .state('onboarding.import', { + url: '/import/:fromOnboarding', + abstract: true, + views: { + 'onboarding': { + templateUrl: 'views/import.html' + }, + }, + params: { + code: null + }, + }) + .state('onboarding.import.phrase', { + url: '/tab-import-phrase', + views: { + 'tab-import-phrase': { + templateUrl: 'views/tab-import-phrase.html', + }, + } + }) + .state('onboarding.import.file', { + url: '/tab-import-file', + views: { + 'tab-import-file': { + templateUrl: 'views/tab-import-file.html', + }, + } + }) + .state('onboarding.import.hardware', { + url: '/tab-import-hardware', + views: { + 'tab-import-hardware': { + templateUrl: 'views/tab-import-hardware.html', + }, + } + }) /* * From d5ef1e071d6a010d6660fdf3440beec59bb02d0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 1 Sep 2016 16:03:43 -0300 Subject: [PATCH 4/5] import refactor --- src/js/controllers/import.js | 90 ++++++++---------------------------- 1 file changed, 20 insertions(+), 70 deletions(-) diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 55fcb5645..8f437368f 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -101,18 +101,7 @@ angular.module('copayApp.controllers').controller('importController', return; } - - walletService.updateRemotePreferences(client, {}, function() { - $log.debug('Remote preferences saved for:' + client.credentials.walletId) - }); - - profileService.setBackupFlag(client.credentials.walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } - $state.go('tabs.home'); + finish(client); }); }, 100); }; @@ -132,19 +121,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - - - walletService.updateRemotePreferences(client, {}, function() { - $log.debug('Remote preferences saved for:' + client.credentials.walletId) - }); - - profileService.setBackupFlag(client.credentials.walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } - $state.go('tabs.home'); + finish(client); }); }, 100); }; @@ -163,13 +140,6 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - - profileService.setBackupFlag(walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } $state.go('tabs.home'); }); }, 100); @@ -193,18 +163,7 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } - - walletService.updateRemotePreferences(client, {}, function() { - $log.debug('Remote preferences saved for:' + client.credentials.walletId) - }); - - profileService.setBackupFlag(client.credentials.walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } - $state.go('tabs.home'); + finish(client); }); }, 100); }; @@ -312,19 +271,7 @@ angular.module('copayApp.controllers').controller('importController', popupService.showAlert(gettextCatalog.getString('Error'), err); return; } - - - walletService.updateRemotePreferences(wallet, {}, function() { - $log.debug('Remote preferences saved for:' + wallet.walletId) - }); - - profileService.setBackupFlag(wallet.walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } - $state.go('tabs.home'); + finish(wallet); }); }, 100); }; @@ -388,23 +335,26 @@ angular.module('copayApp.controllers').controller('importController', popupService.showAlert(gettextCatalog.getString('Error'), err); return; } - - - walletService.updateRemotePreferences(wallet, {}, function() { - $log.debug('Remote preferences saved for:' + wallet.walletId) - }); - - profileService.setBackupFlag(wallet.walletId); - if ($stateParams.fromOnboarding) { - profileService.setDisclaimerAccepted(function(err) { - if (err) $log.error(err); - }); - } - $state.go('tabs.home'); + finish(wallet); }); }, 100); }; + var finish = function(wallet) { + + walletService.updateRemotePreferences(wallet, {}, function() { + $log.debug('Remote preferences saved for:' + wallet.credentials.walletId) + }); + + profileService.setBackupFlag(wallet.credentials.walletId); + if ($stateParams.fromOnboarding) { + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + } + $state.go('tabs.home'); + }; + updateSeedSourceSelect(); $scope.setSeedSource(); if ($stateParams.code) $scope.processWalletInfo($stateParams.code); From 3c9303ab290804aab0a808c0086b4248c35d0e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Baz=C3=A1n?= Date: Thu, 1 Sep 2016 16:08:41 -0300 Subject: [PATCH 5/5] fixes --- src/js/controllers/import.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/js/controllers/import.js b/src/js/controllers/import.js index 8f437368f..4ba74e011 100644 --- a/src/js/controllers/import.js +++ b/src/js/controllers/import.js @@ -140,6 +140,14 @@ angular.module('copayApp.controllers').controller('importController', $scope.$apply(); }); } + + profileService.setBackupFlag(walletId); + if ($stateParams.fromOnboarding) { + profileService.setDisclaimerAccepted(function(err) { + if (err) $log.error(err); + }); + } + $state.go('tabs.home'); }); }, 100);