Sha256: 4b7bde9870225a7391632d470f7b5bd34974e5b81ff3ba62eeac9851f150202e

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

# Controller to create JSON data to be used in react app
class UiAcdController < ::Api::V2::BaseController
  def app
    @app_data = {}
    app_definition = ForemanAcd::AppDefinition.find(params[:id])
    @app_data['app_definition'] = app_definition
  end

  def foreman_data
    @foreman_data = collect_foreman_data(params['id'])
  end

  def ansible_data
    @ansible_data = collect_ansible_data(params['id'])
  end

  def action_permission
    case params[:action]
    when 'app', 'foreman_data', 'ansible_data'
      :view
    else
      super
    end
  end

  private

  def collect_foreman_data(hostgroup_id)
    hg = Hostgroup.find(hostgroup_id)
    fdata = OpenStruct.new(
      :environments => Environment.all,
      :lifecycle_environments => Katello::KTEnvironment.all,
      :domains => Domain.all,
      :computeprofiles => ComputeProfile.all,
      :hostgroup_id => hg.id,
      :ptables => hg&.operatingsystem&.ptables
    )
    fdata
  end

  def collect_ansible_data(playbook_id)
    ForemanAcd::AnsiblePlaybook.find(playbook_id).as_unified_structobj
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_acd-0.7.0 app/controllers/ui_acd_controller.rb
foreman_acd-0.6.0 app/controllers/ui_acd_controller.rb