From b87d96006e03e319d79c7be3cf7886aeb4da87ca Mon Sep 17 00:00:00 2001 From: Manisha Singhal Date: Fri, 21 Jun 2024 14:05:44 +0200 Subject: [PATCH] cleanup rails view --- .../proxmox_compute_selectors_helper.rb | 10 ++---- ...rofile_to_compute_attributes_form.html.erb | 3 +- .../_add_react_js_to_host_form.html.erb | 33 ------------------- .../_add_vm_type_to_volumes_edit.html.erb | 2 ++ .../proxmox/server/_volume_hard_disk.html.erb | 1 + 5 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 app/views/compute_resources_vms/form/proxmox/_add_react_js_to_host_form.html.erb diff --git a/app/helpers/proxmox_compute_selectors_helper.rb b/app/helpers/proxmox_compute_selectors_helper.rb index d919ca9b7..4509972d7 100644 --- a/app/helpers/proxmox_compute_selectors_helper.rb +++ b/app/helpers/proxmox_compute_selectors_helper.rb @@ -19,14 +19,8 @@ module ProxmoxComputeSelectorsHelper def proxmox_types_map - [OpenStruct.new(id: 'qemu', value: 'qemu', name: 'KVM/Qemu server'), - OpenStruct.new(id: 'lxc', value: 'lxc', name: 'LXC container')] - end - def types_map - [ - {key:1, value:'qemu', name: 'KVM/Qemu server'}, - {key:2, value:'lxc', name: 'LXC container' } - ] + [OpenStruct.new(id: 'qemu', name: 'KVM/Qemu server'), + OpenStruct.new(id: 'lxc', name: 'LXC container')] end def proxmox_archs_map diff --git a/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb b/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb index 8a6b864be..f7a138689 100644 --- a/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb +++ b/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb @@ -15,10 +15,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with ForemanFogProxmox. If not, see . %> <% if @set.compute_resource.class == ForemanFogProxmox::Proxmox %> -<% logger.warn("****************** compute attribute form #{f2} #{f2.object}")%> <%= render :partial => "compute_form", :locals => { :f => f2, :compute_resource => @set.compute_resource, :selected_cluster => @set.vm_attrs['cluster'], :from_profile => true } %> <% else %> <%= render :partial => "compute_form", :locals => { :f => f2, :compute_resource => @set.compute_resource, :selected_cluster => @set.vm_attrs['cluster'] } %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/compute_resources_vms/form/proxmox/_add_react_js_to_host_form.html.erb b/app/views/compute_resources_vms/form/proxmox/_add_react_js_to_host_form.html.erb deleted file mode 100644 index 84a848af8..000000000 --- a/app/views/compute_resources_vms/form/proxmox/_add_react_js_to_host_form.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -<% content_for(:javascripts) do %> - <%= webpacked_plugins_js_for :foreman_fog_proxmox %> - <%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm', "data-turbolinks-track" => true %> - -<% end %> -<%= compute_resource %> -<%= fields_for "#{type}[compute_attributes]", @vm || host.compute_object do |compute| %> -<%= f.object_name%> -<%= "this page is loaded"%> - <% if compute.object %> - <%= alert(:header => _('Notice'), - :class => 'alert-info hide', - :id => 'update_not_supported', - :text => _('Virtual machine settings cannot be edited on an existing machine in %s') % - compute_resource.provider_friendly_name) %> - <%= render partial: provider_partial(compute_resource, 'base'), - locals: { f: f, host: host, compute_resource: compute_resource, new_host: host.new_record?, new_vm: !compute.object.persisted?, - arch: host.architecture_id, os: host.operatingsystem_id } %> -<% else %> - <% if host.new_record? %> - <%= alert(:class => 'alert-danger', - :header => _("Failed connecting to %s") % compute_resource, - :text => _("Errors: %s") % compute_resource.errors.full_messages.to_sentence) %> - <% else %> - <%= alert(:class => 'alert-danger', - :header => _("'%{host}' not found on '%{resource}'") % { :host => host.name, :resource => compute_resource }, - :text => _("'%{host}' could be deleted or '%{resource}' is not responding.") % { host: host.name, resource: compute_resource}) %> - <% end %> - <% end%> - <%= hidden_field_tag 'capabilities', compute_resource.capabilities, :disabled => true %> - <%= hidden_field_tag 'provider', compute_resource.provider, :disabled => true %> - <%= content_tag(:div,'', :id => :'supports_update', :data=> { :'supports-update'=> compute_resource.supports_update? || (host && host.new_record?) }) %> -<% end if compute_resource %> diff --git a/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb b/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb index 85d6c93f2..33b3924a1 100644 --- a/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +++ b/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb @@ -26,10 +26,12 @@ along with ForemanFogProxmox. If not, see . %> <% cloud_init = f.object.cloud_init? %> <% logger.debug("_add_vm_type_to_volumes_edit.html cloud_init=#{cloud_init}") %> <% container = type == 'lxc' %> + <%= add_child_link_typed '+ ' + _("Add Hard Disk"), :volumes, 'hard_disk', { :class => "info #{'hide' unless server }", :title => _('add new hard disk') } %> <%= add_child_link_typed '+ ' + _("Add CD-ROM"), :volumes, 'cdrom', { :class => "info #{'hide' if cdrom }", :title => _('add new cd-rom') } %> <%= add_child_link_typed '+ ' + _("Add Cloud-init"), :volumes, 'cloud_init', { :class => "info #{'hide' if cloud_init }", :title => _('add new cloud-init') } %> <%= add_child_link_typed '+ ' + _("Add Mount Point"), :volumes, 'mp', { :class => "info #{'hide' unless container}", :title => _('add new mount point') } %> + <%= new_child_fields_template_typed(f, :volumes, { :type => 'hard_disk', :object => compute_resource.new_typed_volume({},'qemu','hard_disk'), diff --git a/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb b/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb index 570db7075..d648f4a58 100644 --- a/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb +++ b/app/views/compute_resources_vms/form/proxmox/server/_volume_hard_disk.html.erb @@ -20,6 +20,7 @@ along with ForemanFogProxmox. If not, see . %> <% logger.debug("_volume_hard_disk.html f.object.hard_disk?=#{f.object.hard_disk?}") %> <% logger.debug("_volume_hard_disk.html f.object.storage_type=#{f.object.storage_type}") %> <% new_volume = f.object.volid.nil? %> + <%= field_set_tag _('Hard disk'), :id => "server_volume_hard_disk_#{f.index}", :class => ('hide' unless hard_disk), :disabled => !hard_disk do %> <%= f.hidden_field :volid if !new_volume %> <%= f.hidden_field :storage_type %>