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

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

There is a newer version: 2.0.5.RELEASE
Show newest version
function getLog(logIndex) {
  $.ajax({
    type: 'GET',
    url: $('.js_logWindow').data('job-url'),
    headers: {
      Accept: 'application/json; charset=utf-8',
      'Content-Type': 'application/json; charset=utf-8'
    },
    data: {},
    dataType: 'json',
    error: () => {
      console.log('Error polling job status.');
      const jobStatus = $('#job-status');
      jobStatus.attr('class', 'badge badge-danger progress-bar bg-success');
      jobStatus.text('UNKNOWN');
    },
    success: (data) => {
      const numberOfMessages = data.messages.length;
      const logWindow = $('.js_logWindow');

      while (logIndex < numberOfMessages) {
        if (logIndex === 0) {
          logWindow.empty();
        }
        logWindow.append(`
${data.messages[logIndex]}
`); logIndex++; } if ($('#follow-log').prop('checked')) { logWindow.each(function () { const scrollHeight = Math.max(this.scrollHeight, this.clientHeight); this.scrollTop = scrollHeight - this.clientHeight; }); } // schedule further polling if still runnin' if (data.state === 'Running') { setTimeout(() => { getLog(logIndex); }, 2000); } else { const jobStatus = $('#job-status'); if (data.status === 'OK') { jobStatus.attr('class', 'badge progress-bar bg-success'); } else if (data.status === 'SKIPPED') { jobStatus.attr('class', 'badge progress-bar bg-secondary'); } else if (data.status === 'ERROR') { jobStatus.attr('class', 'badge progress-bar bg-danger'); } else if (data.status === 'DEAD') { jobStatus.attr('class', 'badge progress-bar bg-warning'); } jobStatus.text(data.status); $('#job-stopped').text(data.stopped); $('.js_triggerButton').prop('disabled', false); } $('#job-last-updated').text(data.lastUpdated); } }); } // uncheck follow log checkbox if real mouse scrolling detected $('.js_logWindow').bind('scroll mousedown DOMMouseScroll mousewheel keyup', (e) => { if (e.which > 0 || e.type === 'mousedown' || e.type === 'mousewheel') { $('#follow-log').prop('checked', false); } }); setTimeout(() => { getLog(0); }, 1000);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy