Sha256: 8b94976e74257cbda84fd6cf661a9b809e5f31afed14b48cbf79e3b46f7afd32
Contents?: true
Size: 1.54 KB
Versions: 3
Compression:
Stored size: 1.54 KB
Contents
'use strict'; $(document).ready(()=> { new Vue({ el: "#fluent-log", props: ["logUrl", "initialAutoReload"], data: { "autoFetch": false, "logs": [], "limit": 30, "processing": false }, beforeMount: function() { this.logUrl = this.$el.attributes.logUrl.nodeValue; this.initialAutoReload = this.$el.attributes.initialAutoReload.nodeValue; }, mounted: 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.innerHeight()); }, 1000); } else { clearInterval(timer); } }); if(this.initialAutoReload) { this.autoFetch = true; } }, 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fluentd-ui-1.0.0.alpha.3 | app/javascript/packs/fluent_log.js |
fluentd-ui-1.0.0.alpha.2 | app/javascript/packs/fluent_log.js |
fluentd-ui-1.0.0.alpha.1 | app/javascript/packs/fluent_log.js |