fluentd-ui 1.0.0.alpha.2 → 1.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fluentd-ui might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ChangeLog.md +5 -0
- data/Gemfile.lock +56 -1
- data/README.md +2 -2
- data/app/controllers/api/config_definitions_controller.rb +55 -0
- data/app/controllers/api_controller.rb +20 -3
- data/app/controllers/concerns/setting_concern.rb +18 -2
- data/app/controllers/fluentd/settings/in_tail_controller.rb +13 -5
- data/app/controllers/fluentd/settings/out_forward_controller.rb +0 -9
- data/app/controllers/fluentd/settings/out_s3_controller.rb +0 -5
- data/app/controllers/fluentd/settings/out_tdlog_controller.rb +9 -0
- data/app/form_builders/fluentd_form_builder.rb +83 -0
- data/app/helpers/settings_helper.rb +81 -18
- data/app/javascript/packs/application.js +4 -0
- data/app/javascript/packs/in_tail_parse.js +159 -0
- data/app/javascript/packs/owned_plugin_form.js +141 -0
- data/app/javascript/packs/parser_multiline_form.js +51 -0
- data/app/javascript/packs/plugin_setting.js +19 -0
- data/app/models/concerns/fluentd/setting/configurable.rb +113 -0
- data/app/models/concerns/fluentd/setting/pattern.rb +11 -0
- data/app/models/concerns/fluentd/setting/plugin.rb +78 -0
- data/app/models/concerns/fluentd/setting/plugin_config.rb +74 -0
- data/app/models/concerns/fluentd/setting/plugin_parameter.rb +121 -0
- data/app/models/concerns/fluentd/setting/section_parser.rb +36 -0
- data/app/models/concerns/fluentd/setting/section_validator.rb +21 -0
- data/app/models/fluentd.rb +5 -5
- data/app/models/fluentd/setting/buffer_file.rb +23 -0
- data/app/models/fluentd/setting/buffer_memory.rb +17 -0
- data/app/models/fluentd/setting/formatter_csv.rb +21 -0
- data/app/models/fluentd/setting/formatter_hash.rb +19 -0
- data/app/models/fluentd/setting/formatter_json.rb +25 -0
- data/app/models/fluentd/setting/formatter_ltsv.rb +21 -0
- data/app/models/fluentd/setting/formatter_msgpack.rb +13 -0
- data/app/models/fluentd/setting/formatter_out_file.rb +21 -0
- data/app/models/fluentd/setting/formatter_single_value.rb +20 -0
- data/app/models/fluentd/setting/formatter_stdout.rb +19 -0
- data/app/models/fluentd/setting/formatter_tsv.rb +21 -0
- data/app/models/fluentd/setting/in_forward.rb +7 -17
- data/app/models/fluentd/setting/in_http.rb +13 -19
- data/app/models/fluentd/setting/in_monitor_agent.rb +6 -19
- data/app/models/fluentd/setting/in_syslog.rb +14 -12
- data/app/models/fluentd/setting/in_tail.rb +7 -84
- data/app/models/fluentd/setting/out_elasticsearch.rb +12 -21
- data/app/models/fluentd/setting/out_forward.rb +22 -66
- data/app/models/fluentd/setting/out_mongo.rb +20 -26
- data/app/models/fluentd/setting/out_s3.rb +18 -30
- data/app/models/fluentd/setting/out_stdout.rb +21 -18
- data/app/models/fluentd/setting/out_tdlog.rb +35 -0
- data/app/models/fluentd/setting/parser_apache.rb +13 -0
- data/app/models/fluentd/setting/parser_apache2.rb +13 -0
- data/app/models/fluentd/setting/parser_apache_error.rb +13 -0
- data/app/models/fluentd/setting/parser_csv.rb +22 -0
- data/app/models/fluentd/setting/parser_in_http.rb +13 -0
- data/app/models/fluentd/setting/parser_json.rb +25 -0
- data/app/models/fluentd/setting/parser_ltsv.rb +30 -0
- data/app/models/fluentd/setting/parser_msgpack.rb +13 -0
- data/app/models/fluentd/setting/parser_multiline.rb +24 -0
- data/app/models/fluentd/setting/parser_nginx.rb +13 -0
- data/app/models/fluentd/setting/parser_none.rb +19 -0
- data/app/models/fluentd/setting/parser_regexp.rb +26 -0
- data/app/models/fluentd/setting/parser_syslog.rb +29 -0
- data/app/models/fluentd/setting/parser_tsv.rb +19 -0
- data/app/models/fluentd/setting/section.rb +38 -0
- data/app/models/fluentd/setting/storage_local.rb +22 -0
- data/app/models/fluentd/setting/type/array.rb +17 -0
- data/app/models/fluentd/setting/type/bool.rb +18 -0
- data/app/models/fluentd/setting/type/enum.rb +17 -0
- data/app/models/fluentd/setting/type/hash.rb +17 -0
- data/app/models/fluentd/setting/type/regexp.rb +17 -0
- data/app/models/fluentd/setting/type/section.rb +17 -0
- data/app/models/fluentd/setting/type/size.rb +17 -0
- data/app/models/fluentd/setting/type/time.rb +17 -0
- data/app/views/api/settings/_element.json.jbuilder +1 -1
- data/app/views/fluentd/settings/in_forward/_form.html.haml +16 -0
- data/app/views/fluentd/settings/in_tail/_form.html.haml +22 -29
- data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +1 -1
- data/app/views/fluentd/settings/in_tail/after_format.html.haml +4 -4
- data/app/views/fluentd/settings/in_tail/confirm.html.haml +5 -5
- data/app/views/fluentd/settings/source_and_output.html.haml +1 -1
- data/app/views/shared/_global_nav.html.erb +8 -8
- data/app/views/shared/settings/_form.html.haml +40 -9
- data/app/views/shared/settings/show.html.haml +4 -1
- data/app/views/shared/vue/_in_tail_parse.html.haml +20 -0
- data/app/views/shared/vue/_owned_plugin_form.html.haml +68 -0
- data/app/views/shared/vue/_parser_multiline_form.html.haml +19 -0
- data/app/views/shared/vue/_setting.html.erb +1 -1
- data/config/application.rb +1 -1
- data/config/environment.rb +3 -0
- data/config/initializers/types.rb +7 -0
- data/config/routes.rb +2 -1
- data/fluentd-ui.gemspec +5 -0
- data/lib/fluentd-ui/version.rb +1 -1
- data/lib/regexp_preview.rb +2 -2
- data/lib/regexp_preview/multi_line.rb +53 -63
- data/lib/regexp_preview/single_line.rb +40 -46
- data/spec/features/fluentd/setting/out_forward_spec.rb +1 -1
- data/spec/features/fluentd/setting/out_stdout_spec.rb +1 -1
- data/spec/features/{out_td_spec.rb → out_tdlog_spec.rb} +3 -3
- data/spec/lib/regexp_preview/multi_line_spec.rb +29 -34
- data/spec/lib/regexp_preview/single_line_spec.rb +89 -87
- data/spec/models/fluentd/setting/in_forward_spec.rb +75 -0
- data/spec/models/fluentd/setting/in_http_spec.rb +31 -0
- data/spec/models/fluentd/setting/in_monitor_agent_spec.rb +31 -0
- data/spec/models/fluentd/setting/in_syslog_spec.rb +65 -7
- data/spec/models/fluentd/setting/in_tail_spec.rb +47 -0
- data/spec/models/fluentd/setting/out_elasticsearch_spec.rb +31 -0
- data/spec/models/fluentd/setting/out_mongo_spec.rb +35 -12
- data/spec/models/fluentd/setting/out_s3_spec.rb +128 -0
- data/spec/models/fluentd/setting/out_stdout_spec.rb +31 -0
- data/spec/models/fluentd/setting/out_tdlog_spec.rb +47 -0
- metadata +164 -38
- data/app/controllers/fluentd/settings/out_td_controller.rb +0 -18
- data/app/helpers/fluentd/settings_helper.rb +0 -2
- data/app/javascript/packs/in_tail_format.js +0 -174
- data/app/models/fluentd/setting/common.rb +0 -185
- data/app/models/fluentd/setting/out_td.rb +0 -48
- data/app/views/shared/vue/_in_tail_format.html.erb +0 -43
- data/spec/models/fluentd/setting/common_spec.rb +0 -178
- data/spec/models/fluentd/setting/out_td_spec.rb +0 -38
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 371bb07d552eafadfce633dfec5adb819f3035e0d1c2f741a02935aacc5224ab
|
4
|
+
data.tar.gz: 62b220afde0c306b9d86ecddf71cefe85afe2008e4b08a80ab8fc01166002272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 834685ca65b72e54d287fdbcd74abed5df9b2d856c04126364de5e4714597e3f099bec3d38cd933496c15e7cbaac3b1271760a5c6070be1afebb2814c1a5a94c
|
7
|
+
data.tar.gz: 9880d835ba57727cb5a10816e49cae0e4854062fe88cde847231ca630f73eab3232238925e8e457ae610d11c306ab1bc55369a4106236febf1bbf2d873bdd984
|
data/ChangeLog.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## Release 1.0.0.alpha.3 - 2018/06/18
|
2
|
+
|
3
|
+
* [improvement] Support Fluentd v1 [#238](https://github.com/fluent/fluentd-ui/pull/238)
|
4
|
+
* [maintenance] Update document [#237](https://github.com/fluent/fluentd-ui/pull/237)
|
5
|
+
|
1
6
|
## Release 1.0.0-alpha.2 - 2018/05/24
|
2
7
|
|
3
8
|
* [fixed] Update HTML classes [#234](https://github.com/fluent/fluentd-ui/pull/234)
|
data/Gemfile.lock
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluentd-ui (1.0.0.alpha.
|
4
|
+
fluentd-ui (1.0.0.alpha.3)
|
5
5
|
addressable
|
6
6
|
bootsnap (>= 1.1.0)
|
7
7
|
bundler
|
8
8
|
diff-lcs
|
9
9
|
draper (~> 3.0)
|
10
|
+
fluent-plugin-elasticsearch (~> 2.10)
|
11
|
+
fluent-plugin-mongo (~> 1.1)
|
12
|
+
fluent-plugin-s3 (~> 1.1)
|
13
|
+
fluent-plugin-td (~> 1.0)
|
10
14
|
fluentd (>= 1.0.0, < 2)
|
11
15
|
font-awesome-rails
|
12
16
|
haml-rails (~> 1.0)
|
@@ -74,6 +78,24 @@ GEM
|
|
74
78
|
addressable (2.5.2)
|
75
79
|
public_suffix (>= 2.0.2, < 4.0)
|
76
80
|
arel (9.0.0)
|
81
|
+
aws-eventstream (1.0.0)
|
82
|
+
aws-partitions (1.87.0)
|
83
|
+
aws-sdk-core (3.21.2)
|
84
|
+
aws-eventstream (~> 1.0)
|
85
|
+
aws-partitions (~> 1.0)
|
86
|
+
aws-sigv4 (~> 1.0)
|
87
|
+
jmespath (~> 1.0)
|
88
|
+
aws-sdk-kms (1.5.0)
|
89
|
+
aws-sdk-core (~> 3)
|
90
|
+
aws-sigv4 (~> 1.0)
|
91
|
+
aws-sdk-s3 (1.13.0)
|
92
|
+
aws-sdk-core (~> 3, >= 3.21.2)
|
93
|
+
aws-sdk-kms (~> 1)
|
94
|
+
aws-sigv4 (~> 1.0)
|
95
|
+
aws-sdk-sqs (1.3.0)
|
96
|
+
aws-sdk-core (~> 3)
|
97
|
+
aws-sigv4 (~> 1.0)
|
98
|
+
aws-sigv4 (1.0.2)
|
77
99
|
better_errors (2.1.1)
|
78
100
|
coderay (>= 1.0.0)
|
79
101
|
erubis (>= 2.6.6)
|
@@ -83,6 +105,7 @@ GEM
|
|
83
105
|
debug_inspector (>= 0.0.1)
|
84
106
|
bootsnap (1.3.0)
|
85
107
|
msgpack (~> 1.0)
|
108
|
+
bson (4.3.0)
|
86
109
|
builder (3.2.3)
|
87
110
|
capybara (3.0.2)
|
88
111
|
addressable
|
@@ -112,14 +135,39 @@ GEM
|
|
112
135
|
activemodel-serializers-xml (~> 1.0)
|
113
136
|
activesupport (~> 5.0)
|
114
137
|
request_store (~> 1.0)
|
138
|
+
elasticsearch (6.0.2)
|
139
|
+
elasticsearch-api (= 6.0.2)
|
140
|
+
elasticsearch-transport (= 6.0.2)
|
141
|
+
elasticsearch-api (6.0.2)
|
142
|
+
multi_json
|
143
|
+
elasticsearch-transport (6.0.2)
|
144
|
+
faraday
|
145
|
+
multi_json
|
115
146
|
erubi (1.7.1)
|
116
147
|
erubis (2.7.0)
|
148
|
+
excon (0.62.0)
|
117
149
|
factory_bot (4.8.2)
|
118
150
|
activesupport (>= 3.0.0)
|
119
151
|
factory_bot_rails (4.8.2)
|
120
152
|
factory_bot (~> 4.8.2)
|
121
153
|
railties (>= 3.0.0)
|
154
|
+
faraday (0.15.2)
|
155
|
+
multipart-post (>= 1.2, < 3)
|
122
156
|
ffi (1.9.23)
|
157
|
+
fluent-plugin-elasticsearch (2.10.1)
|
158
|
+
elasticsearch
|
159
|
+
excon
|
160
|
+
fluentd (>= 0.14.20)
|
161
|
+
fluent-plugin-mongo (1.1.1)
|
162
|
+
fluentd (>= 0.14.12, < 2)
|
163
|
+
mongo (~> 2.2.0)
|
164
|
+
fluent-plugin-s3 (1.1.3)
|
165
|
+
aws-sdk-s3 (~> 1.0)
|
166
|
+
aws-sdk-sqs (~> 1.0)
|
167
|
+
fluentd (>= 0.14.2, < 2)
|
168
|
+
fluent-plugin-td (1.0.0)
|
169
|
+
fluentd (>= 0.14.13, < 2)
|
170
|
+
td-client (~> 1.0)
|
123
171
|
fluentd (1.2.1)
|
124
172
|
cool.io (>= 1.4.5, < 2.0.0)
|
125
173
|
dig_rb (~> 1.0.0)
|
@@ -159,6 +207,7 @@ GEM
|
|
159
207
|
jbuilder (2.7.0)
|
160
208
|
activesupport (>= 4.2.0)
|
161
209
|
multi_json (>= 1.2)
|
210
|
+
jmespath (1.4.0)
|
162
211
|
json (2.1.0)
|
163
212
|
kramdown (1.16.2)
|
164
213
|
kramdown-haml (0.0.3)
|
@@ -181,8 +230,11 @@ GEM
|
|
181
230
|
mini_mime (1.0.0)
|
182
231
|
mini_portile2 (2.3.0)
|
183
232
|
minitest (5.11.3)
|
233
|
+
mongo (2.2.7)
|
234
|
+
bson (~> 4.0)
|
184
235
|
msgpack (1.2.4)
|
185
236
|
multi_json (1.13.1)
|
237
|
+
multipart-post (2.0.0)
|
186
238
|
nio4r (2.3.0)
|
187
239
|
nokogiri (1.8.2)
|
188
240
|
mini_portile2 (~> 2.3.0)
|
@@ -286,6 +338,9 @@ GEM
|
|
286
338
|
strptime (0.2.3)
|
287
339
|
sucker_punch (2.0.4)
|
288
340
|
concurrent-ruby (~> 1.0.0)
|
341
|
+
td-client (1.0.6)
|
342
|
+
httpclient (>= 2.7)
|
343
|
+
msgpack (>= 0.5.6, < 2)
|
289
344
|
temple (0.8.0)
|
290
345
|
thor (0.20.0)
|
291
346
|
thread_safe (0.3.6)
|
data/README.md
CHANGED
@@ -17,9 +17,9 @@ fluentd-ui is a browser-based [fluentd](http://www.fluentd.org) and [td-agent](h
|
|
17
17
|
## Requirements
|
18
18
|
|
19
19
|
- ruby 2.2.2 or later (since v1.0.0)
|
20
|
-
- fluentd v1.0.0 or later
|
20
|
+
- fluentd v1.0.0 or later (also supports td-agent 3)
|
21
|
+
- Currently, fluentd v1 and td-agent 3 support is in alpha state
|
21
22
|
|
22
|
-
Currently, fluentd-ui doesn't support fleuntd v1 and td-agent 3.
|
23
23
|
And some additional packages (Debian / Ubuntu)
|
24
24
|
|
25
25
|
- build-essential
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Api::ConfigDefinitionsController < ApplicationController
|
2
|
+
before_action :login_required
|
3
|
+
|
4
|
+
def index
|
5
|
+
name = params[:name]
|
6
|
+
type = params[:type]
|
7
|
+
prefix = case type
|
8
|
+
when "input"
|
9
|
+
"in"
|
10
|
+
when "output"
|
11
|
+
"out"
|
12
|
+
when "filter"
|
13
|
+
"filter"
|
14
|
+
when "parse"
|
15
|
+
"parser"
|
16
|
+
when "format"
|
17
|
+
"formatter"
|
18
|
+
when "parser", "formatter", "buffer", "storage"
|
19
|
+
type
|
20
|
+
end
|
21
|
+
|
22
|
+
target_class = Fluentd::Setting.const_get("#{prefix}_#{name}".classify)
|
23
|
+
target = target_class.new
|
24
|
+
|
25
|
+
common_options = target.common_options.map do |key|
|
26
|
+
h = {
|
27
|
+
name: key,
|
28
|
+
type: target.column_type(key),
|
29
|
+
desc: target.desc(key),
|
30
|
+
default: target.default(key)
|
31
|
+
}
|
32
|
+
h[:list] = target.list_of(key) if target.column_type(key) == :enum
|
33
|
+
h
|
34
|
+
end
|
35
|
+
|
36
|
+
advanced_options = target.advanced_options.map do |key|
|
37
|
+
h = {
|
38
|
+
name: key,
|
39
|
+
type: target.column_type(key),
|
40
|
+
desc: target.desc(key),
|
41
|
+
default: target.default(key)
|
42
|
+
}
|
43
|
+
h[:list] = target.list_of(key) if target.column_type(key) == :enum
|
44
|
+
h
|
45
|
+
end
|
46
|
+
|
47
|
+
options = {
|
48
|
+
type: type,
|
49
|
+
name: name,
|
50
|
+
commonOptions: common_options,
|
51
|
+
advancedOptions: advanced_options
|
52
|
+
}
|
53
|
+
render json: options
|
54
|
+
end
|
55
|
+
end
|
@@ -19,9 +19,12 @@ class ApiController < ApplicationController
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def regexp_preview
|
22
|
-
|
22
|
+
plugin_config = prepare_plugin_config || {}
|
23
|
+
preview = RegexpPreview.processor(params[:parse_type]).new(params[:file], params[:parse_type], plugin_config)
|
23
24
|
|
24
|
-
render json: preview.
|
25
|
+
render json: preview.matches
|
26
|
+
rescue Fluent::ConfigError => ex
|
27
|
+
render json: { error: "#{ex.class}: #{ex.message}" }
|
25
28
|
end
|
26
29
|
|
27
30
|
def grok_to_regexp
|
@@ -29,5 +32,19 @@ class ApiController < ApplicationController
|
|
29
32
|
grok.load_patterns
|
30
33
|
render text: grok.convert_to_regexp(params[:grok_str]).source
|
31
34
|
end
|
32
|
-
end
|
33
35
|
|
36
|
+
private
|
37
|
+
|
38
|
+
def prepare_plugin_config
|
39
|
+
plugin_config = params[:plugin_config]
|
40
|
+
case params[:parse_type]
|
41
|
+
when "multiline"
|
42
|
+
plugin_config[:formats].lines.each.with_index do |line, index|
|
43
|
+
plugin_config["format#{index + 1}"] = line.chomp
|
44
|
+
end
|
45
|
+
plugin_config
|
46
|
+
else
|
47
|
+
plugin_config
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -10,11 +10,19 @@ module SettingConcern
|
|
10
10
|
|
11
11
|
def show
|
12
12
|
@setting = target_class.new(initial_params)
|
13
|
+
@buffer = @setting.create_buffer
|
14
|
+
@storage = @setting.create_storage
|
15
|
+
@parser = @setting.create_parser
|
16
|
+
@formatter = @setting.create_formatter
|
17
|
+
@_used_param = {}
|
18
|
+
@_used_section = {}
|
13
19
|
render "shared/settings/show"
|
14
20
|
end
|
15
21
|
|
16
22
|
def finish
|
17
23
|
@setting = target_class.new(setting_params)
|
24
|
+
@_used_param = {}
|
25
|
+
@_used_section = {}
|
18
26
|
unless @setting.valid?
|
19
27
|
return render "shared/settings/show"
|
20
28
|
end
|
@@ -32,7 +40,7 @@ module SettingConcern
|
|
32
40
|
private
|
33
41
|
|
34
42
|
def setting_params
|
35
|
-
params.require(
|
43
|
+
params.require(:setting).permit(*target_class.permit_params)
|
36
44
|
end
|
37
45
|
|
38
46
|
def initial_params
|
@@ -40,7 +48,15 @@ module SettingConcern
|
|
40
48
|
end
|
41
49
|
|
42
50
|
def target_plugin_name
|
43
|
-
target_class.
|
51
|
+
prefix = case target_class.plugin_type
|
52
|
+
when "input"
|
53
|
+
"in"
|
54
|
+
when "output"
|
55
|
+
"out"
|
56
|
+
else
|
57
|
+
target_class.plugin_type
|
58
|
+
end
|
59
|
+
"#{prefix}_#{target_class.plugin_name}"
|
44
60
|
end
|
45
61
|
|
46
62
|
def plugin_setting_form_action_url(*args)
|
@@ -4,8 +4,8 @@ class Fluentd::Settings::InTailController < ApplicationController
|
|
4
4
|
|
5
5
|
def after_file_choose
|
6
6
|
@setting = Fluentd::Setting::InTail.new({
|
7
|
-
:
|
8
|
-
:
|
7
|
+
path: params[:path],
|
8
|
+
tag: nil
|
9
9
|
})
|
10
10
|
end
|
11
11
|
|
@@ -38,20 +38,28 @@ class Fluentd::Settings::InTailController < ApplicationController
|
|
38
38
|
return render "after_format"
|
39
39
|
end
|
40
40
|
|
41
|
-
if @fluentd.agent.configuration.to_s.include?(@setting.
|
41
|
+
if @fluentd.agent.configuration.to_s.include?(@setting.to_config.to_s.strip)
|
42
42
|
@setting.errors.add(:base, :duplicated_conf)
|
43
43
|
return render "after_format"
|
44
44
|
end
|
45
45
|
|
46
|
-
@fluentd.agent.config_append @setting.
|
46
|
+
@fluentd.agent.config_append @setting.to_config.to_s
|
47
47
|
@fluentd.agent.restart if @fluentd.agent.running?
|
48
48
|
redirect_to daemon_setting_path(@fluentd)
|
49
49
|
end
|
50
50
|
|
51
|
+
def target_class
|
52
|
+
Fluentd::Setting::InTail
|
53
|
+
end
|
54
|
+
|
51
55
|
private
|
52
56
|
|
53
57
|
def setting_params
|
54
|
-
|
58
|
+
permit_params = target_class._types.keys
|
59
|
+
permit_params << :parse_type
|
60
|
+
section_class = Fluentd::Setting.const_get("parser_#{params.dig(:setting, :parse_type)}".classify)
|
61
|
+
permit_params << { parse: section_class._types.keys }
|
62
|
+
params.require(:setting).permit(*permit_params)
|
55
63
|
end
|
56
64
|
|
57
65
|
end
|
@@ -6,13 +6,4 @@ class Fluentd::Settings::OutForwardController < ApplicationController
|
|
6
6
|
def target_class
|
7
7
|
Fluentd::Setting::OutForward
|
8
8
|
end
|
9
|
-
|
10
|
-
def setting_params
|
11
|
-
params.require(:fluentd_setting_out_forward).permit(*Fluentd::Setting::OutForward::KEYS).merge(
|
12
|
-
params.require(:fluentd_setting_out_forward).permit(
|
13
|
-
:server => Fluentd::Setting::OutForward::Server::KEYS,
|
14
|
-
:secondary => Fluentd::Setting::OutForward::Secondary::KEYS,
|
15
|
-
),
|
16
|
-
)
|
17
|
-
end
|
18
9
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class FluentdFormBuilder < ActionView::Helpers::FormBuilder
|
2
|
+
include ActionView::Helpers::TagHelper
|
3
|
+
include ActionView::Context
|
4
|
+
|
5
|
+
def field(key, options = {})
|
6
|
+
plugin_class = object.class
|
7
|
+
content_tag(:div, class: "form-group") do
|
8
|
+
if plugin_class._sections[key]
|
9
|
+
render_section(key, options)
|
10
|
+
else
|
11
|
+
resolve_field(key, options)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def resolve_field(key, options = {})
|
19
|
+
plugin_class = object.class
|
20
|
+
column_type = plugin_class.column_type(key)
|
21
|
+
case column_type
|
22
|
+
when :enum
|
23
|
+
enum_field(key, options)
|
24
|
+
when :bool
|
25
|
+
bool_field(key, options)
|
26
|
+
else
|
27
|
+
other_field(key, options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def enum_field(key, options)
|
32
|
+
label(key, nil, data: { toggle: "tooltip", placement: "right" }, title: object.desc(key)) +
|
33
|
+
select(key, object.list_of(key), options, { class: "enum" })
|
34
|
+
end
|
35
|
+
|
36
|
+
def bool_field(key, options)
|
37
|
+
check_box(key, options, "true", "false") + " " +
|
38
|
+
label(key, nil, data: { toggle: "tooltip", placement: "right" }, title: object.desc(key))
|
39
|
+
end
|
40
|
+
|
41
|
+
def other_field(key, options)
|
42
|
+
return unless object.respond_to?(key)
|
43
|
+
label(key, nil, data: { toggle: "tooltip", placement: "right" }, title: object.desc(key)) +
|
44
|
+
text_field(key, class: "form-control", **options)
|
45
|
+
end
|
46
|
+
|
47
|
+
def render_section(key, options)
|
48
|
+
section_class = object.class._sections[key]
|
49
|
+
children = object.__send__(key) || { "0" => {} }
|
50
|
+
html = ""
|
51
|
+
|
52
|
+
children.each do |index, child|
|
53
|
+
html << content_tag("div", class: "js-nested-column #{section_class.multi ? "js-multiple" : ""}") do
|
54
|
+
_html = ""
|
55
|
+
_html << append_and_remove_links if section_class.multi
|
56
|
+
_html << label(key, nil, data: { toggle: "tooltip", placement: "right" }, title: object.desc(key))
|
57
|
+
_html << section_fields(key, index, section_class, child)
|
58
|
+
_html.html_safe
|
59
|
+
end
|
60
|
+
end
|
61
|
+
html.html_safe
|
62
|
+
end
|
63
|
+
|
64
|
+
def section_fields(key, index, section_class, child)
|
65
|
+
section = section_class.new(child)
|
66
|
+
fields("#{key}[#{index}]", model: section) do |section_form|
|
67
|
+
html = ""
|
68
|
+
section_class._types.keys.each do |section_key|
|
69
|
+
html << section_form.field(section_key)
|
70
|
+
end
|
71
|
+
html.html_safe
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def append_and_remove_links
|
76
|
+
%Q!<a class="btn btn-xs btn-default js-append">#{icon('fa-plus')}</a> ! +
|
77
|
+
%Q!<a class="btn btn-xs btn-default js-remove" style="display:none">#{icon('fa-minus')}</a> !
|
78
|
+
end
|
79
|
+
|
80
|
+
def icon(classes, inner=nil)
|
81
|
+
%Q!<i class="fa #{classes}">#{inner}</i> !.html_safe
|
82
|
+
end
|
83
|
+
end
|