Skip to content

Commit

Permalink
Remove legacy settings code
Browse files Browse the repository at this point in the history
  • Loading branch information
GilbertCherrie committed Nov 16, 2023
1 parent f209621 commit 26d720f
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 238 deletions.
1 change: 0 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def pp_options
:display => {
:startpage => "/dashboard/show",
:reporttheme => "MIQ",
:theme => "red", # Luminescent Blue
:taskbartext => true, # Show button text on taskbar
:vmcompare => "Compressed", # Start VM compare and drift in compressed mode
:hostcompare => "Compressed", # Start Host compare in compressed mode
Expand Down
118 changes: 2 additions & 116 deletions app/controllers/configuration_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,40 +96,9 @@ def filters_field_changed
end
end

# AJAX driven routine for gtl view selection
def view_selected
assert_privileges('my_settings_default_views')
# ui1 form
return unless load_edit("config_edit__ui1", "configuration")

@edit[:new][:views][VIEW_RESOURCES[params[:resource]]] = params[:view] # Capture the new view setting
session[:changed] = (@edit[:new] != @edit[:current])
@changed = session[:changed]
render :update do |page|
page << javascript_prologue
page << javascript_for_miq_button_visibility(@changed)
page.replace('tab_div', :partial => "ui_1")
end
end

# AJAX driven routine for theme selection
def theme_changed
assert_privileges('my_settings_visuals')
# ui1 theme changed
@edit = session[:edit]
@edit[:new][:display][:theme] = params[:theme] # Capture the new setting
session[:changed] = (@edit[:new] != @edit[:current])
@changed = session[:changed]
render :update do |page|
page << javascript_prologue
page.replace('tab_div', :partial => 'ui_1')
end
end

def update
assert_privileges('my_settings_admin')
if params["save"]
get_form_vars if @tabform != "ui_3"
case @tabform
when "ui_3" # User Filters tab
@edit = session[:edit]
Expand Down Expand Up @@ -274,7 +243,7 @@ def timeprofile_delete
end
process_timeprofiles(timeprofiles, "destroy") unless timeprofiles.empty?
end
set_form_vars
show_timeprofiles
end

def timeprofile_copy
Expand All @@ -295,26 +264,6 @@ def show
show_timeprofiles if params[:typ] == "timeprofiles"
end

def time_profile_form_fields
assert_privileges("tp_edit")
@timeprofile = TimeProfile.new if params[:id] == 'new'
@timeprofile = TimeProfile.find(params[:id]) if params[:id] != 'new'

render :json => {
:description => @timeprofile.description,
:admin_user => report_admin_user?,
:restricted_time_profile => @timeprofile.profile_type == "global" && !report_admin_user?,
:profile_type => @timeprofile.profile_type || "user",
:profile_tz => @timeprofile.tz.nil? ? "" : @timeprofile.tz,
:rollup_daily => !@timeprofile.rollup_daily_metrics.nil?,
:all_days => Array(@timeprofile.days).size == 7,
:days => Array(@timeprofile.days).uniq.sort,
:all_hours => Array(@timeprofile.hours).size == 24,
:hours => Array(@timeprofile.hours).uniq.sort,
:miq_reports_count => @timeprofile.miq_reports.count
}
end

def self.session_key_prefix
"configuration"
end
Expand Down Expand Up @@ -386,34 +335,13 @@ def build_tabs
@tabs.push(["4", _("Time Profiles")]) if role_allows?(:feature => "my_settings_time_profiles")
end

def merge_in_user_settings(settings)
if (user_settings = current_user.try(:settings))
settings.each do |key, value|
value.merge!(user_settings[key]) unless user_settings[key].nil?
end
end
settings
end

# * start with DEFAULT_SETTINGS
# * merge in current session changes
# * merge in any settings from the DB if they exist
def init_settings
merge_in_user_settings(copy_hash(DEFAULT_SETTINGS))
end

def set_form_vars
case @tabform
when 'ui_1'
@edit = {
:current => init_settings,
:current => {},
:key => 'config_edit__ui1',
}

current_tz = @edit.fetch_path(:current, :display, :timezone)
if current_tz.blank?
@edit.store_path(:current, :display, :timezone, ::Settings.server.timezone)
end
when 'ui_3'
filters = MiqSearch.where(:search_type => "default")
current = filters.map do |filter|
Expand All @@ -431,54 +359,12 @@ def set_form_vars
:current => {},
:key => 'config_edit__ui4',
}
@edit[:timeprofile_id] = @timeprofile.try(:id)
if %w[timeprofile_new timeprofile_copy timeprofile_edit timeprofile_update].include?(params[:action])
@edit[:current] = {
:description => @timeprofile.description,
:profile_type => @timeprofile.profile_type || "user",
:profile_key => @timeprofile.profile_key,
:profile => {
:days => Array(@timeprofile.days).uniq.sort,
:hours => Array(@timeprofile.hours).uniq.sort,
:tz => @timeprofile.tz,
},
:rollup_daily => @timeprofile.rollup_daily_metrics,
}
@edit[:all_days] = @edit.fetch_path(:current, :profile, :days).length == 7
@edit[:all_hours] = @edit.fetch_path(:current, :profile, :hours).length == 24
end
show_timeprofiles
end
@edit[:new] = copy_hash(@edit[:current])
session[:edit] = @edit
end

def get_form_vars
@edit = session[:edit]
case @tabform
when "ui_1" # Visual Settings tab
@edit[:new][:perpage][:grid] = params[:perpage_grid].to_i if params[:perpage_grid]
@edit[:new][:perpage][:tile] = params[:perpage_tile].to_i if params[:perpage_tile]
@edit[:new][:perpage][:list] = params[:perpage_list].to_i if params[:perpage_list]
@edit[:new][:perpage][:reports] = params[:perpage_reports].to_i if params[:perpage_reports]
@edit[:new][:display][:theme] = params[:display_theme] unless params[:display_theme].nil?
@edit[:new][:display][:bg_color] = params[:bg_color] unless params[:bg_color].nil?
@edit[:new][:display][:reporttheme] = params[:display_reporttheme] unless params[:display_reporttheme].nil?
@edit[:new][:display][:dashboards] = params[:display_dashboards] unless params[:display_dashboards].nil?
@edit[:new][:display][:timezone] = params[:display_timezone] unless params[:display_timezone].nil?
@edit[:new][:display][:startpage] = params[:start_page] unless params[:start_page].nil?
@edit[:new][:display][:locale] = params[:display_locale] if params[:display_locale]
@edit[:new][:display][:compare] = params[:display][:compare] if !params[:display].nil? && !params[:display][:compare].nil?
@edit[:new][:display][:drift] = params[:display][:drift] if !params[:display].nil? && !params[:display][:drift].nil?
when "ui_3" # Visual Settings tab
@edit[:new][:display][:compare] = params[:display][:compare] if !params[:display].nil? && !params[:display][:compare].nil?
@edit[:new][:display][:drift] = params[:display][:drift] if !params[:display].nil? && !params[:display][:drift].nil?
when "ui_4" # Visual Settings tab
@edit[:new][:display][:compare] = params[:display][:compare] if !params[:display].nil? && !params[:display][:compare].nil?
@edit[:new][:display][:drift] = params[:display][:drift] if !params[:display].nil? && !params[:display][:drift].nil?
end
end

def get_session_data
super
@tabform = session[:config_tabform] if session[:config_tabform]
Expand Down
3 changes: 0 additions & 3 deletions app/helpers/configuration_helper.rb

This file was deleted.

70 changes: 0 additions & 70 deletions app/helpers/configuration_helper/configuration_view_helper.rb

This file was deleted.

3 changes: 0 additions & 3 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -628,16 +628,13 @@
timeprofile_copy
timeprofile_edit
timeprofile_new
time_profile_form_fields
],
:post => %w[
button
filters_field_changed
theme_changed
timeprofile_delete
tree_autoload
update
view_selected
]
},

Expand Down

This file was deleted.

12 changes: 0 additions & 12 deletions spec/helpers/configuration_helper_spec.rb

This file was deleted.

12 changes: 0 additions & 12 deletions spec/routing/configuration_routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@
end
end

describe '#theme_changed' do
it 'routes' do
expect(post('/configuration/theme_changed')).to route_to('configuration#theme_changed')
end
end

describe '#timeprofile_delete' do
it 'routes' do
expect(post('/configuration/timeprofile_delete')).to route_to('configuration#timeprofile_delete')
Expand All @@ -64,10 +58,4 @@
expect(post('/configuration/update')).to route_to('configuration#update')
end
end

describe '#view_selected' do
it 'routes' do
expect(post('/configuration/view_selected')).to route_to('configuration#view_selected')
end
end
end

0 comments on commit 26d720f

Please sign in to comment.