From 5b1463af60b31a1ab30950f80ea0e58e98f356df Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 14:53:20 -0300 Subject: [PATCH 01/10] Move wallet-info to settings. Fix removing last wallet --- js/controllers/copayers.js | 25 +++++++++++- js/controllers/more.js | 45 +++++++++++++++++++++- js/controllers/profile.js | 69 ---------------------------------- js/models/Identity.js | 3 ++ views/copayers.html | 26 +++++++++++++ views/modals/wallet-info.html | 71 ----------------------------------- views/more.html | 71 +++++++++++++++++++++++++++++++++++ views/profile.html | 65 +++----------------------------- 8 files changed, 171 insertions(+), 204 deletions(-) delete mode 100644 views/modals/wallet-info.html 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.
From 05d1ba98ae14d001fe9df70538f966c900d90f28 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 15:04:13 -0300 Subject: [PATCH 02/10] fixes page not found if there are not wallets --- views/errors/404.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/views/errors/404.html b/views/errors/404.html index a9d8759ec..aa9f768a2 100644 --- a/views/errors/404.html +++ b/views/errors/404.html @@ -1,11 +1,11 @@
+ ng-class="{'wide-page':!$root.iden}">
- Copay - Copay + Copay + Copay
-

404

-

Page not found

+

404

+

Page not found

« Back

From b018028b174a97da6402aad61a558451cd99d55f Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 15:24:46 -0300 Subject: [PATCH 03/10] fix loading spinner for create and join --- js/controllers/join.js | 4 ++-- views/create.html | 6 +++--- views/join.html | 5 ++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/js/controllers/join.js b/js/controllers/join.js index e1029fac2..3234e1bae 100644 --- a/js/controllers/join.js +++ b/js/controllers/join.js @@ -127,13 +127,13 @@ angular.module('copayApp.controllers').controller('JoinController', return; } - $scope.loading = true; + $rootScope.starting = true; identityService.joinWallet({ secret: $scope.connectionId, nickname: $scope.nickname, privateHex: $scope.private, }, function(err) { - $scope.loading = false; + $rootScope.starting = false; if (err) { if (err === 'joinError') notification.error('Fatal error connecting to Insight server'); diff --git a/views/create.html b/views/create.html index 58150b70a..e3cadd62e 100644 --- a/views/create.html +++ b/views/create.html @@ -1,8 +1,8 @@
-
+
-
+
@@ -75,7 +75,7 @@
-
diff --git a/views/join.html b/views/join.html index 15355fbb4..a9ef7b069 100644 --- a/views/join.html +++ b/views/join.html @@ -1,9 +1,9 @@
-
+
-
+

{{$root.title}}

@@ -73,7 +73,6 @@
-
From 1a6f0aacf17199dce1787a7e3d692b8d8b0162b7 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 15:33:19 -0300 Subject: [PATCH 04/10] fix delete profile --- js/controllers/profile.js | 16 ++++++++++------ views/profile.html | 12 ++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/js/controllers/profile.js b/js/controllers/profile.js index 94cc7c6d8..be37345a2 100644 --- a/js/controllers/profile.js +++ b/js/controllers/profile.js @@ -1,5 +1,5 @@ 'use strict'; -angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova) { +angular.module('copayApp.controllers').controller('ProfileController', function($scope, $rootScope, $location, $modal, $filter, $timeout, backupService, identityService, isMobile, isCordova, notification) { $scope.username = $rootScope.iden.getName(); $scope.isSafari = isMobile.Safari(); $scope.isCordova = isCordova; @@ -26,16 +26,20 @@ angular.module('copayApp.controllers').controller('ProfileController', function( }; $scope.deleteProfile = function() { + $scope.loading = true; identityService.deleteProfile(function(err, res) { + $scope.loading = false; if (err) { log.warn(err); notification.error('Error', 'Could not delete profile'); - return; + $timeout(function () { $scope.$digest(); }); + } + else { + $location.path('/'); + $timeout(function() { + notification.success('Success', 'Profile successfully deleted'); + }); } - $location.path('/'); - $timeout(function() { - notification.error('Success', 'Profile successfully deleted'); - }); }); }; }); diff --git a/views/profile.html b/views/profile.html index ae9a82385..ac04632ff 100644 --- a/views/profile.html +++ b/views/profile.html @@ -76,10 +76,18 @@

Are you sure you want to delete this profile?

- Cancel +
- Delete +
From e7c6422770b3cb90c4b9aaa041c680b7a2e4477c Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 16:48:13 -0300 Subject: [PATCH 05/10] fix look&feel setting page --- views/more.html | 151 +++++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 66 deletions(-) diff --git a/views/more.html b/views/more.html index 6a58f05f7..136611381 100644 --- a/views/more.html +++ b/views/more.html @@ -23,77 +23,57 @@
-
-
-

{{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) -
-
+
+
+

Wallet info

+ + + + + + + + + + + + + + + + + + + + + +
Name:{{wallet.name || wallet.id }}
Status:{{isComplete ? 'Complete' : 'Waiting for copayers...'}}
Type:{{wallet.requiredCopayers}} of {{wallet.totalCopayers}} - {{networkName}}
Balance:{{wallet.balanceInfo.totalBalance || 0}} {{wallet.settings.unitName}}
Aprox. size:{{wallet.kb}} kB ({{wallet.usage}}%)
-
-

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

-
- +
+ +
+
+ + +
+
+ +
+
+

Copy backup in a safe place

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

+ Delete wallet +

+
+
+ +
+ + {{error|translate}} + +
+

Permanently delete this wallet. WARNING: this action cannot be reversed.

+
+
+

Are you sure you want to delete this wallet?

+
+
+ +
+
+ +
+
+
+
+

From 3a8717a1f4e72b593057a3fdfcc3adec8a8df5a3 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 14 Jan 2015 17:06:13 -0300 Subject: [PATCH 06/10] fix karma test --- test/unit/controllers/controllersSpec.js | 33 ++++++------------------ 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index d0688342a..edf7f472f 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -568,25 +568,12 @@ describe("Unit: Controllers", function() { }); }); - describe('Profile Controller', function() { - var ctrl, inScope, modalCtrl; + describe('More Controller', function() { + var ctrl, modalCtrl; beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); - ctrl = $controller('ProfileController', { - $scope: scope, - $modal: { - open: function(opts) { - inScope = $rootScope.$new(); - modalCtrl = opts.controller(inScope, { - close: sinon.stub(), - }); - return { - result: { - then: sinon.stub(), - } - }; - }, - }, + ctrl = $controller('MoreController', { + $scope: scope }); saveAsLastCall = null; @@ -595,8 +582,7 @@ describe("Unit: Controllers", function() { it('Backup Wallet controller #download', function() { var w = scope.wallet; expect(saveAsLastCall).equal(null); - scope.showWalletInfo(w); - inScope.downloadWalletBackup(); + scope.downloadWalletBackup(); expect(saveAsLastCall.blob.size).equal(7); expect(saveAsLastCall.blob.type).equal('text/plain;charset=utf-8'); @@ -605,8 +591,7 @@ describe("Unit: Controllers", function() { it('Backup Wallet controller should name backup correctly for multiple copayers', function() { var w = scope.wallet; expect(saveAsLastCall).equal(null); - scope.showWalletInfo(w); - inScope.downloadWalletBackup(); + scope.downloadWalletBackup(); expect(saveAsLastCall.filename).equal('nickname-fakeWallet-keybackup.json.aes'); }); @@ -614,16 +599,14 @@ describe("Unit: Controllers", function() { var w = scope.wallet; expect(saveAsLastCall).equal(null); scope.wallet.totalCopayers = 1; - scope.showWalletInfo(w); - inScope.downloadWalletBackup(); + scope.downloadWalletBackup(); expect(saveAsLastCall.filename).equal('fakeWallet-keybackup.json.aes'); }); it('Delete a wallet', function() { var w = scope.wallet; - scope.showWalletInfo(w); - inScope.deleteWallet(); + scope.deleteWallet(); scope.$digest(); scope.iden.deleteWallet.calledOnce.should.equal(true); scope.iden.deleteWallet.getCall(0).args[0].should.equal(w.getId()); From e2d178df1954be9d04c48ea56f60b4389676e48a Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 16 Jan 2015 02:25:33 -0300 Subject: [PATCH 07/10] Fix confirmation email notification --- css/src/main.css | 10 ++++------ index.html | 40 ++++++++++++++++++++++------------------ views/createProfile.html | 2 +- views/profile.html | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/css/src/main.css b/css/src/main.css index e09b87dea..89f470d51 100644 --- a/css/src/main.css +++ b/css/src/main.css @@ -268,15 +268,13 @@ input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill, inpu } .status { - -moz-box-shadow: inset 0px -1px 1px 0px rgba(159,47,34,0.30); - box-shadow: inset 0px -1px 1px 0px rgba(159,47,34,0.30); color: #FFFFFF; background-color: #A02F23; position: absolute; left: 250px; right: 0; bottom: 0; - padding: 10px 2rem; + padding: 10px 1rem 10px 0.5rem; z-index: 9; font-size: 14px; text-align: left; @@ -284,7 +282,6 @@ input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill, inpu } .status-first-line { - z-index: 9; font-size: 16px; } @@ -414,9 +411,10 @@ input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill, inpu a.close-notification { position: absolute; - top: 8px; - right: 10px; + top: 0; + right: 0; font-size: 24px; + padding: 10px; } .panel.last-transactions { diff --git a/index.html b/index.html index 8096a2b69..12ce5e95b 100644 --- a/index.html +++ b/index.html @@ -50,21 +50,25 @@
- - × - - - - Email not confirmed.
- Please confirm your email address using the confirmation link at the message we sent you -
-
- +
+ × +
+
+ + Email not confirmed.
+ Please confirm your email address using the confirmation link at the message we sent you +
+
+ +
+
+
+
× @@ -72,11 +76,11 @@ An email was sent to {{$root.iden.getName()}}. Please follow the link on it to confirm it. Unconfirmed profiles could be deleted from server. - - +
+
Network Error.
Attempting to reconnect..
- +
-
+
Copay
diff --git a/views/profile.html b/views/profile.html index ac04632ff..9d17bb5e6 100644 --- a/views/profile.html +++ b/views/profile.html @@ -48,7 +48,7 @@
-
+
-
-