1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-18 23:48:35 +02:00
Sonarr/src/UI/Health/HealthView.js
Mark McDowall 99f2b07a11 Bootstrap 3
New: Updated UI
New: Mobile browser support
Fixed: /favicon.ico will return the favicon now
2014-05-11 15:57:33 -07:00

42 lines
1.1 KiB
JavaScript

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