From 5ef1c9b8b1ab47b659f512db86e51dacf1bec860 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 20:51:08 +0100 Subject: Edit machineDetails --- client/js/controllers/home/machineDetails.js | 1 + 1 file changed, 1 insertion(+) (limited to 'client/js/controllers/home/machineDetails.js') diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index f84a073..7476c69 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -11,6 +11,7 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ $scope.machine=machine; + console.log(machine); $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); }); -- cgit v1.2.3 From e9108d4b97132e853a71cb1dfbad6cf4bddb599b Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Tue, 1 Mar 2016 22:50:37 +0100 Subject: Finish details machine --- client/js/controllers/home/machineDetails.js | 3 +- client/js/controllers/home/main.js | 6 +-- client/js/services/Compute.js | 64 ++++++++++++++++++++++++++-- client/partials/home/machineDetails.html | 22 ++-------- 4 files changed, 69 insertions(+), 26 deletions(-) (limited to 'client/js/controllers/home/machineDetails.js') diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 7476c69..24fac42 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -9,8 +9,9 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$ $scope.machine={}; $("#waitingForToggleMachine").hide(); - $scope.$on('showMachineDetailsEvent', function(eventName ,machine){ + $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ $scope.machine=machine; + $scope.axioms=axioms; console.log(machine); $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); }); diff --git a/client/js/controllers/home/main.js b/client/js/controllers/home/main.js index b44836b..9d7ddfc 100644 --- a/client/js/controllers/home/main.js +++ b/client/js/controllers/home/main.js @@ -6,19 +6,19 @@ mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', function ($scope, Compute, $rootScope) { - var callMeAfterGetMachines=function(data){ + var callMeAfterPullData=function(data){ $scope.machines=Compute.getData().machines; } - Compute.pullMachines(callMeAfterGetMachines); + Compute.pullData(callMeAfterPullData); $scope.raiseShowMachineDetailsEvent=function(id){ var callback=function(){ var data=Compute.getData(); - $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id]); + $rootScope.$broadcast("showMachineDetailsEvent", data.machines[id], data.axioms); } Compute.pullMachines(callback); diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index e2fb3df..36ddc16 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -5,12 +5,14 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Init data var data={}; data.machines=null; - - + data.axioms={} // Contain static data + data.axioms.ram=[128,512,1024,2048,4096]; + data.axioms.disk=[1,2,5,10,25,50,100,150,200] + data.axioms.images={}; // Retrieve after /** - * Retrieve machine list + * Parse pullMachines answer * @param {response} the server response * @param {boolean} false if the request as been send true else * @return {requestParserResult} the result of parsing @@ -55,14 +57,68 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ callback(parsePullMachinesAnswer(response, true)); }); }; + + + /** + * Parse pullImages answer + * @param {response} the server response + * @param {boolean} false if the request as been send true else + * @return {requestParserResult} the result of parsing + */ + var parsePullImagesAnswer=function(response, failedToSendRequest){ + + // Defined return object + var requestParserResult={}; + requestParserResult.status=1; + requestParserResult.failReason=null; + + + if (typeof response.data.Images !== 'undefined') { + // Set status code + requestParserResult.status=0; + data.axioms.images=response.data.Images; + } + else if(failedToSendRequest){ + requestParserResult.failReason="Failed to send request"; + } + else{ + requestParserResult.failReason="Error"; + } + return requestParserResult; + }; + + + + /** + * Retrieve machine list + * @param {callback} function to call after request complete + */ + var pullImages=function(callback){ + // Send listServers request + var result=$http.post('../server/index.php', + $.param({"token" : Identity.getToken(), "task" : "compute", "action":"listImages"})); + + // Wait and handle the response + result.then(function (response){ + callback(parsePullImagesAnswer(response, false)); + },function(response){ + callback(parsePullImagesAnswer(response, true)); + }); + }; + /** * Retrieve all data * @param {callback} function to call after request complete */ var pullData=function(callback){ - // TODO call getMachines etc... + var nextFunction=function(response){ + if(response.status==0){ + pullMachines(callback); + } + } + pullImages(nextFunction); } diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 28c9165..47a65fb 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -34,36 +34,22 @@
+ MB
-- cgit v1.2.3 From e2be86814e8ac92778bfa9fc49e1d02946a7efbc Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 2 Mar 2016 20:46:24 +0100 Subject: Clean some things --- client/index.html | 27 +++++++++++++------------- client/js/controllers/home/machineDetails.js | 10 ++++++---- client/partials/home/machineDetails.html | 2 +- client/partials/nav.html | 29 ---------------------------- client/partials/status.html | 29 ++++++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 47 deletions(-) delete mode 100644 client/partials/nav.html create mode 100644 client/partials/status.html (limited to 'client/js/controllers/home/machineDetails.js') diff --git a/client/index.html b/client/index.html index 8ca2b9f..ca6bbe6 100644 --- a/client/index.html +++ b/client/index.html @@ -11,27 +11,28 @@ - + - + + +
+
+
+ + +
- -
- -
-
- - -
+ +
@@ -56,7 +57,7 @@
- + diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js index 24fac42..c015eaa 100644 --- a/client/js/controllers/home/machineDetails.js +++ b/client/js/controllers/home/machineDetails.js @@ -6,23 +6,25 @@ mainApp.controller('machineDetailsCtrl', [ '$scope', 'Compute', '$rootScope', '$timeout', function ($scope, Compute, $rootScope, $timeout) { + // Init scope $scope.machine={}; - $("#waitingForToggleMachine").hide(); + $scope.machineIsStarting=false; // For loading icon + $scope.$on('showMachineDetailsEvent', function(eventName ,machine, axioms){ $scope.machine=machine; $scope.axioms=axioms; - console.log(machine); $('#machineDetailsModal').modal({backdrop: false, keyboard: true}); }); $scope.toggleMachineState=function(){ - $("#waitingForToggleMachine").show(); + // Display gif + $scope.machineIsStarting=true; // Fake timeout $timeout(function(){ - $("#waitingForToggleMachine").hide(); + $scope.machineIsStarting=false; }, 3000); $timeout(function(){ $scope.machine.online=!$scope.machine.online; diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html index 47a65fb..c4c8a38 100644 --- a/client/partials/home/machineDetails.html +++ b/client/partials/home/machineDetails.html @@ -26,7 +26,7 @@   -   +   diff --git a/client/partials/nav.html b/client/partials/nav.html deleted file mode 100644 index 01b9079..0000000 --- a/client/partials/nav.html +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/client/partials/status.html b/client/partials/status.html new file mode 100644 index 0000000..01b9079 --- /dev/null +++ b/client/partials/status.html @@ -0,0 +1,29 @@ + -- cgit v1.2.3