diff --git a/app/assets/javascripts/fluent_log.js b/app/assets/javascripts/fluent_log.js index 1611a48..eba2325 100644 --- a/app/assets/javascripts/fluent_log.js +++ b/app/assets/javascripts/fluent_log.js @@ -8,12 +8,27 @@ el: "#fluent-log", paramAttributes: ["logUrl"], data: { + "autoFetch": false, "logs": [], "limit": 30 }, created: function(){ this.fetchLogs(); + + var self = this; + var timer; + this.$watch("autoFetch", function(newValue){ + if(newValue === true) { + timer = setInterval(function(){ + self.fetchLogs(); + var $log = $(".log", self.$el); + $log.scrollTop($log[0].scrollHeight); + }, 1000); + } else { + clearInterval(timer); + } + }); }, methods: { diff --git a/app/views/shared/vue/_fluent_log.html.erb b/app/views/shared/vue/_fluent_log.html.erb index 781af3a..99b7618 100644 --- a/app/views/shared/vue/_fluent_log.html.erb +++ b/app/views/shared/vue/_fluent_log.html.erb @@ -2,6 +2,7 @@
+ 自動更新{{ $value }}