summaryrefslogtreecommitdiff
path: root/client/js
diff options
context:
space:
mode:
Diffstat (limited to 'client/js')
-rwxr-xr-xclient/js/controllers/home/home.js4
-rw-r--r--client/js/controllers/home/machineCreation.js11
-rw-r--r--client/js/services/Compute.js16
3 files changed, 28 insertions, 3 deletions
diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js
index 7731500..910c6b2 100755
--- a/client/js/controllers/home/home.js
+++ b/client/js/controllers/home/home.js
@@ -32,8 +32,8 @@ mainApp.controller('homeCtrl', ['$scope', 'Compute', '$rootScope', 'Loading', 'I
});
- $scope.raiseShowMachineCreationEvent = function (){
- $rootScope.$broadcast("showMachineCreationEvent");
+ $scope.raiseShowMachineCreationEvent = function () {
+ $rootScope.$broadcast("showMachineCreationEvent", Compute.getData().axioms);
};
// Function to call from view to display the details of a machine
diff --git a/client/js/controllers/home/machineCreation.js b/client/js/controllers/home/machineCreation.js
index 11315dd..d1e6b6a 100644
--- a/client/js/controllers/home/machineCreation.js
+++ b/client/js/controllers/home/machineCreation.js
@@ -9,8 +9,17 @@ mainApp.controller('machineCreationCtrl', ['$scope', 'Compute', '$rootScope', '$
$scope.name = "loic"
// When we need to show details of machine
- $scope.$on('showMachineCreationEvent', function (eventName) {
+ $scope.$on('showMachineCreationEvent', function (eventName, axioms) {
+ $scope.axioms=axioms;
$('#machineCreationModal').modal({backdrop: false, keyboard: true});
});
+
+ $scope.createMachine=function(){
+ machine={}
+ machine.name="loicTest"
+ machine.flavorId=1
+ machine.imageId="fd1ea580-a83e-4dc8-833c-96ce2b6f1358"
+ Compute.createMachine(function(){console.log("done")}, machine)
+ };
}]);
diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js
index 712b9a2..312f235 100644
--- a/client/js/services/Compute.js
+++ b/client/js/services/Compute.js
@@ -105,6 +105,21 @@ 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}));
+
+ // Wait and handle the response
+ result.then(function (response) {
+ callback();
+ console.log(response.data.Error)
+ }, function (response) {
+ console.log("error")
+ callback();
+ });
+ };
+
/**
* Retrieve all data
@@ -134,6 +149,7 @@ mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) {
return {
pullMachines: pullMachines,
pullData: pullData,
+ createMachine:createMachine,
getData: getData
};