Class: ForemanSalt::SaltModulesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- ForemanSalt::SaltModulesController
- Includes:
- Foreman::Controller::AutoCompleteSearch, Concerns::SaltModuleParameters, StateImporter
- Defined in:
- app/controllers/foreman_salt/salt_modules_controller.rb
Instance Method Summary collapse
- #action_permission ⇒ Object
- #apply_changes ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Methods included from Concerns::SaltModuleParameters
Methods inherited from ApplicationController
Instance Method Details
#action_permission ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 49 def case params[:action] when 'import' :import when 'apply_changes' :import else super end end |
#apply_changes ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 70 def apply_changes if params[:changed].blank? info _('No changes found') else params[:changed].each do |environment, states| next unless states[:add] || states[:remove] add_to_environment(JSON.parse(states[:add]), environment) if states[:add] remove_from_environment(JSON.parse(states[:remove]), environment) if states[:remove] end clean_orphans success _('Successfully imported') end redirect_to salt_modules_path end |
#create ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 18 def create logger.info("Params: #{params.inspect}") @salt_module = SaltModule.new(salt_module_params) if @salt_module.save process_success else process_error end end |
#destroy ⇒ Object
41 42 43 44 45 46 47 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 41 def destroy if @salt_module.destroy process_success else process_error end end |
#edit ⇒ Object
28 29 30 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 28 def edit @salt_environments = @salt_module.salt_environments end |
#import ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 60 def import result = fetch_states_from_proxy(@proxy) @changes = result[:changes] @deletes = result[:deletes] return unless @changes.empty? info _('No changes found') redirect_to salt_modules_path end |
#index ⇒ Object
10 11 12 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 10 def index @salt_modules = resource_base.search_for(params[:search], order: params[:order]).includes(:salt_environments).paginate(page: params[:page]) end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 14 def new @salt_module = SaltModule.new end |
#update ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'app/controllers/foreman_salt/salt_modules_controller.rb', line 32 def update if @salt_module.update(salt_module_params) success _("Successfully updated #{@salt_module}.") redirect_to salt_modules_path else process_error end end |