fluentd-ui 0.4.5 → 1.0.0.alpha.1

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.

Files changed (243) hide show
  1. checksums.yaml +5 -5
  2. data/.babelrc +18 -0
  3. data/.editorconfig +11 -0
  4. data/.gitignore +7 -0
  5. data/.postcssrc.yml +3 -0
  6. data/.travis.yml +20 -4
  7. data/ChangeLog.md +7 -2
  8. data/Gemfile +8 -6
  9. data/Gemfile.lock +177 -178
  10. data/README.md +15 -10
  11. data/app/assets/stylesheets/application.css +6 -5
  12. data/app/controllers/concerns/setting_history_concern.rb +1 -1
  13. data/app/controllers/fluentd/agents_controller.rb +5 -0
  14. data/app/controllers/misc_controller.rb +2 -2
  15. data/app/controllers/plugins_controller.rb +4 -4
  16. data/app/helpers/application_helper.rb +8 -2
  17. data/app/helpers/settings_helper.rb +2 -2
  18. data/app/javascript/packs/application.js +31 -0
  19. data/app/{assets/javascripts/codemirror_fluentd.js → javascript/packs/codemirror.js} +32 -1
  20. data/app/javascript/packs/fluent_log.js +63 -0
  21. data/app/javascript/packs/in_tail_format.js +174 -0
  22. data/app/javascript/packs/nested_settings.js +40 -0
  23. data/app/javascript/packs/notification.js +60 -0
  24. data/app/javascript/packs/settings.js +122 -0
  25. data/app/javascript/packs/treeview.js +99 -0
  26. data/{vendor/assets/javascripts/.keep → app/javascript/stylesheets/application.scss} +0 -0
  27. data/app/jobs/all_plugin_check_update_job.rb +10 -0
  28. data/app/jobs/application_job.rb +2 -0
  29. data/app/{workers/fluentd_ui_restart.rb → jobs/fluentd_ui_restart_job.rb} +4 -4
  30. data/app/jobs/fluentd_ui_update_check_job.rb +11 -0
  31. data/app/{workers/gem_installer.rb → jobs/gem_installer_job.rb} +4 -5
  32. data/app/jobs/gem_uninstaller_job.rb +14 -0
  33. data/app/jobs/gem_update_check_job.rb +9 -0
  34. data/app/models/fluentd/agent.rb +9 -5
  35. data/app/models/fluentd/agent/common.rb +10 -6
  36. data/app/models/fluentd/agent/fluentd_gem.rb +2 -3
  37. data/app/models/fluentd/agent/td_agent/unix.rb +7 -5
  38. data/app/models/fluentd/setting/in_tail.rb +2 -2
  39. data/app/views/fluentd/_form.html.haml +1 -1
  40. data/app/views/fluentd/errors.html.haml +5 -6
  41. data/app/views/fluentd/log.html.haml +4 -5
  42. data/app/views/fluentd/settings/edit.html.haml +2 -1
  43. data/app/views/fluentd/settings/histories/_list.html.haml +1 -1
  44. data/app/views/fluentd/settings/histories/show.html.haml +6 -6
  45. data/app/views/fluentd/settings/in_tail/after_file_choose.html.haml +4 -3
  46. data/app/views/fluentd/settings/in_tail/after_format.html.haml +2 -2
  47. data/app/views/fluentd/settings/in_tail/confirm.html.haml +3 -3
  48. data/app/views/fluentd/settings/running_backup/show.html.haml +5 -5
  49. data/app/views/fluentd/settings/show.html.haml +7 -7
  50. data/app/views/fluentd/settings/source_and_output.html.haml +31 -18
  51. data/app/views/fluentd/show.html.haml +16 -15
  52. data/app/views/layouts/application.html.erb +31 -46
  53. data/app/views/layouts/sign_in.html.erb +9 -16
  54. data/app/views/misc/information.html.haml +13 -13
  55. data/app/views/misc/update_fluentd_ui.html.haml +3 -3
  56. data/app/views/plugins/installed.html.haml +8 -8
  57. data/app/views/plugins/recommended.html.haml +5 -5
  58. data/app/views/plugins/updated.html.haml +5 -5
  59. data/app/views/sessions/new.html.haml +5 -6
  60. data/app/views/shared/_global_nav.html.erb +9 -9
  61. data/app/views/shared/_initial_setup.html.haml +3 -3
  62. data/app/views/shared/_modal.html.erb +1 -1
  63. data/app/views/shared/settings/_form.html.haml +9 -8
  64. data/app/views/shared/settings/show.html.haml +4 -2
  65. data/app/views/shared/vue/_fluent_log.html.erb +6 -6
  66. data/app/views/shared/vue/_in_tail_format.html.erb +31 -29
  67. data/app/views/shared/vue/_notification.html.erb +5 -9
  68. data/app/views/shared/vue/_setting.html.erb +12 -10
  69. data/app/views/shared/vue/_treeview.html.erb +13 -10
  70. data/app/views/tutorials/chapter1.html.erb +3 -4
  71. data/app/views/tutorials/chapter2.html.haml +2 -2
  72. data/app/views/tutorials/chapter3.html.haml +2 -2
  73. data/app/views/tutorials/chapter4.html.haml +2 -2
  74. data/app/views/users/show.html.haml +1 -1
  75. data/bin/bundle +1 -1
  76. data/bin/fluentd-ui +1 -0
  77. data/bin/rails +1 -1
  78. data/bin/setup +16 -17
  79. data/bin/update +28 -0
  80. data/bin/webpack +15 -0
  81. data/bin/webpack-dev-server +15 -0
  82. data/bin/yarn +11 -0
  83. data/config/application.rb +18 -5
  84. data/config/boot.rb +2 -1
  85. data/config/environment.rb +1 -1
  86. data/config/environments/development.rb +27 -5
  87. data/config/environments/production.rb +34 -23
  88. data/config/environments/test.rb +7 -3
  89. data/config/initializers/application_controller_renderer.rb +8 -0
  90. data/config/initializers/assets.rb +14 -0
  91. data/config/initializers/content_security_policy.rb +25 -0
  92. data/config/initializers/cookies_serializer.rb +2 -0
  93. data/config/initializers/fluentd_ui_update_check.rb +2 -1
  94. data/config/initializers/new_framework_defaults_5_2.rb +35 -0
  95. data/config/initializers/prefetch_gem_updates.rb +4 -1
  96. data/config/initializers/wrap_parameters.rb +1 -6
  97. data/config/locales/ja.yml +61 -57
  98. data/config/routes.rb +1 -0
  99. data/config/spring.rb +6 -0
  100. data/config/webpack/development.js +5 -0
  101. data/config/webpack/environment.js +20 -0
  102. data/config/webpack/loaders/vue.js +13 -0
  103. data/config/webpack/production.js +5 -0
  104. data/config/webpack/test.js +5 -0
  105. data/config/webpacker.yml +69 -0
  106. data/fluentd-ui.gemspec +16 -6
  107. data/lib/fluentd-ui/version.rb +1 -1
  108. data/lib/regexp_preview/single_line.rb +5 -5
  109. data/package.json +19 -0
  110. data/spec/controllers/application_controller_spec.rb +2 -6
  111. data/spec/controllers/fluentd/agents_controller_spec.rb +12 -0
  112. data/spec/controllers/polling_controller_spec.rb +1 -1
  113. data/spec/factories/fluentd.rb +1 -1
  114. data/spec/factories/plugins.rb +2 -2
  115. data/spec/factories/user.rb +1 -1
  116. data/spec/features/fluentd/setting/histories_spec.rb +7 -6
  117. data/spec/features/fluentd/setting/running_backup_spec.rb +4 -3
  118. data/spec/features/setting_spec.rb +1 -0
  119. data/spec/features/source_and_output_spec.rb +16 -16
  120. data/spec/lib/regexp_preview/single_line_spec.rb +1 -1
  121. data/spec/models/fluentd_spec.rb +4 -4
  122. data/spec/spec_helper.rb +16 -4
  123. data/yarn.lock +6225 -0
  124. metadata +120 -154
  125. data/.bowerrc +0 -3
  126. data/app/assets/javascripts/application.js +0 -24
  127. data/app/assets/javascripts/codemirror.js +0 -29
  128. data/app/assets/javascripts/enable_bootstrap_tooltip.js +0 -3
  129. data/app/assets/javascripts/nested_setting.js +0 -41
  130. data/app/assets/javascripts/vue/fluent_log.js +0 -64
  131. data/app/assets/javascripts/vue/in_tail_format.js +0 -177
  132. data/app/assets/javascripts/vue/notification.js +0 -65
  133. data/app/assets/javascripts/vue/settings.js +0 -121
  134. data/app/assets/javascripts/vue/treeview.js +0 -97
  135. data/app/assets/javascripts/vue_common.js +0 -4
  136. data/app/workers/all_plugin_check_update.rb +0 -14
  137. data/app/workers/fluentd_ui_update_check.rb +0 -15
  138. data/app/workers/gem_uninstaller.rb +0 -15
  139. data/app/workers/gem_update_check.rb +0 -10
  140. data/bower.json +0 -11
  141. data/vendor/assets/javascripts/bower/.gitignore +0 -10
  142. data/vendor/assets/javascripts/bower/codemirror/.bower.json +0 -29
  143. data/vendor/assets/javascripts/bower/codemirror/bower.json +0 -16
  144. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.css +0 -309
  145. data/vendor/assets/javascripts/bower/codemirror/lib/codemirror.js +0 -8029
  146. data/vendor/assets/javascripts/bower/codemirror/theme/3024-day.css +0 -38
  147. data/vendor/assets/javascripts/bower/codemirror/theme/3024-night.css +0 -37
  148. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance-mobile.css +0 -5
  149. data/vendor/assets/javascripts/bower/codemirror/theme/ambiance.css +0 -77
  150. data/vendor/assets/javascripts/bower/codemirror/theme/base16-dark.css +0 -36
  151. data/vendor/assets/javascripts/bower/codemirror/theme/base16-light.css +0 -36
  152. data/vendor/assets/javascripts/bower/codemirror/theme/blackboard.css +0 -30
  153. data/vendor/assets/javascripts/bower/codemirror/theme/cobalt.css +0 -23
  154. data/vendor/assets/javascripts/bower/codemirror/theme/eclipse.css +0 -23
  155. data/vendor/assets/javascripts/bower/codemirror/theme/elegant.css +0 -13
  156. data/vendor/assets/javascripts/bower/codemirror/theme/erlang-dark.css +0 -32
  157. data/vendor/assets/javascripts/bower/codemirror/theme/lesser-dark.css +0 -45
  158. data/vendor/assets/javascripts/bower/codemirror/theme/mbo.css +0 -35
  159. data/vendor/assets/javascripts/bower/codemirror/theme/mdn-like.css +0 -44
  160. data/vendor/assets/javascripts/bower/codemirror/theme/midnight.css +0 -45
  161. data/vendor/assets/javascripts/bower/codemirror/theme/monokai.css +0 -31
  162. data/vendor/assets/javascripts/bower/codemirror/theme/neat.css +0 -12
  163. data/vendor/assets/javascripts/bower/codemirror/theme/neo.css +0 -43
  164. data/vendor/assets/javascripts/bower/codemirror/theme/night.css +0 -26
  165. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-dark.css +0 -36
  166. data/vendor/assets/javascripts/bower/codemirror/theme/paraiso-light.css +0 -36
  167. data/vendor/assets/javascripts/bower/codemirror/theme/pastel-on-dark.css +0 -50
  168. data/vendor/assets/javascripts/bower/codemirror/theme/rubyblue.css +0 -23
  169. data/vendor/assets/javascripts/bower/codemirror/theme/solarized.css +0 -165
  170. data/vendor/assets/javascripts/bower/codemirror/theme/the-matrix.css +0 -28
  171. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-bright.css +0 -35
  172. data/vendor/assets/javascripts/bower/codemirror/theme/tomorrow-night-eighties.css +0 -36
  173. data/vendor/assets/javascripts/bower/codemirror/theme/twilight.css +0 -30
  174. data/vendor/assets/javascripts/bower/codemirror/theme/vibrant-ink.css +0 -32
  175. data/vendor/assets/javascripts/bower/codemirror/theme/xq-dark.css +0 -51
  176. data/vendor/assets/javascripts/bower/codemirror/theme/xq-light.css +0 -43
  177. data/vendor/assets/javascripts/bower/codemirror/theme/zenburn.css +0 -37
  178. data/vendor/assets/javascripts/bower/es6-promise/.bower.json +0 -15
  179. data/vendor/assets/javascripts/bower/es6-promise/bower.json +0 -5
  180. data/vendor/assets/javascripts/bower/es6-promise/promise.js +0 -684
  181. data/vendor/assets/javascripts/bower/es6-promise/promise.min.js +0 -1
  182. data/vendor/assets/javascripts/bower/lodash/.bower.json +0 -33
  183. data/vendor/assets/javascripts/bower/lodash/LICENSE.txt +0 -22
  184. data/vendor/assets/javascripts/bower/lodash/bower.json +0 -23
  185. data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.js +0 -7157
  186. data/vendor/assets/javascripts/bower/lodash/dist/lodash.compat.min.js +0 -61
  187. data/vendor/assets/javascripts/bower/lodash/dist/lodash.js +0 -6785
  188. data/vendor/assets/javascripts/bower/lodash/dist/lodash.min.js +0 -56
  189. data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.js +0 -4979
  190. data/vendor/assets/javascripts/bower/lodash/dist/lodash.underscore.min.js +0 -39
  191. data/vendor/assets/javascripts/bower/vue/.bower.json +0 -29
  192. data/vendor/assets/javascripts/bower/vue/bower.json +0 -17
  193. data/vendor/assets/javascripts/bower/vue/dist/vue.js +0 -7977
  194. data/vendor/assets/javascripts/bower/vue/dist/vue.min.js +0 -7
  195. data/vendor/assets/javascripts/sb-admin-v2/bootstrap.js +0 -1951
  196. data/vendor/assets/javascripts/sb-admin-v2/bootstrap.min.js +0 -6
  197. data/vendor/assets/javascripts/sb-admin-v2/demo/dashboard-demo.js +0 -117
  198. data/vendor/assets/javascripts/sb-admin-v2/demo/flot-demo.js +0 -1242
  199. data/vendor/assets/javascripts/sb-admin-v2/demo/morris-demo.js +0 -155
  200. data/vendor/assets/javascripts/sb-admin-v2/jquery-1.10.2.js +0 -6
  201. data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.js +0 -245
  202. data/vendor/assets/javascripts/sb-admin-v2/plugins/dataTables/jquery.dataTables.js +0 -14013
  203. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/excanvas.min.js +0 -1
  204. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.js +0 -2599
  205. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.pie.js +0 -750
  206. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.resize.js +0 -60
  207. data/vendor/assets/javascripts/sb-admin-v2/plugins/flot/jquery.flot.tooltip.min.js +0 -12
  208. data/vendor/assets/javascripts/sb-admin-v2/plugins/metisMenu/jquery.metisMenu.js +0 -45
  209. data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/morris.js +0 -1888
  210. data/vendor/assets/javascripts/sb-admin-v2/plugins/morris/raphael-2.1.0.min.js +0 -10
  211. data/vendor/assets/javascripts/sb-admin-v2/sb-admin.js +0 -18
  212. data/vendor/assets/stylesheets/.keep +0 -0
  213. data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.css +0 -5830
  214. data/vendor/assets/stylesheets/sb-admin-v2/bootstrap.min.css +0 -7
  215. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.css +0 -1338
  216. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/css/font-awesome.min.css +0 -4
  217. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/FontAwesome.otf +0 -0
  218. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.eot +0 -0
  219. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.svg +0 -414
  220. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.ttf +0 -0
  221. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/fonts/fontawesome-webfont.woff +0 -0
  222. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_bordered-pulled.scss +0 -16
  223. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_core.scss +0 -12
  224. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_fixed-width.scss +0 -6
  225. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_icons.scss +0 -412
  226. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_larger.scss +0 -13
  227. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_list.scss +0 -19
  228. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_mixins.scss +0 -20
  229. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_path.scss +0 -14
  230. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_rotated-flipped.scss +0 -9
  231. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_spinning.scss +0 -30
  232. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_stacked.scss +0 -20
  233. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/_variables.scss +0 -381
  234. data/vendor/assets/stylesheets/sb-admin-v2/font-awesome/scss/font-awesome.scss +0 -17
  235. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.eot +0 -0
  236. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.svg +0 -229
  237. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.ttf +0 -0
  238. data/vendor/assets/stylesheets/sb-admin-v2/fonts/glyphicons-halflings-regular.woff +0 -0
  239. data/vendor/assets/stylesheets/sb-admin-v2/plugins/dataTables/dataTables.bootstrap.css +0 -233
  240. data/vendor/assets/stylesheets/sb-admin-v2/plugins/morris/morris-0.4.3.min.css +0 -2
  241. data/vendor/assets/stylesheets/sb-admin-v2/plugins/social-buttons/social-buttons.css +0 -68
  242. data/vendor/assets/stylesheets/sb-admin-v2/plugins/timeline/timeline.css +0 -144
  243. data/vendor/assets/stylesheets/sb-admin-v2/sb-admin.css +0 -329
data/README.md CHANGED
@@ -16,8 +16,8 @@ fluentd-ui is a browser-based [fluentd](http://www.fluentd.org) and [td-agent](h
16
16
 
17
17
  ## Requirements
18
18
 
19
- - ruby 2.1.3 or later (since v0.4.0)
20
- - fluentd v0.12
19
+ - ruby 2.2.2 or later (since v1.0.0)
20
+ - fluentd v1.0.0 or later
21
21
 
22
22
  Currently, fluentd-ui doesn't support fleuntd v1 and td-agent 3.
23
23
  And some additional packages (Debian / Ubuntu)
@@ -33,20 +33,25 @@ And some additional packages (Debian / Ubuntu)
33
33
  $ git clone https://github.com/fluent/fluentd-ui
34
34
  $ cd fluentd-ui
35
35
  $ bundle install
36
- $ bundle exec rails s
36
+ $ bin/rails s
37
37
 
38
- Also you need a phantomjs for test.
38
+ Also you need a [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) or chromiumdriver for test.
39
39
 
40
- $ npm install -g phantomjs
40
+ $ npm install -g chromedriver
41
41
  Or,
42
- $ brew install phantomjs
42
+ $ brew install chromedriver
43
+ Or,
44
+ $ sudo apt install chromium-driver
43
45
 
44
- NOTE: `phantomjs` executable binary should be located under your `$PATH`.
46
+ NOTE: `chromedriver` executable binary should be located under your `$PATH`.
45
47
 
46
48
  ## Building fluentd-ui.gem
47
49
 
48
- $ bundle exec rake build
49
- fluentd-ui X.X.X built to pkg/fluentd-ui-X.X.X.gem.
50
+ # Generate pre-compiled assets
51
+ $ RAILS_ENV=production bin/rails assets:precompile
52
+
53
+ # fluentd-ui X.X.X built to pkg/fluentd-ui-X.X.X.gem.
54
+ $ RAILS_ENV=production bin/rails build
50
55
 
51
- $ bundle exec rake release
52
56
  # Push to rubygems.org
57
+ $ bin/rails release
@@ -10,11 +10,12 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require sb-admin-v2/bootstrap.css
14
- *= require sb-admin-v2/sb-admin
15
- *= require "sb-admin-v2/font-awesome/scss/font-awesome.scss"
16
- *= require bower/codemirror/lib/codemirror
17
- *= require bower/codemirror/theme/neo
13
+ *= require font-awesome
14
+ *= require bootstrap/dist/css/bootstrap
15
+ *= require startbootstrap-sb-admin/css/sb-admin.css
16
+ *= require datatables.net-bs4/css/dataTables.bootstrap4.css
17
+ *= require codemirror/lib/codemirror
18
+ *= require codemirror/theme/neo
18
19
  *= require_tree .
19
20
  *= require_self
20
21
  */
@@ -28,7 +28,7 @@ module SettingHistoryConcern
28
28
  else
29
29
  flash = { danger: @fluentd.agent.log.tail(1).first }
30
30
  end
31
- redirect_to :back, flash: flash
31
+ redirect_back fallback_location: root_url, flash: flash
32
32
  end
33
33
 
34
34
  end
@@ -16,6 +16,11 @@ class Fluentd::AgentsController < ApplicationController
16
16
  redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
17
17
  end
18
18
 
19
+ def reload
20
+ run_action(__method__) { @fluentd.agent.log.tail(1).first }
21
+ redirect_to daemon_path(@fluentd), status: 303 # 303 is change HTTP Verb GET
22
+ end
23
+
19
24
  def log_tail
20
25
  @logs = @fluentd.agent.log.tail(params[:limit]).reverse if @fluentd
21
26
  render json: @logs
@@ -19,7 +19,7 @@ class MiscController < ApplicationController
19
19
  end
20
20
 
21
21
  def upgrading_status
22
- if FluentdUiRestart::LOCK.present?
22
+ if FluentdUiRestartJob::LOCK.present?
23
23
  return render text: "updating"
24
24
  end
25
25
 
@@ -73,6 +73,6 @@ class MiscController < ApplicationController
73
73
  end
74
74
 
75
75
  def update!
76
- FluentdUiRestart.new.async.perform
76
+ FluentdUiRestart.perform_later
77
77
  end
78
78
  end
@@ -17,27 +17,27 @@ class PluginsController < ApplicationController
17
17
 
18
18
  def install
19
19
  params[:plugins].each do |gem_name|
20
- GemInstaller.new.async.perform(gem_name)
20
+ GemInstallerJob.perform_later(gem_name)
21
21
  end
22
22
  redirect_to plugins_path
23
23
  end
24
24
 
25
25
  def uninstall
26
26
  params[:plugins].each do |gem_name|
27
- GemUninstaller.new.async.perform(gem_name)
27
+ GemUninstallerJob.perform_later(gem_name)
28
28
  end
29
29
  redirect_to plugins_path
30
30
  end
31
31
 
32
32
  def upgrade
33
- GemInstaller.new.async.perform(params[:plugins][:name], params[:plugins][:version])
33
+ GemInstallerJob.perform_later(params[:plugins][:name], params[:plugins][:version])
34
34
  redirect_to plugins_path
35
35
  end
36
36
 
37
37
  def bulk_upgrade
38
38
  params[:plugins].each do |gem_name|
39
39
  pl = Plugin.new(gem_name: gem_name)
40
- GemInstaller.new.async.perform(gem_name, pl.latest_version)
40
+ GemInstallerJob.perform_later(gem_name, pl.latest_version)
41
41
  end
42
42
  redirect_to plugins_path
43
43
  end
@@ -37,12 +37,12 @@ module ApplicationHelper
37
37
  raw html
38
38
  end
39
39
 
40
- def link_to_other(text, path)
40
+ def link_to_other(text, path, **options)
41
41
  if current_page?(path)
42
42
  # NOTE: sb-admin set style for element name instead of class name, such as ".nav a". So use "a" element even if it isn't a link.
43
43
  content_tag(:a, text, class: "current")
44
44
  else
45
- link_to text, path
45
+ link_to text, path, class: "nav-link"
46
46
  end
47
47
  end
48
48
 
@@ -62,4 +62,10 @@ module ApplicationHelper
62
62
  head.html_safe + block.try(:call).to_s
63
63
  end
64
64
  end
65
+
66
+ def add_javascript_pack_tag(name, **options)
67
+ content_for(:additional_javascript_pack_tag) do
68
+ javascript_pack_tag(name, **options)
69
+ end
70
+ end
65
71
  end
@@ -54,8 +54,8 @@ module SettingsHelper
54
54
  end
55
55
 
56
56
  def append_and_remove_links
57
- %Q!<a class="btn btn-xs btn-default js-append">#{icon('fa-plus')}</a> ! +
58
- %Q!<a class="btn btn-xs btn-default js-remove" style="display:none">#{icon('fa-minus')}</a> !
57
+ %Q!<a class="btn btn-sm btn-outline-secondary js-append">#{icon('fa-plus')}</a> ! +
58
+ %Q!<a class="btn btn-sm btn-outline-secondary js-remove" style="display:none">#{icon('fa-minus')}</a> !
59
59
  end
60
60
 
61
61
  def child_data(form, key)
@@ -0,0 +1,31 @@
1
+ /* eslint no-console:0 */
2
+ // This file is automatically compiled by Webpack, along with any other files
3
+ // present in this directory. You're encouraged to place your actual application logic in
4
+ // a relevant structure within app/javascript and only use these pack files to reference
5
+ // that code so it'll be compiled.
6
+ //
7
+ // To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8
+ // layout file, like app/views/layouts/application.html.erb
9
+
10
+ console.log('Hello World from Webpacker')
11
+
12
+ import jQuery from 'jquery/dist/jquery'
13
+
14
+ window.$ = jQuery
15
+ window.jQuery = jQuery
16
+
17
+ import 'popper.js/dist/popper'
18
+ import 'bootstrap/dist/js/bootstrap'
19
+ import 'datatables.net/js/jquery.dataTables'
20
+ import 'startbootstrap-sb-admin/js/sb-admin'
21
+ import 'startbootstrap-sb-admin/js/sb-admin-datatables'
22
+
23
+ import Vue from 'vue/dist/vue.esm'
24
+
25
+ Vue.filter('to_json', function (value) {
26
+ return JSON.stringify(value);
27
+ })
28
+
29
+ window.Vue = Vue
30
+
31
+ import '../stylesheets/application.scss'
@@ -1,7 +1,9 @@
1
+ import CodeMirror from 'codemirror/lib/codemirror'
2
+ import 'lodash/lodash'
3
+
1
4
  // See: http://codemirror.net/doc/manual.html#modeapi
2
5
  // and sample mode files: https://github.com/codemirror/CodeMirror/tree/master/mode
3
6
 
4
-
5
7
  CodeMirror.defineMode('fluentd', function(){
6
8
  return {
7
9
  startState: function(aa){
@@ -57,3 +59,32 @@ CodeMirror.defineMode('fluentd', function(){
57
59
  }
58
60
  };
59
61
  });
62
+
63
+ function codemirrorify(el) {
64
+ return CodeMirror.fromTextArea(el, {
65
+ theme: "neo",
66
+ lineNumbers: true,
67
+ viewportMargin: Infinity,
68
+ mode: "fluentd"
69
+ });
70
+ }
71
+
72
+ $(function(){
73
+ $('.js-fluentd-config-editor').each(function(_, el){
74
+ codemirrorify(el);
75
+ });
76
+ });
77
+
78
+ Vue.directive('config-editor', {
79
+ bind: function(el, binding, vnode, oldVnode){
80
+ // NOTE: needed delay for waiting CodeMirror setup
81
+ _.delay(function(textarea){
82
+ let cm = codemirrorify(textarea);
83
+ // textarea.codemirror = cm; // for test, but doesn't work for now (working on Chrome, but Poltergeist not)
84
+ cm.on('change', function(code_mirror){
85
+ // bridge Vue - CodeMirror world
86
+ el.dataset.content = code_mirror.getValue();
87
+ });
88
+ }, 0, el);
89
+ }
90
+ });
@@ -0,0 +1,63 @@
1
+ 'use strict';
2
+ $(document).ready(()=> {
3
+ new Vue({
4
+ el: "#fluent-log",
5
+ props: ["logUrl", "initialAutoReload"],
6
+ data: {
7
+ "autoFetch": false,
8
+ "logs": [],
9
+ "limit": 30,
10
+ "processing": false
11
+ },
12
+
13
+ beforeMount: function() {
14
+ this.logUrl = this.$el.attributes.logUrl.nodeValue;
15
+ this.initialAutoReload = this.$el.attributes.initialAutoReload.nodeValue;
16
+ },
17
+
18
+ mounted: function(){
19
+ this.fetchLogs();
20
+
21
+ var self = this;
22
+ var timer;
23
+ this.$watch("autoFetch", function(newValue){
24
+ if(newValue === true) {
25
+ timer = setInterval(function(){
26
+ self.fetchLogs();
27
+ var $log = $(".log", self.$el);
28
+ $log.scrollTop($log.innerHeight());
29
+ }, 1000);
30
+ } else {
31
+ clearInterval(timer);
32
+ }
33
+ });
34
+ if(this.initialAutoReload) {
35
+ this.autoFetch = true;
36
+ }
37
+ },
38
+
39
+ computed: {
40
+ isPresentedLogs: function(){
41
+ return this.logs.length > 0;
42
+ }
43
+ },
44
+
45
+ methods: {
46
+ fetchLogs: function() {
47
+ if(this.processing) return;
48
+ this.processing = true;
49
+ var self = this;
50
+ new Promise(function(resolve, reject) {
51
+ $.getJSON(self.logUrl + "?limit=" + self.limit, resolve).fail(reject);
52
+ }).then(function(logs){
53
+ self.logs = logs;
54
+ setTimeout(function(){
55
+ self.processing = false;
56
+ }, 256); // delay to reduce flicking loading icon
57
+ })["catch"](function(error){
58
+ self.processing = false;
59
+ });
60
+ }
61
+ }
62
+ });
63
+ });
@@ -0,0 +1,174 @@
1
+ 'use strict'
2
+ import 'lodash/lodash'
3
+
4
+ window.addEventListener('load', () => {
5
+ const maxFormatCount = 20;
6
+
7
+ new Vue({
8
+ el: "#in_tail_format",
9
+ props: ["formatOptionsJson", "initialSelected", "targetFile", "paramsJson"],
10
+ data: {
11
+ previewProcessing: false,
12
+ format: "",
13
+ highlightedLines: null,
14
+ },
15
+
16
+ computed: {
17
+ options: {
18
+ get: function(){
19
+ return this.formatOptions[this.format];
20
+ },
21
+ },
22
+ selectableFormats: {
23
+ get: function() {
24
+ return Object.keys(this.formatOptions);
25
+ }
26
+ },
27
+ useTextArea: function() {
28
+ return this.format === "multiline";
29
+ }
30
+ },
31
+
32
+ beforeMount: function() {
33
+ this.formatOptions = JSON.parse(this.$el.attributes.formatOptionsJson.nodeValue);
34
+ this.format = this.$el.attributes.initialSelected.nodeValue;
35
+
36
+ // initialize params
37
+ // NOTE: if `params.setting.foo` is undefined, Vue can't binding with v-model="params.setting.foo"
38
+ var params = JSON.parse(this.$el.attributes.paramsJson.nodeValue);
39
+ if(!params.setting) {
40
+ params.setting = {};
41
+ }
42
+
43
+ var formats = _.chain(_.range(1, maxFormatCount + 1)).map(function(i) {return params.setting["format" + String(i)];}).compact().value();
44
+ params.setting.formats = formats.join("\n");
45
+
46
+ _.each(this.formatOptions, function(options){
47
+ _.each(options, function(key){
48
+ if(!params.setting.hasOwnProperty(key)){
49
+ params.setting[key] = "";
50
+ }
51
+ });
52
+ });
53
+ this.params = params;
54
+
55
+ this.targetFile = this.$el.attributes.targetFile.nodeValue;
56
+ },
57
+ mounted: function(){
58
+ this.$emit("data-loaded");
59
+ },
60
+
61
+ watch: {
62
+ 'params.setting.formats': function(formats) {
63
+ _.range(1, maxFormatCount + 1).forEach(()=> {params.setting["format" + String(i)] = "";});
64
+
65
+ _.compact(formats.split("\n")).forEach((formatLine, index)=> {
66
+ params.setting["format" + String(index + 1)] = formatLine;
67
+ })
68
+ },
69
+ 'params.setting.regexp': function() {
70
+ this.preview();
71
+ },
72
+ 'format': function() {
73
+ this.preview();
74
+ },
75
+ },
76
+
77
+ methods: {
78
+ onKeyup: function(ev){
79
+ var el = ev.target;
80
+ if(el.name.match(/\[format/)){
81
+ this.preview();
82
+ }
83
+ },
84
+ updateHighlightedLines: function() {
85
+ if(!this.regexpMatches) {
86
+ this.highlightedLines = null;
87
+ return;
88
+ }
89
+
90
+ var $container = jQuery('<div>');
91
+ _.each(this.regexpMatches, function(match){
92
+ var colors = [
93
+ "#ff9", "#cff", "#fcf", "#dfd"
94
+ ];
95
+ var whole = match.whole;
96
+ var html = "";
97
+ var matches = [];
98
+
99
+ var lastPos = 0;
100
+ _.each(match.matches, function(match) {
101
+ var matched = match.matched;
102
+ if(!matched) return;
103
+ if(matched.length === 0) return; // Ignore empty matched with "foobar".match(/foo(.*?)bar/)[1] #=> ""
104
+
105
+ // rotated highlight color
106
+ var currentColor = colors.shift();
107
+ colors.push(currentColor);
108
+
109
+ // create highlighted range HTML
110
+ var $highlighted = jQuery('<span>').text(matched);
111
+ $highlighted.attr({
112
+ "class": "regexp-preview",
113
+ "data-toggle": "tooltip",
114
+ "data-placement": "top",
115
+ "title": match.key,
116
+ 'style': 'background-color:' + currentColor
117
+ });
118
+ var highlightedHtml = $highlighted.wrap('<div>').parent().html();
119
+
120
+ var pos = {
121
+ "start": match.pos[0],
122
+ "end": match.pos[1]
123
+ };
124
+ if(pos.start > 0) {
125
+ html += _.escape(whole.substring(lastPos, pos.start));
126
+ }
127
+ html += highlightedHtml;
128
+ lastPos = pos.end;
129
+ });
130
+ html += whole.substring(lastPos);
131
+
132
+ $container.append(html);
133
+ $container.append("<br />");
134
+ });
135
+
136
+ this.highlightedLines = $container.html();
137
+ },
138
+
139
+ preview: function(){
140
+ if(this.previewAjax) {
141
+ this.previewAjax.abort();
142
+ }
143
+
144
+ const token = document.getElementsByName("csrf-token")[0].getAttribute('content')
145
+
146
+ var self = this;
147
+ new Promise(function(resolve, reject) {
148
+ self.previewAjax = $.ajax({
149
+ method: "POST",
150
+ url: "/api/regexp_preview",
151
+ headers: {
152
+ 'X-CSRF-Token': token
153
+ },
154
+ data: {
155
+ regexp: self.params.setting.regexp,
156
+ time_format: self.params.setting.time_format,
157
+ format: _.isEmpty(self.format) ? "regexp" : self.format,
158
+ params: self.params.setting,
159
+ file: self.targetFile
160
+ }
161
+ }).done(resolve).fail(reject);
162
+ }).then(function(result){
163
+ self.params = _.merge(self.params, result.params);
164
+ self.regexpMatches = result.matches;
165
+ self.updateHighlightedLines();
166
+ })["catch"](function(error){
167
+ if(error.stack) {
168
+ console.error(error.stack);
169
+ }
170
+ });
171
+ },
172
+ }
173
+ });
174
+ });