Merge pull request #1963 from matiu/feature/receive

simplify receive and wallet home tab
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-04 11:27:15 -03:00
commit 799ef2b7e5
8 changed files with 153 additions and 130 deletions

View file

@ -2,15 +2,6 @@
angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope) { angular.module('copayApp.controllers').controller('HomeWalletController', function($scope, $rootScope) {
$scope.init = function() { $scope.init = function() {
$rootScope.title = 'Home'; $rootScope.title = 'Home';
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
// This is necesarry, since wallet can change in homeWallet, without running init() again.
$rootScope.$watch('wallet', function() {
if ($rootScope.wallet && $rootScope.wallet.isComplete()) {
$scope.addr = _.last($rootScope.wallet.getReceiveAddresses());
}
});
}; };
}); });

View file

@ -2,9 +2,6 @@
angular.module('copayApp.controllers').controller('ReceiveController', angular.module('copayApp.controllers').controller('ReceiveController',
function($scope, $rootScope, $timeout, $modal) { function($scope, $rootScope, $timeout, $modal) {
$rootScope.title = 'Receive';
$scope.loading = false;
$scope.showAll = false;
$scope.newAddr = function() { $scope.newAddr = function() {
var w = $rootScope.wallet; var w = $rootScope.wallet;
@ -16,6 +13,25 @@ angular.module('copayApp.controllers').controller('ReceiveController',
}, 1); }, 1);
}; };
$scope.init = function() {
$rootScope.title = 'Receive';
$scope.showAll = false;
var w = $rootScope.wallet;
var lastAddr = _.first(w.getAddressesOrderer());
var balance = w.balanceInfo.balanceByAddr;
if (balance[lastAddr]>0)
$scope.loading = true;
while (balance && balance[lastAddr] > 0) {
$scope.newAddr();
lastAddr = w.generateAddress(null);
};
$scope.loading = false;
$scope.addr = lastAddr;
};
$scope.openAddressModal = function(address) { $scope.openAddressModal = function(address) {
var ModalInstanceCtrl = function($scope, $modalInstance, address) { var ModalInstanceCtrl = function($scope, $modalInstance, address) {
$scope.address = address; $scope.address = address;
@ -43,6 +59,7 @@ angular.module('copayApp.controllers').controller('ReceiveController',
}; };
$scope.setAddressList = function() { $scope.setAddressList = function() {
if ($scope.showAll) {
var w = $rootScope.wallet; var w = $rootScope.wallet;
var balance = w.balanceInfo.balanceByAddr; var balance = w.balanceInfo.balanceByAddr;
@ -64,6 +81,9 @@ angular.module('copayApp.controllers').controller('ReceiveController',
}); });
$scope.addresses = list; $scope.addresses = list;
} }
} else {
$scope.addresses = [];
}
}; };
} }
); );

View file

@ -145,9 +145,6 @@ describe("Unit: Controllers", function() {
}); });
})); }));
it('should have a ReceiveController controller', function() {
expect(scope.loading).equal(false);
});
}); });
describe('History Controller', function() { describe('History Controller', function() {

View file

@ -30,29 +30,23 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
</div>
<div class="row "> <div class="row ">
<!-- Address--> <div class="large-12 columns line-t m10t">
<div class="large-6 columns"> <div class="right size-10">
<div class="panel oh"> <span ng-if="!$root.wallet.isShared()">Personal Wallet</span>
<h2 class="line-b" translate>Quick receive</h2> <span ng-if="$root.wallet.isShared()">
<div class="text-center"> Multisignature wallet [{{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ]
<qrcode size="220" data="bitcoin:{{addr}}"></qrcode>
<div class="m10t">
<h4 class="size-12">{{addr}} </h4>
<span ng-if="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span> </span>
<span ng-if="$root.wallet.isTestnet()"> in TESTNET</span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="row" ng-if="$root.wallet.isShared()">
<!-- List of copayers --> <!-- List of copayers -->
<div class="large-6 columns"> <div class="large-12 columns">
<div class="panel oh"> <div class="panel oh">
<h2 class="line-b" translate>Copayers</h2> <h2 class="line-b" translate>Copayers</h2>
<div ng-include="'views/includes/copayer.html'"></div> <div ng-include="'views/includes/copayer.html'"></div>

View file

@ -41,12 +41,12 @@
<div class="large-6 medium-12 small-12 columns" ng-show="!tx.sentTs"> <div class="large-6 medium-12 small-12 columns" ng-show="!tx.sentTs">
<div ng-show="tx.signedBy[myId]"> <div ng-show="tx.signedBy[myId]">
<button class="secondary left m10r tiny m0 radius" ng-disabled="true"> <i class="fi-check icon-sign check"></i> <button class="secondary left m10r tiny m0 radius" ng-disabled="true"> <i class="fi-check icon-sign check"></i>
<span translate>I signed</span> <span translate>Signed by me</span>
</button> </button>
</div> </div>
<div ng-show="tx.rejectedBy[myId]"> <div ng-show="tx.rejectedBy[myId]">
<button class="warning left m10r tiny m0 radius" ng-disabled="true"> <i class="fi-x icon-sign x"></i> <button class="warning left m10r tiny m0 radius" ng-disabled="true"> <i class="fi-x icon-sign x"></i>
<span translate>I rejected</span> <span translate>Rejected by me</span>
</button> </button>
</div> </div>
<div ng-show="!tx.signedBy[myId] && !tx.rejectedBy[myId]"> <div ng-show="!tx.signedBy[myId] && !tx.rejectedBy[myId]">
@ -78,9 +78,6 @@
<div> <div>
<strong translate>Fee</strong>: {{tx.fee}} {{$root.wallet.settings.unitName}} <strong translate>Fee</strong>: {{tx.fee}} {{$root.wallet.settings.unitName}}
</div> </div>
<div class="m5t">
<strong translate>Proposal ID</strong>: {{tx.ntxid}}
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -1,6 +1,5 @@
<div ng-controller="VersionController"> <div ng-controller="VersionController">
<small>v{{version}}</small> <small>v{{version}}</small>
<small>#{{commitHash}}</small> <small>#{{commitHash}}</small>
<small ng-if="$root.wallet.isTestnet()">[TESTNET]</small>
</div> </div>

View file

@ -1,9 +1,31 @@
<div class="addresses" ng-controller="ReceiveController" ng-init="setAddressList()"> <div class="addresses" ng-controller="ReceiveController" ng-init="init()">
<div class="row"> <div class="row">
<div class="large-12 medium-12 small-12 columns"> <div class="large-12 medium-12 small-12 columns">
<h1 class="hide-for-large-up">{{$root.title}}</h1> <h1 class="hide-for-large-up">{{$root.title}}</h1>
<div ng-show="!addresses[0]"> </div>
<i class="fi-bitcoin-circle icon-rotate spinner"></i> </div>
<div class="row">
<!-- Address-->
<div class="large-12 columns" ng-if="addr">
<div class="panel oh">
<div class="row">
<h2 class="line-b" translate>My Bitcoin address:</h2>
<div class="text-center" ng-if="!loading">
<qrcode size="220" data="bitcoin:{{addr}}"></qrcode>
<div class="m10t">
<h4 class="size-12">{{addr}}</h4>
</div>
</div>
<div class="text-center" ng-if="loading">
Generating new address...
</div>
</div>
<div class="row">
<div class="large-12 columns line-t m10t size-12">
Share this with anyone to have them send you payments. To protect your privacy, new addresses are generated automatically once you use them.
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -47,21 +69,24 @@
</div> </div>
</div> </div>
</div> </div>
</div> <!-- end of panel mobile --> </div>
<!-- end of panel mobile -->
</div> </div>
</div> </div>
</div> <a class="button primary text-center right" ng-click="newAddr()" ng-disabled="loading">
<div class="large-12 columns"> Generate new address
<div class="m20b text-right"> </a>
<a class="size-12" ng-click="toggleShowAll()" ng-show="addrLength > 3"> <a class="button primary text-center" ng-click="toggleShowAll()" ng-disabled="loading">
<span translate ng-if="!showAll">Show all</span> <span translate ng-if="showAll">Hide them</span>
<span translate ng-if="showAll">Show less</span>
</a> </a>
</div> </div>
<a class="button tiny primary text-center" ng-click="newAddr()" ng-disabled="loading"> <div class="large-12 columns" ng-if="!showAll">
<i class="fi-plus m5r"></i> Add <div class="m20b">
<a class="button primary text-center" ng-click="toggleShowAll()" ng-disabled="loading">
<span translate>Show all my addresses</span>
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</div>

View file

@ -1,4 +1,11 @@
<div class="send" ng-controller="SendController" ng-init="init()"> <div class="send" ng-controller="SendController" ng-init="init()">
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<div ng-show="txps.length != 0" class="line-dashed-h m20b"></div>
<h1 class="hide-for-large-up">{{$root.title}}</h1>
</div>
</div>
<div class="row" ng-show="txps.length != 0"> <div class="row" ng-show="txps.length != 0">
<div class="large-12 columns"> <div class="large-12 columns">
<h2 translate>Pending Transactions Proposals</h2> <h2 translate>Pending Transactions Proposals</h2>
@ -8,13 +15,6 @@
</div> </div>
</div> </div>
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<div ng-show="txps.length != 0" class="line-dashed-h m20b"></div>
<h1 class="hide-for-large-up">{{$root.title}}</h1>
</div>
</div>
<div class="row"> <div class="row">
<div class="large-12 columns"> <div class="large-12 columns">
<h2 ng-show="txps.length != 0" translate>Create Transaction Proposal</h2> <h2 ng-show="txps.length != 0" translate>Create Transaction Proposal</h2>