Sha256: 9bbaa85df1eabb7e82f2bc74ec67b17ab5e547a4a41b3cd224f3751acabaa491

Contents?: true

Size: 1.54 KB

Versions: 18

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
      },

      compiled: 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

18 entries across 18 versions & 1 rubygems

Version Path
fluentd-ui-0.4.5 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.4.4 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.4.3 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.4.2 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.4.1 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.4.0 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.21 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.20 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.19 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.18 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.17 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.16 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.15 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.14 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.13 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.12 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.11 app/assets/javascripts/vue/fluent_log.js
fluentd-ui-0.3.10 app/assets/javascripts/vue/fluent_log.js