Class: UITemplateSyncsController
Instance Method Summary
collapse
#base_export_params, #base_import_params, #location_params, #log_deprecated_param, #organization_params, #template_export_params, #template_import_params, #transform_lock_param, #ui_template_export_params, #ui_template_import_params
Instance Method Details
#action_permission ⇒ Object
39
40
41
42
43
44
45
46
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 39
def action_permission
case params[:action]
when 'sync_settings'
:view_template_syncs
else
super
end
end
|
#export ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 27
def export
@result = OpenStruct.new ForemanTemplates::TemplateExporter.new(ui_template_export_params).export!
if @result.error
render_errors [@result.error]
end
if @result.warning
render_errors [@result.warning], 'warning'
end
end
|
#import ⇒ Object
21
22
23
24
25
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 21
def import
@parse_result = OpenStruct.new ForemanTemplates::TemplateImporter.new(ui_template_import_params).import!
rescue StandardError => e
render :json => { :error => e.result.stderr }, :status => :internal_server_error and return
end
|
#parameter_filter_context ⇒ Object
48
49
50
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 48
def parameter_filter_context
Foreman::ParameterFilter::Context.new(:api, controller_name, params[:action])
end
|
#render_errors(messages, severity = 'danger') ⇒ Object
52
53
54
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 52
def render_errors(messages, severity = 'danger')
render :json => { :error => { :errors => { :base => messages }, full_messages: messages, :severity => severity } }, :status => :unprocessable_entity
end
|
#sync_settings ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'app/controllers/ui_template_syncs_controller.rb', line 12
def sync_settings
import_settings = setting_definitions(ForemanTemplates::IMPORT_SETTING_NAMES)
export_settings = setting_definitions(ForemanTemplates::EXPORT_SETTING_NAMES)
@settings = OpenStruct.new(:import => import_settings, :export => export_settings)
@edit_paths = helpers.edit_paths
render :sync_config
end
|