Merge pull request #1610 from matiu/feature/home

Feature/home
This commit is contained in:
Matias Alejo Garcia 2014-10-30 16:24:07 -03:00
commit 9914fbce12
10 changed files with 76 additions and 59 deletions

View File

@ -55,10 +55,10 @@ var defaultConfig = {
plugins: {
//LocalStorage: true,
EncryptedLocalStorage: true,
// EncryptedLocalStorage: true,
//GoogleDrive: true,
//InsightStorage: true
//EncryptedInsightStorage: true
EncryptedInsightStorage: true,
},
EncryptedInsightStorage: {

View File

@ -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;
@ -78,13 +74,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() {
@ -93,4 +82,7 @@ angular.module('copayApp.controllers').controller('TransactionsController',
return cb ? cb() : null;
});
};
// Autoload transactions
$scope.getTransactions();
});

View File

@ -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;

View File

@ -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

View File

@ -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', {

View File

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

View File

@ -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);
});

View File

@ -1,4 +1,4 @@
<div class="transactions" data-ng-controller="TransactionsController" data-ng-init="update()">
<div class="transactions" data-ng-controller="HistoryController" data-ng-init="update()">
<div ng-show='$root.wallet.isReady()'>
<h2 ng-show="wallet.isShared()">
<span translate>Transaction Proposals</span> <small>({{txs.length}})</small></h2>
@ -20,14 +20,7 @@
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</small>
</h2>
<div class="large-12">
<div class="m10b size-12" ng-hide="wallet.totalCopayers == 1">
<a class="text-gray active" ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-hide="lastShowed && !loading">[ <span translate>Show</span> ]</a>
<a class="text-gray" ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-show="lastShowed && !loading">[ <span translate>Hide</span> ]</a>
</div>
<div class="btransactions" ng-if="lastShowed">
<div class="btransactions">
<div ng-if="!blockchain_txs[0].txid && !loading">
<em><strong translate>No transactions yet.</strong></em></div>
<div class="last-transactions" ng-repeat="btx in blockchain_txs | orderBy: 'time':true">

View File

@ -1,6 +1,6 @@
<div class="addresses" ng-controller="AddressesController">
<div class="addresses" ng-controller="ReceiveController">
<div ng-show='$root.wallet.isReady()'>
<h1 class="hide-for-large-up">{{$root.title}}</h1>
<h1 translate class="hide-for-large-up">Receive</h1>
<div ng-show="!addresses[0]">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</div>

View File

@ -26,6 +26,16 @@
Insight API server is open-source software. You can run your own instances, check <a href="http://insight.is" target="_blank">Insight API Homepage</a>
</div>
</fieldset>
<fieldset>
<legend translate>Wallet and profile storage</legend>
<label for="insightTestnet">Store wallet and profiles on</label>
<select class="form-control" ng-model="selectedStorage" ng-options="o.name for o in availableStorages" required>
</select>
<div translate class="small">
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. <a target="_blank" href="https://github.com/bitpay/copay/tree/master/js/plugins">More pluggins are welcomed!</a>
</div>
</fieldset>
<button translate type="submit" class="button primary radius expand m0" ng-disabled="settingsForm.$invalid || loading" ng-click="save()">
Save
</button>