Sha256: 0f6268c52968750a13b3bdf89e6fcae92c89a7760bdea798c26ed50e4aad6d61
Contents?: true
Size: 1.54 KB
Versions: 14
Compression:
Stored size: 1.54 KB
Contents
(function(){ "use strict"; $(function(){ if($('#fluent-log').length === 0) return; new Vue({ el: "#fluent-log", paramAttributes: ["logUrl", "initialAutoReload"], data: { "autoFetch": false, "logs": [], "limit": 30, "processing": false }, created: function(){ if(this.initialAutoReload) { this.autoFetch = true; } 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); } }); }, computed: { isPresentedLogs: function(){ return this.logs.length > 0; } }, methods: { fetchLogs: function() { if(this.processing) return; this.processing = true; var self = this; new Promise(function(resolve, reject) { $.getJSON(self.logUrl + "?limit=" + self.limit, resolve).fail(reject); }).then(function(logs){ self.logs = logs; setTimeout(function(){ self.processing = false; }, 256); // delay to reduce flicking loading icon })["catch"](function(error){ self.processing = false; }); } } }); }); })();
Version data entries
14 entries across 14 versions & 1 rubygems