diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-17 18:50:05 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-04-17 18:50:05 +0200 |
| commit | bb1598713c0b6bbe39209c14681c759ab9907edc (patch) | |
| tree | 1483ca31662258cfb570ec736e85d63ae48627cc /client/js/controllers | |
| parent | 968eda48cc8f3af2214e347e83937086c5e93ad4 (diff) | |
Clean code, add comment etc..
Diffstat (limited to 'client/js/controllers')
| -rw-r--r-- | client/js/controllers/home/machineDetails.js | 55 | ||||
| -rw-r--r-- | client/js/controllers/image/image.js | 34 | ||||
| -rw-r--r-- | client/js/controllers/image/upload.js | 108 | ||||
| -rw-r--r-- | client/js/controllers/network/network.js | 1 |
4 files changed, 100 insertions, 98 deletions
diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 371310b..9c8c602 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -3,42 +3,43 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity) -{ +mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity) + { - // Init scope - $scope.machine={}; - $scope.machineIsStarting=false; // For loading icon + // Init scope + $scope.machine = {}; + $scope.machineIsStarting = false; // For loading icon + // When we need to show details of machine + $scope.$on('showMachineDetailsEvent', function (eventName, machine, axioms) { + $scope.machine = machine; + $scope.axioms = axioms; + $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); + }); - $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ - $scope.machine=machine; - $scope.axioms=axioms; - $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); - }); + // Try to stop or start a machine + $scope.toggleMachineState = function () { + // Display gif + $scope.machineIsStarting = true; + // Fake timeout + $timeout(function () { + $scope.machineIsStarting = false; + }, 3000); + $timeout(function () { + $scope.machine.online = !$scope.machine.online; - $scope.toggleMachineState=function(){ - // Display gif - $scope.machineIsStarting=true; + }, 3000); - // Fake timeout - $timeout(function(){ - $scope.machineIsStarting=false; - }, 3000); - $timeout(function(){ - $scope.machine.online=!$scope.machine.online; - }, 3000); + }; - - }; + // Apply modifications + $scope.applyModifications = function () { + //Todo + }; - $scope.applyModifications=function(){ - //Todo - } - -}]); + }]); diff --git a/client/js/controllers/image/image.js b/client/js/controllers/image/image.js index d9a9c06..d0578d7 100644 --- a/client/js/controllers/image/image.js +++ b/client/js/controllers/image/image.js @@ -4,23 +4,21 @@ * @param {$scope} $scope The $scope service from angular */ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity) -{ + { - var callbackTest=function(){ - $scope.images=Image.getData().images; - Loading.stop(); - }; + // Update view + var callMeAfterGetImage = function () { + $scope.images = Image.getData().images; + Loading.stop(); + }; - - if(Identity.isAlreadyLogin()){ - - if(Image.getData().images==null){ - Loading.start(); - Image.getImages(callbackTest); - } - else{ - callbackTest(); - } - - } -}]); + // If user is login try to retrieve data + if (Identity.isAlreadyLogin()) { + if (Image.getData().images == null) { + Loading.start(); + Image.getImages(callMeAfterGetImage); + } else { + callMeAfterGetImage(); + } + } + }]); diff --git a/client/js/controllers/image/upload.js b/client/js/controllers/image/upload.js index d9587d0..6737269 100644 --- a/client/js/controllers/image/upload.js +++ b/client/js/controllers/image/upload.js @@ -3,58 +3,60 @@ * * @param {$scope} $scope The $scope service from angular */ -mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity,upload) -{ +mainApp.controller('uploadImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload) + { /*$scope.uploader = new FileUploader({ - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564' - }); - $scope.uploader.url='../server/index.php' - $scope.uploader.alias='file_name' - $scope.uploader.formData={ - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564' - } - */ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + }); + $scope.uploader.url='../server/index.php' + $scope.uploader.alias='file_name' + $scope.uploader.formData={ + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564' + } + */ - $scope.doUpload = function () { - console.log($('#imageToUpload').prop('files')[0]); - Image.uploadImage($('#imageToUpload').prop('files')[0], function(){alert("done")}) - /*$("#drop-area-div").dmUploader({ - extraData: { - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564'}, - url:"../server/index.php" - }); - */ - - /*upload({ - url: '../server/index.php', - method: 'POST', - data: { - "token" : Identity.getToken(), - "task" : "image", - 'action':'uploadImage', - 'id':'6564', - "file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending. - } - }).then( - function (response) { - console.log(response.data); // will output whatever you choose to return from the server on a successful upload - }, - function (response) { - console.error(response); // Will return if status code is above 200 and lower than 300, same as $http - } - );*/ - - - }; - - $scope.token=Identity.getToken(); -}]); + $scope.doUpload = function () { + console.log($('#imageToUpload').prop('files')[0]); + Image.uploadImage($('#imageToUpload').prop('files')[0], function () { + alert("done") + }) + /*$("#drop-area-div").dmUploader({ + extraData: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564'}, + url:"../server/index.php" + }); + */ + + /*upload({ + url: '../server/index.php', + method: 'POST', + data: { + "token" : Identity.getToken(), + "task" : "image", + 'action':'uploadImage', + 'id':'6564', + "file_name": $scope.myFile, // a jqLite type="file" element, upload() will extract all the files from the input and put them into the FormData object before sending. + } + }).then( + function (response) { + console.log(response.data); // will output whatever you choose to return from the server on a successful upload + }, + function (response) { + console.error(response); // Will return if status code is above 200 and lower than 300, same as $http + } + );*/ + + + }; + + $scope.token = Identity.getToken(); + }]); diff --git a/client/js/controllers/network/network.js b/client/js/controllers/network/network.js index 7264aec..f600f83 100644 --- a/client/js/controllers/network/network.js +++ b/client/js/controllers/network/network.js @@ -5,4 +5,5 @@ */ mainApp.controller('networkCtrl', function ($scope) { + });
\ No newline at end of file |
