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,8 +587,10 @@ 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,43 +44,42 @@ angular.module('copayApp.filters', [])
return addrs;
};
})
.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 value = numberFilter(amount, fractionSize);
var sep = value.indexOf(formats.DECIMAL_SEP);
var group = value.indexOf(formats.GROUP_SEP);
if(amount >= 0) {
if (group > 0) {
if (sep < 0) {
.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 value = numberFilter(amount, fractionSize);
var sep = value.indexOf(formats.DECIMAL_SEP);
var group = value.indexOf(formats.GROUP_SEP);
if (amount >= 0) {
if (group > 0) {
if (sep < 0) {
return value;
}
var intValue = value.substring(0, sep);
var floatValue = parseFloat(value.substring(sep));
if (floatValue === 0) {
floatValue = '';
} else {
if (floatValue % 1 === 0) {
floatValue = floatValue.toFixed(0);
}
floatValue = floatValue.toString().substring(1);
}
var finalValue = intValue + floatValue;
return finalValue;
} else {
value = parseFloat(value);
if (value % 1 === 0) {
value = value.toFixed(0);
}
return value;
}
var intValue = value.substring(0, sep);
var floatValue = parseFloat(value.substring(sep));
if (floatValue === 0) {
floatValue = '';
}
else {
if(floatValue % 1 === 0) {
floatValue = floatValue.toFixed(0);
}
floatValue = floatValue.toString().substring(1);
}
var finalValue = intValue + floatValue;
return finalValue;
}
else {
value = parseFloat(value);
if(value % 1 === 0) {
value = value.toFixed(0);
}
return value;
}
}
return 0;
};
} ]);
return 0;
};
}
]);

View File

@ -4,39 +4,39 @@
<span translate>Addresses</span>
<span class="button primary small side-bar" ng-click="newAddr()" ng-disabled="loading"><i class="fi-plus"></i></span>
</h1>
<div class="large-12 medium-12" ng-if="!!(addresses|removeEmpty).length">
<div class="large-12 medium-12" ng-init="showAll=0">
<div class="panel radius oh" ng-repeat="addr in addresses|removeEmpty|limitAddress:showAll">
<div class="row collapse">
<div class="large-10 medium-9 small-8 column" >
<div class="ellipsis list-addr">
<i class="fi-thumbnails size-48 show-for-large-up" ng-click="openAddressModal(addr)">&nbsp;</i>
<span>
<div class="panel radius oh" ng-repeat="addr in addresses|removeEmpty|limitAddress:showAll">
<div class="row collapse">
<div class="large-10 medium-9 small-8 column">
<div class="ellipsis list-addr">
<i class="fi-thumbnails size-48 show-for-large-up" ng-click="openAddressModal(addr)">&nbsp;</i>
<span>
<contact address="{{addr.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
</span>
<span class="btn-copy" clip-copy="addr.address"> </span>
<small translate class="label" ng-if="addr.isChange">change</small>
</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}}
</span>
<span class="btn-copy" clip-copy="addr.address"> </span>
<small translate class="label" ng-if="addr.isChange">change</small>
</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>
</a>
<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.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>
</a>
</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

@ -8,20 +8,19 @@
</a>
</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)}}
<p class="size-14 label">
{{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-1 medium-1 small-2 columns fi-arrow-right"></div>
<div class="large-8 medium-8 small-7 columns ellipsis">
<contact address="{{out.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right"/>
<contact address="{{out.address}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
</div>
</div>
</div>
@ -37,25 +36,25 @@
</a>
<div class="box-status">
<a ng-if="c.actions.create" tooltip-popup-delay="1000" tooltip="Created {{c.actions.create | amTimeAgo}}">
<i class="fi-crown icon-status icon-active"></i>
<i class="fi-crown icon-status icon-active"></i>
</a>
<a ng-if="!c.actions.create"><i class="fi-crown icon-status"></i></a>
<a ng-if="c.actions.seen" tooltip-popup-delay="1000" tooltip="Seen {{c.actions.seen | amTimeAgo}}">
<i class="fi-eye icon-status icon-active"></i>
<i class="fi-eye icon-status icon-active"></i>
</a>
<a ng-if="!c.actions.seen"><i class="fi-eye icon-status"></i></a>
<a ng-if="c.actions.rejected" tooltip-popup-delay="1000" tooltip="Rejected {{c.actions.rejected | amTimeAgo}}">
<i class="fi-x icon-status icon-active-x"></i>
<i class="fi-x icon-status icon-active-x"></i>
</a>
<a ng-if="c.actions.sign" tooltip-popup-delay="1000" tooltip="Signed {{c.actions.sign | amTimeAgo}}">
<i class="fi-check icon-status icon-active-check"></i>
<i class="fi-check icon-status icon-active-check"></i>
</a>
<a ng-if="!c.actions.sign && !c.actions.rejected && tx.missingSignatures" class="icon-status">
<i class="fi-loop icon-rotate"></i>
<i class="fi-loop icon-rotate"></i>
</a>
</div>
@ -100,7 +99,7 @@
</div>
<div ng-show="!tx.missingSignatures && tx.sentTs">
<div class="is-valid m10b">
<strong translate>Sent</strong> <span class="text-gray" am-time-ago="tx.sentTs"></span>
<strong translate>Sent</strong> <span class="text-gray" am-time-ago="tx.sentTs"></span>
</div>
<div class="ellipsis small">
<span translate>Transaction ID</span>:
@ -110,12 +109,12 @@
</div>
</div>
<p translate class="text-gray m5b" ng-show="!tx.finallyRejected && tx.missingSignatures==1">
One signature missing
One signature missing
</p>
<p translate class="text-gray m5b" ng-show="!tx.finallyRejected && tx.missingSignatures>1">
{{tx.missingSignatures}} signatures missing</p>
{{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,9 +51,9 @@
<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"/>
<contact address="{{vin.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
</p>
</div>
</div>
@ -66,20 +65,20 @@
</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"/>
<contact address="{{vout.addr}}" tooltip-popup-delay="500" tooltip tooltip-placement="right" />
</p>
</div>
</div>
</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>Confirmations</span>: {{btx.confirmations || 0}}</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>