/** * The login controler * @param {$scope} $scope The $scope angular service * @param {$sce} $sce The $sce angular service * @param {$http} $http The $http angular service * @param {sharedProfile} sharedProfile The sharedProfile service */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { // Define default states $('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); var username=$("#loginFormUsername").val(); var password=$("#loginFormPassword").val(); var projectname=$("#loginFormProjectname").val(); var result=Identity.login(username, password, projectname); result.then(function (response){ // Parser result var requestResultObject=Identity.parseLoginAnswer(response); // Check for error if(requestResultObject.status!==0){ $('#failedToLoginAlert').show(); } else { $('#loginModal').modal('hide'); Identity.profile.username=username; Identity.profile.projectname=projectname; } // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); },function(response){ $('#failedToLoginAlert').show(); // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); }); }); }]);