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

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-02-03 18:57:20 +01:00
/**
2016-02-06 12:10:04 +01:00
* 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
2016-02-03 18:57:20 +01:00
*/
mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity)
{
// Define default states
$('#loginModal').modal({backdrop: 'static', keyboard: false});
$('#loadingLoginButton').hide();
$('#failedToLoginAlert').hide();
2016-02-05 19:35:38 +01:00
$('#loginButton').click(function(){
2016-02-05 17:47:53 +01:00
$('#loginButton').hide();
$('#loadingLoginButton').show();
$('#failedToLoginAlert').hide();
2016-02-05 19:35:38 +01:00
var username=$("#loginFormUsername").val();
var password=$("#loginFormPassword").val();
var projectname=$("#loginFormProjectname").val();
var result=Identity.login(username, password, projectname);
2016-02-05 17:47:53 +01:00
result.then(function (response){
// Parser result
2016-02-10 19:27:28 +01:00
var response=Identity.getResponse();
2016-02-05 17:47:53 +01:00
// Check for error
2016-02-10 19:27:28 +01:00
if(response.status!==0){
$('#failedToLoginAlert').show();
}
else {
2016-02-10 17:55:13 +01:00
$('#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();
});
2016-02-05 19:35:38 +01:00
2016-02-05 17:47:53 +01:00
});
2016-02-05 19:35:38 +01:00
}]);