Sha256: 765dc87d51ca1a0fb9f22efacf1667a31dad79af4296875552200fa7b3bc3430

Contents?: true

Size: 864 Bytes

Versions: 36

Compression:

Stored size: 864 Bytes

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 save_token_and_sync
      token = Setting::RhCloud.find_by_name("rh_cloud_token")
      token.value = params.require(:value)
      token.save!
      ForemanTasks.sync_task(InsightsCloud::Async::InsightsFullSync)
      redirect_to(:controller => "hits", :action => 'index')
    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

36 entries across 36 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-3.0.33 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.35 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.35 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.34 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.33 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-3.0.32 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.32 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.32 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.31 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.31 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.30 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.30 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-3.0.29 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.29 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.29 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-3.0.28 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-5.0.28 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-4.0.27 app/controllers/insights_cloud/settings_controller.rb
foreman_rh_cloud-3.0.26 app/controllers/insights_cloud/settings_controller.rb