From 784b25754c6b168a6c015aa39837c34339c88444 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 4 Feb 2016 13:20:45 +0100 Subject: Add error checking, add method handler for login --- client/js/controllers/login.js | 48 ++++++++++++++++++++++-------------------- client/js/requests/errors.js | 14 ++++++++++++ client/js/requests/identity.js | 9 ++++++-- 3 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 client/js/requests/errors.js (limited to 'client/js') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 2f74414..d08a9f2 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,8 +1,3 @@ -/* - * 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. @@ -10,30 +5,37 @@ */ mainApp.controller('loginCtrl', function ($scope,$interval,$sce) { - // 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').hide(); - $('#loadingLoginButton').show(); - $('#failedToLoginAlert').hide(); + $('#loginButton').click(function(){ + $('#loginButton').hide(); + $('#loadingLoginButton').show(); + $('#failedToLoginAlert').hide(); - + var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); - $interval( - function() - { - $('#failedToLoginAlert').show(); + $interval( + function() + { + // Check for error + if(!errors.checkForLogin(result)){ + $('#failedToLoginAlert').show(); + } + else { + $('#loginModal').modal('hide'); + } + + // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - - }, 2000,1); - + $('#loadingLoginButton').hide(); + }, 2000,1); + }); -}) +}); diff --git a/client/js/requests/errors.js b/client/js/requests/errors.js new file mode 100644 index 0000000..cc9389a --- /dev/null +++ b/client/js/requests/errors.js @@ -0,0 +1,14 @@ +/* + * 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. + */ + + +var errors={}; + + +errors.checkForLogin=function(result){ + // TODO + return true; +}; \ No newline at end of file diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index cad1261..61f06ed 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -1,9 +1,14 @@ // Make Namespace -var identity = {} ; - +var identity = {}; +identity.login=function(username, projectname, password){ + + // Todo + + return "tokens"; +}; -- cgit v1.2.3 From a16df328c05b3ac005a3c05237a069786b8d5d6f Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Fri, 5 Feb 2016 17:47:53 +0100 Subject: Make login part dynamic --- client/index.html | 1 - client/js/controllers/login.js | 38 ++++++++++++++++++------------ client/js/requests/errors.js | 14 ------------ client/js/requests/identity.js | 52 +++++++++++++++--------------------------- 4 files changed, 42 insertions(+), 63 deletions(-) delete mode 100644 client/js/requests/errors.js (limited to 'client/js') diff --git a/client/index.html b/client/index.html index fe53069..a4845e8 100644 --- a/client/index.html +++ b/client/index.html @@ -73,7 +73,6 @@ - diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index d08a9f2..07f1d19 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -3,7 +3,7 @@ * Represents a book. * @constructor */ -mainApp.controller('loginCtrl', function ($scope,$interval,$sce) +mainApp.controller('loginCtrl', function ($scope,$interval,$sce, $http) { // Define default states $('#loginModal').modal({backdrop: 'static', keyboard: false}); @@ -12,30 +12,40 @@ mainApp.controller('loginCtrl', function ($scope,$interval,$sce) $('#loginButton').click(function(){ - $('#loginButton').hide(); - $('#loadingLoginButton').show(); - $('#failedToLoginAlert').hide(); - - var result=identity.login($("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); + $('#loginButton').hide(); + $('#loadingLoginButton').show(); + $('#failedToLoginAlert').hide(); - - $interval( - function() - { + var result=identity.request.login($http,$("#loginFormUsername").val(), $("#loginFormProjectname").val(), $("#loginFormPassword").val()); + + + result.then(function (response){ + + // Parser result + var requestResultObject=identity.requestParser.parseLoginAnswer(response); + // Check for error - if(!errors.checkForLogin(result)){ + if(requestResultObject.status!==0){ + //alert(result.data) $('#failedToLoginAlert').show(); } else { $('#loginModal').modal('hide'); } - + // Reset button state $('#loginButton').show(); $('#loadingLoginButton').hide(); - }, 2000,1); - + },function(response){ + + $('#failedToLoginAlert').show(); + // Reset button state + $('#loginButton').show(); + $('#loadingLoginButton').hide(); + }); + + }); }); diff --git a/client/js/requests/errors.js b/client/js/requests/errors.js deleted file mode 100644 index cc9389a..0000000 --- a/client/js/requests/errors.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - * 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. - */ - - -var errors={}; - - -errors.checkForLogin=function(result){ - // TODO - return true; -}; \ No newline at end of file diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index 61f06ed..59bbcf2 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -1,47 +1,31 @@ // Make Namespace var identity = {}; +identity.request = {}; // Request part +identity.requestParser = {}; // Parser part -identity.login=function(username, projectname, password){ - - // Todo + +identity.request.login=function($http,username, projectname, password){ + var requestResultObject={}; - return "tokens"; + return $http.post('http://localhost.istic-openstack/server/index.php', + $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}), + {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}}); }; -/* -mainApp.controller('identityCtrl', function($scope, $http) { - - $scope.identityFormData = {}; - - $scope.processForm = function() { - - $http({ - method : 'POST', - url : 'http://148.60.11.31/', - data : $.param($scope.identityFormData), - headers : { 'Content-Type': 'application/x-www-form-urlencoded' } - }) - .success(function(data) { - console.log(data); - - if (!data.success) { - // if not successful, bind errors to error variables - //$scope.errorName = data.errors.name; - //$scope.errorSuperhero = data.errors.superheroAlias; - } else { - // if successful, bind success message to message - //$scope.message = data.message; - } - }); - }; - - +identity.requestParser.parseLoginAnswer=function(response){ + var requestParserResult={}; + + requestParserResult.status=0; + requestParserResult.data=response.data; -});*/ - + // TODO + + + return requestParserResult; +}; -- cgit v1.2.3 From cca5df968e3598b07ee81c1f7f2680f5b9120ec3 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Fri, 5 Feb 2016 19:35:38 +0100 Subject: Add sharedProfile service --- client/index.html | 6 +++++- client/js/app.js | 5 ++++- client/js/controllers/login.js | 19 ++++++++++++------- client/js/controllers/status.js | 24 +++++------------------- client/js/requests/identity.js | 2 +- client/js/services/sharedProfile.js | 11 +++++++++++ client/partials/login.html | 2 +- client/partials/nav.html | 4 ++-- 8 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 client/js/services/sharedProfile.js (limited to 'client/js') 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) -{ - $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);*/ - +mainApp.controller('statusCtrl', ['$scope','sharedProfile', function ($scope, sharedProfile) +{ + $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 @@
+ placeholder="Project Name" type="text" ng-model="identityFormData.project">
diff --git a/client/partials/nav.html b/client/partials/nav.html index f412597..786c53b 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -18,8 +18,8 @@
- \ No newline at end of file + -- cgit v1.2.3 From bfac8211479dbeddd16d2044a4cf41d3ea592016 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 17:55:13 +0100 Subject: Optimize Identity --- client/js/controllers/login.js | 5 +---- client/js/services/Identity.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'client/js') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index e9308b8..106e889 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -37,10 +37,7 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#failedToLoginAlert').show(); } else { - $('#loginModal').modal('hide'); - Identity.profile.username=username; - Identity.profile.projectname=projectname; - + $('#loginModal').modal('hide'); } // Reset button state diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 2164592..7021003 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,11 +1,15 @@ mainApp.factory('Identity',[ '$http', function($http){ - var profile={}; - profile.username="None"; - profile.projectname="None"; + /* Create profile structure */ + var profile={}; + profile.username="Undefined"; + profile.projectname="Undefined"; + profile.token=""; + /** + * Function to connect to OpenStack * * @param {object} $http Angular $http service * @param {string} username The user name @@ -14,6 +18,9 @@ mainApp.factory('Identity',[ '$http', function($http){ * @returns {promise} The result of the request */ var login=function(username, password,projectname){ + profile.username=username; + profile.projectname=projectname; + return $http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); }; @@ -29,7 +36,7 @@ mainApp.factory('Identity',[ '$http', function($http){ requestParserResult.status=0; requestParserResult.data=response.data; - + profile.token="Un Token"; // TODO @@ -39,6 +46,7 @@ mainApp.factory('Identity',[ '$http', function($http){ + // Return services objects return { login: login, parseLoginAnswer: parseLoginAnswer, -- cgit v1.2.3 From 0c985435949c1b7cd034d70559f8bcce744418de Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 19:27:28 +0100 Subject: Simplify Identity... --- client/js/controllers/login.js | 4 ++-- client/js/services/Identity.js | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'client/js') diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 106e889..60eb52f 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -29,10 +29,10 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s result.then(function (response){ // Parser result - var requestResultObject=Identity.parseLoginAnswer(response); + var response=Identity.getResponse(); // Check for error - if(requestResultObject.status!==0){ + if(response.status!==0){ $('#failedToLoginAlert').show(); } diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 7021003..509f800 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -7,6 +7,8 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.projectname="Undefined"; profile.token=""; + /* Will contain the result of the $http request */ + var $httpResponse; /** * Function to connect to OpenStack @@ -21,8 +23,9 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.username=username; profile.projectname=projectname; - return $http.post('../server/index.php', + $httpResponse=$http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); + return $httpResponse; }; @@ -45,11 +48,15 @@ mainApp.factory('Identity',[ '$http', function($http){ }; + var getResponse=function(){ + return parseLoginAnswer($httpResponse); + } + // Return services objects return { login: login, - parseLoginAnswer: parseLoginAnswer, + getResponse: getResponse, profile: profile }; -- cgit v1.2.3 From 3f83cae4178226084dcbf1e826271a04cc97086d Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 10 Feb 2016 21:45:52 +0100 Subject: Login Service complete ! --- client/index.html | 1 + client/js/controllers/login.js | 41 ++++++++++----------- client/js/controllers/status.js | 2 +- client/js/services/Identity.js | 82 +++++++++++++++++++++++------------------ client/js/services/Image.js | 25 +++++++++++++ client/partials/login.html | 4 +- 6 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 client/js/services/Image.js (limited to 'client/js') diff --git a/client/index.html b/client/index.html index 10eceb3..ab5f00f 100644 --- a/client/index.html +++ b/client/index.html @@ -73,6 +73,7 @@ + diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 60eb52f..6358a6d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -4,7 +4,7 @@ * @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 + * @param {Identity} The Identity service */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) @@ -16,42 +16,39 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s $('#loginButton').click(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(); - var result=Identity.login(username, password, projectname); - - - result.then(function (response){ - // Parser result - var response=Identity.getResponse(); - - // Check for error + // Function to call to handle result + var responseCallback=function(response){ + if(response.status!==0){ - + // Set reason of fail + $scope.failReason=response.failReason; + + // Display the error $('#failedToLoginAlert').show(); } else { + // Else the user is online ! $('#loginModal').modal('hide'); } // Reset button state $('#loginButton').show(); - $('#loadingLoginButton').hide(); - },function(response){ - $('#failedToLoginAlert').show(); - - // Reset button state - $('#loginButton').show(); - $('#loadingLoginButton').hide(); - }); - - - - }); + $('#loadingLoginButton').hide(); + } + + // Try to login + Identity.login(username, password, projectname, responseCallback); + }); + }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 7425244..2930e34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -4,7 +4,7 @@ * The status controller * * @param {$scope} $scope The $scope service from angular - * @param {sharedProfile} sharedProfile The sharedProfile build by ourself + * @param {Identity} The Identity service */ mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) { diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 509f800..4c8919c 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,14 +1,42 @@ mainApp.factory('Identity',[ '$http', function($http){ - /* Create profile structure */ + /* Create profile structure to store informations + * about current session + */ var profile={}; - profile.username="Undefined"; - profile.projectname="Undefined"; - profile.token=""; + profile.username=null; + profile.projectname=null; + profile.token=null; + + + /** + * + * @param {string} response The response to parse + * @param {boolean} to check if the request is send or not + * @returns {requestParserResult} Formated data + */ + var parseLoginAnswer=function(response, failedToSendRequest){ + + var requestParserResult={}; + requestParserResult.status=1; + requestParserResult.failReason=null; + + if (typeof response.data.token !== 'undefined') { + requestParserResult.status=0; + profile.token=response.data.token; + } + else if(failedToSendRequest){ + requestParserResult.failReason="Failed to send request"; + } + else{ + requestParserResult.failReason="Please check your username, password and project name !"; + } + + return requestParserResult; + }; + - /* Will contain the result of the $http request */ - var $httpResponse; /** * Function to connect to OpenStack @@ -17,46 +45,28 @@ mainApp.factory('Identity',[ '$http', function($http){ * @param {string} username The user name * @param {string} password The user password * @param {string} projectname The user project name - * @returns {promise} The result of the request + * @param {function} function to call when data is avalaible */ - var login=function(username, password,projectname){ + var login=function(username, password,projectname, callback){ + + // Set profile information (early) profile.username=username; profile.projectname=projectname; - $httpResponse=$http.post('../server/index.php', + var result=$http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); - return $httpResponse; - }; - - /** - * - * @param {string} response The response to parse - * @returns {requestParserResult} Formated data - */ - var parseLoginAnswer=function(response){ - var requestParserResult={}; - - requestParserResult.status=0; - requestParserResult.data=response.data; - profile.token="Un Token"; - - // TODO - - - return requestParserResult; - }; - - - var getResponse=function(){ - return parseLoginAnswer($httpResponse); - } - + // Wait and handle the response + result.then(function (response){ + callback(parseLoginAnswer(response), false); + },function(response){ + callback(parseLoginAnswer(response), true) + }); + }; // Return services objects return { login: login, - getResponse: getResponse, profile: profile }; diff --git a/client/js/services/Image.js b/client/js/services/Image.js new file mode 100644 index 0000000..4cb3590 --- /dev/null +++ b/client/js/services/Image.js @@ -0,0 +1,25 @@ + +mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ + + var httpResponse; + + var uploadImage=function(image){ + + }; + + var parseUploadImageRequest=function(){ + + }; + + var getResponse=function(){ + return parseUploadImageRequest(httpResponse); + }; + + // Return services objects + return { + uploadImage: uploadImage, + getResponse: getResponse + }; + + +}]); diff --git a/client/partials/login.html b/client/partials/login.html index e0ce876..cd7d9ec 100644 --- a/client/partials/login.html +++ b/client/partials/login.html @@ -33,9 +33,9 @@ - \ No newline at end of file + -- cgit v1.2.3 From 7e5db6b5420755a76c1efcd87bf2a61b111b4c09 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 17 Feb 2016 14:01:13 +0100 Subject: Use angular-cookirs --- client/index.html | 3 +- client/js/app.js | 3 +- client/js/controllers/.#status.js | 1 + client/js/controllers/login.js | 16 +++-- client/js/controllers/status.js | 11 ++- client/js/services/Identity.js | 77 +++++++++++++++++++-- client/js/services/Image.js | 21 +++--- client/partials/login.html | 2 +- client/partials/nav.html | 3 +- client/vendors/angularjs/angular-cookies.min.js | 9 +++ server/Test/genTokenOptionsTest.php | 0 server/composer.phar | Bin server/core/App.php | 0 server/core/CoreInterface.php | 0 server/core/Identity.php | 0 server/core/LibOverride/genTokenOptions.php | 0 server/index.php | 0 server/init.php | 0 .../justinrainbow/json-schema/bin/validate-json | 0 19 files changed, 119 insertions(+), 27 deletions(-) create mode 120000 client/js/controllers/.#status.js create mode 100644 client/vendors/angularjs/angular-cookies.min.js mode change 100755 => 100644 server/Test/genTokenOptionsTest.php mode change 100755 => 100644 server/composer.phar mode change 100755 => 100644 server/core/App.php mode change 100755 => 100644 server/core/CoreInterface.php mode change 100755 => 100644 server/core/Identity.php mode change 100755 => 100644 server/core/LibOverride/genTokenOptions.php mode change 100755 => 100644 server/index.php mode change 100755 => 100644 server/init.php mode change 100755 => 100644 server/vendor/justinrainbow/json-schema/bin/validate-json (limited to 'client/js') diff --git a/client/index.html b/client/index.html index ab5f00f..26430f9 100644 --- a/client/index.html +++ b/client/index.html @@ -61,7 +61,7 @@ - + @@ -69,6 +69,7 @@ + diff --git a/client/js/app.js b/client/js/app.js index 90fae89..e2d5b9b 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -3,7 +3,7 @@ * The main app module instance * @type angular.module.angular-1_3_6_L1749.moduleInstance */ -var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']); +var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize', 'ngCookies']); /** * Configure routeProvider @@ -29,6 +29,5 @@ mainApp.config(['$routeProvider', function($routeProvider){ */ mainApp.config(['$httpProvider', function($httpProvider){ $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - }]); diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js new file mode 120000 index 0000000..e6c258f --- /dev/null +++ b/client/js/controllers/.#status.js @@ -0,0 +1 @@ +loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/login.js b/client/js/controllers/login.js index 6358a6d..829fc1d 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -9,14 +9,20 @@ */ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$sce, Identity) { - // Define default states - $('#loginModal').modal({backdrop: 'static', keyboard: false}); + // 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(); @@ -49,6 +55,6 @@ mainApp.controller('loginCtrl', ['$scope','$sce','Identity', function ($scope,$s // Try to login Identity.login(username, password, projectname, responseCallback); - }); + }; }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 2930e34..6bc602a 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -6,9 +6,14 @@ * @param {$scope} $scope The $scope service from angular * @param {Identity} The Identity service */ -mainApp.controller('statusCtrl', ['$scope','Identity', function ($scope, Identity) +mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { $scope.profile=Identity.profile; - - + + $scope.logout=function(){ + Identity.logout(); + $rootScope.$broadcast('logoutEvent'); + + }; + }]); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index 4c8919c..d96b3ab 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', function($http){ +mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ /* Create profile structure to store informations * about current session @@ -9,7 +9,72 @@ mainApp.factory('Identity',[ '$http', function($http){ profile.projectname=null; profile.token=null; +/* var tokenFragment=9; + + var saveTokenInCookies=function(){ + var i=0; + var currentStart=0; + var currentEnd=parseInt(profile.token.length/tokenFragment); + var facto=currentEnd; + + alert("current ren" + currentEnd); + for(i=0;iClose--> - Login + Login diff --git a/client/partials/nav.html b/client/partials/nav.html index 7c34174..3c72844 100644 --- a/client/partials/nav.html +++ b/client/partials/nav.html @@ -32,8 +32,7 @@
  • Informations
  • Settings
  • -
  • Logout -
  • +
  • Logout
  • diff --git a/client/vendors/angularjs/angular-cookies.min.js b/client/vendors/angularjs/angular-cookies.min.js new file mode 100644 index 0000000..d0f126a --- /dev/null +++ b/client/vendors/angularjs/angular-cookies.min.js @@ -0,0 +1,9 @@ +/* + AngularJS v1.5.0 + (c) 2010-2016 Google, Inc. http://angularjs.org + License: MIT +*/ +(function(p,c,n){'use strict';function l(b,a,g){var d=g.baseHref(),k=b[0];return function(b,e,f){var g,h;f=f||{};h=f.expires;g=c.isDefined(f.path)?f.path:d;c.isUndefined(e)&&(h="Thu, 01 Jan 1970 00:00:00 GMT",e="");c.isString(h)&&(h=new Date(h));e=encodeURIComponent(b)+"="+encodeURIComponent(e);e=e+(g?";path="+g:"")+(f.domain?";domain="+f.domain:"");e+=h?";expires="+h.toUTCString():"";e+=f.secure?";secure":"";f=e.length+1;4096 4096 bytes)!");k.cookie=e}}c.module("ngCookies",["ng"]).provider("$cookies",[function(){var b=this.defaults={};this.$get=["$$cookieReader","$$cookieWriter",function(a,g){return{get:function(d){return a()[d]},getObject:function(d){return(d=this.get(d))?c.fromJson(d):d},getAll:function(){return a()},put:function(d,a,m){g(d,a,m?c.extend({},b,m):b)},putObject:function(d,b,a){this.put(d,c.toJson(b),a)},remove:function(a,k){g(a,n,k?c.extend({},b,k):b)}}}]}]);c.module("ngCookies").factory("$cookieStore", +["$cookies",function(b){return{get:function(a){return b.getObject(a)},put:function(a,c){b.putObject(a,c)},remove:function(a){b.remove(a)}}}]);l.$inject=["$document","$log","$browser"];c.module("ngCookies").provider("$$cookieWriter",function(){this.$get=l})})(window,window.angular); +//# sourceMappingURL=angular-cookies.min.js.map diff --git a/server/Test/genTokenOptionsTest.php b/server/Test/genTokenOptionsTest.php old mode 100755 new mode 100644 diff --git a/server/composer.phar b/server/composer.phar old mode 100755 new mode 100644 diff --git a/server/core/App.php b/server/core/App.php old mode 100755 new mode 100644 diff --git a/server/core/CoreInterface.php b/server/core/CoreInterface.php old mode 100755 new mode 100644 diff --git a/server/core/Identity.php b/server/core/Identity.php old mode 100755 new mode 100644 diff --git a/server/core/LibOverride/genTokenOptions.php b/server/core/LibOverride/genTokenOptions.php old mode 100755 new mode 100644 diff --git a/server/index.php b/server/index.php old mode 100755 new mode 100644 diff --git a/server/init.php b/server/init.php old mode 100755 new mode 100644 diff --git a/server/vendor/justinrainbow/json-schema/bin/validate-json b/server/vendor/justinrainbow/json-schema/bin/validate-json old mode 100755 new mode 100644 -- cgit v1.2.3 From d3047bb539a2256cf357784ff49e0ad58e638500 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Thu, 18 Feb 2016 18:06:06 +0100 Subject: Add compute service --- client/index.html | 3 ++- client/js/controllers/home/main.js | 4 ++-- client/js/services/Compute.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 client/js/services/Compute.js (limited to 'client/js') diff --git a/client/index.html b/client/index.html index 26430f9..ba183df 100644 --- a/client/index.html +++ b/client/index.html @@ -75,7 +75,8 @@ - + + diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index e629779..d42e413 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -3,8 +3,8 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', function ($scope) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { -}); \ No newline at end of file +}]); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js new file mode 100644 index 0000000..748510e --- /dev/null +++ b/client/js/services/Compute.js @@ -0,0 +1,30 @@ + +mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + + + // Parser + var parseGetMachinesAnswer=function(response, failedToSendRequest){ + + }; + + + // Get Machine + var getMachines=function(callback){ + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.profile.token, "task" : "Compute"})); + + + + }; + + + + // Return services objects + return { + getMachines: getMachines + }; + + +}]); -- cgit v1.2.3 From 0c31cbdbd4aaf41c5f24f96e1ee0ae79a8baee24 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Mon, 22 Feb 2016 17:14:11 +0100 Subject: Comment and update things --- client/js/services/Identity.js | 56 +++++++++--------------------------------- 1 file changed, 12 insertions(+), 44 deletions(-) (limited to 'client/js') diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index d96b3ab..8ee664c 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -9,56 +9,18 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ profile.projectname=null; profile.token=null; -/* var tokenFragment=9; - - var saveTokenInCookies=function(){ - var i=0; - var currentStart=0; - var currentEnd=parseInt(profile.token.length/tokenFragment); - var facto=currentEnd; - - alert("current ren" + currentEnd); - for(i=0;i Date: Mon, 22 Feb 2016 17:30:25 +0100 Subject: Edit Compute service and home controller --- client/js/controllers/.#status.js | 1 - client/js/controllers/home/main.js | 9 ++++++++- client/js/controllers/status.js | 5 ++++- client/js/services/Compute.js | 14 ++++++++++++-- 4 files changed, 24 insertions(+), 5 deletions(-) delete mode 120000 client/js/controllers/.#status.js (limited to 'client/js') diff --git a/client/js/controllers/.#status.js b/client/js/controllers/.#status.js deleted file mode 120000 index e6c258f..0000000 --- a/client/js/controllers/.#status.js +++ /dev/null @@ -1 +0,0 @@ -loic@Manzerbredes.home.30343:1455008378 \ No newline at end of file diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index d42e413..d25bfad 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -5,6 +5,13 @@ */ mainApp.controller('homeCtrl', [ '$scope', 'Compute', function ($scope, Compute) { - + + + var updatePage=function(){ + // TODO Update graph etc... + } + + // Retrieve all Data + Compute.pullData(updatePage); }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 6bc602a..e01df34 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -8,8 +8,11 @@ */ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { + + // Give profile to model $scope.profile=Identity.profile; - + + // Function to logout $scope.logout=function(){ Identity.logout(); $rootScope.$broadcast('logoutEvent'); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index 748510e..c5c8da9 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,6 +2,10 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ + + var data={}; + data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -13,17 +17,23 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ var getMachines=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param({"token" : Identity.profile.token, "task" : "Compute"})); - }; + + + var pullData=function(callback){ + // TODO call getMachines etc... + } // Return services objects return { getMachines: getMachines + pullData: pullData + data:data }; -- cgit v1.2.3