Currency list in settings
This commit is contained in:
parent
3da033cb06
commit
3225553d78
6 changed files with 94 additions and 22 deletions
|
|
@ -12,10 +12,9 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
$scope.unitToBtc = config.unitToSatoshi / bitcore.util.COIN;
|
||||
$scope.minAmount = config.limits.minAmountSatoshi * satToUnit;
|
||||
$scope.minAlternativeAmount = config.limits.minAmountSatoshi * satToAlternative;
|
||||
// Mockup
|
||||
$rootScope.alternativeName = 'Dollars';
|
||||
$rootScope.alternativeIsoCode = 'USD';
|
||||
config.unitDecimals = 2;
|
||||
|
||||
this.alternativeName = config.alternativeName;
|
||||
this.alternativeIsoCode = config.alternativeIsoCode;
|
||||
this.rateService = rateService;
|
||||
|
||||
$scope._amount = 0;
|
||||
|
|
@ -40,7 +39,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
this._alternative = newValue;
|
||||
if (typeof(newValue) === 'number') {
|
||||
this._amount = -(-(
|
||||
rateService.fromFiat(newValue, $rootScope.alternativeIsoCode) * satToUnit
|
||||
rateService.fromFiat(newValue, config.alternativeIsoCode) * satToUnit
|
||||
).toFixed(config.unitDecimals));
|
||||
}
|
||||
},
|
||||
|
|
@ -56,7 +55,7 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
this._amount = newValue;
|
||||
if (newValue) {
|
||||
this._alternative = -(-(
|
||||
rateService.toFiat(newValue * config.unitToSatoshi, $rootScope.alternativeIsoCode)
|
||||
rateService.toFiat(newValue * config.unitToSatoshi, config.alternativeIsoCode)
|
||||
).toFixed(2));
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location, controllerUtils) {
|
||||
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location, controllerUtils, rateService) {
|
||||
|
||||
controllerUtils.redirIfLogged();
|
||||
$scope.title = 'Settings';
|
||||
|
|
@ -14,27 +14,51 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
$scope.unitOpts = [{
|
||||
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
||||
shortName: 'SAT',
|
||||
value: 1
|
||||
value: 1,
|
||||
decimals: 0
|
||||
}, {
|
||||
name: 'bits (1,000,000 bits = 1BTC)',
|
||||
shortName: 'bits',
|
||||
value: 100
|
||||
value: 100,
|
||||
decimals: 2
|
||||
}, {
|
||||
name: 'mBTC (1,000 mBTC = 1BTC)',
|
||||
shortName: 'mBTC',
|
||||
value: 100000
|
||||
value: 100000,
|
||||
decimals: 5
|
||||
}, {
|
||||
name: 'BTC',
|
||||
shortName: 'BTC',
|
||||
value: 100000000
|
||||
value: 100000000,
|
||||
decimals: 8
|
||||
}];
|
||||
|
||||
$scope.selectedAlternative = {
|
||||
name: 'US Dollar',
|
||||
isoCode: 'USD'
|
||||
};
|
||||
$scope.alternativeOpts = rateService.alternatives;
|
||||
|
||||
rateService.whenAvailable(function() {
|
||||
$scope.alternativeOpts = rateService.listAlternatives();
|
||||
for (var ii in $scope.alternativeOpts) {
|
||||
if (config.alternativeIsoCode === $scope.alternativeOpts[ii].isoCode) {
|
||||
$scope.selectedAlternative = $scope.alternativeOpts[ii];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (var ii in $scope.unitOpts) {
|
||||
if (config.unitName === $scope.unitOpts[ii].shortName) {
|
||||
$scope.selectedUnit = $scope.unitOpts[ii];
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (var ii in $scope.alternativeOpts) {
|
||||
if (config.alternativeIsoCode === $scope.alternativeOpts[ii].isoCode) {
|
||||
$scope.selectedAlternative = $scope.alternativeOpts[ii];
|
||||
}
|
||||
}
|
||||
|
||||
$scope.changeNetwork = function() {
|
||||
$scope.insightHost = $scope.networkName !== 'testnet' ? 'test-insight.bitpay.com' : 'insight.bitpay.com';
|
||||
|
|
@ -68,7 +92,11 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
|||
disableVideo: $scope.disableVideo,
|
||||
unitName: $scope.selectedUnit.shortName,
|
||||
unitToSatoshi: $scope.selectedUnit.value,
|
||||
version: copay.version,
|
||||
unitDecimals: $scope.selectedUnit.decimals,
|
||||
alternativeName: $scope.selectedAlternative.name,
|
||||
alternativeIsoCode: $scope.selectedAlternative.isoCode,
|
||||
|
||||
version: copay.version
|
||||
}));
|
||||
|
||||
// Go home reloading the application
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue