diff options
Diffstat (limited to 'client/js/controllers')
| -rw-r--r-- | client/js/controllers/home/main.js | 9 | ||||
| -rw-r--r-- | client/js/controllers/login.js | 67 | ||||
| -rw-r--r-- | client/js/controllers/network/main.js | 9 | ||||
| -rw-r--r-- | client/js/controllers/status.js | 34 |
4 files changed, 62 insertions, 57 deletions
diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 2898de2..e629779 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -1,9 +1,8 @@ -/* - * home Controller +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular */ - - - mainApp.controller('homeCtrl', function ($scope) { diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..751bd09 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 {sharedProfile} sharedProfile The sharedProfile service + */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce) +mainApp.controller('loginCtrl', ['$scope','$sce','$http', 'sharedProfile', function ($scope,$sce, $http, sharedProfile) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); - $('#loadingLoginButton').hide(); - $('#failedToLoginAlert').hide(); - + // Define default states + $('#loginModal').modal({backdrop: 'static', keyboard: false}); + $('#loadingLoginButton').hide(); + $('#failedToLoginAlert').hide(); + - $('#loginButton').click(function(){ + $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); + var username=$("#loginFormUsername").val(); + var password=$("#loginFormPassword").val(); + var projectname=$("#loginFormProjectname").val(); + + var result=identity.request.login($http,username, password, projectname); + + result.then(function (response){ + // Parser result + var requestResultObject=identity.requestParser.parseLoginAnswer(response); + + // Check for error + if(requestResultObject.status!==0){ + //alert(result.data) + $('#failedToLoginAlert').show(); + } + else { + $('#loginModal').modal('hide'); + sharedProfile.username=username; + sharedProfile.projectname=projectname; - $interval( - function() - { - $('#failedToLoginAlert').show(); + } + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - + $('#loadingLoginButton').hide(); + },function(response){ + $('#failedToLoginAlert').show(); + + // Reset button state + $('#loginButton').show(); + $('#loadingLoginButton').hide(); + }); + }); -}) +}]); diff --git a/client/js/controllers/network/main.js b/client/js/controllers/network/main.js index 6c916ae..7264aec 100644 --- a/client/js/controllers/network/main.js +++ b/client/js/controllers/network/main.js @@ -1,9 +1,8 @@ -/* - * network Controller +/** + * The network controller + * + * @param {$scope} $scope The $scope service from angular */ - - - mainApp.controller('networkCtrl', function ($scope) { });
\ No newline at end of file diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 42a54d4..ce6882e 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -1,28 +1,14 @@ -/* - * mainApp Controller - */ - -mainApp.controller('statusCtrl', function ($scope,$interval,$sce) +/** + * The status controller + * + * @param {$scope} $scope The $scope service from angular + * @param {sharedProfile} sharedProfile The sharedProfile build by ourself + */ +mainApp.controller('statusCtrl', ['$scope','sharedProfile', function ($scope, sharedProfile) { - $scope.username="John Doe"; - $scope.projectname="Web Server"; - // Update status every 2 seconds - /*$interval(function(){ - var status=identity.fetchStatus(); - $scope.username=status[1]; - $scope.lastconnection=status[2]; - if(status[0] == "1"){ - $scope.connection=$sce.trustAsHtml("<span style=\"color:green;\">Online</span>"); - } - else{ - $scope.connection=$sce.trustAsHtml("<span style=\"color:red;\">Offline</span>"); - } - }, 2000);*/ - - - - + $scope.profile=sharedProfile; + -});
\ No newline at end of file +}]);
\ No newline at end of file |
