Sha256: e90612fc83de22ec4fcbf116d0edb0711a8dde6a013fad1316c66a492947589c

Contents?: true

Size: 1.61 KB

Versions: 18

Compression:

Stored size: 1.61 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 = {};
console.log("asas")
    // Check the current status of the TaskStatus object.
    var updateStatus = function() {
      $.ajax({
        method: 'GET',
        url: url,
        dataType: "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

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.1.0 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.167 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.166 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.165 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.164 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.163 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.162 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.161 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.160 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.159 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.158 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.157 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.156 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.155 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.153 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.152 app/assets/javascripts/renalware/components/hd.js
renalware-core-2.0.151 app/assets/javascripts/renalware/components/hd.js