Wallet/src/js/controllers/preferencesUnit.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-03-06 12:00:10 -03:00
'use strict';
2016-08-19 13:17:54 -03:00
angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $state, walletService, profileService) {
2015-03-06 12:00:10 -03:00
2016-08-15 17:42:04 -03:00
$scope.init = function() {
var config = configService.getSync();
$scope.currentUnit = config.wallet.settings.unitCode;
}
2016-06-10 11:19:36 -03:00
2016-08-18 10:37:08 -03:00
$scope.unitList = [{
name: 'bits (1,000,000 bits = 1BTC)',
shortName: 'bits',
value: 100,
decimals: 2,
code: 'bit',
}, {
name: 'BTC',
shortName: 'BTC',
value: 100000000,
decimals: 8,
code: 'btc',
}];
2015-03-06 12:00:10 -03:00
2016-06-10 11:19:36 -03:00
$scope.save = function(newUnit) {
var opts = {
wallet: {
settings: {
unitName: newUnit.shortName,
unitToSatoshi: newUnit.value,
unitDecimals: newUnit.decimals,
unitCode: newUnit.code,
}
}
2015-03-06 12:00:10 -03:00
};
2016-06-10 11:19:36 -03:00
configService.set(opts, function(err) {
if (err) $log.warn(err);
2016-08-23 12:01:09 -03:00
$state.go('tabs.settings');
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
2016-06-10 11:19:36 -03:00
$log.debug('Remote preferences saved');
});
});
};
});