Sha256: a278347ff42580a5c58705efb033b53ab782844e1ea554c742c0118ac11aac93

Contents?: true

Size: 1.62 KB

Versions: 41

Compression:

Stored size: 1.62 KB

Contents

# == Schema Information
#
# Table name: easy_ml_settings
#
#  id                   :bigint           not null, primary key
#  storage              :string
#  timezone             :string
#  s3_access_key_id     :string
#  s3_secret_access_key :string
#  s3_bucket            :string
#  s3_region            :string
#  s3_prefix            :string
#  created_at           :datetime         not null
#  updated_at           :datetime         not null
#
module EasyML
  class SettingsController < ApplicationController
    def index
      @settings = Settings.first_or_create
      render inertia: "pages/SettingsPage", props: {
        settings: { settings: settings_to_json(@settings) },
      }
    end

    def update
      @settings = Settings.first_or_create

      @settings.update(settings_params)
      EasyML::Configuration.configure do |config|
        config.storage = @settings.storage
        config.timezone = @settings.timezone
        config.s3_access_key_id = @settings.s3_access_key_id
        config.s3_secret_access_key = @settings.s3_secret_access_key
        config.s3_bucket = @settings.s3_bucket
        config.s3_region = @settings.s3_region
        config.s3_prefix = @settings.s3_prefix
      end
      flash.now[:notice] = "Settings saved."
      render inertia: "pages/SettingsPage", props: {
        settings: @settings.as_json,
      }
    end

    private

    def settings_params
      params.require(:settings).permit(
        :storage,
        :timezone,
        :s3_access_key_id,
        :s3_secret_access_key,
        :s3_bucket,
        :s3_region,
        :s3_prefix,
        :wandb_api_key
      )
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
easy_ml-0.2.0.pre.rc41 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc40 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc39 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc38 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc37 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc36 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc35 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc34 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc33 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc32 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc31 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc30 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc29 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc28 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc27 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc26 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc25 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc24 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc23 app/controllers/easy_ml/settings_controller.rb
easy_ml-0.2.0.pre.rc22 app/controllers/easy_ml/settings_controller.rb