From cfce59d6dc120848624e105614575ae0f48af81b Mon Sep 17 00:00:00 2001 From: Yoggzo Date: Mon, 29 Feb 2016 14:20:13 +0100 Subject: merge --- client/js/services/Compute.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'client/js/services/Compute.js') diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js index c5c8da9..8148948 100644 --- a/client/js/services/Compute.js +++ b/client/js/services/Compute.js @@ -2,11 +2,12 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ - + // Create data var data={}; data.machines={}; + // Parser var parseGetMachinesAnswer=function(response, failedToSendRequest){ @@ -16,8 +17,24 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Get Machine var getMachines=function(callback){ + var params={ + "token" : Identity.getToken(), + "task" : "compute", + "action":"getServer", + "serverId":"69d5bcc4-2fab-4634-b0d2-f455fee5b7bd" + }; + var result=$http.post('../server/index.php', - $.param({"token" : Identity.profile.token, "task" : "Compute"})); + $.param(params)); + + // Wait and handle the response + result.then(function (response){ + console.log(response.data.Servers); + callback(parseGetMachinesAnswer(response, false)); + },function(response){ + alert(response.status); + callback(parseGetMachinesAnswer(response, true)); + }); }; @@ -31,8 +48,8 @@ mainApp.factory('Compute',[ '$http', 'Identity', function($http, Identity){ // Return services objects return { - getMachines: getMachines - pullData: pullData + getMachines: getMachines, + pullData: pullData, data:data }; -- cgit v1.2.3