 Template.instanceView.helpers
   Steps: -> Steps
   activityIcon: ->
-    # else if "#{@meta?.state}".match /pulling/
-    #   'download'
     if @state is 'running'
       'ok-sign'
-    else if @state is 'starting'
+    else if @state in ['starting', 'created']
       'play-circle'
     else if @state is 'stopping'
       'collapse-down'

      'flash'
    else
      'exclamation-sign'
  showProgressbar: -> !("#{@state}" in ['running', 'failing', 'removed'])
  totalSteps: -> @steps?.length
  progressPercentage: ->
    progress = (@steps.map (s) -> if s.completed then 1 else 0).reduce (prev, curr) -> prev+curr
    totalSteps = @steps.length
    console.log 'progress', totalSteps, progress
    if @state is 'stopping'
      # let the percentage count down
      ((parseInt(totalSteps)-parseInt(progress))/parseInt(totalSteps))*100
    else
      (parseInt(progress)/parseInt(totalSteps))*100
  stopButtonText: -> if @meta.state isnt 'active' then 'Destroy' else 'Stop'
  instanceLink: ->
    port = findWebPort @services?.www

  services: -> {name: k, data: v} for k, v of @services
  pretify: (json) -> JSON.stringify json, undefined, 2
  instanceHash: -> CryptoJS.MD5 "#{@name}"
  startedByUser: -> Meteor.users.findOne(@startedBy).username
  stoppedByUser: -> @stoppedBy?.username

Template.instanceView.events
