diff options
| author | root <root@kabir-PC> | 2016-02-23 20:34:59 +0100 |
|---|---|---|
| committer | root <root@kabir-PC> | 2016-02-23 20:34:59 +0100 |
| commit | d2f5ae5c83ef5bc41cf430ace79769459b4acbf8 (patch) | |
| tree | b48882db52687bdd64a398c7d1844d05dbc01343 /client/js/controllers/login.js | |
| parent | 1eff9ee90bf26127463cae0ae2cb2e1951527591 (diff) | |
| parent | ff1832adcfe10fadb6cbf738c874611f77f6dd43 (diff) | |
Merge branch 'develop' of https://github.com/manzerbredes/istic-openstack into othmane
Diffstat (limited to 'client/js/controllers/login.js')
| -rw-r--r-- | client/js/controllers/login.js | 75 |
1 files changed, 48 insertions, 27 deletions
diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..829fc1d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,39 +1,60 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ /** - * Represents a book. - * @constructor + * 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 {Identity} The Identity service + */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce) +mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); - + // Check for login and define default states + if(!Identity.isAlreadyLogin()){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + } + $scope.$on('logoutEvent', function(){ + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + }); + + $('#loadingLoginButton').hide(); + $('#failedToLoginAlert').hide(); + - $('#loginButton').click(function(){ + $scope.loginAction=function(){ + + // Begin login state for template $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); - + // Get data from templates + var username=$("#loginFormUsername").val(); + var password=$("#loginFormPassword").val(); + var projectname=$("#loginFormProjectname").val(); + + // Function to call to handle result + var responseCallback=function(response){ + + if(response.status!==0){ + // Set reason of fail + $scope.failReason=response.failReason; - $interval( - function() - { - $('#failedToLoginAlert').show(); + // Display the error + $('#failedToLoginAlert').show(); + } + else { + // Else the user is online ! + $('#loginModal').modal('hide'); + } + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - - - - }); -}) + $('#loadingLoginButton').hide(); + } + + // Try to login + Identity.login(username, password, projectname, responseCallback); + }; + +}]); |
