Sha256: d432a6a824eb036897cbb84343b5d39b22b70ea3cf2975c322188f869c23b3fb

Contents?: true

Size: 1.24 KB

Versions: 47

Compression:

Stored size: 1.24 KB

Contents

class Para.JobTracker extends RemoteModalForm
  initialize: (options = {}) ->
    super(options)
    @refreshOnClose = false
    @trackProgress()

  formSuccess: (e, response) ->
    super(e, response)
    @trackProgress()

  trackProgress: ($progressBar) ->
    return unless ($progressBar = @$el.find('[data-async-progress]')).length

    @jobStatusURL = @$el.data('job-status-url')
    @progress = new Para.AsyncProgress(el: $progressBar, progressUrl: @jobStatusURL)
    @listenTo(@progress, 'completed', @onImportComplete)
    @listenTo(@progress, 'failed', @onImportComplete)

  onImportComplete: ->
    $.ajax(
      url: @jobStatusURL
      # Force HTTP ACCEPT header to HTML since Rails treats XHR request without
      # a specific ACCEPT header as JS or JSON by defaut.
      accepts:
        'html': 'text/html'
      dataType: 'html'
    ).done(@onFinalModalLoaded)

  onFinalModalLoaded: (response) =>
    @formSuccess(null, response)
    @refreshOnClose = !(@$link?.data('refresh-on-close') is false)

  modalHide: ->
    super()
    @progress?.stop()

$(document).on 'page:change turbolinks:load', ->
  $('body').on 'ajax:success', '[data-job-tracker-button]', (e, response) ->
      new Para.JobTracker(modalMarkup: response, $link: $(e.currentTarget))

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
para-0.11.4 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.11.3 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.11.2 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.11.1 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.11.0 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.10.0 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.4 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.3.3 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.3.2 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.3.1 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.2 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.9.0 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.15 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.14 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.13 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.12 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.11 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.10 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.9 app/assets/javascripts/para/admin/job-tracker.coffee
para-0.8.8 app/assets/javascripts/para/admin/job-tracker.coffee