summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 22:46:40 +0200
committerLoic GUEGAN <loic@Manzerbredes.home>2016-05-04 22:46:40 +0200
commita9e8c8e6644a83e81fb904ab0febf199421865ba (patch)
treef4a2ea7cce9694fa8b44adaa98e01597694b5141
parentcddd9682e6d6b7c5fd42215dec533c3c38da8eba (diff)
Correct bug
-rw-r--r--client/js/controllers/home/machineCreation.js35
-rw-r--r--client/js/controllers/home/machineDetails.js2
-rw-r--r--client/js/services/Compute.js5
-rw-r--r--client/partials/home/machineCreation.html23
4 files changed, 35 insertions, 30 deletions
diff --git a/client/js/controllers/home/machineCreation.js b/client/js/controllers/home/machineCreation.js
index d1e6b6a..3996c68 100644
--- a/client/js/controllers/home/machineCreation.js
+++ b/client/js/controllers/home/machineCreation.js
@@ -6,20 +6,35 @@
mainApp.controller('machineCreationCtrl', ['$scope', 'Compute', '$rootScope', '$timeout', 'Identity', function ($scope, Compute, $rootScope, $timeout, Identity)
{
-
- $scope.name = "loic"
+ $scope.name = "";
+ $('#pleaseChooseAnImage').hide();
// When we need to show details of machine
$scope.$on('showMachineCreationEvent', function (eventName, axioms) {
- $scope.axioms=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)
+
+ var callMeAfterMachineCreation=function(response){
+ Compute.pullData(function(){});
+ };
+
+ $scope.createMachine = function () {
+ if ($scope.selectedImage == null) {
+ $('#pleaseChooseAnImage').show();
+ } else {
+ $('#pleaseChooseAnImage').hide();
+ $('#machineCreationModal').modal("hide");
+
+ machine = {}
+ machine.name = $scope.name
+ machine.flavorId = 1
+ machine.imageId = $scope.selectedImage
+
+
+ Compute.createMachine(callMeAfterMachineCreation, machine)
+ $scope.name="";
+
+ }
};
}]);
diff --git a/client/js/controllers/home/machineDetails.js b/client/js/controllers/home/machineDetails.js
index 06e296d..9ccb86b 100644
--- a/client/js/controllers/home/machineDetails.js
+++ b/client/js/controllers/home/machineDetails.js
@@ -42,7 +42,7 @@ mainApp.controller('machineDetailsCtrl', ['$scope', 'Compute', '$rootScope', '$t
};
$scope.deleteMachine=function(){
- Compute.deleteMachine(function(){console.log("deleted")},$scope.machine.id);
+ Compute.deleteMachine(function(){Compute.pullData(function(){});},$scope.machine.id);
}
}]);
diff --git a/client/js/services/Compute.js b/client/js/services/Compute.js
index ee2210c..992f20c 100644
--- a/client/js/services/Compute.js
+++ b/client/js/services/Compute.js
@@ -112,8 +112,9 @@ mainApp.factory('Compute', ['$http', 'Identity', function ($http, Identity) {
// Wait and handle the response
result.then(function (response) {
- callback();
- console.log(response.data.Error)
+ console.log(response.data)
+ callback();
+
}, function (response) {
console.log("error")
callback();
diff --git a/client/partials/home/machineCreation.html b/client/partials/home/machineCreation.html
index 16b55b7..7c23ec7 100644
--- a/client/partials/home/machineCreation.html
+++ b/client/partials/home/machineCreation.html
@@ -15,29 +15,17 @@
<div class="form-group">
<label class="control-label col-sm-2">Name</label>
<div class="col-sm-20">
- <input type="text" value="" />
+ <input type="text" value="" ng-model="name"/>
</div>
</div>
- <fieldset class="form-group">
- <label class="control-label col-sm-2">RAM</label>
- <select class="col-sm-20" id="ramSelected">
- <option ng-repeat="ram in axioms.ram" ng-selected="machine.ram == ram">{{ ram}}</option>
- </select>
- <span>MB</span>
- </fieldset>
+
- <fieldset class="form-group">
- <label class="control-label col-sm-2">Disk</label>
- <select class="col-sm-20" id="ramSelected">
- <option ng-repeat="disk in axioms.disk" ng-selected="machine.disk == disk">{{ disk}}</option>
- </select>
- </fieldset>
<fieldset class="form-group">
<label class="control-label col-sm-2">Image</label>
- <select class="col-sm-20" id="ramSelected">
- <option ng-repeat="image in axioms.images" ng-selected="machine.imageId == Object.keys(image)">{{ image.name}}</option>
+ <select class="col-sm-20" id="ramSelected" ng-model="selectedImage">
+ <option ng-repeat="image in axioms.images" value="{{image.id}}">{{ image.name}}</option>
</select>
</fieldset>
</form>
@@ -45,7 +33,8 @@
</div>
<div class="modal-footer">
- <a href="#" data-dismiss="modal" ng-click="createMachine()" class="btn btn-primary">Create</a>
+ <div class="alert alert-danger text-center" role="alert" id="pleaseChooseAnImage"><b>Please choose an image !</b></div>
+ <a href="#" ng-click="createMachine()" class="btn btn-primary">Create</a>
<a href="#" data-dismiss="modal" class="btn btn-default">Cancel</a>
</div>
</div>