diff --git a/js/controllers/copayers.js b/js/controllers/copayers.js index a988ad048..c424741a8 100644 --- a/js/controllers/copayers.js +++ b/js/controllers/copayers.js @@ -1,9 +1,9 @@ 'use strict'; angular.module('copayApp.controllers').controller('CopayersController', - function($scope, $rootScope, $timeout, go) { + function($scope, $rootScope, $timeout, go, identityService, notification) { + var w = $rootScope.wallet; $scope.init = function() { - var w = $rootScope.wallet; $rootScope.title = 'Share this secret with your copayers'; $scope.loading = false; $scope.secret = $rootScope.wallet.getSecret(); @@ -27,4 +27,25 @@ angular.module('copayApp.controllers').controller('CopayersController', $rootScope.$digest(); }, 1); }; + + $scope.deleteWallet = function() { + $scope.loading = true; + identityService.deleteWallet(w, function(err) { + if (err) { + $scope.loading = null; + $scope.error = err.message || err; + copay.logger.warn(err); + $timeout(function () { $scope.$digest(); }); + } else { + $scope.loading = false; + if ($rootScope.wallet) { + go.walletHome(); + } + $timeout(function() { + notification.success('Success', 'The wallet "' + (w.name || w.id) + '" was deleted'); + }); + } + }); + }; + }); diff --git a/js/controllers/more.js b/js/controllers/more.js index f3068922a..36f8e5159 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -1,9 +1,20 @@ 'use strict'; angular.module('copayApp.controllers').controller('MoreController', - function($scope, $rootScope, $location, $filter, balanceService, notification, rateService) { + function($scope, $rootScope, $location, $filter, $timeout, balanceService, notification, rateService, backupService, identityService, isMobile, isCordova, go) { var w = $rootScope.wallet; - $scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; + var max = $rootScope.quotaPerItem; + $scope.isSafari = isMobile.Safari(); + $scope.isCordova = isCordova; + $scope.wallet = w; + $scope.error = null; + $scope.success = null; + + var bits = w.sizes().total; + w.kb = $filter('noFractionNumber')(bits / 1000, 1); + if (max) { + w.usage = $filter('noFractionNumber')(bits / max * 100, 0); + } $rootScope.title = 'Settings'; @@ -105,4 +116,34 @@ angular.module('copayApp.controllers').controller('MoreController', }, true); }); }; + + $scope.deleteWallet = function() { + $scope.loading = true; + identityService.deleteWallet(w, function(err) { + if (err) { + $scope.loading = null; + $scope.error = err.message || err; + copay.logger.warn(err); + $timeout(function () { $scope.$digest(); }); + } else { + $scope.loading = false; + if ($rootScope.wallet) { + go.walletHome(); + } + $timeout(function() { + notification.success('Success', 'The wallet "' + (w.name || w.id) + '" was deleted'); + }); + } + }); + }; + + $scope.downloadWalletBackup = function() { + backupService.walletDownload(w); + }; + + $scope.viewWalletBackup = function() { + $scope.backupWalletPlainText = backupService.walletEncrypted(w); + }; + + }); diff --git a/js/controllers/profile.js b/js/controllers/profile.js index 8bebdfeae..94cc7c6d8 100644 --- a/js/controllers/profile.js +++ b/js/controllers/profile.js @@ -25,25 +25,6 @@ angular.module('copayApp.controllers').controller('ProfileController', function( // no need to add event handlers here. Wallet deletion is handle by callback. }; - $scope.setWallets = function() { - if (!$rootScope.iden) return; - - var wallets = $rootScope.iden.getWallets(); - var max = $rootScope.quotaPerItem; - - _.each(wallets, function(w) { - var bits = w.sizes().total; - w.kb = $filter('noFractionNumber')(bits / 1000, 1); - if (max) { - w.usage = $filter('noFractionNumber')(bits / max * 100, 0); - } - }); - $scope.wallets = wallets; - $timeout(function(){ - $scope.$digest(); - }) - }; - $scope.deleteProfile = function() { identityService.deleteProfile(function(err, res) { if (err) { @@ -57,54 +38,4 @@ angular.module('copayApp.controllers').controller('ProfileController', function( }); }); }; - - $scope.showWalletInfo = function(w) { - var ModalInstanceCtrl = function($scope, $modalInstance) { - if (!w) return; - $scope.isSafari = isMobile.Safari(); - $scope.isCordova = isCordova; - $scope.item = w; - $scope.error = null; - $scope.success = null; - - $scope.deleteWallet = function() { - - $scope.loading = true; - identityService.deleteWallet($scope.item, function(err) { - if (err) { - $scope.loading = null; - $scope.error = err.message || err; - copay.logger.warn(err); - $timeout(function () { $scope.$digest(); }); - } else { - $modalInstance.close($scope.item.name || $scope.item.id); - } - }); - }; - - $scope.downloadWalletBackup = function() { - backupService.walletDownload($scope.item); - }; - - $scope.viewWalletBackup = function() { - $scope.backupWalletPlainText = backupService.walletEncrypted($scope.item); - }; - - $scope.close = function() { - $modalInstance.dismiss('cancel'); - }; - }; - - var modalInstance = $modal.open({ - templateUrl: 'views/modals/wallet-info.html', - windowClass: 'medium', - controller: ModalInstanceCtrl - }); - - modalInstance.result.then(function(walletName) { - $scope.loading = false; - $scope.success = 'The wallet "' + walletName + '" was deleted'; - $scope.setWallets(); - }); - }; }); diff --git a/js/models/Identity.js b/js/models/Identity.js index 289f205bf..ee74ad469 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -218,6 +218,9 @@ Identity.prototype.deleteWallet = function(walletId, cb) { self.storage.removeItem(Wallet.getStorageKey(walletId), function(err) { if (err) return cb(err); self.emitAndKeepAlive('walletDeleted', walletId); + if (!self.walletIds.length) { + self.emitAndKeepAlive('noWallets') + } self.store({ noWallets: true }, cb); diff --git a/views/copayers.html b/views/copayers.html index 9ca0fdcd3..14db0f488 100644 --- a/views/copayers.html +++ b/views/copayers.html @@ -49,6 +49,32 @@ +
+
+ +
+

Are you sure you want to cancel and delete this wallet

+
+
+ +
+
+ +
+
+
+
+
diff --git a/views/modals/wallet-info.html b/views/modals/wallet-info.html deleted file mode 100644 index 1db258d4a..000000000 --- a/views/modals/wallet-info.html +++ /dev/null @@ -1,71 +0,0 @@ -
-
-

{{item.name || item.id }}

-

- {{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}} - , {{isComplete ? 'Complete' : 'Waiting for copayers...'}} -

-
- {{item.balanceInfo.totalBalance || 0}} {{item.settings.unitName}} -
-
- Approximate size: {{item.kb}} kB - ({{item.usage}}%) -
- -
-
- -
- - {{error|translate}} - -
- -
-
- - -
-
- -
-
- -
-

Copy backup in a safe place

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

Are you sure you want to delete the wallet - {{(item.name || item.id)}} -

-
- -
-
- -
-
-
diff --git a/views/more.html b/views/more.html index c5e401438..6a58f05f7 100644 --- a/views/more.html +++ b/views/more.html @@ -22,6 +22,77 @@ + +
+
+

{{wallet.name || wallet.id }}

+

+ {{wallet.requiredCopayers}} of {{wallet.totalCopayers}} - {{networkName}} + , {{isComplete ? 'Complete' : 'Waiting for copayers...'}} +

+
+ {{wallet.balanceInfo.totalBalance || 0}} {{wallet.settings.unitName}} +
+
+ Approximate size: {{wallet.kb}} kB + ({{wallet.usage}}%) +
+ +
+
+ +
+ + {{error|translate}} + +
+ +
+
+ + +
+
+ +
+
+ +
+

Copy backup in a safe place

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

Are you sure you want to delete the wallet + {{(wallet.name || wallet.id)}} +

+
+ +
+
+ +
+
+
diff --git a/views/profile.html b/views/profile.html index e3e83cede..ae9a82385 100644 --- a/views/profile.html +++ b/views/profile.html @@ -35,68 +35,13 @@
-
+
-

Manage wallets

- -
-
- -
- - {{success|translate}} - - × +
+ Your current server usage quotas are: {{perItem}}kB per wallet and up to {{nrWallets}} wallets.
- - - - - - - - - - - - - - - - - - - - -
NameTypeStatusBalanceApprox Size
- - - {{item.name || item.id }} - - {{item.requiredCopayers}} of {{item.totalCopayers}} - {{networkName}} - {{isComplete ? 'Complete' : 'Waiting for copayers...'}} - - - - - {{item.balanceInfo.totalBalance || 0}} {{item.settings.unitName}} - - - - {{item.kb}} kB - ({{item.usage}}%) - -
- -
-
- Your current server usage quotas are: {{perItem}}kB per wallet and up to {{nrWallets}} wallets. -
-
- Confirm your email address to increase storage usage limits. -
+
+ Confirm your email address to increase storage usage limits.