Add functionnality

This commit is contained in:
Loic GUEGAN 2016-04-17 20:43:41 +02:00
parent a481b727d9
commit ae4e028231
5 changed files with 41 additions and 46 deletions

View file

@ -24,6 +24,7 @@
<div ng-include="'./partials/home/machineDetails.html'"></div>
<div ng-include="'./partials/loading.html'"></div>
<div ng-include="'./partials/image/upload.html'"></div>
<div ng-include="'./partials/image/edit.html'"></div>
<!-- MAIN GRID -->
@ -93,6 +94,8 @@
<script src="./js/controllers/network/network.js"></script>
<script src="./js/controllers/image/image.js"></script>
<script src="./js/controllers/image/upload.js"></script>
<script src="./js/controllers/image/edit.js"></script>

View file

@ -0,0 +1,13 @@
/**
* The image controller
*
* @param {$scope} $scope The $scope service from angular
*/
mainApp.controller('editImageCtrl', ['$scope', 'Image', 'Loading', 'Identity', 'upload', function ($scope, Image, Loading, Identity, upload)
{
$scope.$on('editImageEvent', function (eventName, image) {
$scope.image = image;
$('#editImageModal').modal('show');
console.log(image)
});
}]);

View file

@ -3,7 +3,7 @@
*
* @param {$scope} $scope The $scope service from angular
*/
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', function ($scope, Image, Loading, Identity)
mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity','$rootScope', function ($scope, Image, Loading, Identity, $rootScope)
{
// Update view
@ -21,4 +21,9 @@ mainApp.controller('imageCtrl', ['$scope', 'Image', 'Loading', 'Identity', funct
callMeAfterGetImage();
}
}
$scope.edit=function(image){
$rootScope.$broadcast("editImageEvent", image);
}
}]);

View file

@ -1,4 +1,4 @@
<div class="modal fade" id="uploadImageModal" ng-controller="uploadImageCtrl">
<div class="modal fade" id="editImageModal" ng-controller="editImageCtrl">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
@ -6,7 +6,7 @@
<div class="modal-content">
<div class="modal-header">
<!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>-->
<h4 class="modal-title">Upload Image</h4>
<h4 class="modal-title">Edit Image</h4>
</div>
@ -14,54 +14,28 @@
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="control-label col-sm-2" for="email">Name</label>
<label class="control-label col-sm-2">Name</label>
<div class="col-sm-10">
<p class="form-control-static">{{ machine.name}}</p>
<p class="form-control-static">{{ image.name}}</p>
</div>
<label class="control-label col-sm-2">Protected</label>
<div class="col-sm-10">
<p class="form-control-static">{{ image.protected}}</p>
</div>
<label class="control-label col-sm-2">Visibility</label>
<div class="col-sm-10">
<p class="form-control-static">{{ image.visibility}}</p>
</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>
&nbsp;
<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>
&nbsp;<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">
<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>
</fieldset>
</form>
<div class="modal-footer">
<!--<a href="#" data-dismiss="modal" class="btn btn-default">Close</a>-->
<a class="btn btn-lg btn-primary btn-block" data-dismiss="modal" >Apply</a>
</div>
</div>
</div>
</div>
</div>

View file

@ -8,7 +8,7 @@
<div class="btn-group btn-group-md" role="group" aria-label="...">
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#uploadImageModal"">Upload</button>
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#uploadImageModal">Upload</button>
<button type="button" class="btn btn-default">Download</button>
</div>
<p></p>
@ -25,7 +25,7 @@
<td>{{ image.name}}</td>
<td>{{ (image.size / 1048576).toFixed(2)}} MB</td>
<td>
<button type="button" class="btn btn-primary">Edit</button>
<button type="button" class="btn btn-primary" ng-click="edit(image)">Edit</button>
<button type="button" class="btn btn-danger">Remove</button>
</td>
</tr>