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
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+ import 'lodash/lodash';
3
+ $(document).ready(()=> {
4
+ var $firstSetting = $('.js-nested-column.js-multiple:first');
5
+
6
+ if ($firstSetting.length === 0) {
7
+ return;
8
+ }
9
+
10
+ var counter = 0;
11
+ $('.js-append', $firstSetting).on('click', function(ev){
12
+ ev.preventDefault();
13
+ var $new = $firstSetting.clone(true);
14
+ counter++;
15
+
16
+ var fields = $('input,select,textarea', $new);
17
+ _.each(fields, function(elm){
18
+ elm.name = elm.name.replace("0", counter);
19
+ });
20
+ $('label', $new).each(function(_, label){
21
+ var $label = $(label);
22
+ $label.attr('for', $label.attr('for').replace("0", counter));
23
+ });
24
+
25
+ $('.js-remove', $new).show();
26
+ $('.js-append', $new).hide();
27
+ $new.appendTo($firstSetting.parent());
28
+ });
29
+
30
+ $('.js-remove').on('click', function(ev){
31
+ ev.preventDefault();
32
+ $(this).closest('.js-nested-column').remove();
33
+ });
34
+
35
+ var $allSettings = $('.js-nested-column.js-multiple');
36
+ $('.js-append', $allSettings).hide();
37
+ $('.js-remove', $allSettings).show();
38
+ $('.js-append', $firstSetting).show();
39
+ $('.js-remove', $firstSetting).hide();
40
+ });
@@ -0,0 +1,60 @@
1
+ const POLLING_INTERVAL = 3 * 1000
2
+ const POLLING_URL = "/polling/alerts"
3
+
4
+ $(document).ready(()=> {
5
+ let alert = new Vue({
6
+ el: "#vue-notification",
7
+ data: {
8
+ "alerts": []
9
+ },
10
+
11
+ created: function(){
12
+ let timer;
13
+ let self = this;
14
+ let currentInterval = POLLING_INTERVAL;
15
+ let fetch = function(){
16
+ self.fetchAlertsData().then(function(alerts){
17
+ if(self.alerts.toString() == alerts.toString()) {
18
+ currentInterval *= 1.1;
19
+ } else {
20
+ currentInterval = POLLING_INTERVAL;
21
+ }
22
+ self.alerts = alerts;
23
+ timer = setTimeout(fetch, currentInterval);
24
+ })["catch"](function(xhr){
25
+ if(xhr.status === 401) {
26
+ // signed out
27
+ }
28
+ if(xhr.status === 0) {
29
+ // server unreachable (maybe down)
30
+ }
31
+ });
32
+ };
33
+ window.addEventListener('focus', function(ev){
34
+ currentInterval = POLLING_INTERVAL;
35
+ timer = setTimeout(fetch, currentInterval);
36
+ }, false);
37
+ window.addEventListener('blur', function(ev){
38
+ clearTimeout(timer);
39
+ }, false);
40
+ fetch();
41
+ },
42
+
43
+ computed: {
44
+ alertsCount: {
45
+ get: function(){ return this.alerts.length; }
46
+ },
47
+ hasAlerts: {
48
+ get: function(){ return this.alertsCount > 0; }
49
+ }
50
+ },
51
+
52
+ methods: {
53
+ fetchAlertsData: function() {
54
+ return new Promise(function(resolve, reject) {
55
+ $.getJSON(POLLING_URL, resolve).fail(reject);
56
+ });
57
+ }
58
+ }
59
+ });
60
+ });
@@ -0,0 +1,122 @@
1
+ $(document).ready(() => {
2
+ const SettingSection = {
3
+ template: '#vue-setting-section',
4
+ props: ['id', 'content', 'type', 'name', 'arg'],
5
+ data: function() {
6
+ return {
7
+ mode: 'default',
8
+ processing: false
9
+ };
10
+ },
11
+ created: function() {
12
+ this.initialState();
13
+ },
14
+ computed: {
15
+ endpoint: function() {
16
+ return '/api/settings/' + this.id;
17
+ }
18
+ },
19
+ methods: {
20
+ onCancel: function(event) {
21
+ this.initialState();
22
+ },
23
+ onEdit: function(ev) {
24
+ this.mode = "edit";
25
+ },
26
+ onDelete: function(ev) {
27
+ if (!confirm("really?")) {
28
+ return;
29
+ }
30
+ this.destroy();
31
+ },
32
+ onSubmit: function(ev) {
33
+ const token = document.getElementsByName("csrf-token")[0].getAttribute('content');
34
+ this.processing = true;
35
+ this.content = $(`#${this.id} textarea.form-control`)[0].dataset.content;
36
+ $.ajax({
37
+ url: this.endpoint,
38
+ method: "POST",
39
+ data: {
40
+ _method: "PATCH",
41
+ id: this.id,
42
+ content: this.content
43
+ },
44
+ headers: {
45
+ 'X-CSRF-Token': token
46
+ }
47
+ }).then((data)=> {
48
+ _.each(data, function(v,k){
49
+ this[k] = v;
50
+ });
51
+ this.initialState();
52
+ }).always(()=> {
53
+ this.processing = false;
54
+ });
55
+ },
56
+ initialState: function(){
57
+ this.processing = false;
58
+ this.mode = 'default';
59
+ },
60
+ destroy: function(){
61
+ const token = document.getElementsByName("csrf-token")[0].getAttribute('content');
62
+ $.ajax({
63
+ url: this.endpoint,
64
+ method: "POST",
65
+ data: {
66
+ _method: "DELETE",
67
+ id: this.id
68
+ },
69
+ headers: {
70
+ 'X-CSRF-Token': token
71
+ }
72
+ }).then(()=> {
73
+ this.$parent.update();
74
+ });
75
+ }
76
+ }
77
+ };
78
+
79
+ new Vue({
80
+ el: "#vue-setting",
81
+ data: function(){
82
+ return {
83
+ loaded: false,
84
+ loading: false,
85
+ sections: {
86
+ sources: [],
87
+ matches: []
88
+ }
89
+ };
90
+ },
91
+ mounted: function() {
92
+ this.$nextTick(() => {
93
+ this.update();
94
+ })
95
+ },
96
+ components: {
97
+ 'setting-section': SettingSection
98
+ },
99
+ methods: {
100
+ update: function() {
101
+ this.loading = true;
102
+ $.getJSON("/api/settings", (data)=> {
103
+ var sources = [];
104
+ var matches = [];
105
+ data.forEach((v)=> {
106
+ if(v.name === "source"){
107
+ sources.push(v);
108
+ }else{
109
+ matches.push(v);
110
+ }
111
+ });
112
+ this.sections.sources = sources;
113
+ this.sections.matches = matches;
114
+ this.loaded = true;
115
+ setTimeout(()=> {
116
+ this.loading = false;
117
+ }, 500);
118
+ });
119
+ }
120
+ }
121
+ });
122
+ })
@@ -0,0 +1,99 @@
1
+ 'use strict';
2
+ import 'lodash/lodash';
3
+ $(document).ready(() => {
4
+ new Vue({
5
+ el: "#treeview",
6
+ props: {
7
+ initialPath: {
8
+ default: "/var/log",
9
+ type: String
10
+ }
11
+ },
12
+ data: {
13
+ preview: "",
14
+ path: "",
15
+ paths: []
16
+ },
17
+
18
+ mounted: function(){
19
+ console.log(this.initialPath);
20
+ this.path = this.initialPath;
21
+ this.fetchTree();
22
+ this.$watch("path", this.fetchTree);
23
+ this.$watch("path", this.fetchPreview);
24
+ },
25
+
26
+ computed: {
27
+ selected: function(){
28
+ var self = this;
29
+ return _.find(this.paths, function(path){
30
+ return self.path == path.path;
31
+ });
32
+ },
33
+ selectedIsDir: function() {
34
+ if(!this.selected) return true;
35
+ return this.selected.is_dir;
36
+ },
37
+ currentDirs: function() {
38
+ if(this.path === "/") {
39
+ return ["/"];
40
+ }
41
+
42
+ var path = this.path;
43
+ if(this.selected && !this.selected.is_dir) {
44
+ path = path.replace(/\/[^/]+$/, "");
45
+ }
46
+ var root = "/";
47
+ var dirs = [];
48
+ path.split("/").forEach(function(dir) {
49
+ dirs.push(root + dir);
50
+ if(dir) {
51
+ root = root + dir + "/";
52
+ }
53
+ });
54
+ return dirs;
55
+ }
56
+ },
57
+
58
+ methods: {
59
+ isAncestor: function(target) {
60
+ return this.path.indexOf(target) === 0;
61
+ },
62
+ basename: function(path) {
63
+ if (path === "/") return "/";
64
+ return path.match(/[^/]+$/)[0];
65
+ },
66
+ fetchTree: function() {
67
+ var self = this;
68
+ return new Promise(function(resolve, reject) {
69
+ $.getJSON("/api/tree?path=" + self.path, resolve).fail(reject);
70
+ }).then(function(paths){
71
+ console.log(paths);
72
+ self.paths = paths;
73
+ });
74
+ },
75
+ fetchPreview: function(){
76
+ if(!this.selected) return ;
77
+ var self = this;
78
+ this.preview = "";
79
+ new Promise(function(resolve, reject) {
80
+ $.getJSON("/api/file_preview?file=" + self.selected.path, resolve).fail(reject);
81
+ }).catch(function(e){
82
+ console.error(e);
83
+ }).then(function(lines){
84
+ self.preview = lines.join("\n");
85
+ });
86
+ },
87
+
88
+ selectPath: function(path){
89
+ this.path = path;
90
+ },
91
+ isSuffixRequired: function(data){
92
+ return data.is_dir && data.path != "/";
93
+ },
94
+ isSelected: function(path){
95
+ return this.path == path;
96
+ }
97
+ }
98
+ });
99
+ });
@@ -0,0 +1,10 @@
1
+ class AllPluginCheckUpdateJob < ApplicationJob
2
+ queue_as :default
3
+
4
+ def perform(*args)
5
+ Plugin.installed.each do |pl|
6
+ GemUpdateCheckJob.perform_later(pl.gem_name)
7
+ end
8
+ AllPluginCheckUpdateJob.set(wait: 1.hour).perform_later # will be checked every hour
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -1,5 +1,5 @@
1
- class FluentdUiRestart
2
- include SuckerPunch::Job
1
+ class FluentdUiRestartJob < ApplicationJob
2
+ queue_as :default
3
3
 
4
4
  LOCK = []
5
5
 
@@ -20,7 +20,7 @@ class FluentdUiRestart
20
20
  lock!
21
21
 
22
22
  # NOTE: install will be failed before released fluentd-ui gem
23
- SuckerPunch.logger.info "[restart] install new fluentd-ui"
23
+ logger.info "[restart] install new fluentd-ui"
24
24
  Plugin.new(gem_name: "fluentd-ui").install!
25
25
 
26
26
  if Rails.env.production?
@@ -29,7 +29,7 @@ class FluentdUiRestart
29
29
  cmd = %W(bundle exec rails s)
30
30
  end
31
31
 
32
- SuckerPunch.logger.info "[restart] will restart"
32
+ logger.info "[restart] will restart"
33
33
  Bundler.with_clean_env do
34
34
  restarter = "#{Rails.root}/bin/fluentd-ui-restart"
35
35
  Process.spawn(*[restarter, $$.to_s, *cmd, *ARGV]) && Process.kill(:TERM, $$)
@@ -0,0 +1,11 @@
1
+ class FluentdUiUpdateCheckJob < ApplicationJob
2
+ queue_as :default
3
+
4
+ def perform
5
+ pl = Plugin.new(gem_name: "fluentd-ui")
6
+ if pl.gem_versions
7
+ FluentdUI.latest_version = pl.latest_version
8
+ end
9
+ FluentdUiUpdateCheckJob.set(wait: 1.hour).perform_later # will be checked every hour
10
+ end
11
+ end
@@ -1,6 +1,5 @@
1
- class GemInstaller
2
- include SuckerPunch::Job
3
- workers 16
1
+ class GemInstallerJob < ApplicationJob
2
+ queue_as :default
4
3
 
5
4
  def perform(gem_name, version = nil)
6
5
  SuckerPunch.logger.info "install #{gem_name} #{version}"
@@ -9,9 +8,9 @@ class GemInstaller
9
8
  # NOTE: uninstall all versions of `gem_name` then install it for upgrade/downgrade
10
9
  pl.uninstall! if pl.installed?
11
10
  pl.install!
12
- SuckerPunch.logger.info "installed #{gem_name} #{version}"
11
+ logger.info "installed #{gem_name} #{version}"
13
12
  rescue Plugin::GemError
14
- SuckerPunch.logger.warn "installing #{gem_name} #{version} is failed"
13
+ logger.warn "installing #{gem_name} #{version} is failed"
15
14
  end
16
15
  end
17
16
  end
@@ -0,0 +1,14 @@
1
+ class GemUninstallerJob < ApplicationJob
2
+ queue_as :default
3
+
4
+ def perform(gem_name)
5
+ logger.info "uninstall #{gem_name}"
6
+ pl = Plugin.new(gem_name: gem_name)
7
+ begin
8
+ pl.uninstall!
9
+ logger.info "uninstalled #{gem_name}"
10
+ rescue Plugin::GemError
11
+ logger.warn "uninstalling #{gem_name} is failed"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class GemUpdateCheckJob < ApplicationJob
2
+ queue_as :default
3
+
4
+ def perform(gem_name)
5
+ logger.info "check #{gem_name} latest version"
6
+ pl = Plugin.new(gem_name: gem_name)
7
+ pl.gem_versions!
8
+ end
9
+ end
@@ -10,19 +10,23 @@ class Fluentd
10
10
  class Agent
11
11
  # pidfile
12
12
  # td-agent: /var/run/td-agent/td-agent.pid
13
- # - https://github.com/treasure-data/td-agent/blob/master/td-agent.logrotate#L10
14
- # - https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.init#L25
13
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/systemd/td-agent.service.erb#L18
14
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/init.d/deb/td-agent#L24
15
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/init.d/rpm/td-agent#L24
16
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/td-agent/logrotate.d/td-agent.logrotate#L10
15
17
  # fluentd: nothing (or --daemon PIDFILE)
16
18
  #
17
19
  # logfile
18
20
  # td-agent: /var/log/td-agent/td-agent.log
19
- # - https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.init#L28
21
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/systemd/td-agent.service.erb#L21
22
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/init.d/deb/td-agent#L23
23
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/init.d/rpm/td-agent#L23
20
24
  # fluentd: stdout (or --log LOGFILE)
21
25
  #
22
26
  # config file
23
27
  # td-agent: /etc/td-agent/td-agent.conf
24
- # - https://github.com/treasure-data/td-agent/blob/master/debian/td-agent.postinst#L69
25
- # fluentd: /etc/fluent/fluent.conf (by fluentd -s)
28
+ # - https://github.com/treasure-data/omnibus-td-agent/blob/master/templates/etc/systemd/td-agent.service.erb#L14
29
+ # fluentd: /etc/fluent/fluent.conf (created by fluentd -s)
26
30
  class ConfigError < StandardError; end
27
31
  end
28
32
  end