diff --git a/config.js b/config.js index cbf991b12..f948ea2ac 100644 --- a/config.js +++ b/config.js @@ -55,10 +55,10 @@ var defaultConfig = { plugins: { //LocalStorage: true, - EncryptedLocalStorage: true, +// EncryptedLocalStorage: true, //GoogleDrive: true, //InsightStorage: true - //EncryptedInsightStorage: true + EncryptedInsightStorage: true, }, EncryptedInsightStorage: { diff --git a/js/controllers/transactions.js b/js/controllers/history.js similarity index 82% rename from js/controllers/transactions.js rename to js/controllers/history.js index e15aac4f2..e142a8c57 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/history.js @@ -1,14 +1,12 @@ 'use strict'; var bitcore = require('bitcore'); -angular.module('copayApp.controllers').controller('TransactionsController', +angular.module('copayApp.controllers').controller('HistoryController', function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) { controllerUtils.redirIfNotComplete(); - var w = $rootScope.wallet; - $rootScope.title = 'History'; $scope.loading = false; $scope.lastShowed = false; @@ -19,6 +17,7 @@ angular.module('copayApp.controllers').controller('TransactionsController', var satToUnit = 1 / w.settings.unitToSatoshi; + $scope.update = function() { $scope.loading = true; var from = ($scope.txpCurrentPage - 1) * $scope.txpItemsPerPage; @@ -32,6 +31,8 @@ angular.module('copayApp.controllers').controller('TransactionsController', }, 0); }; + + $scope.show = function() { $scope.loading = true; setTimeout(function() { @@ -39,20 +40,15 @@ angular.module('copayApp.controllers').controller('TransactionsController', }, 10); }; - $scope.toogleLast = function() { - $scope.lastShowed = !$scope.lastShowed; - if ($scope.lastShowed) { - $scope.getTransactions(); - } - }; $scope.getTransactions = function() { - var self = this; + var w = $rootScope.wallet; if (!w) return; $scope.blockchain_txs = w.cached_txs || []; $scope.loading = true; + w.getTransactionHistory(function(err, res) { if (err) throw err; @@ -81,13 +77,6 @@ angular.module('copayApp.controllers').controller('TransactionsController', $scope.getShortNetworkName = function() { return w.getNetworkName().substring(0, 4); }; - - // Autoload transactions on 1-of-1 - if ($rootScope.wallet && $rootScope.wallet.totalCopayers == 1) { - $scope.lastShowed = true; - $scope.getTransactions(); - } - $scope.amountAlternative = function(amount, txIndex, cb) { var w = $rootScope.wallet; rateService.whenAvailable(function() { @@ -96,4 +85,7 @@ angular.module('copayApp.controllers').controller('TransactionsController', return cb ? cb() : null; }); }; + + // Autoload transactions + $scope.getTransactions(); }); diff --git a/js/controllers/home.js b/js/controllers/home.js index ab9cefac6..fdc4f7e92 100644 --- a/js/controllers/home.js +++ b/js/controllers/home.js @@ -5,7 +5,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc $scope.retreiving = true; identityService.check($scope); - + $scope.confirmedEmail = getParam('confirmed'); $scope.openProfile = function(form) { if (form && form.$invalid) { notification.error('Error', 'Please enter the required fields'); @@ -14,4 +14,18 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc $scope.loading = true; identityService.open($scope, form); } + + function getParam(sname) { + var params = location.search.substr(location.search.indexOf("?") + 1); + var sval = ""; + params = params.split("&"); + // split param and value into individual pieces + for (var i = 0; i < params.length; i++) { + var temp = params[i].split("="); + if ([temp[0]] == sname) { + sval = temp[1]; + } + } + return sval; + } }); diff --git a/js/controllers/more.js b/js/controllers/more.js index 210fa4c2c..48fe1103b 100644 --- a/js/controllers/more.js +++ b/js/controllers/more.js @@ -54,6 +54,18 @@ angular.module('copayApp.controllers').controller('MoreController', } } + $scope.hideAdv = true; + $scope.hidePriv = true; + $scope.hideSecret = true; + if (w) { + $scope.priv = w.privateKey.toObj().extendedPrivateKeyString; + $scope.secret = w.getSecret(); + } + + setTimeout(function() { + $scope.$digest(); + }, 1); + $scope.save = function() { w.changeSettings({ unitName: $scope.selectedUnit.shortName, @@ -66,15 +78,6 @@ angular.module('copayApp.controllers').controller('MoreController', controllerUtils.updateBalance(); }; - - $scope.hideAdv = true; - $scope.hidePriv = true; - $scope.hideSecret = true; - if (w) { - $scope.priv = w.privateKey.toObj().extendedPrivateKeyString; - $scope.secret = w.getSecret(); - } - $scope.downloadBackup = function() { backupService.walletDownload(w); } diff --git a/js/controllers/addresses.js b/js/controllers/receive.js similarity index 95% rename from js/controllers/addresses.js rename to js/controllers/receive.js index 3c735212f..c48755481 100644 --- a/js/controllers/addresses.js +++ b/js/controllers/receive.js @@ -1,11 +1,9 @@ 'use strict'; -angular.module('copayApp.controllers').controller('AddressesController', +angular.module('copayApp.controllers').controller('ReceiveController', function($scope, $rootScope, $timeout, $modal, controllerUtils) { controllerUtils.redirIfNotComplete(); - $rootScope.title = 'Addresses'; - $scope.loading = false; $scope.showAll = false; diff --git a/js/controllers/settings.js b/js/controllers/settings.js index c9fdede6f..9671c5598 100644 --- a/js/controllers/settings.js +++ b/js/controllers/settings.js @@ -8,6 +8,23 @@ angular.module('copayApp.controllers').controller('SettingsController', function $scope.insightLivenet = config.network.livenet.url; $scope.insightTestnet = config.network.testnet.url; + $scope.availableStorages = [{ + name: 'Insight', + pluginName: 'EncryptedInsightStorage', + }, { + name: 'Localstorage', + pluginName: 'EncryptedLocalStorage', + }, + // { + // name: 'GoogleDrive', + // pluginName: 'GoogleDrive', + // } + ]; + + _.each($scope.availableStorages, function(v){ + if (config.plugins[v.pluginName]) + $scope.selectedStorage = v; + }); $scope.availableLanguages = [{ name: 'English', @@ -39,11 +56,14 @@ angular.module('copayApp.controllers').controller('SettingsController', function }, } + var plugins = {}; + plugins[$scope.selectedStorage.pluginName] = true; localStorage.setItem('config', JSON.stringify({ network: insightSettings, version: copay.version, - defaultLanguage: $scope.selectedLanguage.isoCode + defaultLanguage: $scope.selectedLanguage.isoCode, + plugins: plugins, })); // Go home reloading the application diff --git a/js/routes.js b/js/routes.js index 49473ee04..c3b0cf8ac 100644 --- a/js/routes.js +++ b/js/routes.js @@ -35,11 +35,11 @@ angular logged: true }) .when('/receive', { - templateUrl: 'views/addresses.html', + templateUrl: 'views/receive.html', logged: true }) .when('/history', { - templateUrl: 'views/transactions.html', + templateUrl: 'views/history.html', logged: true }) .when('/send', { diff --git a/js/services/controllerUtils.js b/js/services/controllerUtils.js index 0d42459ce..9c581e897 100644 --- a/js/services/controllerUtils.js +++ b/js/services/controllerUtils.js @@ -32,22 +32,23 @@ angular.module('copayApp.services') root.logout = function() { if ($rootScope.iden) { - $rootScope.iden.store(null, function(){ + $rootScope.iden.store(null, function() { $rootScope.iden.close(); + + delete $rootScope['wallet']; + delete $rootScope['iden']; + + // Clear rootScope + for (var i in $rootScope) { + if (i.charAt(0) != '$') { + delete $rootScope[i]; + } + } + + $location.path('/'); + }); } - - delete $rootScope['wallet']; - delete $rootScope['iden']; - - // Clear rootScope - for (var i in $rootScope) { - if (i.charAt(0) != '$') { - delete $rootScope[i]; - } - } - - $location.path('/'); }; root.onError = function(scope) { diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js index a25175799..654484485 100644 --- a/test/unit/controllers/controllersSpec.js +++ b/test/unit/controllers/controllersSpec.js @@ -64,7 +64,7 @@ describe("Unit: Controllers", function() { w.getSecret = sinon.stub().returns('secret'); w.getName = sinon.stub().returns('fakeWallet'); w.exportEncrypted = sinon.stub().returns('1234567'); - w.getTransactionHistory = sinon.stub().yields({}); + w.getTransactionHistory = sinon.stub().yields(null); w.getNetworkName = sinon.stub().returns('testnet'); w.createTx = sinon.stub().yields(null); @@ -132,34 +132,37 @@ describe("Unit: Controllers", function() { }); - describe('Address Controller', function() { - var addressCtrl; + describe('Receive Controller', function() { + var c; beforeEach(inject(function($controller, $rootScope) { scope = $rootScope.$new(); - addressCtrl = $controller('AddressesController', { + c = $controller('ReceiveController', { $scope: scope, }); })); - it('should have a AddressesController controller', function() { + it('should have a ReceiveController controller', function() { expect(scope.loading).equal(false); }); }); - describe('Transactions Controller', function() { - var transactionsCtrl; + describe('History Controller', function() { + var ctrl; beforeEach(inject(function($controller, $rootScope) { + scope = $rootScope.$new(); - transactionsCtrl = $controller('TransactionsController', { + scope.wallet = null; + scope.getTransactions = sinon.stub(); + ctrl = $controller('HistoryController', { $scope: scope, }); })); it('should exist', function() { - should.exist(transactionsCtrl); + should.exist(ctrl); }); - it('should have a TransactionController controller', function() { + it('should have a HistoryController controller', function() { expect(scope.loading).equal(false); }); diff --git a/views/transactions.html b/views/history.html similarity index 83% rename from views/transactions.html rename to views/history.html index bd01be246..d4ee065bb 100644 --- a/views/transactions.html +++ b/views/history.html @@ -1,4 +1,4 @@ -
+

Transaction Proposals ({{txs.length}})

@@ -20,14 +20,7 @@ - -
- - -
+
No transactions yet.
diff --git a/views/home.html b/views/home.html index 2cb19606a..f09995dc8 100644 --- a/views/home.html +++ b/views/home.html @@ -9,6 +9,15 @@ Copay
+
+
+ +
+
+ Copay now needs a confirmation.
+ You have to sign in to confirm your email +
+

Sign in to Copay

diff --git a/views/addresses.html b/views/receive.html similarity index 96% rename from views/addresses.html rename to views/receive.html index 0883d8df8..391270c2f 100644 --- a/views/addresses.html +++ b/views/receive.html @@ -1,6 +1,6 @@ -
+
-

{{$root.title}}

+

Receive

diff --git a/views/settings.html b/views/settings.html index 5c3169805..da62e5ca9 100644 --- a/views/settings.html +++ b/views/settings.html @@ -26,6 +26,16 @@ Insight API server is open-source software. You can run your own instances, check Insight API Homepage
+
+ Wallet and profile storage + + +
+ Wallets and profiles are stored encrypted using your password as a key. You can store the encrypted data locally, on your platform, or remotely on the Insight Server. More pluggins are welcomed! +
+
+