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-11.0.3 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.59 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-11.0.2 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-11.0.1 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-11.0.0 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.58 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-10.0.2 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.57 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-10.0.1 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.56 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.55 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.54 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.53 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.52 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.52 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-9.0.51 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.51 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-7.0.48 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-7.0.47 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-8.0.50 app/controllers/insights_cloud/settings_controller.rb