2016-02-03 16:59:04 +01:00
|
|
|
|
2016-02-03 18:57:20 +01:00
|
|
|
/**
|
|
|
|
* Represents a book.
|
|
|
|
* @constructor
|
|
|
|
*/
|
2016-02-05 17:47:53 +01:00
|
|
|
mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http)
|
2016-02-03 16:59:04 +01:00
|
|
|
{
|
2016-02-04 13:20:45 +01:00
|
|
|
// Define default states
|
|
|
|
$('#loginModal').modal({backdrop: 'static', keyboard: false});
|
|
|
|
$('#loadingLoginButton').hide();
|
|
|
|
$('#failedToLoginAlert').hide();
|
2016-02-03 16:59:04 +01:00
|
|
|
|
|
|
|
|
2016-02-04 13:20:45 +01:00
|
|
|
$('#loginButton').click(function(){
|
2016-02-05 17:47:53 +01:00
|
|
|
$('#loginButton').hide();
|
|
|
|
$('#loadingLoginButton').show();
|
|
|
|
$('#failedToLoginAlert').hide();
|
2016-02-03 16:59:04 +01:00
|
|
|
|
2016-02-05 17:47:53 +01:00
|
|
|
var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val());
|
|
|
|
|
|
|
|
|
|
|
|
result.then(function (response){
|
|
|
|
|
|
|
|
// Parser result
|
|
|
|
var requestResultObject=identity.requestParser.parseLoginAnswer(response);
|
|
|
|
|
2016-02-04 13:20:45 +01:00
|
|
|
// Check for error
|
2016-02-05 17:47:53 +01:00
|
|
|
if(requestResultObject.status!==0){
|
|
|
|
//alert(result.data)
|
2016-02-04 13:20:45 +01:00
|
|
|
$('#failedToLoginAlert').show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$('#loginModal').modal('hide');
|
|
|
|
}
|
2016-02-05 17:47:53 +01:00
|
|
|
|
2016-02-04 13:20:45 +01:00
|
|
|
// Reset button state
|
2016-02-03 16:59:04 +01:00
|
|
|
$('#loginButton').show();
|
2016-02-04 13:20:45 +01:00
|
|
|
$('#loadingLoginButton').hide();
|
2016-02-05 17:47:53 +01:00
|
|
|
},function(response){
|
|
|
|
|
|
|
|
$('#failedToLoginAlert').show();
|
2016-02-03 17:16:36 +01:00
|
|
|
|
2016-02-05 17:47:53 +01:00
|
|
|
// Reset button state
|
|
|
|
$('#loginButton').show();
|
|
|
|
$('#loadingLoginButton').hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-02-03 16:59:04 +01:00
|
|
|
|
|
|
|
});
|
2016-02-04 13:20:45 +01:00
|
|
|
});
|