forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathems_configuration_controller.rb
113 lines (94 loc) · 3.09 KB
/
ems_configuration_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
class EmsConfigurationController < ApplicationController
include Mixins::GenericListMixin
include Mixins::GenericShowMixin
include Mixins::GenericSessionMixin
include Mixins::BreadcrumbsMixin
include Mixins::GenericFormMixin
include Mixins::ManagerControllerMixin
include Mixins::FindRecord
before_action :check_privileges
before_action :get_session_data
after_action :cleanup_action
after_action :set_session_data
def self.model
ManageIQ::Providers::ConfigurationManager
end
def self.table_name
@table_name ||= "ems_configuration"
end
def self.display_methods
%w[configuration_profiles configured_systems]
end
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if display_methods.include?(@display) # Were we displaying nested list
# Handle Toolbar Policy Tag Button
@refresh_div = "main_div" # Default div for button.rjs to refresh
model = self.class.model
tag(model) if params[:pressed] == "#{params[:controller]}_tag"
return if ["#{params[:controller]}_tag"].include?(params[:pressed]) && @flash_array.nil? # Tag screen showing
if params[:pressed].starts_with?("configured_system_") # Handle buttons from sub-items screen
tag(ConfiguredSystem) if params[:pressed] == "configured_system_tag"
provision if params[:pressed] == "configured_system_provision"
end
case params[:pressed]
when 'ems_configuration_edit_provider'
edit
when 'ems_configuration_add_provider'
new
when "ems_configuration_refresh_provider"
refresh
when "ems_configuration_delete_provider"
delete
end
if single_delete_test
single_delete_redirect
elsif (params[:pressed].ends_with?("_edit_provider") || params[:pressed] == "ems_configuration_add_provider") && @flash_array.nil?
if @flash_array
show_list
replace_gtl_main_div
else
javascript_redirect(:action => @refresh_partial, :id => @redirect_id)
end
elsif @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
else
render_flash unless performed?
end
end
private
def self.model_to_name(_provmodel)
Dictionary.gettext('ems_configuration', :type => :ui_title, :translate => false)
end
def manager_prefix
"configuration_manager"
end
def privilege_prefix
"ems_configuration"
end
def refresh
assert_privileges("ems_configuration_refresh_provider")
manager_button_operation('refresh_ems', _('Refresh'))
end
def concrete_model
ManageIQ::Providers::ConfigurationManager
end
def provider_class
ManageIQ::Providers::Foreman::Provider
end
def breadcrumbs_options
{
:breadcrumbs => [
{:title => _("Configuration Management")},
{:title => _("Providers"), :url => controller_url},
],
}
end
def set_redirect_vars
@in_a_form = true
@redirect_controller = "ems_configuration"
@redirect_id = @provider_manager.id if @provider_manager.try(:id)
@refresh_partial = @provider_manager.try(:id) ? "edit" : "new"
end
menu_section :conf
end