Sha256: e737dec3cde93bad04ccdba027b1b6f1903c66a0ac7b4837e2cf398f5d4c1774

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module ForemanAcd
  # Application Definition Controller
  class AppDefinitionsController < ::ForemanAcd::ApplicationController
    include Foreman::Controller::AutoCompleteSearch
    include ::ForemanAcd::Concerns::AppDefinitionParameters

    before_action :find_resource, :only => [:edit, :update, :destroy]

    def index
      @app_definitions = resource_base.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
    end

    def read_hostgroups
      @hostgroups = Hostgroup.all.map { |elem| { elem.id => elem.name } }.reduce({}) { |h, v| h.merge v }
    end

    def new
      read_hostgroups
      @app_definition = AppDefinition.new
    end

    def create
      @app_definition = AppDefinition.new(app_definition_params)
      if @app_definition.save
        process_success
      else
        process_error
      end
    end

    def edit
      read_hostgroups
    end

    def update
      if @app_definition.update(app_definition_params)
        process_success
      else
        process_error
      end
    end

    def destroy
      if @app_definition.destroy
        process_success
      else
        process_error
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
foreman_acd-0.0.6 app/controllers/foreman_acd/app_definitions_controller.rb
foreman_acd-0.0.5 app/controllers/foreman_acd/app_definitions_controller.rb
foreman_acd-0.0.4 app/controllers/foreman_acd/app_definitions_controller.rb
foreman_acd-0.0.3 app/controllers/foreman_acd/app_definitions_controller.rb
foreman_acd-0.0.2 app/controllers/foreman_acd/app_definitions_controller.rb
foreman_acd-0.0.1 app/controllers/foreman_acd/app_definitions_controller.rb