diff --git a/client/index.html b/client/index.html index a4845e8..013b1b4 100644 --- a/client/index.html +++ b/client/index.html @@ -71,6 +71,9 @@ + + + @@ -79,7 +82,8 @@ - + + diff --git a/client/js/app.js b/client/js/app.js index 0e9c423..96997eb 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -15,4 +15,7 @@ mainApp.config(['$routeProvider', function($routeProvider){ }).otherwise({ redirectTo: '/home' }); -}]); \ No newline at end of file +}]); + + + diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 07f1d19..3447ab1 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -3,24 +3,27 @@ * Represents a book. * @constructor */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) +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(); - + $('#loginButton').click(function(){ $('#loginButton').hide(); $('#loadingLoginButton').show(); $('#failedToLoginAlert').hide(); - var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); + 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); @@ -31,21 +34,23 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) } else { $('#loginModal').modal('hide'); + sharedProfile.username=username; + sharedProfile.projectname=projectname; + } // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); },function(response){ - $('#failedToLoginAlert').show(); // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); }); - + }); -}); +}]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 42a54d4..4ffdb6b 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -4,25 +4,11 @@ -mainApp.controller('statusCtrl', function ($scope,$interval,$sce) + + +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("Online"); - } - else{ - $scope.connection=$sce.trustAsHtml("Offline"); - } - }, 2000);*/ - - - + $scope.profile=sharedProfile; + - -}); \ No newline at end of file +}]); \ No newline at end of file diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index 59bbcf2..7a08714 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -6,7 +6,7 @@ identity.requestParser = {}; // Parser part -identity.request.login=function($http,username, projectname, password){ +identity.request.login=function($http,username, password,projectname){ var requestResultObject={}; return $http.post('http://localhost.istic-openstack/server/index.php', diff --git a/client/js/services/sharedProfile.js b/client/js/services/sharedProfile.js new file mode 100644 index 0000000..2a5ab83 --- /dev/null +++ b/client/js/services/sharedProfile.js @@ -0,0 +1,11 @@ + + + +mainApp.factory('sharedProfile',[function(){ + var profile={}; + + profile.username="None"; + profile.projectname="None"; + + return profile; +}]); \ No newline at end of file diff --git a/client/partials/login.html b/client/partials/login.html index aa974ab..e0ce876 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -19,7 +19,7 @@