Sha256: 30ddcfd08fdee470ffc3e158a82997c5dde43065210c086ce6d084ca2ac0e085

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

class App.Log extends Spine.Controller
  
  elements:
    '#events'  : 'eventsDiv'
    
  constructor: ->
    super
    @render()
    @bindEvents()
    @changed = false
    setInterval => 
      @eventsDiv.animate({ scrollTop: @eventsDiv[0].scrollHeight }, 500)
    , 1000
  
  activate: ->
    @el.addClass("active")
    $("li#nav_log").addClass('active')
    @

  deactivate: ->
    @el.removeClass("active")
    $("li#nav_log").removeClass('active')
    @
  
  bindEvents: ->
    
    Spine.bind 'server_started',    (event) => @add(event)
    Spine.bind 'server_stopped',    (event) => @add(event)
  
    Spine.bind 'worker_started',    (event) => @add(event)
    Spine.bind 'worker_stopped',    (event) => @add(event)
    
    Spine.bind 'cache_started',     (event) => @add(event)
    Spine.bind 'cache_stopped',     (event) => @add(event)
    
    Spine.bind 'server_put_request_in_queue',     (event) => @add(event)
    Spine.bind 'server_took_response_from_queue', (event) => @add(event)
    Spine.bind 'worker_took_request_from_queue',  (event) => @add(event)
    Spine.bind 'worker_put_response_in_queue',    (event) => @add(event)
    
    Spine.bind 'push_resource',     (event) => @add(event)
    Spine.bind 'destroy_resource',  (event) => @add(event)
    
    Spine.bind 'push_partial',      (event) => @add(event)
    Spine.bind 'destroy_partial',   (event) => @add(event)
   
  
  render: (event) ->
    @html JST['app/views/log'](@)
  
  add: (event) ->
    out = "<br/><span class='date'>#{new Date().getTime()}</span> <span class='event'>#{event.type}</span>"
    for item, data of event
      if item == "key" or item == "safe" or item == "escape" or item == "server" or item == "color" or item == "type"
        # no need for them
      else
        out += "<br/>&nbsp;&nbsp;&nbsp; -> #{item} = #{data}"
      
    @eventsDiv.append out
    @changed = true

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
scales-monitor-0.0.4 lib/scales-monitor/app/app/assets/javascripts/app/controllers/log.jst.coffee