Sha256: 61d874d521bd799822dba08bdb81855a007c910ba494665e2605620107981c66

Contents?: true

Size: 978 Bytes

Versions: 13

Compression:

Stored size: 978 Bytes

Contents

module SettingHistoryConcern
  extend ActiveSupport::Concern

  included do
    before_action :login_required
    before_action :find_fluentd
    before_action :find_backup_file, only: [:show, :reuse, :configtest]
  end

  def show
    current = @fluentd.agent.config
    target = @backup_file.content
    if target
      @sdiff = Diff::LCS.sdiff(current.split("\n").map(&:rstrip), target.split("\n").map(&:rstrip))
      @changed = @sdiff.any? { |context_change| context_change.changed? }
    end
  end

  def reuse
    @fluentd.agent.config_write @backup_file.content
    redirect_to daemon_setting_path, flash: { success: t('messages.config_successfully_copied',  brand: fluentd_ui_brand) }
  end

  def configtest
    @fluentd.config_file = @backup_file.file_path
    if @fluentd.agent.dryrun
      flash = { success: t('messages.dryrun_is_passed') }
    else
      flash = { danger: @fluentd.agent.log.tail(1).first }
    end
    redirect_to :back, flash: flash
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fluentd-ui-0.4.5 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.4.4 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.4.3 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.4.2 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.4.1 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.4.0 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.21 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.20 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.19 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.18 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.17 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.16 app/controllers/concerns/setting_history_concern.rb
fluentd-ui-0.3.15 app/controllers/concerns/setting_history_concern.rb