mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-08 23:37:08 +02:00
Complete setup in_tail pages
This commit is contained in:
parent
7ab814f240
commit
a9b6cde15d
@ -103,4 +103,6 @@ label {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
*[data-toggle] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -19,9 +19,35 @@ class Fluentd::SettingsController < ApplicationController
|
||||
end
|
||||
|
||||
def in_tail_after_file_choose
|
||||
@file = params[:file]
|
||||
@setting = Fluentd::Setting::InTail.new({
|
||||
:file => params[:file],
|
||||
:tag => nil,
|
||||
})
|
||||
end
|
||||
|
||||
def in_tail_confirm
|
||||
@setting = Fluentd::Setting::InTail.new(setting_params)
|
||||
unless @setting.valid?
|
||||
return render "in_tail_after_file_choose"
|
||||
end
|
||||
end
|
||||
|
||||
def in_tail_finish
|
||||
@setting = Fluentd::Setting::InTail.new(setting_params)
|
||||
unless @setting.valid?
|
||||
return render "in_tail_after_file_choose"
|
||||
end
|
||||
File.open(@fluentd.agent.config_file, "a") do |f| # TODO: should update by agent class
|
||||
f.write "\n"
|
||||
f.write @setting.to_conf
|
||||
end
|
||||
@fluentd.agent.restart if @fluentd.agent.running?
|
||||
redirect_to fluentd_setting_path(@fluentd)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def setting_params
|
||||
params.require(:setting).permit(:file, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval)
|
||||
end
|
||||
end
|
||||
|
25
app/models/fluentd/setting.rb
Normal file
25
app/models/fluentd/setting.rb
Normal file
@ -0,0 +1,25 @@
|
||||
class Fluentd
|
||||
module Setting
|
||||
class InTail
|
||||
include ActiveModel::Model
|
||||
attr_accessor :file, :tag, :rotate_wait, :pos_file, :read_from_head, :refresh_interval
|
||||
|
||||
validates :file, presence: true
|
||||
validates :tag, presence: true
|
||||
|
||||
def to_conf
|
||||
<<-XML.strip_heredoc.gsub(/^[ ]+\n/m, "")
|
||||
<source>
|
||||
type tail
|
||||
file #{file}
|
||||
tag #{tag}
|
||||
#{read_from_head.to_i.zero? ? "" : "read_from_head true"}
|
||||
#{pos_file.present? ? "pos_file #{pos_file}" : ""}
|
||||
#{rotate_wait.present? ? "rotate_wait #{rotate_wait}" : ""}
|
||||
#{refresh_interval.present? ? "refresh_interval #{refresh_interval}" : ""}
|
||||
</source>
|
||||
XML
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
- page_title "TODO: 監視したいファイルをえらんでください"
|
||||
- page_title t(".page_title")
|
||||
|
||||
= render partial: "shared/vue/treeview", locals: {name: "file", action: in_tail_after_file_choose_fluentd_setting_path(@fluentd), submit_button: "(TODO)次へ"}
|
||||
= render partial: "shared/vue/treeview", locals: {name: "file", action: in_tail_after_file_choose_fluentd_setting_path(@fluentd), submit_button: t('terms.next')}
|
||||
|
||||
|
@ -1,3 +1,36 @@
|
||||
- page_title "TODO: 監視したいファイルをえらんでください"
|
||||
- page_title t(".page_title")
|
||||
|
||||
= @file
|
||||
= link_to t('fluentd.settings.restart_from_first'), in_tail_fluentd_setting_path
|
||||
|
||||
= form_for(@setting, as: "setting", url: in_tail_confirm_fluentd_setting_path(@fluentd)) do |f|
|
||||
- @setting.errors.full_messages.each do |e|
|
||||
%div.alert.alert-danger= e
|
||||
|
||||
%div.form-group
|
||||
= f.label :file
|
||||
= f.hidden_field :file
|
||||
= f.text_field :file, class: "form-control", disabled: true
|
||||
%div.form-group
|
||||
= f.label :tag
|
||||
= f.text_field :tag, class: "form-control"
|
||||
.well.well-sm
|
||||
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
|
||||
= icon('fa-caret-down')
|
||||
= t('terms.advanced_setting')
|
||||
#advanced-setting.collapse
|
||||
%div.form-group
|
||||
= f.label :rotate_wait
|
||||
= f.text_field :rotate_wait, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :pos_file
|
||||
= f.text_field :pos_file, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :read_from_head
|
||||
= f.check_box :read_from_head, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :refresh_interval
|
||||
= f.text_field :refresh_interval, class: "form-control"
|
||||
|
||||
|
||||
%p
|
||||
= f.submit t('terms.next'), class: "btn btn-primary"
|
||||
|
38
app/views/fluentd/settings/in_tail_confirm.html.haml
Normal file
38
app/views/fluentd/settings/in_tail_confirm.html.haml
Normal file
@ -0,0 +1,38 @@
|
||||
- page_title t(".page_title")
|
||||
|
||||
= link_to t('fluentd.settings.restart_from_first'), in_tail_fluentd_setting_path
|
||||
|
||||
= form_for(@setting, as: "setting", url: in_tail_finish_fluentd_setting_path(@fluentd)) do |f|
|
||||
- @setting.errors.full_messages.each do |e|
|
||||
%div.alert.alert-danger= e
|
||||
|
||||
%div.form-group
|
||||
= f.label :file
|
||||
= f.hidden_field :file
|
||||
= f.text_field :file, class: "form-control", disabled: true
|
||||
%div.form-group
|
||||
= f.label :tag
|
||||
= f.text_field :tag, class: "form-control"
|
||||
.well.well-sm
|
||||
%h4{"data-toggle" => "collapse", "href" => "#advanced-setting"}
|
||||
= icon('fa-caret-down')
|
||||
= t('terms.advanced_setting')
|
||||
#advanced-setting.collapse
|
||||
%div.form-group
|
||||
= f.label :rotate_wait
|
||||
= f.text_field :rotate_wait, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :pos_file
|
||||
= f.text_field :pos_file, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :read_from_head
|
||||
= f.check_box :read_from_head, class: "form-control"
|
||||
%div.form-group
|
||||
= f.label :refresh_interval
|
||||
= f.text_field :refresh_interval, class: "form-control"
|
||||
|
||||
%pre= @setting.to_conf
|
||||
|
||||
%p
|
||||
= f.submit t('.finish'), class: "btn btn-primary"
|
||||
= t('.notice_restart_for_config_edit')
|
@ -6,4 +6,4 @@
|
||||
|
||||
= link_to t(".edit"), edit_fluentd_setting_path(@fluentd)
|
||||
|
||||
= link_to "TODO: in_tailセットアップ", in_tail_fluentd_setting_path(@fluentd)
|
||||
= link_to t(".setup_in_tail"), in_tail_fluentd_setting_path(@fluentd)
|
||||
|
@ -33,6 +33,9 @@ en:
|
||||
Really %{action}?
|
||||
reload_log: Reload fluend log
|
||||
auto_reload: "Auto Reload(every %{seconds} seconds)"
|
||||
next: Next
|
||||
advanced_setting: Advanced Setting
|
||||
notice_restart_for_config_edit: "NOTICE: fluentd will restart after update config"
|
||||
|
||||
plugins:
|
||||
notice_restart_for_config_edit: "NOTICE: fluentd will restart after update config"
|
||||
@ -81,6 +84,7 @@ en:
|
||||
setting: Setting
|
||||
config_file: Config file
|
||||
page_title: "%{label}"
|
||||
setup_in_tail: Setup in_tail
|
||||
form:
|
||||
<<: *fluentd_common
|
||||
index:
|
||||
@ -102,6 +106,16 @@ en:
|
||||
<<: *fluentd_common
|
||||
edit:
|
||||
<<: *fluentd_common
|
||||
in_tail:
|
||||
<<: *fluentd_common
|
||||
page_title: "Setup in_tail | Choosing File"
|
||||
in_tail_after_file_choose:
|
||||
<<: *fluentd_common
|
||||
page_title: "Setup in_tail | Other config"
|
||||
in_tail_confirm:
|
||||
<<: *fluentd_common
|
||||
page_title: "Setup in_tail | Confirmation"
|
||||
finish: Update config
|
||||
|
||||
misc:
|
||||
common: &misc_common
|
||||
|
@ -33,6 +33,9 @@ ja:
|
||||
%{action}しますか?
|
||||
reload_log: fluentdのログを更新
|
||||
auto_reload: "自動更新(%{seconds}秒ごと)"
|
||||
next: 次へ
|
||||
advanced_setting: 高度な設定
|
||||
notice_restart_for_config_edit: ※更新するとfluentdが再起動されます
|
||||
|
||||
plugins:
|
||||
notice_restart_for_config_edit: ※更新するとfluentdが再起動されます
|
||||
@ -98,10 +101,21 @@ ja:
|
||||
fluentd_info: 設定情報
|
||||
recent_errors: "最新 %{count}件のエラー"
|
||||
settings:
|
||||
restart_from_first: 最初からやり直す
|
||||
show:
|
||||
<<: *fluentd_common
|
||||
edit:
|
||||
<<: *fluentd_common
|
||||
in_tail:
|
||||
<<: *fluentd_common
|
||||
page_title: "in_tailセットアップ | ファイルの選択"
|
||||
in_tail_after_file_choose:
|
||||
<<: *fluentd_common
|
||||
page_title: "in_tailセットアップ | その他の設定"
|
||||
in_tail_confirm:
|
||||
<<: *fluentd_common
|
||||
page_title: "in_tailセットアップ | 確認"
|
||||
finish: 設定する
|
||||
|
||||
misc:
|
||||
common: &misc_common
|
||||
|
@ -12,6 +12,8 @@ Rails.application.routes.draw do
|
||||
resource :setting, only: [:show, :edit, :update], module: :fluentd do
|
||||
get "in_tail"
|
||||
post "in_tail_after_file_choose"
|
||||
post "in_tail_confirm"
|
||||
post "in_tail_finish"
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user