From dd9e48df1497bb384256e37bf10a87ac872d882c Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 7 Sep 2016 12:23:09 -0300 Subject: [PATCH] complete export process --- public/views/export.html | 29 ++-- public/views/preferencesAdvanced.html | 2 +- public/views/tab-export-file.html | 189 ++++++++++++-------------- public/views/tab-export-qrCode.html | 33 ++--- src/js/controllers/export.js | 53 +++++--- src/js/routes.js | 19 --- 6 files changed, 150 insertions(+), 175 deletions(-) diff --git a/public/views/export.html b/public/views/export.html index 563513f03..0d17c0124 100644 --- a/public/views/export.html +++ b/public/views/export.html @@ -1,13 +1,22 @@ - - + + + {{'Export wallet' | translate}} + + + + - - - + +
+
+ File/Text +
+
+ QR Code +
+
- - - - -
+
+
+
diff --git a/public/views/preferencesAdvanced.html b/public/views/preferencesAdvanced.html index e2a87c140..e63d6eb8c 100644 --- a/public/views/preferencesAdvanced.html +++ b/public/views/preferencesAdvanced.html @@ -17,7 +17,7 @@ Sweep paper wallet - + Export Wallet diff --git a/public/views/tab-export-file.html b/public/views/tab-export-file.html index 6e64f2fce..70fc041c4 100644 --- a/public/views/tab-export-file.html +++ b/public/views/tab-export-file.html @@ -1,104 +1,93 @@ - - - {{'Export Wallet' | translate}} - - - - +
+
+ + Failed to export +
- +
+
+ -
-
- - Failed to export -
- - - - - - - - Show advanced options - Hide advanced options - - - - Do not include private key - - -
- - - - WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so funds will not be accessible from the export. - - -
- -
- - - - WARNING: Not including the private key allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so funds will not be accessible from the export. - - -
- - - - -
-

Export options

- - -
+
+ -
-
-

Wallet Export

-
- -
-
- - Copy this text as it is to a safe place (notepad or email) -
-
-
- - + + Show advanced options + Hide advanced options + + +
+ + Do not include private key + +
+ +
+ + + + WARNING: The private key of this wallet is not available. The export allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so funds will not be accessible from the export. + + +
+ +
+ + + + WARNING: Not including the private key allows to check the wallet balance, transaction history, and create spend proposals from the export. However, does not allow to approve (sign) proposals, so funds will not be accessible from the export. + + +
+ + + + + +
+

Export options

+ + +
+
+ +
+ +
+ +

Copy this text as it is to a safe place (notepad or email)

+
+
\ No newline at end of file diff --git a/public/views/tab-export-qrCode.html b/public/views/tab-export-qrCode.html index b6254e42d..18ca08122 100644 --- a/public/views/tab-export-qrCode.html +++ b/public/views/tab-export-qrCode.html @@ -1,25 +1,10 @@ - - - {{'Export Wallet' | translate}} - - - - +
+
+ +
+
From the destination device, go to Add wallet > Import wallet and scan this QR code
+
- - -
-
- -
-
From the destination device, go to Add wallet > Import wallet and scan this QR code
-
- -
-
Exporting via QR not supported for this wallet
-
- -
-
+
+
Exporting via QR not supported for this wallet
+
diff --git a/src/js/controllers/export.js b/src/js/controllers/export.js index 1e4d78e47..c68443750 100644 --- a/src/js/controllers/export.js +++ b/src/js/controllers/export.js @@ -5,16 +5,14 @@ angular.module('copayApp.controllers').controller('exportController', var prevState; var isWP = platformInfo.isWP; var isAndroid = platformInfo.isAndroid; - var wallet = profileService.getWallet($stateParams.walletId); - $scope.isEncrypted = wallet.isPrivKeyEncrypted(); - $scope.isCordova = platformInfo.isCordova; - $scope.isSafari = platformInfo.isSafari; $scope.init = function() { - $scope.supported = true; - $scope.exportQR = false; - $scope.noSignEnabled = false; + $scope.formData = {}; + $scope.isEncrypted = wallet.isPrivKeyEncrypted(); + $scope.isCordova = platformInfo.isCordova; + $scope.isSafari = platformInfo.isSafari; + $scope.formData.noSignEnabled = false; $scope.showAdvanced = false; $scope.wallet = wallet; $scope.canSign = wallet.canSign(); @@ -22,13 +20,15 @@ angular.module('copayApp.controllers').controller('exportController', walletService.getEncodedWalletInfo(wallet, function(err, code) { if (err || !code) { $log.warn(err); - return $state.go('wallet.preferencesAdvanced') + return $ionicHistory.goBack(); } if (!code) - $scope.supported = false; - else - $scope.exportWalletInfo = code; + $scope.formData.supported = false; + else { + $scope.formData.supported = true; + $scope.formData.exportWalletInfo = code; + } $timeout(function() { $scope.$apply(); @@ -38,14 +38,25 @@ angular.module('copayApp.controllers').controller('exportController', /* EXPORT WITHOUT PRIVATE KEY - PENDING + */ $scope.noSignEnabledChange = function() { - $scope.exportWalletInfo = encodeWalletInfo(); - $timeout(function() { - $scope.$apply(); - }, 1); + if (!$scope.supported) return; + + walletService.getEncodedWalletInfo(wallet, function(err, code) { + if (err) { + $log.error(err); + $scope.formData.supported = false; + $scope.formData.exportWalletInfo = null; + } else { + $scope.formData.supported = true; + $scope.formData.exportWalletInfo = code; + } + $timeout(function() { + $scope.$apply(); + }, 1); + }); }; - */ $scope.downloadWalletBackup = function() { $scope.getAddressbook(function(err, localAddressBook) { @@ -54,11 +65,11 @@ angular.module('copayApp.controllers').controller('exportController', return; } var opts = { - noSign: $scope.noSignEnabled, + noSign: $scope.formData.noSignEnabled, addressBook: localAddressBook }; - backupService.walletDownload($scope.password, opts, function(err) { + backupService.walletDownload($scope.formData.password, opts, function(err) { if (err) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); return; @@ -91,11 +102,11 @@ angular.module('copayApp.controllers').controller('exportController', return cb(null); } var opts = { - noSign: $scope.noSignEnabled, + noSign: $scope.formData.noSignEnabled, addressBook: localAddressBook }; - var ew = backupService.walletExport($scope.password, opts); + var ew = backupService.walletExport($scope.formData.password, opts); if (!ew) { popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Failed to export')); } @@ -132,7 +143,7 @@ angular.module('copayApp.controllers').controller('exportController', var ew = backup; if (!ew) return; - if ($scope.noSignEnabled) + if ($scope.formData.noSignEnabled) name = name + '(No Private Key)'; var subject = 'Copay Wallet Backup: ' + name; diff --git a/src/js/routes.js b/src/js/routes.js index 1b8f754d0..70a2041e6 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -459,7 +459,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } }) .state('tabs.preferences.export', { - abstract: true, url: '/export', views: { 'preferences': { @@ -467,24 +466,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr } } }) - .state('tabs.preferences.export.file', { - url: '/tab-export-file', - needProfile: true, - views: { - 'tab-export-file': { - templateUrl: 'views/tab-export-file.html', - }, - } - }) - .state('tabs.preferences.export.qrCode', { - url: '/tab-export-qrCode', - needProfile: true, - views: { - 'tab-export-qrCode': { - templateUrl: 'views/tab-export-qrCode.html', - }, - } - }) .state('tabs.preferences.preferencesBwsUrl', { url: '/preferencesBwsUrl', views: {