Merge pull request #3776 from cmgustavo/feat/activity-historic-rate

Adds historic rate to transaction history (if available)
This commit is contained in:
Matias Alejo Garcia 2016-01-21 17:01:12 -03:00
commit 86f5651c0d
3 changed files with 40 additions and 5 deletions

View File

@ -15,7 +15,7 @@
<div class="modal-content fix-modals-touch"
ng-swipe-disable-mouse
ng-swipe-right="cancel()">
<div class="header-modal size-36 text-center">
<div class="header-modal text-center" ng-init="getAlternativeAmount()">
<div ng-show="btx.action != 'invalid'">
<div ng-show="btx.action == 'received'">
<img src="img/icon-receive-history.svg" alt="sync" width="50">
@ -30,11 +30,21 @@
<p class="m0 text-gray size-14" translate>Moved</p>
</div>
<span ng-if="btx.action == 'received'">+</span><span ng-if="btx.action == 'sent'">-</span>{{btx.amountStr}}
<div class="size-36">
<span ng-if="btx.action == 'received'">+</span><span ng-if="btx.action == 'sent'">-</span>{{btx.amountStr}}
</div>
<div class="alternative-amount" ng-click="showRate=!showRate" ng-init="showRate = false">
<span class="label gray radius" ng-show="!showRate && alternativeAmountStr">
{{alternativeAmountStr}}
</span>
<span class="size-12" ng-show="showRate && alternativeAmountStr">
{{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}})
</span>
</div>
</div>
<div ng-show="btx.action == 'invalid'">
-
</div>
</div>
</div>
<h4 class="title m0" translate>Details</h4>

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);