From 753aad949ff366751cd5b16b37d5c3ece3d7ceb1 Mon Sep 17 00:00:00 2001 From: Erez Freiberger Date: Thu, 13 Jul 2017 16:07:03 +0300 Subject: [PATCH] adding proxy settings tab --- app/controllers/mixins/ems_common_angular.rb | 3 +- .../ems_container_helper/textual_summary.rb | 8 +++- .../_provider_settings.html.haml | 30 +++++--------- .../_provider_settings_section.html.haml | 23 +++++++++++ .../angular/_multi_auth_credentials.html.haml | 40 ++++++++++++------- 5 files changed, 66 insertions(+), 38 deletions(-) create mode 100644 app/views/layouts/angular-bootstrap/_provider_settings_section.html.haml diff --git a/app/controllers/mixins/ems_common_angular.rb b/app/controllers/mixins/ems_common_angular.rb index a4db8857ad2..f965b209244 100644 --- a/app/controllers/mixins/ems_common_angular.rb +++ b/app/controllers/mixins/ems_common_angular.rb @@ -445,7 +445,8 @@ def set_ems_record_vars(ems, mode = nil) ems.settings_options.each do |section_name, section| section.each do |opt, _| new_options[section_name.to_sym] ||= {} - new_options[section_name.to_sym][opt.to_sym] = params["provider_options_#{section_name}_#{opt}".to_sym] + value = params["provider_options_#{section_name}_#{opt}".to_sym] + new_options[section_name.to_sym][opt.to_sym] = value.blank? ? nil : value end end ems.options = new_options diff --git a/app/helpers/ems_container_helper/textual_summary.rb b/app/helpers/ems_container_helper/textual_summary.rb index 61cd7c30ea3..141e58f02d7 100644 --- a/app/helpers/ems_container_helper/textual_summary.rb +++ b/app/helpers/ems_container_helper/textual_summary.rb @@ -142,7 +142,11 @@ def textual_miq_custom_attributes end end - def textual_provider_settings_api - @ems.settings_options + def textual_proxy_settings_api + @ems.proxy_settings + end + + def textual_advanced_settings_api + @ems.advanced_settings end end diff --git a/app/views/layouts/angular-bootstrap/_provider_settings.html.haml b/app/views/layouts/angular-bootstrap/_provider_settings.html.haml index 7bb55279547..1d4a396609d 100644 --- a/app/views/layouts/angular-bootstrap/_provider_settings.html.haml +++ b/app/views/layouts/angular-bootstrap/_provider_settings.html.haml @@ -1,29 +1,17 @@ - ng_show ||= true -- validate_url ||= 'log_depot_edit' -- prefix ||= 'log' +- prefix ||= 'provider_options' - vm_scope ||= false - main_scope = vm_scope ? "$parent.vm" : "$parent" %div{"ng-controller" => "emsCommonFormController as vm", "vm-scope" => "$parent.vm.model ? $parent.vm : $parent"} - - textual_provider_settings_api.each do |section_name, settings_section| + - textual_advanced_settings_api.each do |section_name, settings_section| %h4 = section_name.to_s.titleize - - settings_section.each do |option_name, option| - %div{"ng-show" => "#{ng_show}"} - .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_#{option_name}.$invalid}"} - %label.col-md-2.control-label{"for" => "#{prefix}_#{option_name}"} - = option_name.to_s.titleize - .col-md-4 - - hash_for_options = {"type" => "text", - "id" => "#{prefix}_#{section_name}_#{option_name}", - "name" => "#{prefix}_#{section_name}_#{option_name}", - "ng-model" => "#{main_scope}.#{ng_model}.provider_options.#{section_name}.#{option_name}", - "checkchange" => "", - "ng-trim" => false, - "detect_spaces" => "", - "placeholder" => option[:global_default], - "prefix" => "#{prefix}"} - %input.form-control{hash_for_options} - %span.help-block{"ng-show" => "angularForm.#{prefix}_#{option_name}.$error.detectedSpaces"} - = _("Spaces are prohibited") + = render :partial => "layouts/angular-bootstrap/provider_settings_section", + :locals => {:ng_show => ng_show, + :ng_model => ng_model, + :id => id, + :prefix => prefix, + :section_name => section_name, + :settings_section => settings_section} diff --git a/app/views/layouts/angular-bootstrap/_provider_settings_section.html.haml b/app/views/layouts/angular-bootstrap/_provider_settings_section.html.haml new file mode 100644 index 00000000000..1be4d8660e6 --- /dev/null +++ b/app/views/layouts/angular-bootstrap/_provider_settings_section.html.haml @@ -0,0 +1,23 @@ +- ng_show ||= true +- prefix ||= 'provider_options' +- vm_scope ||= false +- main_scope = vm_scope ? "$parent.vm" : "$parent" + +- settings_section.each do |option_name, option| + %div{"ng-show" => "#{ng_show}"} + .form-group{"ng-class" => "{'has-error': angularForm.#{prefix}_#{option_name}.$invalid}"} + %label.col-md-2.control-label{"for" => "#{prefix}_#{option_name}"} + = option_name.to_s.titleize + .col-md-4 + - hash_for_options = {"type" => "text", + "id" => "#{prefix}_#{section_name}_#{option_name}", + "name" => "#{prefix}_#{section_name}_#{option_name}", + "ng-model" => "#{main_scope}.#{ng_model}.provider_options.#{section_name}.#{option_name}", + "checkchange" => "", + "ng-trim" => false, + "detect_spaces" => "", + "placeholder" => option[:global_default], + "prefix" => "#{prefix}"} + %input.form-control{hash_for_options} + %span.help-block{"ng-show" => "angularForm.#{prefix}_#{option_name}.$error.detectedSpaces"} + = _("Spaces are prohibited") diff --git a/app/views/layouts/angular/_multi_auth_credentials.html.haml b/app/views/layouts/angular/_multi_auth_credentials.html.haml index f3c51d94fc4..04a6a84f456 100644 --- a/app/views/layouts/angular/_multi_auth_credentials.html.haml +++ b/app/views/layouts/angular/_multi_auth_credentials.html.haml @@ -24,9 +24,6 @@ = miq_tab_header('hawkular', nil, {'ng-click' => "changeAuthTab('hawkular')"}) do %i{"error-on-tab" => "hawkular", :style => "color:#cc0000"} = _("Hawkular") - = miq_tab_header('settings', nil, {'ng-click' => "changeAuthTab('settings')"}) do - %i{"error-on-tab" => "settings", :style => "color:#cc0000"} - = _("Settings") - elsif controller_name == "host" = miq_tab_header('remote', nil, {'ng-click' => "changeAuthTab('remote')"}) do = _("Remote Login") @@ -34,8 +31,34 @@ = _("Web Services") = miq_tab_header('ipmi', nil, {'ng-click' => "changeAuthTab('ipmi')"}) do = _("IPMI") + - if respond_to?(:textual_proxy_settings_api) + = miq_tab_header('proxy_settings', nil, {'ng-click' => "changeAuthTab('proxy_settings')"}) do + %i{"error-on-tab" => "proxy_settings", :style => "color:#cc0000"} + = _("Proxy Settings") + - if respond_to?(:textual_advanced_settings_api) + = miq_tab_header('advanced_settings', nil, {'ng-click' => "changeAuthTab('advanced_settings')"}) do + %i{"error-on-tab" => "advanced_settings", :style => "color:#cc0000"} + = _("Advanced Settings") .tab-content + = miq_tab_content('proxy_settings', 'default') do + .form-group + .col-md-12.col-md-12 + = render :partial => "layouts/angular-bootstrap/provider_settings_section", + :locals => {:ng_show => true, + :ng_model => ng_model.to_s, + :id => record.id, + :section_name => "proxy_settings", + :settings_section => textual_proxy_settings_api, + :prefix => "provider_options",} + = miq_tab_content('advanced_settings', 'default') do + .form-group + .col-md-12.col-md-12 + = render :partial => "layouts/angular-bootstrap/provider_settings", + :locals => {:ng_show => true, + :ng_model => ng_model.to_s, + :id => record.id, + :prefix => "provider_options"} = miq_tab_content('default', 'default') do .form-group .col-md-12{"ng-if" => "#{ng_model}.ems_controller == 'ems_container' || " + | @@ -255,17 +278,6 @@ %span{:style => "color:black"} = _("Used for SSH connection to all %{hosts} in this provider.") % {:hosts => title_for_hosts} - elsif controller_name == "ems_container" - = miq_tab_content('settings', 'default') do - .form-group - .col-md-12.col-md-12 - = render :partial => "layouts/angular-bootstrap/provider_settings", - :locals => {:ng_show => true, - :ng_model => ng_model.to_s, - :id => record.id, - :ng_reqd_hostname => "true", - :ng_reqd_api_port => "true", - :prefix => "provider_options", - :detection => true} = miq_tab_content('hawkular', 'default') do .form-group .col-md-12.col-md-12