Skip to content

Commit

Permalink
Merge pull request #4182 from ZitaNemeckova/fix_reconfig
Browse files Browse the repository at this point in the history
Fix issues in Reconfigure/Resize
  • Loading branch information
himdel authored Jun 25, 2018
2 parents 5482513 + eaf041f commit 9837678
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,34 @@ ManageIQ.angular.app.controller('vmCloudResizeFormController', ['$http', '$scope
flavor_id: null,
};
vm.flavors = [];
vm.vmCloudResizeformId = vmCloudResizeFormId;
vm.formId = vmCloudResizeFormId;
vm.objectId = objectId;

ManageIQ.angular.scope = vm;

vm.newRecord = vmCloudResizeFormId == 'new';
vm.newRecord = vm.formId == 'new';

$http.get('/vm_cloud/resize_form_fields/' + vmCloudResizeFormId + '?objectId=' + vm.objectId)
miqService.sparkleOn();
$http.get('/vm_cloud/resize_form_fields/' + vm.formId + '?objectId=' + vm.objectId)
.then(getResizeFormData)
.catch(miqService.handleFailure);
};

$scope.cancelClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=cancel';
miqService.miqAjaxButton(url, {objectId: vm.objectId});
var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=cancel';
miqService.miqAjaxButton(url, {
objectId: vm.objectId,
});
};

$scope.submitClicked = function() {
miqService.sparkleOn();
var url = '/vm_cloud/resize_vm/' + vmCloudResizeFormId + '?button=submit';
miqService.miqAjaxButton(url, {objectId: vm.objectId,
flavor_id: vm.vmCloudModel.flavor_id});
var url = '/vm_cloud/resize_vm/' + vm.formId + '?button=submit';
miqService.miqAjaxButton(url, {
objectId: vm.objectId,
flavor_id: vm.vmCloudModel.flavor_id,
});
};

function getResizeFormData(response) {
Expand Down
13 changes: 10 additions & 3 deletions app/controllers/mixins/actions/vm_actions/resize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ module Actions
module VmActions
module Resize
def resizevms
assert_privileges(params[:pressed])
case params[:pressed]
when "instance_resize"
assert_privileges("instance_resize")
when "miq_request_edit"
assert_privileges("miq_request_edit")
else
raise MiqException::RbacPrivilegeException, _("The user is not authorized for this task or item.")
end
# if coming in to edit from miq_request list view
recs = checked_or_params
@record = nil
if !session[:checked_items].nil? && (@lastaction == "set_checked_items" || params[:pressed] == "miq_request_edit")
request_id = params[:id]
@record = VmCloudReconfigureRequest.find(request_id).vms.first
end

recs = [params[:id].to_i] if recs.blank?
@record ||= find_record_with_rbac(VmOrTemplate, recs.first) # Set the VM object
if @record.supports_resize?
if @explorer
Expand Down Expand Up @@ -43,7 +50,7 @@ def resize
)
end
@sb[:explorer] = @explorer
@request_id = params[:req_id] ? params[:req_id] : nil
@request_id = params[:req_id]
@in_a_form = true
@resize = true
render :action => "show" unless @explorer
Expand Down
3 changes: 1 addition & 2 deletions app/views/vm_common/_resize.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
%select{:name => 'flavor_id',
'ng-model' => 'vm.vmCloudModel.flavor_id',
'ng-options' => 'flavor.id as flavor.name for flavor in vm.flavors',
:miqrequired => true,
:checkchange => true}
:miqrequired => true}
%div_for_paging{'ng-controller' => "pagingDivButtonGroupController",
'paging_div_buttons_id' => "angular_paging_div_buttons",
Expand Down

0 comments on commit 9837678

Please sign in to comment.