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') 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 96094547dd793868092dda4c2699a839287fa175 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 14:51:50 +0100 Subject: Add image view, controller. --- client/index.html | 1 + client/js/app.js | 8 ++++++-- client/js/controllers/image/image.js | 9 +++++++++ client/partials/home/home.html | 12 ++++++++++++ client/partials/home/main.html | 12 ------------ client/partials/image/image.html | 8 ++++++++ client/partials/menu.html | 3 ++- client/partials/network/main.html | 8 -------- client/partials/network/network.html | 8 ++++++++ 9 files changed, 46 insertions(+), 23 deletions(-) create mode 100644 client/js/controllers/image/image.js create mode 100644 client/partials/home/home.html delete mode 100644 client/partials/home/main.html create mode 100644 client/partials/image/image.html delete mode 100644 client/partials/network/main.html create mode 100644 client/partials/network/network.html (limited to 'client') diff --git a/client/index.html b/client/index.html index 48ea4a0..a06994c 100644 --- a/client/index.html +++ b/client/index.html @@ -89,6 +89,7 @@ + diff --git a/client/js/app.js b/client/js/app.js index e2d5b9b..1602e65 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -13,12 +13,16 @@ mainApp.config(['$routeProvider', function($routeProvider){ $routeProvider. when('/home',{ - templateUrl: 'partials/home/main.html', + templateUrl: 'partials/home/home.html', controller: 'homeCtrl' }). when('/network',{ - templateUrl: 'partials/network/main.html', + templateUrl: 'partials/network/network.html', controller: 'networkCtrl' + }). + when('/image',{ + templateUrl: 'partials/image/image.html', + controller: 'imageCtrl' }).otherwise({ redirectTo: '/home' }); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js new file mode 100644 index 0000000..036dec3 --- /dev/null +++ b/client/js/controllers/image/image.js @@ -0,0 +1,9 @@ +/** + * The image controller + * + * @param {$scope} $scope The $scope service from angular + */ +mainApp.controller('imageCtrl', function ($scope) +{ + $scope.title="Test"; +}); diff --git a/client/partials/home/home.html b/client/partials/home/home.html new file mode 100644 index 0000000..f9f8878 --- /dev/null +++ b/client/partials/home/home.html @@ -0,0 +1,12 @@ +
+
+ Home +
+
+ + Pour charger les machines, recharger la page (temporaire)
+ Selectionner une machine: +
{{ machine.name }}
+ +
+
diff --git a/client/partials/home/main.html b/client/partials/home/main.html deleted file mode 100644 index f9f8878..0000000 --- a/client/partials/home/main.html +++ /dev/null @@ -1,12 +0,0 @@ -
-
- Home -
-
- - Pour charger les machines, recharger la page (temporaire)
- Selectionner une machine: -
{{ machine.name }}
- -
-
diff --git a/client/partials/image/image.html b/client/partials/image/image.html new file mode 100644 index 0000000..586f003 --- /dev/null +++ b/client/partials/image/image.html @@ -0,0 +1,8 @@ +
+
+ Image +
+
+ Main Content +
+
diff --git a/client/partials/menu.html b/client/partials/menu.html index dfd5842..a473fd8 100644 --- a/client/partials/menu.html +++ b/client/partials/menu.html @@ -1,4 +1,5 @@ \ No newline at end of file + Images + diff --git a/client/partials/network/main.html b/client/partials/network/main.html deleted file mode 100644 index 8b779be..0000000 --- a/client/partials/network/main.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
- Network -
-
- Main Content -
-
diff --git a/client/partials/network/network.html b/client/partials/network/network.html new file mode 100644 index 0000000..8b779be --- /dev/null +++ b/client/partials/network/network.html @@ -0,0 +1,8 @@ +
+
+ Network +
+
+ Main Content +
+
-- 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') 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 3b569b6d008d5b1936ee04948cf5c1cc08790f39 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Sun, 6 Mar 2016 15:10:34 +0100 Subject: Make some test --- client/js/controllers/home/home.js | 5 +++++ client/js/controllers/image/image.js | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'client') diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js index 18133fa..4402e62 100644 --- a/client/js/controllers/home/home.js +++ b/client/js/controllers/home/home.js @@ -16,6 +16,11 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','I Loading.start(); Compute.pullData(callMeAfterPullData); } + else{ + if(Identity.isAlreadyLogin()){ + callMeAfterPullData(); + } + } Image.getImages(function(){}); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index a8346b3..e298fcc 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -3,11 +3,19 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('imageCtrl', ['$scope', 'Image', function ($scope, Image) +mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', function ($scope, Image, Loading) { var callbackTest=function(){ $scope.images=Image.getData().images; + Loading.stop(); }; - Image.getImages(callbackTest); + if(Image.getData().images==null){ + Loading.start(); + Image.getImages(callbackTest); + } + else{ + callbackTest(); + } + }]); -- cgit v1.2.3