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.
Lidarr/src/UI/Health/HealthView.js

37 lines
917 B

9 years ago
var _ = require('underscore');
var Marionette = require('marionette');
var HealthCollection = require('./HealthCollection');
9 years ago
module.exports = Marionette.ItemView.extend({
tagName : 'span',
initialize : function() {
9 years ago
this.listenTo(HealthCollection, 'sync', this._healthSync);
HealthCollection.fetch();
},
render : function() {
9 years ago
this.$el.empty();
if (HealthCollection.length === 0) {
9 years ago
return this;
}
9 years ago
var count = HealthCollection.length;
var label = 'label-warning';
var errors = HealthCollection.some(function(model) {
9 years ago
return model.get('type') === 'error';
});
if (errors) {
9 years ago
label = 'label-danger';
}
9 years ago
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
return this;
},
_healthSync : function() {
9 years ago
this.render();
}
});