settings: fix references to unitName

This commit is contained in:
Manuel Araoz 2014-09-03 16:24:25 -03:00
parent 53869531c2
commit 0fe4778637
10 changed files with 113 additions and 114 deletions

View File

@ -30,6 +30,7 @@ var defaultConfig = {
settings: {
unitName: 'bits',
unitToSatoshi: 100,
unitDecimals: 2,
alternativeName: 'US Dollar',
alternativeIsoCode: 'USD',
}

View File

@ -5,13 +5,13 @@ angular.module('copayApp.controllers').controller('SendController',
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) {
$scope.title = 'Send';
$scope.loading = false;
var satToUnit = 1 / config.unitToSatoshi;
var satToUnit = 1 / $rootScope.wallet.settings.unitToSatoshi;
$scope.defaultFee = bitcore.TransactionBuilder.FEE_PER_1000B_SAT * satToUnit;
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
$scope.unitToSatoshi = config.unitToSatoshi;
$scope.unitToBtc = $rootScope.wallet.settings.unitToSatoshi / bitcore.util.COIN;
$scope.unitToSatoshi = $rootScope.wallet.settings.unitToSatoshi;
$scope.alternativeName = config.alternativeName;
$scope.alternativeIsoCode = config.alternativeIsoCode;
$scope.alternativeName = $rootScope.wallet.settings.alternativeName;
$scope.alternativeIsoCode = $rootScope.wallet.settings.alternativeIsoCode;
$scope.isRateAvailable = false;
$scope.rateService = rateService;
@ -36,7 +36,7 @@ angular.module('copayApp.controllers').controller('SendController',
this._alternative = newValue;
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
this._amount = parseFloat(
(rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit).toFixed(config.unitDecimals), 10);
(rateService.fromFiat(newValue, $rootScope.wallet.settings.alternativeIsoCode) * satToUnit).toFixed($rootScope.wallet.settings.unitDecimals), 10);
} else {
this._amount = 0;
}
@ -53,7 +53,7 @@ angular.module('copayApp.controllers').controller('SendController',
this._amount = newValue;
if (typeof(newValue) === 'number' && $scope.isRateAvailable) {
this._alternative = parseFloat(
(rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)).toFixed(2), 10);
(rateService.toFiat(newValue * $rootScope.wallet.settings.unitToSatoshi, $rootScope.wallet.settings.alternativeIsoCode)).toFixed(2), 10);
} else {
this._alternative = 0;
}
@ -91,7 +91,7 @@ angular.module('copayApp.controllers').controller('SendController',
if ($rootScope.pendingPayment) {
var pp = $rootScope.pendingPayment;
$scope.address = pp.address + '';
var amount = pp.data.amount / config.unitToSatoshi * 100000000;
var amount = pp.data.amount / $rootScope.wallet.settings.unitToSatoshi * 100000000;
$scope.amount = amount;
$scope.commentText = pp.data.message;
}
@ -113,7 +113,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.loading = true;
var address = form.address.$modelValue;
var amount = parseInt((form.amount.$modelValue * config.unitToSatoshi).toFixed(0));
var amount = parseInt((form.amount.$modelValue * $rootScope.wallet.settings.unitToSatoshi).toFixed(0));
var commentText = form.comment.$modelValue;
var w = $rootScope.wallet;
@ -403,7 +403,7 @@ angular.module('copayApp.controllers').controller('SendController',
};
$scope.getAvailableAmount = function() {
var amount = ((($rootScope.availableBalance * config.unitToSatoshi).toFixed(0) - bitcore.TransactionBuilder.FEE_PER_1000B_SAT) / config.unitToSatoshi);
var amount = ((($rootScope.availableBalance * $rootScope.wallet.settings.unitToSatoshi).toFixed(0) - bitcore.TransactionBuilder.FEE_PER_1000B_SAT) / $rootScope.wallet.settings.unitToSatoshi);
return amount > 0 ? amount : 0;
};
@ -497,7 +497,7 @@ angular.module('copayApp.controllers').controller('SendController',
// Payment Protocol URI (BIP-72)
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
var balance = $rootScope.availableBalance;
var available = +(balance * config.unitToSatoshi).toFixed(0);
var available = +(balance * $rootScope.wallet.settings.unitToSatoshi).toFixed(0);
if (merchantData && available < +merchantData.total) {
err = new Error('No unspent outputs available.');
@ -508,7 +508,7 @@ angular.module('copayApp.controllers').controller('SendController',
scope.sendForm.address.$isValid = false;
if (err.amount) {
scope.sendForm.amount.$setViewValue(+err.amount / config.unitToSatoshi);
scope.sendForm.amount.$setViewValue(+err.amount / $rootScope.wallet.settings.unitToSatoshi);
scope.sendForm.amount.$render();
scope.sendForm.amount.$isValid = false;
scope.notEnoughAmount = true;
@ -538,7 +538,7 @@ angular.module('copayApp.controllers').controller('SendController',
var url = merchantData.request_url;
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
merchantData.unitTotal = (+merchantData.total / config.unitToSatoshi) + '';
merchantData.unitTotal = (+merchantData.total / $rootScope.wallet.settings.unitToSatoshi) + '';
merchantData.expiration = new Date(
merchantData.pr.pd.expires * 1000).toISOString();
merchantData.domain = domain;
@ -587,7 +587,9 @@ angular.module('copayApp.controllers').controller('SendController',
}
notification.info('Payment Request',
'Server is requesting ' + merchantData.unitTotal + ' ' + config.unitName + '.' + ' Message: ' + merchantData.pr.pd.memo);
'Server is requesting ' + merchantData.unitTotal +
' ' + $rootScope.wallet.settings.unitName +
'.' + ' Message: ' + merchantData.pr.pd.memo);
});
};

View File

@ -44,13 +44,13 @@ angular.module('copayApp.filters', [])
return addrs;
};
})
.filter('noFractionNumber',
[ '$filter', '$locale', '$rootScope',
.filter('noFractionNumber', ['$filter', '$locale', '$rootScope',
function(filter, locale, $rootScope) {
var numberFilter = filter('number');
var formats = locale.NUMBER_FORMATS;
return function(amount, n) {
var fractionSize = (typeof(n) != 'undefined') ? n : $rootScope.wallet.settings.unitToSatoshi.toString().length - 1;
var fractionSize = (typeof(n) !== 'undefined') ?
n : $rootScope.wallet.settings.unitToSatoshi.toString().length - 1;
var value = numberFilter(amount, fractionSize);
var sep = value.indexOf(formats.DECIMAL_SEP);
var group = value.indexOf(formats.GROUP_SEP);
@ -63,8 +63,7 @@ angular.module('copayApp.filters', [])
var floatValue = parseFloat(value.substring(sep));
if (floatValue === 0) {
floatValue = '';
}
else {
} else {
if (floatValue % 1 === 0) {
floatValue = floatValue.toFixed(0);
}
@ -72,8 +71,7 @@ angular.module('copayApp.filters', [])
}
var finalValue = intValue + floatValue;
return finalValue;
}
else {
} else {
value = parseFloat(value);
if (value % 1 === 0) {
value = value.toFixed(0);
@ -83,4 +81,5 @@ angular.module('copayApp.filters', [])
}
return 0;
};
} ]);
}
]);

View File

@ -19,18 +19,20 @@
<small translate class="label" ng-if="addr.isChange">change</small>
</div>
</div>
</div>
<div class="large-2 medium-3 small-4 column text-right">
<span ng-if="$root.updatingBalance">
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<span class="size-12" ng-if="!$root.updatingBalance">
{{addr.balance || 0|noFractionNumber}} {{$root.unitName}}
{{addr.balance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
</span>
</div>
</div>
</div>
<a class="secondary radius" ng-click="showAll=!showAll" ng-show="(addresses|removeEmpty).length != (addresses|removeEmpty|limitAddress).length">
<span translate ng-if="!showAll">Show all</span>
<span translate ng-if="showAll">Show less</span>
@ -38,5 +40,3 @@
</div>
</div>
</div>
</div>

View File

@ -19,7 +19,7 @@
tooltip="{{totalBalanceBTC |noFractionNumber:8}} BTC"
tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{totalBalance || 0
|noFractionNumber}} {{$root.unitName}}
|noFractionNumber}} {{$root.wallet.settings.unitName}}
</span>
</div>
<div>
@ -31,7 +31,7 @@
data-options="disable_for_touch:true"
tooltip="{{lockedBalanceBTC |noFractionNumber:8}} BTC"
tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}}
tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
</span> &nbsp;<i class="fi-info medium" tooltip="Balance locked in pending transaction proposals" tooltip-placement="bottom"></i>
</div>
<div class="line-sidebar-b"></div>

View File

@ -26,7 +26,7 @@
tooltip-popup-delay='500'
tooltip="{{totalBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}"
tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{totalBalance || 0 |noFractionNumber}} {{$root.unitName}}
tooltip-placement="bottom">{{totalBalance || 0 |noFractionNumber}} {{$root.wallet.settings.unitName}}
</span>
<div class="m10t" ng-show="lockedBalance">
<span translate>Locked</span> &nbsp;
@ -39,7 +39,7 @@
tooltip-popup-delay='500'
tooltip="{{lockedBalanceAlternative |noFractionNumber:2}} {{alternativeIsoCode}}"
tooltip-trigger="mouseenter"
tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.unitName}}
tooltip-placement="bottom">{{lockedBalance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
</span> &nbsp;<i class="fi-info medium" tooltip="{{'Balance locked in pending transaction proposals'|translate}}" tooltip-placement="bottom"></i>
</div>
</div>

View File

@ -9,15 +9,14 @@
</div>
<div class="show-for-small-only small-12 columns m10b" ng-show="tx.comment">
<p class="size-14 label">
{{tx.comment}} -
{{$root.wallet.publicKeyRing.nicknameForCopayer(tx.creator)}}
{{tx.comment}} - {{$root.wallet.publicKeyRing.nicknameForCopayer(tx.creator)}}
</p>
</div>
<div class="large-8 medium-8 small-8 columns">
<div ng-repeat="out in tx.outs">
<div class="large-3 medium-3 small-3 columns">
<p class="size-14 hide-for-small-only">{{out.value | noFractionNumber}} {{$root.unitName}}</p>
<p class="size-12 show-for-small-only">{{out.value | noFractionNumber}} {{$root.unitName}}</p>
<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>
<div class="large-1 medium-1 small-2 columns fi-arrow-right"></div>
<div class="large-8 medium-8 small-7 columns ellipsis">
@ -115,7 +114,7 @@
<p translate class="text-gray m5b" ng-show="!tx.finallyRejected && tx.missingSignatures>1">
{{tx.missingSignatures}} signatures missing</p>
<div class="ellipsis small text-gray">
<strong translate>Fee</strong>: {{tx.fee|noFractionNumber}} {{$root.unitName}}
<strong translate>Fee</strong>: {{tx.fee|noFractionNumber}} {{$root.wallet.settings.unitName}}
<strong translate>Proposal ID</strong>: {{tx.ntxid}}
</div>
</div>

View File

@ -7,7 +7,7 @@
<i class="fi-bitcoin-circle icon-rotate spinner"></i>
</span>
<p class="m15b" ng-if="!$root.updatingBalance">
{{address.balance || 0|noFractionNumber}} {{$root.unitName}}
{{address.balance || 0|noFractionNumber}} {{$root.wallet.settings.unitName}}
</p>
<button class="m15t button secondary" open-external address="{{address.address}}">
<i class="fi-link">&nbsp;</i> <span translate>Open in external application</span>

View File

@ -77,11 +77,11 @@
<a class="small input-note" title="{{'Send all funds'|translate}}"
ng-show="$root.availableBalance > 0 && (!$root.merchant || +$root.merchant.total === 0)"
ng-click="topAmount(sendForm)">
<span translate>Use all funds</span> ({{getAvailableAmount()}} {{$root.unitName}})
<span translate>Use all funds</span> ({{getAvailableAmount()}} {{$root.wallet.settings.unitName}})
</a>
</div>
<div class="small-3 columns">
<span class="postfix">{{$root.unitName}}</span>
<span class="postfix">{{$root.wallet.settings.unitName}}</span>
</div>
</div>
</div>
@ -138,13 +138,13 @@
</p>
<h6 translate>Total amount for this transaction:</h6>
<p class="text-gray" ng-class="{'hidden': sendForm.amount.$invalid || !amount > 0}">
<b>{{amount + defaultFee |noFractionNumber}}</b> {{$root.unitName}}
<b>{{amount + defaultFee |noFractionNumber}}</b> {{$root.wallet.settings.unitName}}
<small ng-if="isRateAvailable">
{{ rateService.toFiat((amount + defaultFee) * unitToSatoshi, alternativeIsoCode) | noFractionNumber: 2 }} {{ alternativeIsoCode }}
<br>
</small>
<small>
<span translate>Including fee of</span> {{defaultFee|noFractionNumber}} {{$root.unitName}}
<span translate>Including fee of</span> {{defaultFee|noFractionNumber}} {{$root.wallet.settings.unitName}}
</small>
</p>
<div ng-show="wallet.isShared()">

View File

@ -7,7 +7,8 @@
<div class="last-transactions" ng-repeat="tx in txs | paged">
<div ng-include="'views/includes/transaction.html'"></div>
</div>
<p ng-show="txs.length == 0"><span translate>No transactions proposals yet.</span></p>
<p ng-show="txs.length == 0"><span translate>No transactions proposals yet.</span>
</p>
<pagination ng-show="txs.length > txpItemsPerPage" total-items="txs.length" items-per-page="txpItemsPerPage" page="txpCurrentPage" on-select-page="show()" class="pagination-small primary"></pagination>
</div>
@ -20,10 +21,8 @@
<div class="large-12">
<div class="m10b size-12" ng-hide="wallet.totalCopayers == 1">
<a class="text-gray active" ng-click="toogleLast()"
ng-disabled="loading" loading="Updating" ng-hide="lastShowed && !loading">[ <span translate>Show</span> ]</a>
<a class="text-gray" ng-click="toogleLast()" ng-disabled="loading"
loading="Updating" ng-show="lastShowed && !loading">[ <span translate>Hide</span> ]</a>
<a class="text-gray active" ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-hide="lastShowed && !loading">[ <span translate>Show</span> ]</a>
<a class="text-gray" ng-click="toogleLast()" ng-disabled="loading" loading="Updating" ng-show="lastShowed && !loading">[ <span translate>Hide</span> ]</a>
</div>
<div class="btransactions" ng-if="lastShowed">
@ -52,7 +51,7 @@
<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.unitName}}</small>
<small class="right m5t">{{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>
@ -66,7 +65,7 @@
</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.unitName}}</small>
<small class="right m5t">{{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>
@ -75,11 +74,11 @@
</div>
<div class="last-transactions-footer">
<div class="large-6 medium-6 small-6 columns">
<p class="size-12"><span translate>Fee</span>: {{btx.fees | noFractionNumber}} {{$root.unitName}}</p>
<p class="size-12"><span translate>Fee</span>: {{btx.fees | noFractionNumber}} {{$root.wallet.settings.unitName}}</p>
<p class="size-12"><span translate>Confirmations</span>: {{btx.confirmations || 0}}</p>
</div>
<div class="large-6 medium-6 small-6 columns text-right">
<p class="label size-14"><span translate>Total</span>: {{btx.valueOut| noFractionNumber}} {{$root.unitName}}</p>
<p class="label size-14"><span translate>Total</span>: {{btx.valueOut| noFractionNumber}} {{$root.wallet.settings.unitName}}</p>
</div>
</div>
</div>
@ -87,4 +86,3 @@
</div>
</div>
</div>