Make login part dynamic

This commit is contained in:
manzerbredes 2016-02-05 17:47:53 +01:00
parent 31f3a9d77f
commit a16df328c0
4 changed files with 43 additions and 64 deletions

View file

@ -3,7 +3,7 @@
* Represents a book.
* @constructor
*/
mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http)
{
// Define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false});
@ -12,30 +12,40 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce)
$('#loginButton').click(function(){
$('#loginButton').hide();
$('#loadingLoginButton').show();
$('#failedToLoginAlert').hide();
$('#loginButton').hide();
$('#loadingLoginButton').show();
$('#failedToLoginAlert').hide();
var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
$interval(
function()
{
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(!errors.checkForLogin(result)){
if(requestResultObject.status!==0){
//alert(result.data)
$('#failedToLoginAlert').show();
}
else {
$('#loginModal').modal('hide');
}
// Reset button state
$('#loginButton').show();
$('#loadingLoginButton').hide();
}, 2000,1);
},function(response){
$('#failedToLoginAlert').show();
// Reset button state
$('#loginButton').show();
$('#loadingLoginButton').hide();
});
});
});