diff options
Diffstat (limited to 'client/js/controllers')
| -rw-r--r-- | client/js/controllers/home/main.js | 18 | ||||
| -rw-r--r-- | client/js/controllers/login.js | 75 | ||||
| -rw-r--r-- | client/js/controllers/network/main.js | 9 | ||||
| -rw-r--r-- | client/js/controllers/status.js | 38 |
4 files changed, 80 insertions, 60 deletions
diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index 2898de2..d25bfad 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -1,11 +1,17 @@ -/* - * home Controller +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular */ +mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) +{ + var updatePage=function(){ + // TODO Update graph etc... + } -mainApp.controller('homeCtrl', function ($scope) -{ - + // Retrieve all Data + Compute.pullData(updatePage); -});
\ No newline at end of file +}]); 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); + }; + +}]); 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..e01df34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -1,28 +1,22 @@ -/* - * mainApp Controller - */ - -mainApp.controller('statusCtrl', function ($scope,$interval,$sce) +/** + * The status controller + * + * @param {$scope} $scope The $scope service from angular + * @param {Identity} The Identity service + */ +mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { - $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);*/ + // Give profile to model + $scope.profile=Identity.profile; + + // Function to logout + $scope.logout=function(){ + Identity.logout(); + $rootScope.$broadcast('logoutEvent'); + }; - - -});
\ No newline at end of file +}]); |
