Sha256: 53ad7585c46a2bc115037b393f32e4da9146dde1d91945932216d6bc8c31639a

Contents?: true

Size: 1.02 KB

Versions: 39

Compression:

Stored size: 1.02 KB

Contents

module InsightsCloud
  class SettingsController < ::ApplicationController
    def show
      render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
    end

    def update
      Setting[:allow_auto_insights_sync] = settings_params
      render_setting(:insightsSyncEnabled, :allow_auto_insights_sync)
    end

    def set_org_parameter
      parameter = params.require(:parameter)
      new_value = ActiveModel::Type::Boolean.new.cast(params.require(:value))
      org_id = params.require(:organization_id)

      organization = Organization.authorized.find(org_id)

      org_param = organization.organization_parameters.find_or_create_by(name: parameter) do |org_param|
        org_param.name = parameter
      end
      org_param.value = new_value
      org_param.save!
    end

    private

    def render_setting(node_name, setting)
      render json: {
        node_name => Setting[setting],
      }
    end

    def settings_params
      ActiveModel::Type::Boolean.new.cast(params.require(:insightsSyncEnabled))
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
foreman_rh_cloud-8.0.49 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.48 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.47 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.46 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.45 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.46 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.45 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-7.0.46 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.44 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-7.0.45 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.44 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.43 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.42.2 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.42.1 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.43 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.42 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-6.0.42 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.41 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.39 app/controllers/insights_cloud/settings_controller.rb