settings: refactor controllers
This commit is contained in:
parent
e992b976e0
commit
921cb8dd90
2 changed files with 48 additions and 49 deletions
|
|
@ -4,6 +4,53 @@ angular.module('copayApp.controllers').controller('MoreController',
|
||||||
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils, notification) {
|
function($scope, $rootScope, $location, backupService, walletFactory, controllerUtils, notification) {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
|
|
||||||
|
$scope.unitOpts = [{
|
||||||
|
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
||||||
|
shortName: 'SAT',
|
||||||
|
value: 1,
|
||||||
|
decimals: 0
|
||||||
|
}, {
|
||||||
|
name: 'bits (1,000,000 bits = 1BTC)',
|
||||||
|
shortName: 'bits',
|
||||||
|
value: 100,
|
||||||
|
decimals: 2
|
||||||
|
}, {
|
||||||
|
name: 'mBTC (1,000 mBTC = 1BTC)',
|
||||||
|
shortName: 'mBTC',
|
||||||
|
value: 100000,
|
||||||
|
decimals: 5
|
||||||
|
}, {
|
||||||
|
name: 'BTC',
|
||||||
|
shortName: 'BTC',
|
||||||
|
value: 100000000,
|
||||||
|
decimals: 8
|
||||||
|
}];
|
||||||
|
$scope.selectedAlternative = {
|
||||||
|
name: config.alternativeName,
|
||||||
|
isoCode: config.alternativeIsoCode
|
||||||
|
};
|
||||||
|
$scope.alternativeOpts = rateService.isAvailable ?
|
||||||
|
rateService.listAlternatives() : [$scope.selectedAlternative];
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$scope.hideAdv = true;
|
$scope.hideAdv = true;
|
||||||
$scope.hidePriv = true;
|
$scope.hidePriv = true;
|
||||||
if (w)
|
if (w)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location, controllerUtils, rateService) {
|
angular.module('copayApp.controllers').controller('SettingsController', function($scope, $rootScope, $window, $location, controllerUtils) {
|
||||||
|
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
$scope.title = 'Settings';
|
$scope.title = 'Settings';
|
||||||
|
|
@ -24,54 +24,6 @@ angular.module('copayApp.controllers').controller('SettingsController', function
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.unitOpts = [{
|
|
||||||
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
|
||||||
shortName: 'SAT',
|
|
||||||
value: 1,
|
|
||||||
decimals: 0
|
|
||||||
}, {
|
|
||||||
name: 'bits (1,000,000 bits = 1BTC)',
|
|
||||||
shortName: 'bits',
|
|
||||||
value: 100,
|
|
||||||
decimals: 2
|
|
||||||
}, {
|
|
||||||
name: 'mBTC (1,000 mBTC = 1BTC)',
|
|
||||||
shortName: 'mBTC',
|
|
||||||
value: 100000,
|
|
||||||
decimals: 5
|
|
||||||
}, {
|
|
||||||
name: 'BTC',
|
|
||||||
shortName: 'BTC',
|
|
||||||
value: 100000000,
|
|
||||||
decimals: 8
|
|
||||||
}];
|
|
||||||
|
|
||||||
$scope.selectedAlternative = {
|
|
||||||
name: config.alternativeName,
|
|
||||||
isoCode: config.alternativeIsoCode
|
|
||||||
};
|
|
||||||
$scope.alternativeOpts = rateService.isAvailable ?
|
|
||||||
rateService.listAlternatives() : [$scope.selectedAlternative];
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.changeNetwork = function() {
|
|
||||||
$scope.insightHost = $scope.networkName !== 'testnet' ? 'test-insight.bitpay.com' : 'insight.bitpay.com';
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
$scope.changeInsightSSL = function() {
|
$scope.changeInsightSSL = function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue