Select Git revision
settings-controllers.js
-
Benoit Lavenier authoredBenoit Lavenier authored
settings-controllers.js 4.19 KiB
angular.module('cesium.settings.controllers', ['cesium.services', 'cesium.currency.controllers'])
.config(function($stateProvider, $urlRouterProvider) {
'ngInject';
$stateProvider
.state('app.settings', {
url: "/settings",
views: {
'menuContent': {
templateUrl: "templates/settings/settings.html",
controller: 'SettingsCtrl'
}
}
})
;
})
.controller('SettingsCtrl', SettingsController)
;
function SettingsController($scope, $state, UIUtils, Wallet, $translate, BMA, $q, $ionicPopup, $timeout, localStorage) {
'ngInject';
$scope.locales = [
{id:'fr-FR', label:'Français'},
{id:'en', label:'English'}
];
$scope.formData = angular.copy(Wallet.defaultSettings);
$scope.loading = true;
$scope.$on('$ionicView.enter', function(e, $state) {
$scope.loading = true; // to avoid the call of Wallet.store()
$scope.formData.locale = _.findWhere($scope.locales, {id: $translate.use()});
Wallet.restore()
.then(function() {
angular.merge($scope.formData, Wallet.data.settings);
if (Wallet.data.settings.locale && Wallet.data.settings.locale.id) {
$scope.formData.locale = _.findWhere($scope.locales, {id: Wallet.data.settings.locale.id});
}
UIUtils.loading.hide();
$scope.loading = false;
})
.catch(function(err) {
$scope.loading = false;
UIUtils.loading.hide();
});
});
$scope.setSettingsForm = function(settingsForm) {
$scope.settingsForm = settingsForm;
};
$scope.changeLanguage = function(langKey) {
$translate.use(langKey);
};
// Change node
$scope.changeNode= function(node) {
if (!node) {
node = $scope.formData.node;
}
$scope.showNodePopup(node)
.then(function(node) {
if (node == $scope.formData.node) {
return; // same node = nothing to do
}
UIUtils.loading.show();