Sha256: f81269584013fb6c6579c436bb6e005cd1378bcc32a3382131dafa50d2a7470a

Contents?: true

Size: 1.55 KB

Versions: 3

Compression:

Stored size: 1.55 KB

Contents

class App.Machines extends Spine.Controller
  
  elements:
    '#servers'  : 'serversDiv'
    '#caches'   : 'cachesDiv'
    '#workers'  : 'workersDiv'
    
  constructor: ->
    super
    [@servers, @caches, @workers] = [{}, {}, {}]
    @render()
    @bindEvents()
  
  activate: ->
    @el.addClass("active")
    $("li#nav_machines").addClass('active')
    @

  deactivate: ->
    @el.removeClass("active")
    $("li#nav_machines").removeClass('active')
    @
  
  bindEvents: ->
    
    Spine.bind 'server_started', (server) =>
      @servers[server.id] = server
      @renderMachines(@servers, @serversDiv)
    
    Spine.bind 'server_stopped', (server) =>
      delete @servers[server.id]
      @renderMachines(@servers, @serversDiv)
    
    Spine.bind 'worker_started', (worker) =>
      @workers[worker.id] = worker
      @renderMachines(@workers, @workersDiv)

    Spine.bind 'worker_stopped', (worker) =>
      delete @workers[worker.id]
      @renderMachines(@workers, @workersDiv)
    
    Spine.bind 'cache_started', (cache) =>
      @caches[cache.id] = cache
      @renderMachines(@caches, @cachesDiv)

    Spine.bind 'cache_stopped', (cache) =>
      delete @caches[cache.id]
      @renderMachines(@caches, @cachesDiv)
  
  render: ->
    @html JST['app/views/machines'](@)
  
  renderMachines: (machines, div) ->
    machineAmount = 0
    machineAmount += 1 for id, machine of machines
    out = JST['app/views/_top']({amount: machineAmount})
    
    out += JST['app/views/_machine'](machine) for id, machine of machines
    div.html out
    $("time.timeago").timeago()

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-monitor-0.0.4 lib/scales-monitor/app/app/assets/javascripts/app/controllers/machines.js.coffee
scales-monitor-0.0.1.beta.2 lib/scales-monitor/app/app/assets/javascripts/app/controllers/machines.js.coffee
scales-monitor-0.0.1.beta.1 lib/scales-monitor/app/app/assets/javascripts/app/controllers/machines.js.coffee