Show alternative currency on the list of transactions

This commit is contained in:
Gustavo Maximiliano Cortez 2014-09-24 02:13:56 -03:00
parent 82acccce2a
commit 8ef737083a
3 changed files with 50 additions and 7 deletions

View File

@ -2,7 +2,7 @@
var bitcore = require('bitcore'); var bitcore = require('bitcore');
angular.module('copayApp.controllers').controller('TransactionsController', angular.module('copayApp.controllers').controller('TransactionsController',
function($scope, $rootScope, $timeout, controllerUtils, notification) { function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) {
var w = $rootScope.wallet; var w = $rootScope.wallet;
@ -13,6 +13,7 @@ angular.module('copayApp.controllers').controller('TransactionsController',
$scope.txpCurrentPage = 1; $scope.txpCurrentPage = 1;
$scope.txpItemsPerPage = 4; $scope.txpItemsPerPage = 4;
$scope.blockchain_txs = []; $scope.blockchain_txs = [];
$scope.alternativeCurrency = [];
var satToUnit = 1 / w.settings.unitToSatoshi; var satToUnit = 1 / w.settings.unitToSatoshi;
@ -37,6 +38,7 @@ angular.module('copayApp.controllers').controller('TransactionsController',
}; };
var _aggregateItems = function(items) { var _aggregateItems = function(items) {
var w = $rootScope.wallet;
if (!items) return []; if (!items) return [];
var l = items.length; var l = items.length;
@ -92,6 +94,10 @@ angular.module('copayApp.controllers').controller('TransactionsController',
angular.forEach(tmp, function(v) { angular.forEach(tmp, function(v) {
v.value = (parseInt(v.valueSat || 0).toFixed(0)) * satToUnit; 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); ret.push(v);
}); });
return ret; return ret;
@ -150,4 +156,11 @@ angular.module('copayApp.controllers').controller('TransactionsController',
$scope.getTransactions(); $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);
});
};
}); });

View File

@ -1,8 +1,8 @@
<div class="last-transactions-header"> <div class="last-transactions-header" ng-init="txIndex = $index">
<div class="row collapse"> <div class="row collapse">
<div class="hide-for-small-only large-1 medium-1 columns"> <div class="hide-for-small-only large-1 medium-1 columns">
<a class="text-black" ng-show="tx.comment"> <a class="text-black" ng-show="tx.comment">
<i class="fi-comment-quotes size-24" Popover-animation="true" popover="{{$root.wallet.publicKeyRing.nicknameForCopayer(tx.creator)}}" popover-title="{{tx.comment}}" popover-placement="right" popover-trigger="mouseenter"></i> <i class="fi-comment-quotes size-24" popover-animation="true" popover="{{$root.wallet.publicKeyRing.nicknameForCopayer(tx.creator)}}" popover-title="{{tx.comment}}" popover-placement="right" popover-trigger="mouseenter"></i>
</a> </a>
<a class="disable" ng-show="!tx.comment"> <a class="disable" ng-show="!tx.comment">
<i class="fi-comment-quotes size-24 text-gray"></i> <i class="fi-comment-quotes size-24 text-gray"></i>
@ -16,8 +16,21 @@
<div class="large-8 medium-8 small-9 columns"> <div class="large-8 medium-8 small-9 columns">
<div class="row collapse" ng-repeat="out in tx.outs"> <div class="row collapse" ng-repeat="out in tx.outs">
<div class="large-3 medium-3 small-4 columns"> <div class="large-3 medium-3 small-4 columns">
<p class="size-14 hide-for-small-only">{{out.value | noFractionNumber}} {{$root.wallet.settings.unitName}}</p> <div class="size-14 hide-for-small-only">
<p class="size-12 show-for-small-only">{{out.value | noFractionNumber}} {{$root.wallet.settings.unitName}}</p> <span
ng-class="{'has-tip': alternativeCurrency[txIndex]}"
ng-init="amountAlternative(out.value, txIndex)"
data-options="disable_for_touch:true"
tooltip-popup-delay='500'
tooltip="{{alternativeCurrency[txIndex]|noFractionNumber}} {{alternativeIsoCode}}"
tooltip-trigger="mouseenter"
tooltip-placement="right"
>{{out.value |noFractionNumber}}
{{$root.wallet.settings.unitName}}</span>
</div>
<div class="size-12 show-for-small-only">
<span>{{out.value |noFractionNumber}} {{$root.wallet.settings.unitName}}</span>
</div>
</div> </div>
<div class="large-1 medium-1 small-1 columns fi-arrow-right"></div> <div class="large-1 medium-1 small-1 columns fi-arrow-right"></div>
<div class="large-8 medium-8 small-7 columns ellipsis"> <div class="large-8 medium-8 small-7 columns ellipsis">

View File

@ -54,7 +54,16 @@
<div class="last-transactions-content"> <div class="last-transactions-content">
<div class="large-5 medium-5 small-12 columns"> <div class="large-5 medium-5 small-12 columns">
<div ng-repeat="vin in btx.vinSimple"> <div ng-repeat="vin in btx.vinSimple">
<small class="right m5t">{{vin.value| noFractionNumber}} {{$root.wallet.settings.unitName}}</small> <small class="right m5t"
ng-class="{'has-tip': vin.valueAlt}"
data-options="disable_for_touch:true"
tooltip-popup-delay='500'
tooltip="{{vin.valueAlt|noFractionNumber}} {{alternativeIsoCode}}"
tooltip-trigger="mouseenter"
tooltip-placement="right"
>
{{vin.value| noFractionNumber}} {{$root.wallet.settings.unitName}}
</small>
<p class="ellipsis text-gray size-12"> <p class="ellipsis text-gray size-12">
<contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" /> <contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
</p> </p>
@ -68,7 +77,15 @@
</div> </div>
<div class="large-6 medium-6 small-12 columns"> <div class="large-6 medium-6 small-12 columns">
<div ng-repeat="vout in btx.voutSimple"> <div ng-repeat="vout in btx.voutSimple">
<small class="right m5t">{{vout.value| noFractionNumber}} {{$root.wallet.settings.unitName}}</small> <small class="right m5t"
ng-class="{'has-tip': vout.valueAlt}"
data-options="disable_for_touch:true"
tooltip-popup-delay='500'
tooltip="{{vout.valueAlt|noFractionNumber}} {{alternativeIsoCode}}"
tooltip-trigger="mouseenter"
tooltip-placement="left"
>
{{vout.value| noFractionNumber}} {{$root.wallet.settings.unitName}}</small>
<p class="ellipsis text-gray size-12"> <p class="ellipsis text-gray size-12">
<contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" /> <contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
</p> </p>