simplify receive and wallet home tab

This commit is contained in:
Matias Alejo Garcia 2014-12-04 10:36:58 -03:00
parent 6f1342ea27
commit 3edec5e597
7 changed files with 174 additions and 137 deletions

View File

@ -4,13 +4,12 @@ angular.module('copayApp.controllers').controller('HomeWalletController', functi
$scope.init = function() {
$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());
}
});
// $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',
function($scope, $rootScope, $timeout, $modal) {
$rootScope.title = 'Receive';
$scope.loading = false;
$scope.showAll = false;
$scope.newAddr = function() {
var w = $rootScope.wallet;
@ -16,6 +13,25 @@ angular.module('copayApp.controllers').controller('ReceiveController',
}, 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) {
var ModalInstanceCtrl = function($scope, $modalInstance, address) {
$scope.address = address;
@ -43,26 +59,30 @@ angular.module('copayApp.controllers').controller('ReceiveController',
};
$scope.setAddressList = function() {
var w = $rootScope.wallet;
var balance = w.balanceInfo.balanceByAddr;
if ($scope.showAll) {
var w = $rootScope.wallet;
var balance = w.balanceInfo.balanceByAddr;
var addresses = w.getAddressesOrderer();
if (addresses) {
$scope.addrLength = addresses.length;
var addresses = w.getAddressesOrderer();
if (addresses) {
$scope.addrLength = addresses.length;
if (!$scope.showAll)
addresses = addresses.slice(0,3);
if (!$scope.showAll)
addresses = addresses.slice(0, 3);
var list = [];
_.each(addresses, function(address, index){
list.push({
'index': index,
'address': address,
'balance': balance ? balance[address] : null,
'isChange': w.addressIsChange(address),
var list = [];
_.each(addresses, function(address, index) {
list.push({
'index': index,
'address': address,
'balance': balance ? balance[address] : null,
'isChange': w.addressIsChange(address),
});
});
});
$scope.addresses = list;
$scope.addresses = list;
}
} else {
$scope.addresses = [];
}
};
}

View File

@ -1,63 +1,57 @@
<div class="home-wallet" ng-controller="HomeWalletController" ng-init="init()">
<div class="row hide-for-large-up">
<div class="medium-12 small-12 columns">
<h1 translate>Home</h1>
</div>
<div class="row hide-for-large-up">
<div class="medium-12 small-12 columns">
<h1 translate>Home</h1>
</div>
</div>
<div class="row">
<div class="large-12 columns">
<div class="panel oh">
<div class="row">
<div class="large-8 medium-6 small-3 columns">
<div class="avatar-wallet left">{{$root.wallet.getName() | limitTo: 1}}</div>
<h2 class="ellipsis m10t left hide-for-small-only">{{$root.wallet.getName()}}</h2>
</div>
<div class="large-4 medium-6 small-9 columns">
<div class="text-right">
<span class="size-21">
<div class="row">
<div class="large-12 columns">
<div class="panel oh">
<div class="row">
<div class="large-8 medium-6 small-3 columns">
<div class="avatar-wallet left">{{$root.wallet.getName() | limitTo: 1}}</div>
<h2 class="ellipsis m10t left hide-for-small-only">{{$root.wallet.getName()}}</h2>
</div>
<div class="large-4 medium-6 small-9 columns">
<div class="text-right">
<span class="size-21">
<strong>
<span ng-if="!$root.updatingBalance">{{$root.wallet.balanceInfo.totalBalance || 0}}</span>
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
{{$root.wallet.settings.unitName}}
</strong>
</span>
<span class="size-14 db m5t text-gray">
<span ng-if="$root.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
{{$root.wallet.settings.unitName}}
</strong>
</span>
<span class="size-14 db m5t text-gray">
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && $root.wallet.balanceInfo.alternativeBalanceAvailable">{{$root.wallet.balanceInfo.totalBalanceAlternative}} {{$root.wallet.balanceInfo.alternativeIsoCode}}</span>
<span ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<!-- Address-->
<div class="large-6 columns">
<div class="panel oh">
<h2 class="line-b" translate>Quick receive</h2>
<div class="text-center">
<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 ng-if="!$root.wallet.balanceInfo.updatingBalance && !$root.wallet.balanceInfo.alternativeBalanceAvailable">N/A</span>
<span ng-if="$root.wallet.balanceInfo.updatingBalance"><i class="fi-bitcoin-circle icon-rotate spinner"></i></span>
</span>
</div>
</div>
</div>
<div class="row ">
<div class="large-12 columns line-t m10t">
<div class="right size-10">
<span ng-if="!$root.wallet.isShared()">Personal Wallet</span>
<span ng-if="$root.wallet.isShared()">
Multisignature wallet [{{$root.wallet.requiredCopayers}} of {{$root.wallet.totalCopayers}} ]
</span>
<span ng-if="$root.wallet.isTestnet()"> in TESTNET</span>
</div>
</div>
</div>
</div>
</div>
<div class="row" ng-if="$root.wallet.isShared()">
<!-- List of copayers -->
<div class="large-6 columns">
<div class="large-12 columns">
<div class="panel oh">
<h2 class="line-b" translate>Copayers</h2>
<div ng-include="'views/includes/copayer.html'"></div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -41,12 +41,12 @@
<div class="large-6 medium-12 small-12 columns" ng-show="!tx.sentTs">
<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>
<span translate>I signed</span>
<span translate>Signed by me</span>
</button>
</div>
<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>
<span translate>I rejected</span>
<span translate>Rejected by me</span>
</button>
</div>
<div ng-show="!tx.signedBy[myId] && !tx.rejectedBy[myId]">
@ -79,7 +79,7 @@
<strong translate>Fee</strong>: {{tx.fee}} {{$root.wallet.settings.unitName}}
</div>
<div class="m5t">
<strong translate>Proposal ID</strong>: {{tx.ntxid}}
<strong translate>Proposal ID</strong>: <span:e >{{tx.ntxid}}
</div>
</div>
</div>

View File

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

View File

@ -1,67 +1,92 @@
<div class="addresses" ng-controller="ReceiveController" ng-init="setAddressList()">
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<h1 class="hide-for-large-up">{{$root.title}}</h1>
<div ng-show="!addresses[0]">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</div>
</div>
<div class="addresses" ng-controller="ReceiveController" ng-init="init()">
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<h1 class="hide-for-large-up">{{$root.title}}</h1>
</div>
<div class="row">
<div class="large-12 columns" ng-if="addresses.length">
<div ng-repeat="addr in addresses">
<div class="panel">
<div class="row show-for-large-up">
<div class="large-7 medium-9 columns">
<div class="list-addr">
<contact address="{{::addr.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right">
<small translate class="label" ng-if="::addr.isChange">change</small>
</div>
</div>
<div class="large-3 medium-3 columns text-right">
<span ng-show="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span class="size-14" ng-show="!$root.updatingBalance">
<b>{{addr.balance || '0'}} {{$root.wallet.settings.unitName}}</b>
</span>
</div>
<div class="large-2 columns show-for-large-up text-right">
<a class="size-12" ng-click="openAddressModal(addr)"> Show QR</a>
</div>
</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 class="row hide-for-large-up" ng-click="openAddressModal(addr)">
<div class="small-12 columns">
<div class="list-addr">
<div class="ellipsis">
<span><contact address="{{::addr.address}}"></span>
<small translate class="label" ng-if="::addr.isChange">change</small>
</div>
<div class="text-right m10t">
<span class="size-14" ng-show="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span class="size-14" ng-show="!$root.updatingBalance">
<b>{{addr.balance || '0'}} {{$root.wallet.settings.unitName}}</b>
</span>
</div>
</div>
</div>
</div> <!-- end of panel mobile -->
</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 class="large-12 columns">
<div class="m20b text-right">
<a class="size-12" ng-click="toggleShowAll()" ng-show="addrLength > 3">
<span translate ng-if="!showAll">Show all</span>
<span translate ng-if="showAll">Show less</span>
</a>
</div>
</div>
<div class="row">
<div class="large-12 columns" ng-if="addresses.length">
<div ng-repeat="addr in addresses">
<div class="panel">
<div class="row show-for-large-up">
<div class="large-7 medium-9 columns">
<div class="list-addr">
<contact address="{{::addr.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right">
<small translate class="label" ng-if="::addr.isChange">change</small>
</div>
</div>
<div class="large-3 medium-3 columns text-right">
<span ng-show="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span class="size-14" ng-show="!$root.updatingBalance">
<b>{{addr.balance || '0'}} {{$root.wallet.settings.unitName}}</b>
</span>
</div>
<div class="large-2 columns show-for-large-up text-right">
<a class="size-12" ng-click="openAddressModal(addr)"> Show QR</a>
</div>
</div>
<div class="row hide-for-large-up" ng-click="openAddressModal(addr)">
<div class="small-12 columns">
<div class="list-addr">
<div class="ellipsis">
<span><contact address="{{::addr.address}}"></span>
<small translate class="label" ng-if="::addr.isChange">change</small>
</div>
<div class="text-right m10t">
<span class="size-14" ng-show="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span class="size-14" ng-show="!$root.updatingBalance">
<b>{{addr.balance || '0'}} {{$root.wallet.settings.unitName}}</b>
</span>
</div>
</div>
</div>
</div>
<!-- end of panel mobile -->
</div>
<a class="button tiny primary text-center" ng-click="newAddr()" ng-disabled="loading">
<i class="fi-plus m5r"></i> Add
</div>
<a class="button primary text-center right" ng-click="newAddr()" ng-disabled="loading">
Generate new address
</a>
<a class="button primary text-center" ng-click="toggleShowAll()" ng-disabled="loading">
<span translate ng-if="showAll">Hide them</span>
</a>
</div>
<div class="large-12 columns" ng-if="!showAll">
<div class="m20b">
<a class="button primary text-center" ng-click="toggleShowAll()" ng-disabled="loading">
<span translate>Show all my addresses</span>
</a>
</div>
</div>
</div>
</div>

View File

@ -1,4 +1,11 @@
<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="large-12 columns">
<h2 translate>Pending Transactions Proposals</h2>
@ -8,13 +15,6 @@
</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="large-12 columns">
<h2 ng-show="txps.length != 0" translate>Create Transaction Proposal</h2>