Adds historic rate to transaction history (if available)

This commit is contained in:
Gustavo Maximiliano Cortez 2016-01-18 17:08:24 -03:00
commit a5e9373975
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
3 changed files with 40 additions and 5 deletions

View file

@ -195,6 +195,11 @@ _:-ms-fullscreen, :root .main {
height: 175px;
}
.alternative-amount {
height: 25px;
text-align: center;
}
.scroll-section {
position: absolute;
top: 120px;

View file

@ -1214,12 +1214,32 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$rootScope.modalOpened = true;
var self = this;
var fc = profileService.focusedClient;
var ModalInstanceCtrl = function($scope, $modalInstance) {
var ModalInstanceCtrl = function($scope, $filter, $log, $modalInstance) {
$scope.btx = btx;
$scope.settings = walletSettings;
$scope.color = fc.backgroundColor;
$scope.copayerId = fc.credentials.copayerId;
$scope.isShared = fc.credentials.n > 1;
$scope.isShared = fc.credentials.n > 1;
$scope.getAlternativeAmount = function() {
var satToBtc = 1 / 100000000;
fc.getFiatRate({
code : self.alternativeIsoCode,
ts : btx.time * 1000
}, function(err, res) {
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
var alternativeAmountBtc = (btx.amount * satToBtc).toFixed(8);
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + self.alternativeIsoCode;
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + self.alternativeIsoCode;
$scope.$apply();
}
});
};
$scope.getAmount = function(amount) {
return self.getAmount(amount);