Sha256: a17a98353f6280a359b12d991d0ebdb4d47bba6c059beeecb0e3ff73dfee1b0e

Contents?: true

Size: 1.59 KB

Versions: 12

Compression:

Stored size: 1.59 KB

Contents

var Renalware = typeof Renalware === 'undefined' ? {} : Renalware;

Renalware.HD = (function() {
  // This is pretty much a duplicate of Letters.pollBatchStatus and we will merge them soon
  var pollBatchStatus = function(url) {
    var POLL_INTERVAL = 2000; // ms
    var batch = {};

    // Check the current status of the TaskStatus object.
    var updateStatus = function() {
      $.ajax({
        method: 'GET',
        url: url,
        contentType: 'json'
      }).fail(function(e, x, a) {
        // Possible network glitch or perhaps a re-deploy causing the site to be down momentarily.
        // Anyway, not enough for us to give up polling.
        // TODO: examine the response code to see if we should in fact give up and show an
        // appropriate message.
        setTimeout(updateStatus, POLL_INTERVAL);
      }).done(function(batch) {
        $(".modal .percent_complete").html(batch.percent_complete + "%");

        switch(batch.status) {
          case 'awaiting_printing':
            $(".batch_results_container .preparing").hide();
            $(".batch_results_container .generated-batch-print-pdf-container").show();
            break;
          case 'failure':
            $(".batch_results_container .preparing").html("Failed");
            break;
          default:
            // Ask again in POLL_INTERVAL ms.
            setTimeout(updateStatus, POLL_INTERVAL);
        };
      });
    };
    setTimeout(updateStatus, POLL_INTERVAL);
  };

  return {
    init: function () {
      // nothing here yet
    },
    pollBatchStatus: pollBatchStatus
  };
}());

$(document).ready(Renalware.HD.init);

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
renalware-core-2.0.149 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.148 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.147 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.146 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.145 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.144 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.143 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.142 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.141 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.140 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.139 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.138 app/assets/javascripts/renalware/components/hd.js