diff options
Diffstat (limited to 'server/sonar-web/src/main/js/common/processes.js')
-rw-r--r-- | server/sonar-web/src/main/js/common/processes.js | 54 |
1 files changed, 24 insertions, 30 deletions
diff --git a/server/sonar-web/src/main/js/common/processes.js b/server/sonar-web/src/main/js/common/processes.js index 6582863d910..1116a60e134 100644 --- a/server/sonar-web/src/main/js/common/processes.js +++ b/server/sonar-web/src/main/js/common/processes.js @@ -68,43 +68,37 @@ model: Process }), - ProcessView = Marionette.ItemView.extend({ - tagName: 'li', - className: 'process-spinner', + ProcessesView = Marionette.ItemView.extend({ + tagName: 'ul', + className: 'processes-container', - modelEvents: { - 'change': 'render' + collectionEvents: { + 'all': 'render' }, render: function () { - var that = this; - switch (this.model.get('state')) { - case 'timeout': - this.$el.html(this.model.get('message')).addClass('shown'); - break; - case 'failed': - this.$el.html(this.model.get('message')).addClass('process-spinner-failed shown'); - var close = $('<button></button>').html('<i class="icon-close"></i>').addClass('process-spinner-close'); - close.appendTo(this.$el); - close.on('click', function () { - var a = { force: true }; - that.model.finish(a); - }); - break; - case 'finished': - this.$el.addClass('hidden'); - break; - default: - break; + var failed = this.collection.findWhere({ state: 'failed' }), + timeout = this.collection.findWhere({ state: 'timeout' }), + el; + this.$el.empty(); + if (failed != null) { + el = $('<li></li>') + .html(failed.get('message')) + .addClass('process-spinner process-spinner-failed shown'); + var close = $('<button></button>').html('<i class="icon-close"></i>').addClass('process-spinner-close'); + close.appendTo(el); + close.on('click', function () { + failed.finish({ force: true }); + }); + el.appendTo(this.$el); + } else if (timeout != null) { + el = $('<li></li>') + .html(timeout.get('message')) + .addClass('process-spinner shown'); + el.appendTo(this.$el); } return this; } - }), - - ProcessesView = Marionette.CollectionView.extend({ - tagName: 'ul', - className: 'processes-container', - itemView: ProcessView }); |