diff options
| author | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-04 19:38:09 +0200 |
|---|---|---|
| committer | Loic GUEGAN <loic@Manzerbredes.home> | 2016-05-04 19:38:09 +0200 |
| commit | 0266c16ffc97042853916c390aaaccecc72e69a1 (patch) | |
| tree | aed361ca7133bdab46683d1ff9c3edf38048ef27 | |
| parent | f819bc0c909dd85c4d98c8fb870ce5c6fce37383 (diff) | |
Commit for testing
| -rwxr-xr-x | client/js/controllers/home/home.js | 4 | ||||
| -rw-r--r-- | client/js/controllers/home/machineCreation.js | 11 | ||||
| -rw-r--r-- | client/js/services/Compute.js | 16 | ||||
| -rw-r--r-- | client/partials/home/machineCreation.html | 25 |
4 files changed, 32 insertions, 24 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 }; diff --git a/client/partials/home/machineCreation.html b/client/partials/home/machineCreation.html index ee2f952..16b55b7 100644 --- a/client/partials/home/machineCreation.html +++ b/client/partials/home/machineCreation.html @@ -13,24 +13,12 @@ <form class="form-horizontal" role="form"> <div class="form-group"> - <label class="control-label col-sm-2" for="email">Name</label> - <div class="col-sm-10"> - <p class="form-control-static">{{ name}}</p> + <label class="control-label col-sm-2">Name</label> + <div class="col-sm-20"> + <input type="text" value="" /> </div> </div> - <div class="form-group"> - <label class="control-label col-sm-2" for="pwd">State</label> - <div class="col-sm-10"> - <span ng-if="machine.status == 'ACTIVE'">Online</span> - <span ng-if="machine.status !== 'ACTIVE'">Offline</span> - - <button class="btn btn-danger" ng-if="machine.status == 'ACTIVE'" ng-click="toggleMachineState()">Turn Off</button> - <button class="btn btn-success" ng-if="machine.status !== 'ACTIVE'" ng-click="toggleMachineState()">Turn On</button> - <img src="images/spin/32x32/Preloader_1.gif" ng-if="machineIsStarting"></span> - - </div> - </div> <fieldset class="form-group"> <label class="control-label col-sm-2">RAM</label> <select class="col-sm-20" id="ramSelected"> @@ -52,17 +40,12 @@ <option ng-repeat="image in axioms.images" ng-selected="machine.imageId == Object.keys(image)">{{ image.name}}</option> </select> </fieldset> - - - - - </form> </div> <div class="modal-footer"> - <a href="#" data-dismiss="modal" class="btn btn-primary">Apply</a> + <a href="#" data-dismiss="modal" ng-click="createMachine()" class="btn btn-primary">Create</a> <a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a> </div> </div> |
