lib/scales-monitor/app/app/assets/javascripts/app/controllers/resources.js.coffee in scales-monitor-0.0.1.beta.2 vs lib/scales-monitor/app/app/assets/javascripts/app/controllers/resources.js.coffee in scales-monitor-0.0.4
- old
+ new
@@ -6,14 +6,24 @@
'#content_types' : 'contentTypesDiv'
constructor: ->
super
[@resources, @partials, @servers] = [{}, {}, {}]
+ [@resourcesChanged, @partialsChanged] = [false, false]
@colors = {}
@bindColors()
@render()
@bindEvents()
+ setInterval =>
+ if @resourcesChanged
+ @resourcesChanged = false
+ @renderResources(@resources, @resourcesDiv)
+
+ if @partialsChanged
+ @partialsChanged = false
+ @renderResources(@partials, @partialsDiv)
+ , 200
activate: ->
@el.addClass("active")
$("li#nav_resources").addClass('active')
@
@@ -38,31 +48,31 @@
bindEvents: ->
Spine.bind 'push_resource', (resource) =>
@resources[resource.path] = resource
- @renderResources(@resources, @resourcesDiv)
+ @resourcesChanged = true
Spine.bind 'destroy_resource', (resource) =>
delete @resources[resource.path]
- @renderResources(@resources, @resourcesDiv)
+ @resourcesChanged = true
Spine.bind 'push_partial', (partial) =>
@partials[partial.path] = partial
- @renderResources(@partials, @partialsDiv)
+ @partialsChanged = true
Spine.bind 'destroy_partial', (partial) =>
delete @partials[partial.path]
- @renderResources(@partials, @partialsDiv)
+ @partialsChanged = true
Spine.bind 'server_started', (server) =>
@servers[server.id] = server
- @renderResources(@resources, @resourcesDiv)
+ @resourcesChanged = true
Spine.bind 'server_stopped', (server) =>
delete @servers[server.id]
- @renderResources(@resources, @resourcesDiv)
+ @resourcesChanged = true
render: ->
@html JST['app/views/resources'](@)
renderResources: (resources, div) ->
@@ -89,9 +99,10 @@
@i = 0
div.html out
div.tooltip({ selector: "a" })
@renderContentTypes()
+
processContentTypes: ->
formats = {}
total = 0
for id, resource of @resources
\ No newline at end of file