summaryrefslogtreecommitdiff
path: root/client/js/services
diff options
context:
space:
mode:
Diffstat (limited to 'client/js/services')
-rw-r--r--client/js/services/Compute.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js
index 312f235..ee2210c 100644
--- a/client/js/services/Compute.js
+++ b/client/js/services/Compute.js
@@ -108,7 +108,22 @@ mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) {
var createMachine = function (callback, machine) {
// Send listServers request
var result = $http.post('../server/index.php',
- $.param({"token": Identity.getToken(), "task": "compute", "action": "createServer", 'name':machine.name, "imageId":machine.imageId,"flavorId":machine.flavorId}));
+ $.param({"token": Identity.getToken(), "task": "compute", "action": "createServer", 'name': machine.name, "imageId": machine.imageId, "flavorId": machine.flavorId}));
+
+ // Wait and handle the response
+ result.then(function (response) {
+ callback();
+ console.log(response.data.Error)
+ }, function (response) {
+ console.log("error")
+ callback();
+ });
+ };
+
+ var deleteMachine = function (callback, machineId) {
+ // Send listServers request
+ var result = $http.post('../server/index.php',
+ $.param({"token": Identity.getToken(), "task": "compute", "action": "deleteServer", 'serverId': machineId}));
// Wait and handle the response
result.then(function (response) {
@@ -149,7 +164,8 @@ mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) {
return {
pullMachines: pullMachines,
pullData: pullData,
- createMachine:createMachine,
+ createMachine: createMachine,
+ deleteMachine: deleteMachine,
getData: getData
};