Moves the global preferences to the sidebar

This commit is contained in:
Gustavo Maximiliano Cortez 2015-11-09 15:20:15 -03:00
commit 308616c254
16 changed files with 177 additions and 130 deletions

View file

@ -1,20 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesController',
function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService, uxLanguage) {
function($scope, $rootScope, $timeout, $log, configService, profileService) {
this.init = function() {
var config = configService.getSync();
this.unitName = config.wallet.settings.unitName;
this.bwsurl = config.bws.url;
this.currentLanguageName = uxLanguage.getCurrentLanguageName();
this.selectedAlternative = {
name: config.wallet.settings.alternativeName,
isoCode: config.wallet.settings.alternativeIsoCode
};
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.glideraTestnet = config.glidera.testnet;
var fc = profileService.focusedClient;
if (fc) {
$scope.encrypt = fc.hasPrivKeyEncrypted();
@ -31,20 +21,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
}
};
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
wallet: {
spendUnconfirmed: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/SpendUnconfirmedUpdated');
if (err) $log.debug(err);
});
});
var unwatch = $scope.$watch('encrypt', function(val) {
var unwatchEncrypt = $scope.$watch('encrypt', function(val) {
var fc = profileService.focusedClient;
if (!fc) return;
@ -80,32 +57,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
}
});
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
enabled: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
testnet: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchRequestTouchid = $scope.$watch('touchid', function(newVal, oldVal) {
if (newVal == oldVal || $scope.touchidError) {
$scope.touchidError = false;
@ -139,10 +90,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
});
$scope.$on('$destroy', function() {
unwatch();
unwatchSpendUnconfirmed();
unwatchGlideraEnabled();
unwatchGlideraTestnet();
unwatchEncrypt();
unwatchRequestTouchid();
});
});

View file

@ -0,0 +1,63 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesGlobalController',
function($scope, $rootScope, $log, configService, uxLanguage) {
this.init = function() {
var config = configService.getSync();
this.unitName = config.wallet.settings.unitName;
this.currentLanguageName = uxLanguage.getCurrentLanguageName();
this.selectedAlternative = {
name: config.wallet.settings.alternativeName,
isoCode: config.wallet.settings.alternativeIsoCode
};
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
$scope.glideraEnabled = config.glidera.enabled;
$scope.glideraTestnet = config.glidera.testnet;
};
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
wallet: {
spendUnconfirmed: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/SpendUnconfirmedUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraEnabled = $scope.$watch('glideraEnabled', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
enabled: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
var unwatchGlideraTestnet = $scope.$watch('glideraTestnet', function(newVal, oldVal) {
if (newVal == oldVal) return;
var opts = {
glidera: {
testnet: newVal
}
};
configService.set(opts, function(err) {
$rootScope.$emit('Local/GlideraUpdated');
if (err) $log.debug(err);
});
});
$scope.$on('$destroy', function() {
unwatchSpendUnconfirmed();
unwatchGlideraEnabled();
unwatchGlideraTestnet();
});
});

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('preferencesLanguageController',
function($scope, $log, $timeout, configService, go, uxLanguage) {
function($scope, $log, $timeout, configService, uxLanguage) {
this.availableLanguages = uxLanguage.getLanguages();
@ -19,7 +19,7 @@ angular.module('copayApp.controllers').controller('preferencesLanguageController
if (err) $log.warn(err);
$scope.$emit('Local/LanguageSettingUpdated');
$timeout(function() {
go.preferences();
$scope.$apply();
}, 100);
});
};

View file

@ -433,11 +433,14 @@ angular
},
}
})
.state('settings', {
url: '/settings',
controller: 'settingsController',
templateUrl: 'views/settings.html',
needProfile: false
.state('preferencesGlobal', {
url: '/preferencesGlobal',
needProfile: true,
views: {
'main': {
templateUrl: 'views/preferencesGlobal.html',
},
}
})
.state('warning', {
url: '/warning',

View file

@ -21,6 +21,7 @@ angular.module('copayApp.services').factory('animationService', function(isCordo
uriglidera: -1,
preferences: 11,
preferencesGlobal: 11,
glidera: 11,
preferencesColor: 12,
backup: 12,
@ -151,4 +152,4 @@ angular.module('copayApp.services').factory('animationService', function(isCordo
}
return root;
});
});