summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 20:19:06 +0200
committerLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 20:19:06 +0200
commitcddd9682e6d6b7c5fd42215dec533c3c38da8eba (patch)
tree52c05c4cf9e15337c6083d4c5127842688c7bcaf
parentb2c76ddf0a27521a1f11a52af968ac3df1c063f7 (diff)
Add delete machine
-rwxr-xr-xclient/js/controllers/home/home.js3
-rw-r--r--client/js/controllers/home/machineDetails.js4
-rw-r--r--client/js/services/Compute.js20
-rw-r--r--client/partials/home/machineDetails.html2
4 files changed, 26 insertions, 3 deletions
diff --git a/client/js/controllers/home/home.js b/client/js/controllers/home/home.js
index 1b4acf8..d6d6621 100755
--- a/client/js/controllers/home/home.js
+++ b/client/js/controllers/home/home.js
@@ -5,6 +5,9 @@
*/
mainApp.controller('homeCtrl', [ '$scope', 'Compute', '$rootScope', 'Loading','Identity', 'Image', function ($scope, Compute, $rootScope, Loading, Identity, Image)
{
+ $scope.raiseShowMachineCreationEvent = function () {
+ $rootScope.$broadcast("showMachineCreationEvent", Compute.getData().axioms);
+ };
var displayMachine = function(){
var machineNames = [];
var i = 0;
diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js
index cd7bb57..06e296d 100644
--- a/client/js/controllers/home/machineDetails.js
+++ b/client/js/controllers/home/machineDetails.js
@@ -41,6 +41,8 @@ mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$t
//Todo
};
-
+ $scope.deleteMachine=function(){
+ Compute.deleteMachine(function(){console.log("deleted")},$scope.machine.id);
+ }
}]);
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
};
diff --git a/client/partials/home/machineDetails.html b/client/partials/home/machineDetails.html
index c34158d..4fc3f32 100644
--- a/client/partials/home/machineDetails.html
+++ b/client/partials/home/machineDetails.html
@@ -63,6 +63,8 @@
</div>
<div class="modal-footer">
<a href="#" data-dismiss="modal" class="btn btn-primary">Apply</a>
+ <a href="#" data-dismiss="modal" ng-click="deleteMachine()" class="btn btn-danger">Delete</a>
+
<a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>
</div>
</div>