diff --git a/app/controllers/fluentd/settings/notes_controller.rb b/app/controllers/fluentd/settings/notes_controller.rb new file mode 100644 index 0000000..e1271d9 --- /dev/null +++ b/app/controllers/fluentd/settings/notes_controller.rb @@ -0,0 +1,20 @@ +class Fluentd::Settings::NotesController < ApplicationController + before_action :login_required + before_action :find_fluentd + before_action :find_note, only: [:update] + + def update + if @note.update(params[:note][:content]) + flash[:success] = t('messages.note_updating_success') + else + flash[:error] = t('errors.messages.note_updating_failed') + end + redirect_to daemon_setting_path + end + + private + + def find_note + @note = Fluentd::SettingArchive::Note.find_by_file_id(@fluentd.agent.config_backup_dir, params[:id]) + end +end diff --git a/config/locales/translation_en.yml b/config/locales/translation_en.yml index e29beaf..66fad7e 100644 --- a/config/locales/translation_en.yml +++ b/config/locales/translation_en.yml @@ -12,6 +12,7 @@ en: fluentd_status_running: Running fluentd_status_stopped: Stopped config_successfully_copied: "Config has been copied successfully. Please restart %{brand} to use the new config" + note_updating_success: "Note successfully updated." terms: &terms name: Name @@ -284,6 +285,7 @@ en: is_a_directory: is a directory. should be a file duplicated_conf: Configurations is duplicated out_forward_blank_server: server settings should be at least one + note_updating_failed: Updating the note is failed. See application logs. activemodel: &activemodel errors: diff --git a/config/locales/translation_ja.yml b/config/locales/translation_ja.yml index 3e3d63d..cb0d840 100644 --- a/config/locales/translation_ja.yml +++ b/config/locales/translation_ja.yml @@ -12,6 +12,7 @@ ja: fluentd_status_running: 稼働中 fluentd_status_stopped: 停止中 config_successfully_copied: "設定をコピーしました。反映させるには、 %{brand}を再起動してください。" + note_updating_success: "メモを更新しました。" terms: &terms name: アカウント名 @@ -289,6 +290,7 @@ ja: is_a_directory: はディレクトリです。ファイルを指定してください duplicated_conf: 同じ内容の設定がすでに存在しています out_forward_blank_server: serverの設定がありません。 + note_updating_failed: メモの更新に失敗しました。ログを確認して下さい。 activemodel: &activemodel errors: diff --git a/config/routes.rb b/config/routes.rb index 1f86f7a..42ea789 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,6 +68,8 @@ Rails.application.routes.draw do post "reuse", action: 'reuse', on: :member, as: 'reuse' end + resources :notes, only: [:update], module: :settings, controller: :notes + resource :running_backup, only: [:show], module: :settings, controller: :running_backup do post "reuse", action: 'reuse', on: :member, as: 'reuse' end