All Downloads are FREE. Search and download functionalities are using the official Maven repository.

static.internal.js.jobs.js Maven / Gradle / Ivy

There is a newer version: 2.0.5.RELEASE
Show newest version
function update() {
  const jobsContainer = $('#jobsContainer');
  let typeFilter = jobsContainer.data('type-filter');
  if (!typeFilter) {
    typeFilter = '';
  }
  const jobsUrl = jobsContainer.data('jobs-url');

  $.ajax({
    type: 'GET',
    url: `${jobsUrl}?humanReadable=true${typeFilter === '' ? '' : '&type=' + typeFilter}`,
    headers: {
      Accept: 'application/json; charset=utf-8',
      'Content-Type': 'application/json; charset=utf-8'
    },
    data: {},
    dataType: 'json',
    error: () => {
      console.log('Error polling job status');
      setTimeout(update, 10000);
    },
    success: (data) => {
      for (const propertyKey in data) {
        if (data.hasOwnProperty(propertyKey)) {
          let dataRow = null;
          dataRow = data[propertyKey];

          const jobStatus = $(`#job-status-${dataRow.id}`);
          // there is a new job that is not in this list -> reload page!
          if (!jobStatus.length) {
            location.reload();
          }

          if (dataRow.state !== 'Running') {
            if (dataRow.status === 'OK') {
              jobStatus.attr('class', 'badge progress-bar bg-success');
            } else if (dataRow.status === 'SKIPPED') {
              jobStatus.attr('class', 'badge progress-bar bg-secondary');
            } else if (dataRow.status === 'ERROR') {
              jobStatus.attr('class', 'badge progress-bar bg-danger');
            } else if (dataRow.status === 'DEAD') {
              jobStatus.attr('class', 'badge progress-bar bg-warning');
            }
            jobStatus.text(dataRow.status);
            $(`#trigger-button-${dataRow.id}`).prop('disabled', false);
          }
          $(`#job-stopped-${dataRow.id}`).text(dataRow.stopped);
          $(`#job-runtime-${dataRow.id}`).text(dataRow.runtime);
          $(`#job-last-updated-${dataRow.id}`).text(dataRow.lastUpdated);
        }
      }
      setTimeout(update, 4000);
    }
  });
}

setTimeout(() => {
  update();
}, 1000);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy