From 26c087bab4c991070f4e06b82195bcc6fad32729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20=C4=8C=C3=AD=C5=BEek?= Date: Fri, 31 Mar 2017 09:30:06 +0200 Subject: [PATCH 1/6] vm_controller and session mixin --- .../mixins/generic_session_mixin.rb | 30 ++++++++++--------- app/controllers/vm_controller.rb | 20 ++++--------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/app/controllers/mixins/generic_session_mixin.rb b/app/controllers/mixins/generic_session_mixin.rb index 29c47b8dacc..fb33d95936a 100644 --- a/app/controllers/mixins/generic_session_mixin.rb +++ b/app/controllers/mixins/generic_session_mixin.rb @@ -4,24 +4,26 @@ module GenericSessionMixin private def get_session_data - prefix = self.class.session_key_prefix - @title = respond_to?(:title) ? title : ui_lookup(:tables => self.class.table_name) - @layout = prefix - @table_name = request.parameters[:controller] - @lastaction = session["#{prefix}_lastaction".to_sym] - @display = session["#{prefix}_display".to_sym] - @filters = session["#{prefix}_filters".to_sym] - @catinfo = session["#{prefix}_catinfo".to_sym] - @showtype = session["#{prefix}_showtype".to_sym] + prefix = self.class.session_key_prefix + @title = respond_to?(:title) ? title : ui_lookup(:tables => self.class.table_name) + @layout = prefix + @table_name = request.parameters[:controller] + @lastaction = session["#{prefix}_lastaction".to_sym] + @display = session["#{prefix}_display".to_sym] + @filters = session["#{prefix}_filters".to_sym] + @catinfo = session["#{prefix}_catinfo".to_sym] + @showtype = session["#{prefix}_showtype".to_sym] end def set_session_data prefix = self.class.session_key_prefix - session["#{prefix}_lastaction".to_sym] = @lastaction - session["#{prefix}_display".to_sym] = @display unless @display.nil? - session["#{prefix}_filters".to_sym] = @filters - session["#{prefix}_catinfo".to_sym] = @catinfo - session["#{prefix}_showtype".to_sym] = @showtype + session["#{prefix}_lastaction".to_sym] = @lastaction + session["#{prefix}_display".to_sym] = @display unless @display.nil? + session["#{prefix}_filters".to_sym] = @filters + session["#{prefix}_catinfo".to_sym] = @catinfo + session["#{prefix}_showtype".to_sym] = @showtype + session[:miq_compressed] = @compressed unless @compressed.nil? + session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil? end end end diff --git a/app/controllers/vm_controller.rb b/app/controllers/vm_controller.rb index 341814da07d..8674e0f55ec 100644 --- a/app/controllers/vm_controller.rb +++ b/app/controllers/vm_controller.rb @@ -6,6 +6,8 @@ class VmController < ApplicationController include VmCommon # common methods for vm controllers include VmRemote # methods for VM remote access + include Mixins::GenericSessionMixin + def index session[:vm_type] = nil # Reset VM type if coming in from All tab redirect_to :action => 'show_list' @@ -20,26 +22,16 @@ def show_list private #### def get_session_data - @title = _("Virtual Machines") - @layout = "vm" - @lastaction = session[:vm_lastaction] - @showtype = session[:vm_showtype] - @filters = session[:vm_filters] - @catinfo = session[:vm_catinfo] - @display = session[:vm_display] @polArr = session[:polArr] || "" # current tags in effect @policy_options = session[:policy_options] || "" end def set_session_data - session[:vm_lastaction] = @lastaction - session[:vm_showtype] = @showtype - session[:miq_compressed] = @compressed unless @compressed.nil? - session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil? - session[:vm_filters] = @filters - session[:vm_catinfo] = @catinfo - session[:vm_display] = @display unless @display.nil? session[:polArr] = @polArr unless @polArr.nil? session[:policy_options] = @policy_options unless @policy_options.nil? end + + def title + _("Virtual Machines") + end end From bfa6319a48b88d23c02394ba7d0e08352c219f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20=C4=8C=C3=AD=C5=BEek?= Date: Fri, 7 Apr 2017 08:22:54 +0200 Subject: [PATCH 2/6] moved title method above private in vm_controller --- app/controllers/vm_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/vm_controller.rb b/app/controllers/vm_controller.rb index 8674e0f55ec..b60874936b9 100644 --- a/app/controllers/vm_controller.rb +++ b/app/controllers/vm_controller.rb @@ -18,6 +18,10 @@ def show_list options[:model] = "ManageIQ::Providers::CloudManager::Vm" if params['sb_controller'] == 'availability_zone' process_show_list(options) end + + def title + _("Virtual Machines") + end private #### @@ -31,7 +35,4 @@ def set_session_data session[:policy_options] = @policy_options unless @policy_options.nil? end - def title - _("Virtual Machines") - end end From 99b303dc9ea021bc4b9708796f073d361b2f5b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20=C4=8C=C3=AD=C5=BEek?= Date: Fri, 7 Apr 2017 08:27:37 +0200 Subject: [PATCH 3/6] Update vm_controller.rb removed some cosmetic things as spaces and empty lines --- app/controllers/vm_controller.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/vm_controller.rb b/app/controllers/vm_controller.rb index b60874936b9..01d2768ad94 100644 --- a/app/controllers/vm_controller.rb +++ b/app/controllers/vm_controller.rb @@ -18,7 +18,7 @@ def show_list options[:model] = "ManageIQ::Providers::CloudManager::Vm" if params['sb_controller'] == 'availability_zone' process_show_list(options) end - + def title _("Virtual Machines") end @@ -34,5 +34,4 @@ def set_session_data session[:polArr] = @polArr unless @polArr.nil? session[:policy_options] = @policy_options unless @policy_options.nil? end - end From d66f9e33062b76d0f1095614e60147564b6b6065 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 22 May 2017 16:52:10 +0000 Subject: [PATCH 4/6] GenericShowMixin - fix formatting too much indent because of an earlier (removed) change --- .../mixins/generic_session_mixin.rb | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/controllers/mixins/generic_session_mixin.rb b/app/controllers/mixins/generic_session_mixin.rb index fb33d95936a..9ba444c1f31 100644 --- a/app/controllers/mixins/generic_session_mixin.rb +++ b/app/controllers/mixins/generic_session_mixin.rb @@ -4,26 +4,26 @@ module GenericSessionMixin private def get_session_data - prefix = self.class.session_key_prefix - @title = respond_to?(:title) ? title : ui_lookup(:tables => self.class.table_name) - @layout = prefix - @table_name = request.parameters[:controller] - @lastaction = session["#{prefix}_lastaction".to_sym] - @display = session["#{prefix}_display".to_sym] - @filters = session["#{prefix}_filters".to_sym] - @catinfo = session["#{prefix}_catinfo".to_sym] - @showtype = session["#{prefix}_showtype".to_sym] + prefix = self.class.session_key_prefix + @title = respond_to?(:title) ? title : ui_lookup(:tables => self.class.table_name) + @layout = prefix + @table_name = request.parameters[:controller] + @lastaction = session["#{prefix}_lastaction".to_sym] + @display = session["#{prefix}_display".to_sym] + @filters = session["#{prefix}_filters".to_sym] + @catinfo = session["#{prefix}_catinfo".to_sym] + @showtype = session["#{prefix}_showtype".to_sym] end def set_session_data prefix = self.class.session_key_prefix - session["#{prefix}_lastaction".to_sym] = @lastaction - session["#{prefix}_display".to_sym] = @display unless @display.nil? - session["#{prefix}_filters".to_sym] = @filters - session["#{prefix}_catinfo".to_sym] = @catinfo - session["#{prefix}_showtype".to_sym] = @showtype - session[:miq_compressed] = @compressed unless @compressed.nil? - session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil? + session["#{prefix}_lastaction".to_sym] = @lastaction + session["#{prefix}_display".to_sym] = @display unless @display.nil? + session["#{prefix}_filters".to_sym] = @filters + session["#{prefix}_catinfo".to_sym] = @catinfo + session["#{prefix}_showtype".to_sym] = @showtype + session[:miq_compressed] = @compressed unless @compressed.nil? + session[:miq_exists_mode] = @exists_mode unless @exists_mode.nil? end end end From 89be05931726ea303f192d5a24fe5cdcaa48dd8a Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 22 May 2017 16:54:12 +0000 Subject: [PATCH 5/6] VmController - get/set_session_data from GenericShowMixin Actually call super when using the mixin.. --- app/controllers/vm_controller.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/vm_controller.rb b/app/controllers/vm_controller.rb index 01d2768ad94..94653a71096 100644 --- a/app/controllers/vm_controller.rb +++ b/app/controllers/vm_controller.rb @@ -5,7 +5,6 @@ class VmController < ApplicationController after_action :set_session_data include VmCommon # common methods for vm controllers include VmRemote # methods for VM remote access - include Mixins::GenericSessionMixin def index @@ -22,15 +21,17 @@ def show_list def title _("Virtual Machines") end - - private #### + + private def get_session_data + super @polArr = session[:polArr] || "" # current tags in effect @policy_options = session[:policy_options] || "" end def set_session_data + super session[:polArr] = @polArr unless @polArr.nil? session[:policy_options] = @policy_options unless @policy_options.nil? end From 3990cfdc9b51ccc63e4383ea31a25cc04ee25774 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Mon, 22 May 2017 16:55:54 +0000 Subject: [PATCH 6/6] vm_controller - clear extra whitespace --- app/controllers/vm_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/vm_controller.rb b/app/controllers/vm_controller.rb index 94653a71096..e2e5b1d8b45 100644 --- a/app/controllers/vm_controller.rb +++ b/app/controllers/vm_controller.rb @@ -21,7 +21,7 @@ def show_list def title _("Virtual Machines") end - + private def get_session_data