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/js/app.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'client/js/app.js') 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 +}]); + + + -- cgit v1.2.3 From bd81674a85677378b8a6a167439cac92c807dc23 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sat, 6 Feb 2016 12:10:04 +0100 Subject: Add doc --- client/js/app.js | 9 ++++++-- client/js/controllers/home/main.js | 9 ++++---- client/js/controllers/login.js | 8 +++++-- client/js/controllers/network/main.js | 9 ++++---- client/js/controllers/status.js | 12 +++++------ client/js/requests/identity.js | 40 +++++++++++++++++++++++++++-------- client/js/services/sharedProfile.js | 6 ++++-- 7 files changed, 62 insertions(+), 31 deletions(-) (limited to 'client/js/app.js') diff --git a/client/js/app.js b/client/js/app.js index 96997eb..451df66 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -1,8 +1,13 @@ -// Declare main app +/** + * The main app module instance + * @type angular.module.angular-1_3_6_L1749.moduleInstance + */ var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']); - +/** + * Configure the router + */ mainApp.config(['$routeProvider', function($routeProvider){ $routeProvider. when('/home',{ 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 3447ab1..751bd09 100644 --- a/client/js/controllers/login.js +++ b/client/js/controllers/login.js @@ -1,7 +1,11 @@ /** - * 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', ['$scope','$sce','$http', 'sharedProfile', function ($scope,$sce, $http, sharedProfile) { 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 4ffdb6b..ce6882e 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -1,11 +1,11 @@ -/* - * mainApp Controller - */ - - - +/** + * 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.profile=sharedProfile; diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index d34af53..b2c7273 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -1,21 +1,43 @@ -// Make Namespace +/** + * Client Identity Module + * @namespace identity + */ var identity = {}; -identity.request = {}; // Request part -identity.requestParser = {}; // Parser part - - -identity.request.login=function($http,username, password,projectname){ - var requestResultObject={}; - +/** + * Contain all request who can be send with http request + * @namespace request + */ +identity.request = {}; + +/** + * Contain parser for result of request made by {@link identity.request} + * @namespace request + */ +identity.requestParser = {}; + + +/** + * + * @param {object} $http Angular $http service + * @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 + */ +identity.request.login=function($http,username, password,projectname){ return $http.post('../server/index.php', $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}), {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}}); }; - +/** + * + * @param {string} response The response to parse + * @returns {requestParserResult} Formated data + */ identity.requestParser.parseLoginAnswer=function(response){ var requestParserResult={}; diff --git a/client/js/services/sharedProfile.js b/client/js/services/sharedProfile.js index 2a5ab83..6e78cf6 100644 --- a/client/js/services/sharedProfile.js +++ b/client/js/services/sharedProfile.js @@ -1,6 +1,8 @@ - - +/** + * The sharedProfile service + * It's used to shared the profile between controller + */ mainApp.factory('sharedProfile',[function(){ var profile={}; -- cgit v1.2.3 From cfe4616c4af86743aa6771f427be98dc4412433b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 7 Feb 2016 11:10:44 +0100 Subject: Configure http provider --- client/js/app.js | 12 ++++++++++-- client/js/requests/identity.js | 3 +-- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'client/js/app.js') diff --git a/client/js/app.js b/client/js/app.js index 451df66..90fae89 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -6,9 +6,11 @@ var mainApp=angular.module("mainApp",['ngRoute', 'ngSanitize']); /** - * Configure the router + * Configure routeProvider */ mainApp.config(['$routeProvider', function($routeProvider){ + + $routeProvider. when('/home',{ templateUrl: 'partials/home/main.html', @@ -22,5 +24,11 @@ mainApp.config(['$routeProvider', function($routeProvider){ }); }]); - +/** + * Configure httpProvider + */ +mainApp.config(['$httpProvider', function($httpProvider){ + $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + +}]); diff --git a/client/js/requests/identity.js b/client/js/requests/identity.js index b2c7273..be3f4f8 100644 --- a/client/js/requests/identity.js +++ b/client/js/requests/identity.js @@ -28,8 +28,7 @@ identity.requestParser = {}; */ identity.request.login=function($http,username, password,projectname){ return $http.post('../server/index.php', - $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname}), - {headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}}); + $.param({"task" : "Authenticate", "user" : username, "password" : password, "project" : projectname})); }; -- 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/app.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