From c5f810c069f9c3cfb7916ba3c3e07b5f9c4bd240 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Tue, 11 Nov 2014 16:53:57 -0300 Subject: [PATCH] Add backup to list of wallets in "manage wallets". Support for safari. --- js/controllers/more.js | 23 ++------------------ js/controllers/profile.js | 40 ++++++++++++++++++++++++++++++----- js/controllers/sidebar.js | 1 + views/modals/backup-text.html | 14 ++++++++++++ views/more.html | 40 ----------------------------------- views/profile.html | 36 +++++++++++++++++++------------ 6 files changed, 74 insertions(+), 80 deletions(-) create mode 100644 views/modals/backup-text.html diff --git a/js/controllers/more.js b/js/controllers/more.js index f1e129e4a..286cc1f44 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -1,7 +1,7 @@ 'use strict'; angular.module('copayApp.controllers').controller('MoreController', - function($scope, $rootScope, $location, $filter, backupService, controllerUtils, notification, rateService) { + function($scope, $rootScope, $location, $filter, controllerUtils, notification, rateService) { controllerUtils.redirIfNotComplete(); var w = $rootScope.wallet; $scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; @@ -76,26 +76,7 @@ angular.module('copayApp.controllers').controller('MoreController', }); notification.success('Success', $filter('translate')('settings successfully updated')); controllerUtils.updateBalance(); - }; - - $scope.downloadBackup = function() { - backupService.walletDownload(w); - } - - $scope.viewBackup = function() { - $scope.backupPlainText = backupService.walletEncrypted(w); - $scope.hideViewBackup = true; - }; - - $scope.deleteWallet = function() { - $scope.loading = true; - controllerUtils.deleteWallet($scope, $rootScope.wallet, function() { - $rootScope.wallet = null; - var lastFocused = $rootScope.iden.getLastFocusedWallet(); - controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused); - $scope.loading = false; - }); - }; + }; $scope.purge = function(deleteAll) { var removed = w.purgeTxProposals(deleteAll); diff --git a/js/controllers/profile.js b/js/controllers/profile.js index c034d0858..8794d809a 100644 --- a/js/controllers/profile.js +++ b/js/controllers/profile.js @@ -1,19 +1,20 @@ 'use strict'; -angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, controllerUtils, backupService) { +angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, controllerUtils, backupService) { $scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; $rootScope.title = 'Profile'; - $scope.downloadBackup = function() { + $scope.downloadProfileBackup = function() { backupService.profileDownload($rootScope.iden); }; - $scope.viewBackup = function() { - $scope.backupPlainText = backupService.profileEncrypted($rootScope.iden); - $scope.hideViewBackup = true; + $scope.viewProfileBackup = function() { + $scope.backupProfilePlainText = backupService.profileEncrypted($rootScope.iden); + $scope.hideViewProfileBackup = true; }; $scope.getWallets = function() { + if (!$rootScope.iden) return; $scope.wallets = []; var wids = _.pluck($rootScope.iden.listWallets(), 'id'); _.each(wids, function(wid) { @@ -29,8 +30,37 @@ angular.module('copayApp.controllers').controller('ProfileController', function( if (!w) return; $scope.loading = w.id; controllerUtils.deleteWallet($scope, w, function() { + if ($rootScope.wallet.id === w.id) { + $rootScope.wallet = null; + var lastFocused = $rootScope.iden.getLastFocusedWallet(); + controllerUtils.bindProfile($scope, $rootScope.iden, lastFocused); + } $scope.loading = false; $scope.getWallets(); }); }; + + $scope.downloadWalletBackup = function(w) { + if (!w) return; + backupService.walletDownload(w); + } + + $scope.viewWalletBackup = function(w) { + var ModalInstanceCtrl = function($scope, $modalInstance) { + + if (!w) return; + $scope.backupWalletPlainText = backupService.walletEncrypted(w); + $scope.hideViewWalletBackup = true; + $scope.cancel = function() { + $modalInstance.dismiss('cancel'); + }; + }; + + $modal.open({ + templateUrl: 'views/modals/backup-text.html', + windowClass: 'tiny', + controller: ModalInstanceCtrl + }); + }; + }); diff --git a/js/controllers/sidebar.js b/js/controllers/sidebar.js index bf42dce01..4ee22cc00 100644 --- a/js/controllers/sidebar.js +++ b/js/controllers/sidebar.js @@ -66,6 +66,7 @@ angular.module('copayApp.controllers').controller('SidebarController', function( }; $scope.getWallets = function() { + if (!$rootScope.iden) return; $scope.wallets = []; var wids = _.pluck($rootScope.iden.listWallets(), 'id'); _.each(wids, function(wid) { diff --git a/views/modals/backup-text.html b/views/modals/backup-text.html new file mode 100644 index 000000000..e6be16bdf --- /dev/null +++ b/views/modals/backup-text.html @@ -0,0 +1,14 @@ +
+

Copy backup in a safe place

+
+ + Copy to clipboard + +
+
+ +
+
Copy this text as it is in a safe place (notepad or email)
+
+ +× diff --git a/views/more.html b/views/more.html index 59a9e29ad..eb9e73441 100644 --- a/views/more.html +++ b/views/more.html @@ -18,46 +18,6 @@ - -
- -
-
-
-

Backup

-

- It's important to backup your wallet so that you can recover it in case of disaster -

- Download File - View Backup -
-
- - Copy to clipboard -
-
- -
-
Copy this text as it is in a safe place (notepad or email)
-
-
-
-
-
-

Delete Wallet

-

If all funds have been removed from your wallet and you do not wish to have the wallet data stored on your computer anymore, you can delete your wallet.

- - Delete - Deleting... - -
-
-
diff --git a/views/profile.html b/views/profile.html index 35e535c6e..cf08e592f 100644 --- a/views/profile.html +++ b/views/profile.html @@ -6,14 +6,15 @@

Backup Profile

It's important to backup your profile so that you can recover it in case of disaster. The backup will include all your profile's wallets

- Backup profile - View profile backup -
- + View profile backup +
+
- Copy to clipboard + Copy to clipboard
Copy this text as it is in a safe place (notepad or email) @@ -41,8 +42,8 @@ + networkName = item.getNetworkName()" + ng-class="{'deleting':loading==item.id}"> {{item.name || item.id }} {{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}} {{isReady ? 'Complete' : 'Waiting for copayers...'}} @@ -53,13 +54,20 @@ - Delete + +
+ + +     + +
- Active