mirror of https://github.com/BTCPrivate/copay.git
ref addresses view
This commit is contained in:
parent
c3dd222c68
commit
8f241b2efc
|
@ -1,32 +1,43 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('addressesController', function($scope, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, ongoingProcess, lodash, profileService, walletService, bwcError, platformInfo) {
|
angular.module('copayApp.controllers').controller('addressesController', function($scope, $log, $stateParams, $state, $timeout, $ionicHistory, $ionicScrollDelegate, configService, popupService, gettextCatalog, lodash, profileService, walletService, bwcError, platformInfo) {
|
||||||
var UNUSED_ADDRESS_LIMIT = 5;
|
var UNUSED_ADDRESS_LIMIT = 5;
|
||||||
var BALANCE_ADDRESS_LIMIT = 5;
|
var BALANCE_ADDRESS_LIMIT = 5;
|
||||||
var config;
|
var config = configService.getSync().wallet.settings;
|
||||||
var unitName;
|
var unitName = config.unitName;
|
||||||
var unitToSatoshi;
|
var unitToSatoshi = config.unitToSatoshi;
|
||||||
var satToUnit;
|
var satToUnit = 1 / unitToSatoshi;
|
||||||
var unitDecimals;
|
var unitDecimals = config.unitDecimals;
|
||||||
var withBalance;
|
var withBalance, cachedWallet;
|
||||||
$scope.showInfo = false;
|
|
||||||
$scope.showMore = false;
|
|
||||||
$scope.allAddressesView = false;
|
|
||||||
$scope.isCordova = platformInfo.isCordova;
|
$scope.isCordova = platformInfo.isCordova;
|
||||||
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
$scope.wallet = profileService.getWallet($stateParams.walletId);
|
||||||
|
|
||||||
function init() {
|
function resetValues() {
|
||||||
ongoingProcess.set('gettingAddresses', true);
|
$scope.loading = false;
|
||||||
|
$scope.showInfo = false;
|
||||||
|
$scope.showMore = false;
|
||||||
|
$scope.allAddressesView = false;
|
||||||
|
$scope.latestUnused = $scope.latestWithBalance = null;
|
||||||
|
$scope.viewAll = {
|
||||||
|
value: false
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.init = function() {
|
||||||
|
resetValues();
|
||||||
|
$scope.loading = true;
|
||||||
|
|
||||||
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
walletService.getMainAddresses($scope.wallet, {}, function(err, addresses) {
|
||||||
if (err) {
|
if (err) {
|
||||||
ongoingProcess.set('gettingAddresses', false);
|
$scope.loading = false;
|
||||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||||
}
|
}
|
||||||
|
|
||||||
var allAddresses = addresses;
|
var allAddresses = addresses;
|
||||||
|
|
||||||
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
walletService.getBalance($scope.wallet, {}, function(err, resp) {
|
||||||
ongoingProcess.set('gettingAddresses', false);
|
$scope.loading = false;
|
||||||
if (err) {
|
if (err) {
|
||||||
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
return popupService.showAlert(bwcError.msg(err, gettextCatalog.getString('Could not update wallet')));
|
||||||
}
|
}
|
||||||
|
@ -51,6 +62,10 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
||||||
value: $scope.noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT
|
value: $scope.noBalance.length > UNUSED_ADDRESS_LIMIT || withBalance.length > BALANCE_ADDRESS_LIMIT
|
||||||
};
|
};
|
||||||
$scope.allAddresses = $scope.noBalance.concat(withBalance);
|
$scope.allAddresses = $scope.noBalance.concat(withBalance);
|
||||||
|
|
||||||
|
cachedWallet = $scope.wallet.id;
|
||||||
|
$log.debug('Addresses cached for Wallet:', cachedWallet);
|
||||||
|
$ionicScrollDelegate.resize();
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -163,20 +178,14 @@ angular.module('copayApp.controllers').controller('addressesController', functio
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isCachedWallet(walletId) {
|
||||||
|
if (cachedWallet && cachedWallet == walletId) return true;
|
||||||
|
else return false;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
$scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false;
|
$scope.allAddressesView = data.stateName == 'tabs.receive.allAddresses' ? true : false;
|
||||||
$timeout(function() {
|
if (!isCachedWallet($stateParams.walletId)) $scope.init();
|
||||||
$scope.$apply();
|
else $log.debug('Addresses cached for Wallet:', $stateParams.walletId);
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.$on("$ionicView.afterEnter", 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();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,6 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
|
||||||
'loadingTxInfo': gettext('Loading transaction info...'),
|
'loadingTxInfo': gettext('Loading transaction info...'),
|
||||||
'sendingFeedback': gettext('Sending feedback...'),
|
'sendingFeedback': gettext('Sending feedback...'),
|
||||||
'generatingNewAddress': gettext('Generating new address...'),
|
'generatingNewAddress': gettext('Generating new address...'),
|
||||||
'gettingAddresses': gettext('Getting addresses...'),
|
|
||||||
'sendingByEmail': gettext('Preparing addresses...'),
|
'sendingByEmail': gettext('Preparing addresses...'),
|
||||||
'sending2faCode': gettext('Sending 2FA code...'),
|
'sending2faCode': gettext('Sending 2FA code...'),
|
||||||
'buyingBitcoin': gettext('Buying Bitcoin...'),
|
'buyingBitcoin': gettext('Buying Bitcoin...'),
|
||||||
|
|
|
@ -136,7 +136,7 @@ input[type=number] {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.updatingHistory {
|
.updating {
|
||||||
div {
|
div {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content class="padding">
|
<ion-content class="padding">
|
||||||
|
|
||||||
<div ng-if="fetchingNotifications" class="updatingHistory">
|
<div ng-if="fetchingNotifications" class="updating">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
||||||
<div translate>Updating... Please stand by</div>
|
<div translate>Updating... Please stand by</div>
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
<ion-nav-title>{{'Wallet Addresses' | translate}}</ion-nav-title>
|
<ion-nav-title>{{'Wallet Addresses' | translate}}</ion-nav-title>
|
||||||
<ion-nav-back-button>
|
<ion-nav-back-button>
|
||||||
</ion-nav-back-button>
|
</ion-nav-back-button>
|
||||||
|
<ion-nav-buttons side="secondary">
|
||||||
|
<button class="button back-button" ng-click="init()">
|
||||||
|
<i class="icon ion-ios-refresh-empty"></i>
|
||||||
|
</button>
|
||||||
|
</ion-nav-buttons>
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
@ -26,23 +31,35 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="list">
|
<div class="list">
|
||||||
|
<div class="item view-all" ng-click="scan()">
|
||||||
|
<span translate>Scan addresses for funds</span>
|
||||||
|
</div>
|
||||||
<div class="item item-icon-right view-all" ng-click="requestSpecificAmount()">
|
<div class="item item-icon-right view-all" ng-click="requestSpecificAmount()">
|
||||||
<span translate>Request Specific amount</span>
|
<span translate>Request Specific amount</span>
|
||||||
<i class="icon ion-ios-arrow-thin-right"></i>
|
<i class="icon ion-ios-arrow-thin-right"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="item item-icon-right view-all" ng-show="viewAll.value" ng-click="viewAllAddresses()">
|
<div class="item item-icon-right view-all" ng-if="viewAll.value" ng-click="viewAllAddresses()">
|
||||||
<span translate>View All Addresses</span>
|
<span translate>View All Addresses</span>
|
||||||
<i class="icon ion-ios-arrow-thin-right"></i>
|
<i class="icon ion-ios-arrow-thin-right"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="item view-all" ng-show="latestWithBalance[0]" ng-click="scan()">
|
|
||||||
<span translate>Scan addresses for funds</span>
|
<div ng-if="loading" class="updating">
|
||||||
|
<div class="item item-divider row">
|
||||||
|
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<span translate>Loading addresses...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div ng-if="latestUnused[0]">
|
||||||
<div class="item item-divider item-icon-right" ng-click="newAddress()">
|
<div class="item item-divider item-icon-right" ng-click="newAddress()">
|
||||||
<span translate>Unused Addresses</span>
|
<span translate>Unused Addresses</span>
|
||||||
<i class="icon ion-ios-plus-empty"></i>
|
<i class="icon ion-ios-plus-empty"></i>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="latestUnused[0]">
|
|
||||||
<div class="box-error" ng-if="gapReached">
|
<div class="box-error" ng-if="gapReached">
|
||||||
<h5 translate>Unused Addresses Limit</h5>
|
<h5 translate>Unused Addresses Limit</h5>
|
||||||
<p><span translate>The maximum number of consecutive unused addresses (20) has been reached. When one of your unused addresses receives a payment, a new address will be generated and shown in your Receive tab.</span> <a ng-click="readMore()" ng-if="!showMore" translate>Read more</a></p>
|
<p><span translate>The maximum number of consecutive unused addresses (20) has been reached. When one of your unused addresses receives a payment, a new address will be generated and shown in your Receive tab.</span> <a ng-click="readMore()" ng-if="!showMore" translate>Read more</a></p>
|
||||||
|
|
|
@ -9,6 +9,17 @@
|
||||||
<div class="addr-list list">
|
<div class="addr-list list">
|
||||||
<div class="item item-divider"></div>
|
<div class="item item-divider"></div>
|
||||||
|
|
||||||
|
<div ng-if="loading" class="updating">
|
||||||
|
<div class="row">
|
||||||
|
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<span translate>Loading addresses...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ng-show="isCordova && allAddresses[0]">
|
<div ng-show="isCordova && allAddresses[0]">
|
||||||
<div class="item view-all" ng-click="sendByEmail()">
|
<div class="item view-all" ng-click="sendByEmail()">
|
||||||
<span translate>Send addresses by email</span>
|
<span translate>Send addresses by email</span>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
</ion-nav-bar>
|
</ion-nav-bar>
|
||||||
<ion-content class="padding">
|
<ion-content class="padding">
|
||||||
|
|
||||||
<div ng-if="fetchingProposals" class="updatingHistory">
|
<div ng-if="fetchingProposals" class="updating">
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
||||||
<div translate>Updating pending proposals. Please stand by</div>
|
<div translate>Updating pending proposals. Please stand by</div>
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-show="updatingTxHistory && updatingTxHistoryProgress>5" class="updatingHistory">
|
<div ng-show="updatingTxHistory && updatingTxHistoryProgress>5" class="updating">
|
||||||
<div class="row" >
|
<div class="row" >
|
||||||
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
<ion-spinner class="spinner-dark" icon="crescent"></ion-spinner>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue