'use strict';
$(document).ready(()=> {
  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;
        });
      }
    }
  });
});

'use strict';
$(document).ready(()=> {
  new Vue({
    el: "#fluent-log",
    paramAttributes: ["logUrl", "initialAutoReload"],
    data: {
      "autoFetch": false,
      "logs": [],
      "limit": 30,
      "processing": false
    },

    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;
        });
      }
    }
  });
});

Use mounted instead of compiled
Use mounted instead of compiled

Because compiled is removed.

Signed-off-by: Kenji Okimoto <7a4b90a0a1e6fc688adec907898b6822ce215e6c@clear-code.com>
