From fa5a48bc3a76b109f6611620b6e56f3024def029 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 17:41:04 +0100 Subject: Correct bugs --- client/js/services/Identity.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'client/js/services') diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index da85ecd..e6a9daf 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ +mainApp.factory('Identity',[ '$http', '$cookies', '$rootScope', function($http, $cookies, $rootScope){ /* Create profile structure to store informations * about current session @@ -51,6 +51,9 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ token=null; profile.username=null; profile.projectname=null; + + // Reload Page + location.reload(); } @@ -95,6 +98,7 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ else{ requestParserResult.failReason="Please check your username, password and project name !"; } + return requestParserResult; }; -- cgit v1.2.3 From 824382b3ea5902d5e5343d2898232e1521565dff Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 20:51:04 +0100 Subject: Clean file name --- client/index.html | 4 ++-- client/js/controllers/home/home.js | 36 ++++++++++++++++++++++++++++++++ client/js/controllers/home/main.js | 36 -------------------------------- client/js/controllers/network/main.js | 8 ------- client/js/controllers/network/network.js | 8 +++++++ client/js/services/Identity.js | 2 +- client/js/services/Loading.js | 15 ++++++------- 7 files changed, 55 insertions(+), 54 deletions(-) create mode 100644 client/js/controllers/home/home.js delete mode 100644 client/js/controllers/home/main.js delete mode 100644 client/js/controllers/network/main.js create mode 100644 client/js/controllers/network/network.js (limited to 'client/js/services') diff --git a/client/index.html b/client/index.html index ca6bbe6..48ea4a0 100644 --- a/client/index.html +++ b/client/index.html @@ -86,9 +86,9 @@ - + - + diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js new file mode 100644 index 0000000..f84f625 --- /dev/null +++ b/client/js/controllers/home/home.js @@ -0,0 +1,36 @@ +/** + * The home controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) +{ + + var callMeAfterPullData=function(data){ + $scope.machines=Compute.getData().machines; + Loading.stop(); + } + + ; + if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ + Loading.start(); + Compute.pullData(callMeAfterPullData); + } + + + + + $scope.raiseShowMachineDetailsEvent=function(id){ + + var callback=function(){ + Loading.stop(); + var data=Compute.getData(); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); + + } + Loading.start(); + Compute.pullMachines(callback); + } + + +}]); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js deleted file mode 100644 index f84f625..0000000 --- a/client/js/controllers/home/main.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * The home controller - * - * @param {$scope} $scope The $scope service from angular - */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) -{ - - var callMeAfterPullData=function(data){ - $scope.machines=Compute.getData().machines; - Loading.stop(); - } - - ; - if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ - Loading.start(); - Compute.pullData(callMeAfterPullData); - } - - - - - $scope.raiseShowMachineDetailsEvent=function(id){ - - var callback=function(){ - Loading.stop(); - var data=Compute.getData(); - $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); - - } - Loading.start(); - Compute.pullMachines(callback); - } - - -}]); diff --git a/client/js/controllers/network/main.js b/client/js/controllers/network/main.js deleted file mode 100644 index 7264aec..0000000 --- a/client/js/controllers/network/main.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 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/network/network.js b/client/js/controllers/network/network.js new file mode 100644 index 0000000..7264aec --- /dev/null +++ b/client/js/controllers/network/network.js @@ -0,0 +1,8 @@ +/** + * 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/services/Identity.js b/client/js/services/Identity.js index e6a9daf..db93e97 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -1,5 +1,5 @@ -mainApp.factory('Identity',[ '$http', '$cookies', '$rootScope', function($http, $cookies, $rootScope){ +mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ /* Create profile structure to store informations * about current session diff --git a/client/js/services/Loading.js b/client/js/services/Loading.js index b12aaa0..db06194 100644 --- a/client/js/services/Loading.js +++ b/client/js/services/Loading.js @@ -1,22 +1,23 @@ -mainApp.factory('Loading',[ '$http', 'Identity', function($http, Identity){ - - - - +mainApp.factory('Loading',[ function(){ + /** + * Display Loading modal + */ var start=function(){ $('#loadingModal').modal({backdrop: 'static', keyboard: false}); }; + /** + * Hide Loading modal + */ var stop=function(){ $('#loadingModal').modal('hide'); } + // Service returns return { start:start, stop:stop }; - - }]); -- cgit v1.2.3 From 3454c71f0523bd6957e10873d0b95bc191b2f283 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 14:42:50 +0100 Subject: Test request --- client/js/controllers/home/home.js | 5 +++-- client/js/services/Image.js | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'client/js/services') diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index f84f625..18133fa 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', function ($scope, Compute, $rootScope, Loading, Identity) +mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image) { var callMeAfterPullData=function(data){ @@ -17,7 +17,8 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I Compute.pullData(callMeAfterPullData); } - + + Image.getImages(function(){}); $scope.raiseShowMachineDetailsEvent=function(id){ diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 23b33a8..eccd4af 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -4,16 +4,22 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ var parseUploadImageAnswer=function(response, failedToSendRequest){ - + console.log(response.data.Images[0]) }; var getImages=function(callback){ var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Image"})); + $.param({"token" : Identity.getToken(), "task" : "image", 'action':'listImage'})); + + // Wait and handle the response + result.then(function (response){ + callback(parseUploadImageAnswer(response, false)); + },function(response){ + callback(parseUploadImageAnswer(response, true)); + }); - }; @@ -21,7 +27,7 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { - uploadImage: uploadImage + getImages:getImages }; -- cgit v1.2.3 From b0b2dc9a6451fc1a2d41b255600094da1ece6485 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 15:04:47 +0100 Subject: Avalaible images can be display --- client/js/controllers/image/image.js | 10 +++++++--- client/js/services/Image.js | 29 +++++++++++++++++++++++++++-- client/partials/image/image.html | 8 +++++--- 3 files changed, 39 insertions(+), 8 deletions(-) (limited to 'client/js/services') diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index 036dec3..a8346b3 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,7 +3,11 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', function ($scope) +mainApp.controller('imageCtrl', ['$scope', 'Image', function ($scope, Image) { - $scope.title="Test"; -}); + var callbackTest=function(){ + $scope.images=Image.getData().images; + }; + + Image.getImages(callbackTest); +}]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index eccd4af..2e8c56f 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -1,10 +1,31 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ + var data={}; + data.images=null; var parseUploadImageAnswer=function(response, failedToSendRequest){ - console.log(response.data.Images[0]) + + // Defined return object + var requestParserResult={}; + requestParserResult.status=1; + requestParserResult.failReason=null; + + + if (typeof response.data.Images !== 'undefined') { + // Set status code + requestParserResult.status=0; + data.images=response.data.Images; + + } + else if(failedToSendRequest){ + requestParserResult.failReason="Failed to send request"; + } + else{ + requestParserResult.failReason="Error"; + } + return requestParserResult; }; @@ -24,10 +45,14 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ }; + var getData=function(response){ + return data; + }; // Return services objects return { - getImages:getImages + getImages:getImages, + getData:getData }; diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 586f003..8af8af5 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -1,8 +1,10 @@ -
+
- Image + Images disponibles
- Main Content +
+ {{image.name}} +
-- cgit v1.2.3 From 8ad216dedf017f3d6de047a25d08db3b98e16361 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 9 Mar 2016 15:33:52 +0100 Subject: test --- client/index.html | 2 +- client/js/controllers/image/image.js | 6 +++++- client/js/services/Image.js | 20 +++++++++++++++++++- client/partials/image/image.html | 7 +++++++ 4 files changed, 32 insertions(+), 3 deletions(-) (limited to 'client/js/services') diff --git a/client/index.html b/client/index.html index a06994c..7ff859d 100644 --- a/client/index.html +++ b/client/index.html @@ -66,7 +66,7 @@ - + diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index e298fcc..d499acb 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,7 +3,7 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading',function ($scope, Image, Loading) { var callbackTest=function(){ $scope.images=Image.getData().images; @@ -17,5 +17,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, else{ callbackTest(); } + + $scope.doUpload = function () { + Image.uploadImage($scope.myFile,function(){}); + }; }]); diff --git a/client/js/services/Image.js b/client/js/services/Image.js index 2e8c56f..decb5b2 100644 --- a/client/js/services/Image.js +++ b/client/js/services/Image.js @@ -44,6 +44,23 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ }; + var uploadImage=function(fileToUpload, callback) { + + + var result=$http.post('../server/index.php', + $.param({"token" : Identity.getToken(), "task" : "image", 'action':'uploadImage', 'filename':fileToUpload, 'id':'6564'})); + + // Wait and handle the response + result.then(function (response){ + callback(parseUploadImageAnswer(response, false)); + },function(response){ + callback(parseUploadImageAnswer(response, true)); + }); + + + + } + var getData=function(response){ return data; @@ -52,7 +69,8 @@ mainApp.factory('Image',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { getImages:getImages, - getData:getData + getData:getData, + uploadImage:uploadImage }; diff --git a/client/partials/image/image.html b/client/partials/image/image.html index 8af8af5..3f597fb 100644 --- a/client/partials/image/image.html +++ b/client/partials/image/image.html @@ -6,5 +6,12 @@
{{image.name}}
+
+ + +
+ + +
-- cgit v1.2.3 From 57006dba22e26273b6bcb75fff73522fb5f216f8 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 20 Mar 2016 11:23:06 +0100 Subject: Add login check --- client/js/controllers/home/home.js | 36 +++++++++++++++------------- client/js/controllers/home/machineDetails.js | 7 +++--- client/js/controllers/image/image.js | 24 +++++++++++-------- client/js/controllers/status.js | 1 + client/js/services/Identity.js | 9 ++++--- 5 files changed, 44 insertions(+), 33 deletions(-) (limited to 'client/js/services') diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 4402e62..2b355b1 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -8,23 +8,9 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I var callMeAfterPullData=function(data){ $scope.machines=Compute.getData().machines; - Loading.stop(); - } - - ; - if(Compute.getData().machines == null && Identity.isAlreadyLogin()){ - Loading.start(); - Compute.pullData(callMeAfterPullData); - } - else{ - if(Identity.isAlreadyLogin()){ - callMeAfterPullData(); - } - } - + Loading.stop(); + }; - Image.getImages(function(){}); - $scope.raiseShowMachineDetailsEvent=function(id){ @@ -32,11 +18,27 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I Loading.stop(); var data=Compute.getData(); $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); - + } Loading.start(); Compute.pullMachines(callback); } + + + + if(Identity.isAlreadyLogin()){ + if(Compute.getData().machines == null{ + Loading.start(); + Compute.pullData(callMeAfterPullData); + } + else{ + if(Identity.isAlreadyLogin()){ + callMeAfterPullData(); + } + } + Image.getImages(function(){}); + } + }]); diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index c015eaa..371310b 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -3,9 +3,10 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) +mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity) { + // Init scope $scope.machine={}; $scope.machineIsStarting=false; // For loading icon @@ -27,7 +28,7 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ $scope.machineIsStarting=false; }, 3000); $timeout(function(){ - $scope.machine.online=!$scope.machine.online; + $scope.machine.online=!$scope.machine.online; }, 3000); @@ -37,7 +38,7 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ $scope.applyModifications=function(){ //Todo } - + }]); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index d499acb..b0b162b 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,23 +3,27 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading',function ($scope, Image, Loading) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity) { + var callbackTest=function(){ $scope.images=Image.getData().images; - Loading.stop(); + Loading.stop(); }; - if(Image.getData().images==null){ - Loading.start(); - Image.getImages(callbackTest); - } - else{ - callbackTest(); - } - $scope.doUpload = function () { Image.uploadImage($scope.myFile,function(){}); }; + if(Identity.isAlreadyLogin()){ + + if(Image.getData().images==null){ + Loading.start(); + Image.getImages(callbackTest); + } + else{ + callbackTest(); + } + + } }]); diff --git a/client/js/controllers/status.js b/client/js/controllers/status.js index 6f398ad..b4a5dd9 100644 --- a/client/js/controllers/status.js +++ b/client/js/controllers/status.js @@ -9,6 +9,7 @@ mainApp.controller('statusCtrl', ['$scope','Identity', '$rootScope', function ($scope, Identity, $rootScope) { + // Give profile to model $scope.profile=Identity.getProfile(); diff --git a/client/js/services/Identity.js b/client/js/services/Identity.js index db93e97..f9d1df4 100644 --- a/client/js/services/Identity.js +++ b/client/js/services/Identity.js @@ -27,9 +27,12 @@ mainApp.factory('Identity',[ '$http', '$cookies', function($http, $cookies){ && typeof tokenPart_1InCookie !== 'undefined' ){ - // If yes, put it into variables - angular.extend(profile, profileInCookie); - token=tokenPart_0InCookie+tokenPart_1InCookie; + if(token!==null){ + // If yes, put it into variables + angular.extend(profile, profileInCookie); + token=tokenPart_0InCookie+tokenPart_1InCookie; + + } // Return I'm Login return true; -- cgit v1.2.3