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';
angular.module('copayApp.controllers').controller('preferencesUnitController', function($scope, $log, configService, $ionicHistory, gettextCatalog, walletService, profileService) {
2016-06-10 11:19:36 -03:00
var config = configService.getSync();
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-29 16:48:15 -03:00
$ionicHistory.goBack();
2016-08-23 12:01:09 -03:00
walletService.updateRemotePreferences(profileService.getWallets(), {}, function() {
2016-06-10 11:19:36 -03:00
$log.debug('Remote preferences saved');
});
});
};
$scope.$on("$ionicView.enter", function(event, data){
$scope.currentUnit = config.wallet.settings.unitCode;
});
2016-06-10 11:19:36 -03:00
});