Adds historic fiat rate to tx-details

This commit is contained in:
Gustavo Maximiliano Cortez 2016-11-09 10:40:18 -03:00
commit 164c775a79
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
2 changed files with 29 additions and 2 deletions

View file

@ -1,6 +1,6 @@
'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $timeout, $ionicHistory, $scope, $stateParams, walletService, lodash, gettextCatalog, profileService, configService, externalLinkService, popupService) {
angular.module('copayApp.controllers').controller('txDetailsController', function($log, $ionicHistory, $scope, $stateParams, walletService, lodash, gettextCatalog, profileService, externalLinkService, popupService) {
$scope.$on("$ionicView.beforeEnter", function(event, data) {
$scope.title = gettextCatalog.getString('Transaction');
@ -130,6 +130,27 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
return n.substring(0, 4);
};
$scope.getFiatRate = function() {
if ($scope.rateDate) return;
var alternativeIsoCode = $scope.wallet.status.alternativeIsoCode;
$scope.loadingRate = true;
$scope.wallet.getFiatRate({
code: alternativeIsoCode,
ts: $scope.btx.time * 1000
}, function(err, res) {
$scope.loadingRate = false;
if (err) {
$log.debug('Could not get historic rate');
return;
}
if (res && res.rate) {
$scope.rateDate = res.fetchedOn;
$scope.rateStr = res.rate + ' ' + alternativeIsoCode;
$scope.$apply();
}
});
};
$scope.cancel = function() {
$scope.txDetailsModal.hide();
};

View file

@ -16,7 +16,13 @@
</div>
<div class="amount-label">
<div class="amount">{{displayAmount}} <span class="unit">{{displayUnit}}</span></div>
<div class="alternative">{{btx.alternativeAmountStr}}</div>
<div class="alternative" ng-click="getFiatRate(); showRate = !showRate">
<span ng-show="!showRate">{{btx.alternativeAmountStr}}</span>
<span ng-show="showRate">
<span ng-show="!loadingRate">{{rateStr}} ({{rateDate | amDateFormat:'MM/DD/YYYY HH:mm a'}})</span>
<span ng-show="loadingRate">...</span>
</span>
</div>
</div>
</div>
<div class="info">