Sha256: 2050c3ae780e2372b1bbd4ecb52ce24affffb6a2e151340a2fba428e442de3b9

Contents?: true

Size: 1.8 KB

Versions: 82

Compression:

Stored size: 1.8 KB

Contents

window.CoalescingPanda or= {}

window.CoalescingPanda.CanvasBatchProgress = class CanvasBatchProgress
  constructor: (successCallback, errorCallback, messages)  ->
    window.messages = messages if messages != undefined
    setFlashMessages()
    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, successCallback, errorCallback)

  getBatchStatus = (id, url, successCallback, errorCallback) ->
    $.ajax
      url: url
      success: (data) ->
        $('#batch-progress').html(data)
        setFlashMessages()
        batch = $('#batch-info').data('batch')
        if batch && batch.status == "Completed"
          clearIntervalAndBatch(data, batch)
          successCallback() if successCallback != undefined
        else if batch && batch.status == 'Error'
          clearIntervalAndBatch(data, batch)
          errorCallback() if errorCallback != undefined
        else if batch && batch.status == "Canceled"
          clearIntervalAndBatch(data, batch)

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

  clearBatchFromSession = (id) ->
    $.ajax
      url: window.clearPath
      type: 'POST'
      success: (data) ->
        # Don't need to do anything

  clearIntervalAndBatch = (data, batch) ->
    clearInterval(window.batchInterval)
    $('#batch-progress').html(data)
    setFlashMessages()
    clearBatchFromSession(batch.id)

  setFlashMessages = ->
    if window.messages != undefined
      for key of window.messages
        $(".batch-message-#{key}").text("#{window.messages[key]}")

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
coalescing_panda-4.6.0.rc1 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.7 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.6 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.5 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.4 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.3 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.2 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.1 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.5.0 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.0.11 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.0.10 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.0.9 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.4.1 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.0.8 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.4.0 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.0.7 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.3.2 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.3.0 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.2.2 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee
coalescing_panda-4.2.1 app/assets/javascripts/coalescing_panda/canvas_batch.js.coffee