static.internal.js.jobs.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-breuninger-jobs Show documentation
Show all versions of spring-boot-starter-breuninger-jobs Show documentation
spring-boot-starter-breuninger-jobs
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);