A few examples illustrating what you can do with celery-progress.
To understand how this works, you can read this guide. For a complete working code example, check out SaaS Pegasus—a Django starter kit for your next big project.
A simple progress UI with zero configuration required.
CeleryProgressBar.initProgressBar(taskUrl);
Demonstrating how you can modify the way progress is rendered to your liking. In this case, using a line of 😊 emojis.
function customProgress(progressBarElement, progressBarMessageElement, progress) {
progressBarElement.innerHTML = Array(parseInt(progress.percent) / 2).join("😊");
progressBarMessageElement.innerHTML = (
"about " + progress.percent + "% of the way through " + progress.total + ' custom thingies.'
);
}
CeleryProgressBar.initProgressBar(taskUrl, {
onProgress: customProgress
});
Overriding what happens on success/failure with your own custom UI.
function customSuccess(progressBarElement, progressBarMessageElement) {
progressBarElement.innerHTML = (
'<figure class="image"><img src="/static/images/web/progress-bars/success-kid.2e2340b7a9da.jpg"></figure>'
)
progressBarElement.style.backgroundColor = '#fff';
progressBarMessageElement.innerHTML = 'Success!'
}
function customError(progressBarElement, progressBarMessageElement) {
progressBarElement.innerHTML = (
'<figure class="image"><img src="/static/images/web/progress-bars/fail-stamp.a7cb2c6828f8.jpg"></figure>'
)
progressBarElement.style.backgroundColor = '#fff';
progressBarMessageElement.innerHTML = 'Fail.'
}
CeleryProgressBar.initProgressBar(taskUrl, {
onSuccess: customSuccess,
onError: customError,
});
I don't spam and you can unsubscribe anytime.