/** * Represents a book. * @constructor */ mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) { // Define default states $('#loginModal').modal({backdrop: 'static', keyboard: false}); $('#loadingLoginButton').hide(); $('#failedToLoginAlert').hide(); $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); result.then(function (response){ // Parser result var requestResultObject=identity.requestParser.parseLoginAnswer(response); // Check for error if(requestResultObject.status!==0){ //alert(result.data) $('#failedToLoginAlert').show(); } else { $('#loginModal').modal('hide'); } // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); },function(response){ $('#failedToLoginAlert').show(); // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); }); }); });