istic-openstack/client/js/controllers/login.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

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)
{
// Define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false});
$('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide();
$('#loginButton').click(function(){
2016-02-05 17:47:53 +01:00
$('#loginButton').hide();
$('#loadingLoginButton').show();
$('#failedToLoginAlert').hide();
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);
// Check for error
2016-02-05 17:47:53 +01:00
if(requestResultObject.status!==0){
//alert(result.data)
$('#failedToLoginAlert').show();
}
else {
$('#loginModal').modal('hide');
}
2016-02-05 17:47:53 +01:00
// Reset button state
$('#loginButton').show();
$('#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();
});
});
});