You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sonarr/src/UI/Activity/Queue/QueueView.js

47 lines
1.5 KiB

9 years ago
'use strict';
define(
[
'underscore',
'marionette',
'Activity/Queue/QueueCollection'
], function (_, Marionette, QueueCollection) {
return Marionette.ItemView.extend({
tagName: 'span',
initialize: function () {
this.listenTo(QueueCollection, 'sync', this.render);
QueueCollection.fetch();
},
render: function () {
this.$el.empty();
if (QueueCollection.length === 0) {
return this;
}
var count = QueueCollection.fullCollection.length;
var label = 'label-info';
var errors = QueueCollection.fullCollection.some(function (model) {
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'error';
});
var warnings = QueueCollection.fullCollection.some(function (model) {
return model.has('trackedDownloadStatus') && model.get('trackedDownloadStatus').toLowerCase() === 'warning';
});
if (errors) {
label = 'label-danger';
}
else if (warnings) {
label = 'label-warning';
}
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
return this;
}
});
});