From 8ef737083a617a471f529947c0f659c7b43305fd Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Wed, 24 Sep 2014 02:13:56 -0300 Subject: [PATCH] Show alternative currency on the list of transactions --- js/controllers/transactions.js | 15 ++++++++++++++- views/includes/transaction.html | 21 +++++++++++++++++---- views/transactions.html | 21 +++++++++++++++++++-- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/js/controllers/transactions.js b/js/controllers/transactions.js index 7b51f0135..2f49bf3d6 100644 --- a/js/controllers/transactions.js +++ b/js/controllers/transactions.js @@ -2,7 +2,7 @@ var bitcore = require('bitcore'); angular.module('copayApp.controllers').controller('TransactionsController', - function($scope, $rootScope, $timeout, controllerUtils, notification) { + function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) { var w = $rootScope.wallet; @@ -13,6 +13,7 @@ angular.module('copayApp.controllers').controller('TransactionsController', $scope.txpCurrentPage = 1; $scope.txpItemsPerPage = 4; $scope.blockchain_txs = []; + $scope.alternativeCurrency = []; var satToUnit = 1 / w.settings.unitToSatoshi; @@ -37,6 +38,7 @@ angular.module('copayApp.controllers').controller('TransactionsController', }; var _aggregateItems = function(items) { + var w = $rootScope.wallet; if (!items) return []; var l = items.length; @@ -92,6 +94,10 @@ angular.module('copayApp.controllers').controller('TransactionsController', angular.forEach(tmp, function(v) { v.value = (parseInt(v.valueSat || 0).toFixed(0)) * satToUnit; + rateService.whenAvailable(function() { + var valueSat = v.value * w.settings.unitToSatoshi; + v.valueAlt = rateService.toFiat(valueSat, w.settings.alternativeIsoCode); + }); ret.push(v); }); return ret; @@ -150,4 +156,11 @@ angular.module('copayApp.controllers').controller('TransactionsController', $scope.getTransactions(); } + $scope.amountAlternative = function (amount, txIndex) { + var w = $rootScope.wallet; + rateService.whenAvailable(function() { + var valueSat = amount * w.settings.unitToSatoshi; + $scope.alternativeCurrency[txIndex] = rateService.toFiat(valueSat, w.settings.alternativeIsoCode); + }); + }; }); diff --git a/views/includes/transaction.html b/views/includes/transaction.html index 60918c04c..a24afa6fe 100644 --- a/views/includes/transaction.html +++ b/views/includes/transaction.html @@ -1,8 +1,8 @@ -
+