Skip to content

Commit

Permalink
Merge pull request #100 from giovcandido/patch-1
Browse files Browse the repository at this point in the history
Allow default colors to be accessed without class instantiation
  • Loading branch information
czue authored Nov 11, 2022
2 parents 670166f + 3eaa7cb commit 11e1870
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions celery_progress/static/celery_progress/celery_progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ class CeleryProgressBar {
this.onHttpError = options.onHttpError || this.onError;
this.pollInterval = options.pollInterval || 500;
// Other options
let barColorsDefault = {
success: '#76ce60',
error: '#dc4f63',
progress: '#68a9ef',
ignored: '#7a7a7a'
}
this.barColors = Object.assign({}, barColorsDefault, options.barColors);
this.barColors = Object.assign({}, this.getBarColorsDefault(), options.barColors);

let defaultMessages = {
waiting: 'Waiting for task to start...',
Expand Down Expand Up @@ -169,6 +163,15 @@ class CeleryProgressBar {
this.onHttpError(this.progressBarElement, this.progressBarMessageElement, "HTTP Code " + response.status, response);
}
}

static getBarColorsDefault() {
return {
success: '#76ce60',
error: '#dc4f63',
progress: '#68a9ef',
ignored: '#7a7a7a'
};
}

static initProgressBar(progressUrl, options) {
const bar = new this(progressUrl, options);
Expand Down

0 comments on commit 11e1870

Please sign in to comment.