Sha256: bdd7d4d765da6c6d6bcff9694bdeb9e9405a615bfb6a842afe4de2e4c0c2bdae

Contents?: true

Size: 1.54 KB

Versions: 62

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

# UI controller for ansible roles
class AnsibleRolesController < ::ApplicationController
  include Foreman::Controller::AutoCompleteSearch
  include ForemanAnsible::Concerns::ImportControllerHelper
  include ::ForemanAnsible::AnsibleRolesDataPreparations
  def index
    @ansible_roles = resource_base.search_for(params[:search],
                                              :order => params[:order]).
                     paginate(:page => params[:page],
                              :per_page => params[:per_page])
  end

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

  def import
    changed = @importer.import!
    @rows = prepare_ansible_import_rows(changed, @variables_importer)
    if @rows.empty?
      success no_changed_roles_message
      redirect_to ansible_roles_path
    else
      render
    end
  end

  def confirm_import
    job = SyncRolesAndVariables.perform_later(params['changed'].to_unsafe_h, @proxy)
    task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
    render json: {
      task: task
    }, status: :ok
  end

  private

  def default_order
    params[:order] ||= 'name ASC'
  end

  def create_importer
    @importer = ForemanAnsible::UiRolesImporter.new(@proxy)
    @variables_importer = ForemanAnsible::VariablesImporter.new(@proxy)
  end

  def no_changed_roles_message
    return _('No added or removed roles nor variables.') if @proxy.blank?
    _('No added or removed roles nor variables detected on %s.') % @proxy.name
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
foreman_ansible-14.2.2 app/controllers/ansible_roles_controller.rb
foreman_ansible-14.2.1 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.7 app/controllers/ansible_roles_controller.rb
foreman_ansible-14.2.0 app/controllers/ansible_roles_controller.rb
foreman_ansible-14.1.1 app/controllers/ansible_roles_controller.rb
foreman_ansible-14.1.0 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.5 app/controllers/ansible_roles_controller.rb
foreman_ansible-14.0.0 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.4 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.3 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.2 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.1 app/controllers/ansible_roles_controller.rb
foreman_ansible-13.0.0 app/controllers/ansible_roles_controller.rb
foreman_ansible-12.0.7 app/controllers/ansible_roles_controller.rb
foreman_ansible-10.4.4 app/controllers/ansible_roles_controller.rb
foreman_ansible-7.1.8 app/controllers/ansible_roles_controller.rb
foreman_ansible-12.0.6 app/controllers/ansible_roles_controller.rb
foreman_ansible-12.0.5 app/controllers/ansible_roles_controller.rb
foreman_ansible-10.4.3 app/controllers/ansible_roles_controller.rb
foreman_ansible-12.0.4 app/controllers/ansible_roles_controller.rb