worker-checker.js.coffee 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. $ ->
  2. firstEventCount = null
  3. if $("#job-indicator").length
  4. check = ->
  5. $.getJSON "/worker_status", (json) ->
  6. firstEventCount = json.event_count unless firstEventCount?
  7. if json.pending? && json.pending > 0
  8. tooltipOptions = {
  9. title: "#{json.pending} jobs pending, #{json.awaiting_retry} awaiting retry, and #{json.recent_failures} recent failures"
  10. delay: 0
  11. placement: "bottom"
  12. trigger: "hover"
  13. }
  14. $("#job-indicator").tooltip('destroy').tooltip(tooltipOptions).fadeIn().find(".number").text(json.pending)
  15. else
  16. $("#job-indicator:visible").tooltip('destroy').fadeOut()
  17. if firstEventCount? && json.event_count > firstEventCount
  18. $("#event-indicator").tooltip('destroy').
  19. tooltip(title: "Click to reload", delay: 0, placement: "bottom", trigger: "hover").
  20. fadeIn().
  21. find(".number").
  22. text(json.event_count - firstEventCount)
  23. else
  24. $("#event-indicator").tooltip('destroy').fadeOut()
  25. window.workerCheckTimeout = setTimeout check, 2000
  26. check()
  27. $("#event-indicator a").on "click", (e) ->
  28. e.preventDefault()
  29. window.location.reload()