diff --git a/.files/js/controllers/CloudSpaceNavigatorController.js b/.files/js/controllers/CloudSpaceNavigatorController.js index 9566fccef896bfda44aa4fba49926c4b5bbef4be..629af5e3abe472268b042347d0bdc0dedcc9de38 100644 --- a/.files/js/controllers/CloudSpaceNavigatorController.js +++ b/.files/js/controllers/CloudSpaceNavigatorController.js @@ -116,7 +116,8 @@ name: $scope.newCloudSpace.name, accountId: $scope.newCloudSpace.account.id, selectedLocation: $scope.selectedLocation, - privatenetwork: $scope.newCloudSpace.privatenetwork + privatenetwork: $scope.newCloudSpace.privatenetwork, + routerType: $scope.newCloudSpace.routerType }); }; $scope.cancel = function() { @@ -139,7 +140,7 @@ modalInstance.result.then(function(space) { LoadingDialog.show('Creating cloudspace'); - CloudSpace.create(space.name, space.accountId, $scope.currentUser.username, space.selectedLocation, space.privatenetwork) + CloudSpace.create(space.name, space.accountId, $scope.currentUser.username, space.selectedLocation, space.privatenetwork, space.routerType) .then(function(cloudspaceId) { //Wait a second, consistency on the api is not garanteed before that $timeout(function() { diff --git a/.files/js/controllers/Machines/MachineEditController.js b/.files/js/controllers/Machines/MachineEditController.js index 007382af58bcdc1480e5c303386c390578cfca21..6010301fd0e3b6ee978692b6129653e2cd038391 100644 --- a/.files/js/controllers/Machines/MachineEditController.js +++ b/.files/js/controllers/Machines/MachineEditController.js @@ -16,6 +16,7 @@ $scope.getMachine = getMachine; $scope.createDisk = createDisk; $scope.removeDisk = removeDisk; + $scope.resizeDisk = resizeDisk; $scope.moveDisk = moveDisk; $scope.isValidCreateDisk = isValidCreateDisk; $scope.resize = resize; @@ -126,6 +127,39 @@ }); } + function resizeDisk(disk) { + var modalInstance = $modal.open({ + templateUrl: 'resizeDiskDialog.html', + controller: function ($scope, $modalInstance) { + $scope.disk = disk; + $scope.submit = function (form) { + if (form.newsize <= disk.sizeMax) { + $scope.warning = "New size can not be smaller then current disk size " + disk.sizeMax + "GB"; + } + else { + $scope.warning = ""; + $modalInstance.close(form.newsize); + } + }; + $scope.cancelResize = function () { + $modalInstance.dismiss('cancel'); + }; + }, + resolve: {} + }); + + modalInstance.result.then(function (newsize) { + LoadingDialog.show('Resizing disk'); + Machine.resizeDisk(disk.id, newsize).then(function () { + disk.sizeMax = newsize; + LoadingDialog.hide(); + }, function (reason) { + $ErrorResponseAlert(reason); + LoadingDialog.hide(); + }); + }); + } + function moveDisk(disk, currentSpace, machines) { if ($scope.machine.status !== 'HALTED') { $alert('Machine must be stopped to move disk.'); diff --git a/.files/js/services/CloudSpaceServices.js b/.files/js/services/CloudSpaceServices.js index 0eb00cdd585b95aab018adf0b9b840387d5af2c8..49e15277535b7c1a8b4895853908e238280ee049 100644 --- a/.files/js/services/CloudSpaceServices.js +++ b/.files/js/services/CloudSpaceServices.js @@ -24,13 +24,14 @@ angular.module('cloudscalers.services') setCurrent: function (space) { SessionData.setSpace(space); }, - create: function (name, accountId, userId, location, privatenetwork) { + create: function (name, accountId, userId, location, privatenetwork, routerType) { var data = { name: name, accountId: accountId, access: userId, location: location, - privatenetwork: privatenetwork + privatenetwork: privatenetwork, + type: routerType }; return $http.post(cloudspaceconfig.apibaseurl + '/cloudspaces/create', data) .then( @@ -182,4 +183,4 @@ angular.module('cloudscalers.services') ); }, }; - }); \ No newline at end of file + }); diff --git a/.files/js/services/machineServices.js b/.files/js/services/machineServices.js index 7d59955394aa9d35bfeb7032b394959218d1f45d..f3f54c08f6f99f1261f6048f75dc0748eca0d08b 100644 --- a/.files/js/services/machineServices.js +++ b/.files/js/services/machineServices.js @@ -423,6 +423,18 @@ angular.module('cloudscalers.services') } ); }, + resizeDisk: function (diskId, newsize) { + var data = { diskId: diskId, size: newsize }; + var url = cloudspaceconfig.apibaseurl + '/disks/resize'; + return $http.post(url, data).then( + function (result) { + return result.data; + }, + function (reason) { + return $q.reject(reason); + } + ); + }, moveDisk: function (machineId, diskId) { var data = { diskId: diskId, machineId: machineId }; var url = cloudspaceconfig.apibaseurl + '/machines/attachDisk'; diff --git a/Portal/Decks/MachineDeck/includes/storage_list.html b/Portal/Decks/MachineDeck/includes/storage_list.html index 043b6c233454f4a65f650feed6a350a0e13fce60..669bbeff6f3e772a1b6d375865172e4ffb3ae57a 100644 --- a/Portal/Decks/MachineDeck/includes/storage_list.html +++ b/Portal/Decks/MachineDeck/includes/storage_list.html @@ -4,6 +4,7 @@ <li ng-repeat="disk in machine.disks" class="disk-container relative"> <div class="disk-control-bar clearfix" ng-show="currentUser.acl.cloudspace > 1 || currentUser.acl.account > 1"> <span ng-show="disk.type != 'B'" class="disk-control detach right margin-left-medium" title="Remove disk" ng-click="removeDisk(disk)"><i class="fa fa-minus-circle"></i></span> + <span class="disk-control right margin-left-medium" title="Resize disk" ng-click="resizeDisk(disk)"><i class="fa fa-edit"></i></span> </div> <button type="button" class="btn btn-selector table-cell disk relative" title="{[disk.descr]}"> <span ng-class="{'label-name': disk.type == 'B' }"> @@ -32,6 +33,26 @@ </div> </form> </script> +<script type="text/ng-template" id="resizeDiskDialog.html"> + <form name="resizediskform" ng-submit="submit(form)"> + <div class="modal-header"> + <h3>Resize disk?</h3> + <div ng-show="warning" class="alert alert-warning margin-top-large"> + {[warning]} + </div> + + </div> + <div class="modal-body"> + <ul> + New Size: <input ng-model="form.newsize" type="number" class="input-large" />GB + </ul> + </div> + <div class="modal-footer"> + <button type="submit" class="btn btn-primary" autofocus>Ok</button> + <button type="button" class="btn cancel" ng-click="cancelResize()">Cancel</button> + </div> + </form> +</script> <script type="text/ng-template" id="moveDiskDialog.html"> <form name="movediskform" ng-submit="cancelDestroy()"> diff --git a/header.html b/header.html index 6f82665cc68c3f79c846fd1080c059dad63b5c50..f32efe3ec34c18338675abc0e1402a448fb53423 100644 --- a/header.html +++ b/header.html @@ -91,7 +91,16 @@ <div class="form-group"> <label class="col-sm-2 control-label">Location</label> <div class="controls col-sm-9"> - <select class="form-control" ng-model="newCloudSpace.locationCode" required ng-options="location.locationCode as location.name for location in locations"> + <select class="form-control" ng-model="newCloudSpace.locationCode" required ng-options="location.locationCode as location.name for location in locations" ng-init="newCloudSpace.locationCode=locations[0].locationCode"> + </select> + </div> + </div> + <div class="form-group"> + <label class="col-sm-2 control-label">Gateway Type</label> + <div class="controls col-sm-9"> + <select class="form-control" ng-model="newCloudSpace.routerType" required ng-init="newCloudSpace.routerType='vgw'"> + <option value="vgw">Virtual Gateway</option> + <option value="routeros">Router OS</option> </select> </div> </div>