load all addresses

This commit is contained in:
Javier 2016-11-16 16:11:36 -03:00
parent e3746bfaec
commit 3e156e7129
3 changed files with 47 additions and 48 deletions

View File

@ -8,17 +8,10 @@ angular.module('copayApp.controllers').controller('addressesController', functio
var unitToSatoshi;
var satToUnit;
var unitDecimals;
$scope.wallet = profileService.getWallet($stateParams.walletId);
var withBalance;
var noBalance;
$scope.showInfo = false;
$scope.$on("$ionicView.beforeEnter", function(event, data) {
config = configService.getSync().wallet.settings;
unitToSatoshi = config.unitToSatoshi;
satToUnit = 1 / unitToSatoshi;
unitName = config.unitName;
unitDecimals = config.unitDecimals;
init();
});
$scope.wallet = profileService.getWallet($stateParams.walletId);
function init() {
ongoingProcess.set('extractingWalletInfo', true);
@ -28,7 +21,7 @@ angular.module('copayApp.controllers').controller('addressesController', functio
return popupService.showAlert(gettextCatalog.getString('Error'), err);
}
$scope.allAddresses = addresses;
var allAddresses = addresses;
walletService.getBalance($scope.wallet, {}, function(err, resp) {
ongoingProcess.set('extractingWalletInfo', false);
@ -36,33 +29,51 @@ angular.module('copayApp.controllers').controller('addressesController', functio
return popupService.showAlert(gettextCatalog.getString('Error'), err);
}
var withBalance = resp.byAddress;
withBalance = resp.byAddress;
var idx = lodash.indexBy(withBalance, 'address');
var noBalance = lodash.reject($scope.allAddresses, function(x) {
noBalance = lodash.reject(allAddresses, function(x) {
return idx[x.address];
});
lodash.each(noBalance, function(n) {
n.path = n.path.replace(/^m/g, 'xpub');
});
$scope.unused = lodash.slice(noBalance, 0, UNUSED_ADDRESS_LIMIT);
$scope.withBalance = lodash.slice(withBalance, 0, BALANCE_ADDRESS_LIMIT);
lodash.each($scope.withBalance, function(a) {
processPaths(noBalance);
processPaths(withBalance);
$scope.latestUnused = lodash.slice(noBalance, 0, UNUSED_ADDRESS_LIMIT);
$scope.latestWithBalance = lodash.slice(withBalance, 0, BALANCE_ADDRESS_LIMIT);
lodash.each(withBalance, function(a) {
a.balanceStr = (a.amount * satToUnit).toFixed(unitDecimals) + ' ' + unitName;
});
$scope.viewAll = {
value: noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT
};
$scope.allAddresses = noBalance.concat(withBalance);
$scope.$digest();
});
});
};
function processPaths(list) {
lodash.each(list, function(n) {
n.path = n.path.replace(/^m/g, 'xpub');
});
};
$scope.showInformation = function() {
$timeout(function() {
$scope.showInfo = !$scope.showInfo;
$ionicScrollDelegate.resize();
});
};
$scope.$on("$ionicView.beforeEnter", function(event, data) {
config = configService.getSync().wallet.settings;
unitToSatoshi = config.unitToSatoshi;
satToUnit = 1 / unitToSatoshi;
unitName = config.unitName;
unitDecimals = config.unitDecimals;
if (!$scope.allAddresses || $scope.allAddresses.length < 0) init();
});
});

View File

@ -29,8 +29,8 @@
<i class="icon ion-ios-plus-empty"></i>
</div>
<div ng-if="unused[0]">
<div class="item" ng-repeat="u in unused track by $index">
<div ng-if="latestUnused[0]">
<div class="item" ng-repeat="u in latestUnused track by $index">
{{u.address}}
<div class="addr-path">
{{u.path}} {{u.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
@ -38,7 +38,7 @@
</div>
</div>
<div ng-if="!unused[0]">
<div ng-if="!latestUnused[0]">
<span class="item" translate>Not unused addresses available</span>
</div>
@ -46,13 +46,13 @@
Addresses With Balance
</div>
<div class="item" ng-repeat="w in withBalance track by $index">
<div class="item" ng-repeat="w in latestWithBalance track by $index">
{{w.address}}
<div class="addr-balance">{{w.balanceStr}}</div>
</div>
<div class="item item-icon-right view-all" ng-show="viewAll.value">
<a ui-sref="#" translate>View All Addresses</a>
<a ui-sref="tabs.receive.allAddresses({walletId: wallet.id})" translate>View All Addresses</a>
<i class="icon ion-ios-arrow-thin-right"></i>
</div>
</div>

View File

@ -1,4 +1,4 @@
<ion-view class="settings" hide-tabs>
<ion-view hide-tabs id="addresses" class="addr">
<ion-nav-bar class="bar-royal">
<ion-nav-title>{{'All Addresses' | translate}}</ion-nav-title>
<ion-nav-back-button>
@ -6,30 +6,18 @@
</ion-nav-bar>
<ion-content>
<div class="list">
<div class="item item-divider" translate>
Translation Credits
<div class="addr-list list">
<div class="item item-divider"></div>
<div class="item" ng-repeat="a in allAddresses track by $index">
{{a.address}}
<div class="addr-path" ng-if="!a.balanceStr">
{{a.path}} {{a.createdOn * 1000 | amDateFormat:'MMMM Do YYYY, hh:mm a'}}
</div>
<div class="addr-balance" ng-if="a.balanceStr">{{a.balanceStr}}</div>
</div>
<div class="item">kinoshitajona<span class="item-note" translate>Japanese</span></div>
<div class="item">Kirvx<span class="item-note" translate>French</span></div>
<div class="item">saschad<span class="item-note" translate>German</span></div>
<div class="item">cmgustavo83<span class="item-note" translate>Spanish</span></div>
<div class="item">RussianNeuroMancer<span class="item-note" translate>Russian</span></div>
<div class="item">HostFat<span class="item-note" translate>Italian</span></div>
<div class="item">xm2hi<span class="item-note" translate>Chinese</span></div>
<div class="item">Pirx1618<span class="item-note" translate>Polish</span></div>
<div class="item">mareksip<span class="item-note" translate>Czech</span></div>
</div>
<div class="padding">
<p>
<span translate>Were always looking for translation contributions! You can make corrections or help to make this app available in your native language by joining our community on Crowdin.</span>
<button class="button button-standard button-primary" ng-click="openExternalLink(true, 'Open Translation Community', 'You can make contributions by signing up on our Crowdin community translation website. Were looking forward to hearing from you!
', 'Open Crowdin', 'Go Back')" translate>Contribute Translations
</button>
</p>
<span translate>
Don't see your language on Crowdin? Contact the Owner on Crowdin! We'd love to support your language.
</span>
<div class="item item-divider"></div>
</div>
</ion-content>
</ion-view>