show status balance
This commit is contained in:
parent
5656caaa5a
commit
e3076d18ab
4 changed files with 90 additions and 88 deletions
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
<div class="oh pr" ng-show="wallet && wallet.isComplete()">
|
||||||
<div ng-style="{'background-color':wallet.color}" class="amount">
|
<div ng-style="{'background-color':wallet.color}" class="amount">
|
||||||
<div ng-if="!wallet.notAuthorized && !wallet.updating">
|
<div ng-if="!wallet.notAuthorized && !updating">
|
||||||
|
|
||||||
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
|
<div class="m20t" ng-show="wallet.updateError" ng-click='update()'>
|
||||||
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
|
<span class="size-12 db m10b">{{wallet.updateError|translate}}</span>
|
||||||
|
|
@ -46,11 +46,11 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div ng-click='wallet.updateAll({triggerTxUpdate: true})' ng-show="!wallet.updateError && wallet.walletScanStatus != 'error' && !wallet.hideBalance" on-hold="hideToggle()">
|
<div ng-click='updateAll({triggerTxUpdate: true})' ng-show="!updateError && wallet.walletScanStatus != 'error' && !hideBalance" on-hold="hideToggle()">
|
||||||
<strong class="size-36">{{wallet.totalBalanceStr}}</strong>
|
<strong class="size-36">{{status.totalBalanceStr}}</strong>
|
||||||
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{wallet.totalBalanceAlternative}} {{wallet.alternativeIsoCode}}</div>
|
<div class="size-14" ng-if="wallet.totalBalanceAlternative">{{status.totalBalanceAlternative}} {{status.alternativeIsoCode}}</div>
|
||||||
<div class="size-14" ng-if="wallet.pendingAmount">
|
<div class="size-14" ng-if="wallet.pendingAmount">
|
||||||
<span translate>Pending Confirmation</span>: {{wallet.pendingAmountStr}}
|
<span translate>Pending Confirmation</span>: {{status.pendingAmountStr}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ng-if="wallet.updating">
|
<div ng-if="updating">
|
||||||
<div class="size-36">
|
<div class="size-36">
|
||||||
<strong>...</strong>
|
<strong>...</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -82,7 +82,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !wallet.updating">
|
<div class="oh pr m20t" ng-show="wallet.notAuthorized && !updating">
|
||||||
<div class="text-center text-warning">
|
<div class="text-center text-warning">
|
||||||
<i class="fi-alert"></i>
|
<i class="fi-alert"></i>
|
||||||
<span translate>
|
<span translate>
|
||||||
|
|
@ -128,11 +128,11 @@
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<div class="oh pr m20t text-gray size-12 text-center"
|
<div class="oh pr m20t text-gray size-12 text-center"
|
||||||
ng-show="!wallet.loadingWallet && !wallet.txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
|
ng-show="!wallet.loadingWallet && !txHistory[0] && !wallet.updatingTxHistory && !wallet.txHistoryError && !wallet.updateError && !wallet.notAuthorized"
|
||||||
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
|
translate>No transactions yet ZZZZ {{wallet.totalBalanceStr}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="oh pr" ng-show="(wallet.txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
|
<div class="oh pr" ng-show="(txHistory[0] || wallet.txProgress > 5) && !wallet.notAuthorized">
|
||||||
|
|
||||||
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
|
<div ng-show="wallet.updatingTxHistory && wallet.txProgress > 5">
|
||||||
<div class="row p20 text-center">
|
<div class="row p20 text-center">
|
||||||
|
|
@ -146,7 +146,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-if="wallet.txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
<div ng-if="txHistory[0] && wallet.updatingTxHistory && wallet.newTx" class="row collapse last-transactions-content animated fadeInDown">
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
<div class="large-6 medium-6 small-6 columns size-14">
|
||||||
<div class="m10r left">
|
<div class="m10r left">
|
||||||
<img src="img/icon-new.svg" width="40">
|
<img src="img/icon-new.svg" width="40">
|
||||||
|
|
@ -160,7 +160,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ng-repeat="btx in wallet.txHistory track by btx.txid"
|
<div ng-repeat="btx in txHistory track by btx.txid"
|
||||||
ng-click="openTxModal(btx)"
|
ng-click="openTxModal(btx)"
|
||||||
class="row collapse last-transactions-content">
|
class="row collapse last-transactions-content">
|
||||||
<div class="large-6 medium-6 small-6 columns size-14">
|
<div class="large-6 medium-6 small-6 columns size-14">
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,10 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
lodash.each(wallets, function(wallet) {
|
lodash.each(wallets, function(wallet) {
|
||||||
walletService.updateStatus(wallet, {}, function(err) {
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
var status = wallet.status;
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log('[tab-home.js.35:err:]',$log.error(err)); //TODO
|
console.log('[tab-home.js.35:err:]', $log.error(err)); //TODO
|
||||||
return;
|
return;
|
||||||
} // TODO
|
} // TODO
|
||||||
if (status.pendingTxps && status.pendingTxps[0]) {
|
if (status.pendingTxps && status.pendingTxps[0]) {
|
||||||
txps = txps.concat(status.pendingTxps);
|
txps = txps.concat(status.pendingTxps);
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,21 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.updateAll = function() {
|
||||||
|
$scope.update();
|
||||||
|
}
|
||||||
|
|
||||||
$scope.update = function() {
|
$scope.update = function() {
|
||||||
walletService.updateStatus(wallet, {
|
$scope.updating = true;
|
||||||
force: true
|
$timeout(function() {
|
||||||
}, function(err, status) {
|
walletService.getStatus(wallet, {
|
||||||
if (err) {} // TODO
|
force: true
|
||||||
});
|
}, function(err, status) {
|
||||||
|
if (err) {} // TODO
|
||||||
|
$scope.status = status;
|
||||||
|
$scope.updating = false;
|
||||||
|
});
|
||||||
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.hideToggle = function() {
|
$scope.hideToggle = function() {
|
||||||
|
|
@ -85,9 +94,15 @@ angular.module('copayApp.controllers').controller('walletDetailsController', fun
|
||||||
$scope.wallet = wallet;
|
$scope.wallet = wallet;
|
||||||
|
|
||||||
if (wallet) {
|
if (wallet) {
|
||||||
walletService.updateStatus(wallet, {}, function(err, status) {
|
walletService.getStatus(wallet, {}, function(err, status) {
|
||||||
console.log(status);
|
console.log('*** [walletDetails.js ln89] status:', status); // TODO
|
||||||
if (err) {} // TODO
|
if (err) {} // TODO
|
||||||
|
$scope.status = status;
|
||||||
|
});
|
||||||
|
walletService.getHistory(wallet, {}, function(err, txHistory) {
|
||||||
|
console.log('*** [walletDetails.js ln93] txHistory:', txHistory); // TODO
|
||||||
|
if (err) {} // TODO
|
||||||
|
$scope.txHistory = txHistory;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -128,64 +128,71 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
|
|
||||||
var config = configService.getSync().wallet.settings;
|
var config = configService.getSync().wallet.settings;
|
||||||
|
|
||||||
|
var cache = wallet.cachedStatus;
|
||||||
|
|
||||||
// Address with Balance
|
// Address with Balance
|
||||||
wallet.balanceByAddress = balance.byAddress;
|
cache.balanceByAddress = balance.byAddress;
|
||||||
|
|
||||||
// Spend unconfirmed funds
|
// Spend unconfirmed funds
|
||||||
if (wallet.spendUnconfirmed) {
|
if (cache.spendUnconfirmed) {
|
||||||
wallet.totalBalanceSat = balance.totalAmount;
|
cache.totalBalanceSat = balance.totalAmount;
|
||||||
wallet.lockedBalanceSat = balance.lockedAmount;
|
cache.lockedBalanceSat = balance.lockedAmount;
|
||||||
wallet.availableBalanceSat = balance.availableAmount;
|
cache.availableBalanceSat = balance.availableAmount;
|
||||||
wallet.totalBytesToSendMax = balance.totalBytesToSendMax;
|
cache.totalBytesToSendMax = balance.totalBytesToSendMax;
|
||||||
wallet.pendingAmount = null;
|
cache.pendingAmount = null;
|
||||||
} else {
|
} else {
|
||||||
wallet.totalBalanceSat = balance.totalConfirmedAmount;
|
cache.totalBalanceSat = balance.totalConfirmedAmount;
|
||||||
wallet.lockedBalanceSat = balance.lockedConfirmedAmount;
|
cache.lockedBalanceSat = balance.lockedConfirmedAmount;
|
||||||
wallet.availableBalanceSat = balance.availableConfirmedAmount;
|
cache.availableBalanceSat = balance.availableConfirmedAmount;
|
||||||
wallet.totalBytesToSendMax = balance.totalBytesToSendConfirmedMax;
|
cache.totalBytesToSendMax = balance.totalBytesToSendConfirmedMax;
|
||||||
wallet.pendingAmount = balance.totalAmount - balance.totalConfirmedAmount;
|
cache.pendingAmount = balance.totalAmount - balance.totalConfirmedAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selected unit
|
// Selected unit
|
||||||
wallet.unitToSatoshi = config.unitToSatoshi;
|
cache.unitToSatoshi = config.unitToSatoshi;
|
||||||
wallet.satToUnit = 1 / wallet.unitToSatoshi;
|
cache.satToUnit = 1 / cache.unitToSatoshi;
|
||||||
wallet.unitName = config.unitName;
|
cache.unitName = config.unitName;
|
||||||
|
|
||||||
//STR
|
//STR
|
||||||
wallet.totalBalanceStr = root.formatAmount(wallet.totalBalanceSat) + ' ' + wallet.unitName;
|
cache.totalBalanceStr = root.formatAmount(cache.totalBalanceSat) + ' ' + cache.unitName;
|
||||||
wallet.lockedBalanceStr = root.formatAmount(wallet.lockedBalanceSat) + ' ' + wallet.unitName;
|
cache.lockedBalanceStr = root.formatAmount(cache.lockedBalanceSat) + ' ' + cache.unitName;
|
||||||
wallet.availableBalanceStr = root.formatAmount(wallet.availableBalanceSat) + ' ' + wallet.unitName;
|
cache.availableBalanceStr = root.formatAmount(cache.availableBalanceSat) + ' ' + cache.unitName;
|
||||||
|
|
||||||
if (wallet.pendingAmount) {
|
if (cache.pendingAmount) {
|
||||||
wallet.pendingAmountStr = root.formatAmount(wallet.pendingAmount) + ' ' + wallet.unitName;
|
cache.pendingAmountStr = root.formatAmount(cache.pendingAmount) + ' ' + cache.unitName;
|
||||||
} else {
|
} else {
|
||||||
wallet.pendingAmountStr = null;
|
cache.pendingAmountStr = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet.alternativeName = config.alternativeName;
|
cache.alternativeName = config.alternativeName;
|
||||||
wallet.alternativeIsoCode = config.alternativeIsoCode;
|
cache.alternativeIsoCode = config.alternativeIsoCode;
|
||||||
|
|
||||||
rateService.whenAvailable(function() {
|
rateService.whenAvailable(function() {
|
||||||
|
|
||||||
var totalBalanceAlternative = rateService.toFiat(wallet.totalBalanceSat, wallet.alternativeIsoCode);
|
var totalBalanceAlternative = rateService.toFiat(cache.totalBalanceSat, cache.alternativeIsoCode);
|
||||||
var lockedBalanceAlternative = rateService.toFiat(wallet.lockedBalanceSat, wallet.alternativeIsoCode);
|
var lockedBalanceAlternative = rateService.toFiat(cache.lockedBalanceSat, cache.alternativeIsoCode);
|
||||||
var alternativeConversionRate = rateService.toFiat(100000000, wallet.alternativeIsoCode);
|
var alternativeConversionRate = rateService.toFiat(100000000, cache.alternativeIsoCode);
|
||||||
|
|
||||||
wallet.totalBalanceAlternative = $filter('formatFiatAmount')(totalBalanceAlternative);
|
cache.totalBalanceAlternative = $filter('formatFiatAmount')(totalBalanceAlternative);
|
||||||
wallet.lockedBalanceAlternative = $filter('formatFiatAmount')(lockedBalanceAlternative);
|
cache.lockedBalanceAlternative = $filter('formatFiatAmount')(lockedBalanceAlternative);
|
||||||
wallet.alternativeConversionRate = $filter('formatFiatAmount')(alternativeConversionRate);
|
cache.alternativeConversionRate = $filter('formatFiatAmount')(alternativeConversionRate);
|
||||||
|
|
||||||
wallet.alternativeBalanceAvailable = true;
|
cache.alternativeBalanceAvailable = true;
|
||||||
wallet.isRateAvailable = true;
|
cache.isRateAvailable = true;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function cacheStatus = (status) {
|
function isStatusCached() {
|
||||||
wallet.status = status;
|
return wallet.cachedStatus && wallet.cachedStatus.isValid;
|
||||||
wallet.statusUpdatedOn = Date.now();
|
};
|
||||||
wallet.isValid = true;
|
|
||||||
|
function cacheStatus(status) {
|
||||||
|
wallet.cachedStatus = status || {};
|
||||||
|
var cache = wallet.cachedStatus;
|
||||||
|
cache.statusUpdatedOn = Date.now();
|
||||||
|
cache.isValid = true;
|
||||||
|
cache.email = status.preferences ? status.preferences.email : null;
|
||||||
cacheBalance(wallet, status.balance);
|
cacheBalance(wallet, status.balance);
|
||||||
wallet.email = status.preferences.email;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function walletStatusHash(status) {
|
function walletStatusHash(status) {
|
||||||
|
|
@ -193,7 +200,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
function _getStatus(initStatusHash, tries, cb) {
|
function _getStatus(initStatusHash, tries, cb) {
|
||||||
if (wallet.isValid && !opts.force) return cb(null, wallet.status);
|
if (isStatusCached() && !opts.force) return cb(null, wallet.cachedStatus);
|
||||||
|
|
||||||
tries = tries || 0;
|
tries = tries || 0;
|
||||||
|
|
||||||
|
|
@ -215,7 +222,7 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
|
|
||||||
$log.debug('Got Wallet Status for:' + wallet.credentials.walletName);
|
$log.debug('Got Wallet Status for:' + wallet.credentials.walletName);
|
||||||
|
|
||||||
root.cacheStatus(wallet, status);
|
cacheStatus(status);
|
||||||
|
|
||||||
// wallet.setPendingTxps(status.pendingTxps);
|
// wallet.setPendingTxps(status.pendingTxps);
|
||||||
return cb(null, status);
|
return cb(null, status);
|
||||||
|
|
@ -354,7 +361,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
// First update
|
// First update
|
||||||
if (walletId == wallet.credentials.walletId) {
|
if (walletId == wallet.credentials.walletId) {
|
||||||
wallet.completeHistory = txsFromLocal;
|
wallet.completeHistory = txsFromLocal;
|
||||||
setCompactTxHistory(wallet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wallet.historyUpdateInProgress)
|
if (wallet.historyUpdateInProgress)
|
||||||
|
|
@ -388,7 +394,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
var newHistory = processNewTxs(wallet, newTxs);
|
var newHistory = processNewTxs(wallet, newTxs);
|
||||||
newHistory = lodash.compact(newHistory.concat(confirmedTxs));
|
newHistory = lodash.compact(newHistory.concat(confirmedTxs));
|
||||||
wallet.completeHistory = newHistory;
|
wallet.completeHistory = newHistory;
|
||||||
setCompactTxHistory(wallet);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -438,7 +443,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
// Final update
|
// Final update
|
||||||
if (walletId == wallet.credentials.walletId) {
|
if (walletId == wallet.credentials.walletId) {
|
||||||
wallet.completeHistory = newHistory;
|
wallet.completeHistory = newHistory;
|
||||||
setCompactTxHistory(wallet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return storageService.setTxHistory(historyToSave, walletId, function() {
|
return storageService.setTxHistory(historyToSave, walletId, function() {
|
||||||
|
|
@ -452,28 +456,21 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
root.updateHistory = function(wallet, cb) {
|
root.getHistory = function(wallet, opts, cb) {
|
||||||
|
opts = opts || {};
|
||||||
|
opts.skip = opts.skip || 0;
|
||||||
|
opts.limit = opts.limit || root.HISTORY_SHOW_LIMIT;
|
||||||
|
|
||||||
var walletId = wallet.credentials.walletId;
|
var walletId = wallet.credentials.walletId;
|
||||||
|
|
||||||
if (!wallet.isComplete()) return cb();
|
if (!wallet.isComplete()) return cb();
|
||||||
|
|
||||||
$log.debug('Updating Transaction History');
|
$log.debug('Updating Transaction History');
|
||||||
wallet.txHistoryError = false;
|
|
||||||
wallet.updatingTxHistory = true;
|
|
||||||
|
|
||||||
$timeout(function() {
|
updateLocalTxHistory(wallet, function(err) {
|
||||||
updateLocalTxHistory(wallet, function(err) {
|
if (err) return cb(err);
|
||||||
wallet.historyUpdateInProgress = wallet.updatingTxHistory = false;
|
var txs = wallet.completeHistory ? wallet.completeHistory.slice(opts.skip, opts.limit) : null;
|
||||||
wallet.loadingWallet = false;
|
return cb(err, txs);
|
||||||
wallet.txProgress = 0;
|
|
||||||
if (err)
|
|
||||||
wallet.txHistoryError = true;
|
|
||||||
|
|
||||||
$timeout(function() {
|
|
||||||
wallet.newTx = false
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -662,15 +659,6 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var setCompactTxHistory = function(wallet) {
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
wallet.isSearching = false;
|
|
||||||
wallet.nextTxHistory = root.HISTORY_SHOW_LIMIT;
|
|
||||||
wallet.txHistory = wallet.completeHistory ? wallet.completeHistory.slice(0, root.HISTORY_SHOW_LIMIT) : null;
|
|
||||||
wallet.historyShowMore = wallet.completeHistory ? wallet.completeHistory.length > root.HISTORY_SHOW_LIMIT : null;
|
|
||||||
};
|
|
||||||
|
|
||||||
root.debounceUpdateHistory = lodash.debounce(function() {
|
root.debounceUpdateHistory = lodash.debounce(function() {
|
||||||
root.updateHistory();
|
root.updateHistory();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue