Add auto-reload for log tail

This commit is contained in:
uu59 2014-06-11 12:46:28 +09:00
parent 08d3d4aa0d
commit b99132d67b
2 changed files with 16 additions and 0 deletions

View File

@ -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: {

View File

@ -2,6 +2,7 @@
<div id="fluent-log" logUrl="<%= log_tail_fluentd_agent_path(fluentd) %>">
<pre>
<button class="btn btn-primary" v-on="click: fetchLogs"><%= t "terms.reload_log" %></button> <input type="text" v-model="limit" size="4" v-on="keyup: fetchLogs | key enter" />
<input type="checkbox" v-model="autoFetch" /> 自動更新
<div class="log"><span v-repeat="logs">{{ $value }}
</span></div></pre>