Skip to content

Commit

Permalink
adding proxy settings tab
Browse files Browse the repository at this point in the history
  • Loading branch information
Erez Freiberger committed Jul 13, 2017
1 parent 1ab3b9b commit 753aad9
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 38 deletions.
3 changes: 2 additions & 1 deletion app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions app/helpers/ems_container_helper/textual_summary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
30 changes: 9 additions & 21 deletions app/views/layouts/angular-bootstrap/_provider_settings.html.haml
Original file line number Diff line number Diff line change
@@ -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}
Original file line number Diff line number Diff line change
@@ -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")
40 changes: 26 additions & 14 deletions app/views/layouts/angular/_multi_auth_credentials.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,41 @@
= 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")
= miq_tab_header('ws', nil, {'ng-click' => "changeAuthTab('ws')"}) do
= _("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' || " + |
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 753aad9

Please sign in to comment.