mirror of https://github.com/BTCPrivate/copay.git
Merge pull request #1470 from cmgustavo/feature/01-currency
Show alternative currency on the list of transactions
This commit is contained in:
commit
7ca22c2904
|
@ -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,12 @@ angular.module('copayApp.controllers').controller('TransactionsController',
|
|||
$scope.getTransactions();
|
||||
}
|
||||
|
||||
$scope.amountAlternative = function (amount, txIndex, cb) {
|
||||
var w = $rootScope.wallet;
|
||||
rateService.whenAvailable(function() {
|
||||
var valueSat = amount * w.settings.unitToSatoshi;
|
||||
$scope.alternativeCurrency[txIndex] = rateService.toFiat(valueSat, w.settings.alternativeIsoCode);
|
||||
return cb ? cb() : null;
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -127,6 +127,10 @@ describe("Unit: Controllers", function() {
|
|||
});
|
||||
}));
|
||||
|
||||
it('should exist', function() {
|
||||
should.exist(transactionsCtrl);
|
||||
});
|
||||
|
||||
it('should have a TransactionController controller', function() {
|
||||
expect(scope.loading).equal(false);
|
||||
});
|
||||
|
@ -135,6 +139,17 @@ describe("Unit: Controllers", function() {
|
|||
scope.getTransactions();
|
||||
expect(scope.blockchain_txs).to.be.empty;
|
||||
});
|
||||
|
||||
it('should call amountAlternative and return a value', function() {
|
||||
var cb = sinon.spy();
|
||||
var s1 = sinon.stub(scope, 'amountAlternative');
|
||||
s1.onCall(0).returns(1000);
|
||||
s1.onCall(1).returns(2000);
|
||||
expect(s1(100, 0, cb)).equal(1000);
|
||||
expect(s1(200, 1, cb)).equal(2000);
|
||||
sinon.assert.callCount(scope.amountAlternative, 2);
|
||||
s1.restore();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Send Controller', function() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<div class="last-transactions-header">
|
||||
<div class="last-transactions-header" ng-init="txIndex = $index">
|
||||
<div class="row collapse">
|
||||
<div class="hide-for-small-only large-1 medium-1 columns">
|
||||
<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 class="disable" ng-show="!tx.comment">
|
||||
<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="row collapse" ng-repeat="out in tx.outs">
|
||||
<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>
|
||||
<p class="size-12 show-for-small-only">{{out.value | noFractionNumber}} {{$root.wallet.settings.unitName}}</p>
|
||||
<div class="size-14 hide-for-small-only">
|
||||
<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 class="large-1 medium-1 small-1 columns fi-arrow-right"></div>
|
||||
<div class="large-8 medium-8 small-7 columns ellipsis">
|
||||
|
|
|
@ -54,7 +54,16 @@
|
|||
<div class="last-transactions-content">
|
||||
<div class="large-5 medium-5 small-12 columns">
|
||||
<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">
|
||||
<contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
|
||||
</p>
|
||||
|
@ -68,7 +77,15 @@
|
|||
</div>
|
||||
<div class="large-6 medium-6 small-12 columns">
|
||||
<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">
|
||||
<contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue