Sha256: b7564f90d485fee2140fca2d2a0bb53a5f3fe6bc69ce2a988646488cb3eacf00

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

class CanvasBatchProgress
  constructor: ->
    batch = $('#batch-progress').data('batch')
    url = $('#batch-progress').data('url')
    window.clearPath = $('#batch-progress').data('clear-path')
    if batch && batch.status != "Completed" || batch.status != "Error"
      window.batchInterval = setInterval(getBatchStatus, 3000, batch.id, url)

  getBatchStatus = (id, url) ->
    $.ajax
      url: url
      success: (data) ->
        $('#batch-progress').html(data)
        batch = $('#batch-info').data('batch')
        if batch.status == "Completed" || batch.status == "Error"
          clearInterval(window.batchInterval)
          $('#batch-progress').html(data)
          clearBatchFromSession(batch.id)

      error: (message) ->
        $('#batch-progress').html('Batch status request failed')
        clearInterval(window.batchInterval)

  clearBatchFromSession = (id) ->
    $.ajax
      url: window.clearPath
      type: 'POST'
      success: (data) ->
        delay 3000, ->
          $('#batch-progress').fadeOut(1000)
          $('#batch-progress').html("")
          $('#batch-progress').show()

  delay = (ms, func) -> setTimeout func, ms

$ ->
  new CanvasBatchProgress() if $('#batch-progress').length > 0

  $("#batch-container").unbind().bind "batchStarted", (event, data) ->
    new CanvasBatchProgress()

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
coalescing_panda-3.1.3 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee.erb
coalescing_panda-3.1.2 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee.erb
coalescing_panda-3.1.1 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee.erb
coalescing_panda-3.1.0 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee.erb