Fix angular style issues.

This commit is contained in:
Alexis Lahouze 2016-10-14 07:50:06 +02:00
parent a872788def
commit edac1ee6a9

View File

@ -27,7 +27,7 @@ angular.module('accountant', [
'Storage.Service' 'Storage.Service'
]) ])
.factory('sessionInjector', ['$storage', function($storage) { .factory('sessionInjector', function($storage) {
var sessionInjector = { var sessionInjector = {
request: function(config) { request: function(config) {
var token = $storage.get('token'); var token = $storage.get('token');
@ -43,14 +43,14 @@ angular.module('accountant', [
}; };
return sessionInjector; return sessionInjector;
}]) })
.config(['$httpProvider', function($httpProvider) { .config(function($httpProvider) {
// Define interceptors. // Define interceptors.
$httpProvider.interceptors.push('sessionInjector'); $httpProvider.interceptors.push('sessionInjector');
}]) })
.config(['$routeProvider', function($routeProvider) { .config(function($routeProvider) {
// Defining template and controller in function of route. // Defining template and controller in function of route.
$routeProvider $routeProvider
.when('/account/:accountId/operations', { .when('/account/:accountId/operations', {
@ -71,9 +71,9 @@ angular.module('accountant', [
.otherwise({ .otherwise({
redirectTo: '/accounts' redirectTo: '/accounts'
}); });
}]) })
.config(['$storageProvider', function($storageProvider) { .config(function($storageProvider) {
// Configure storage // Configure storage
// Set global prefix for stored keys // Set global prefix for stored keys
$storageProvider.setPrefix('accountant'); $storageProvider.setPrefix('accountant');
@ -85,24 +85,24 @@ angular.module('accountant', [
// Change the enabled storage engines // Change the enabled storage engines
// Defaults to ['memory', 'cookie', 'session', 'local'] // Defaults to ['memory', 'cookie', 'session', 'local']
$storageProvider.setEnabledStorageEngines(['local', 'session']); $storageProvider.setEnabledStorageEngines(['local', 'session']);
}]) })
.run(function(editableOptions) { .run(function(editableOptions) {
editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default' editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
}) })
.controller('MainController', [ .controller('MainController', function($scope, $rootScope, $http, authService, $storage, $ngBootbox) {
'$scope', '$rootScope', '$http', 'authService', '$storage', '$ngBootbox', var vm = this;
function($scope, $rootScope, $http, authService, $storage, $ngBootbox) {
$scope.dialogShown = false;
$scope.showLoginForm = function() { vm.dialogShown = false;
vm.showLoginForm = function() {
// First, if there are registered credentials, use them // First, if there are registered credentials, use them
if ($scope.dialogShown) { if ($scope.dialogShown) {
return; return;
} }
$scope.dialogShown = true; vm.dialogShown = true;
$storage.clear(); $storage.clear();
@ -114,7 +114,7 @@ angular.module('accountant', [
label: 'Login', label: 'Login',
className: 'btn-primary', className: 'btn-primary',
callback: function() { callback: function() {
$scope.dialogShown = false; vm.dialogShown = false;
var email = $('#email').val(); var email = $('#email').val();
var password = $('#password').val(); var password = $('#password').val();
@ -144,15 +144,18 @@ angular.module('accountant', [
className: 'btn-default', className: 'btn-default',
callback: function() { callback: function() {
authService.loginCancelled(null, 'Login cancelled by user action.'); authService.loginCancelled(null, 'Login cancelled by user action.');
$scope.dialogShown = false; vm.dialogShown = false;
} }
} }
} }
}); });
}; };
$rootScope.$on('event:auth-loginRequired', $scope.showLoginForm); var onAuthLoginRequired = $rootScope.$on('event:auth-loginRequired', $scope.showLoginForm);
}
]) $scope.$on('$destroy', function() {
onAuthLoginRequired = angular.noop();
});
})
; ;