UI Cleanup - Updated Health subtree.
This commit is contained in:
parent
a5fd28326e
commit
44928c8f64
|
@ -2,12 +2,12 @@ var Backbone = require('backbone');
|
||||||
var HealthModel = require('./HealthModel');
|
var HealthModel = require('./HealthModel');
|
||||||
require('../Mixins/backbone.signalr.mixin');
|
require('../Mixins/backbone.signalr.mixin');
|
||||||
|
|
||||||
module.exports = (function(){
|
var Collection = Backbone.Collection.extend({
|
||||||
var Collection = Backbone.Collection.extend({
|
url : window.NzbDrone.ApiRoot + '/health',
|
||||||
url : window.NzbDrone.ApiRoot + '/health',
|
model : HealthModel
|
||||||
model : HealthModel
|
});
|
||||||
});
|
|
||||||
var collection = new Collection().bindSignalR();
|
var collection = new Collection().bindSignalR();
|
||||||
collection.fetch();
|
collection.fetch();
|
||||||
return collection;
|
|
||||||
}).call(this);
|
module.exports = collection;
|
|
@ -5,29 +5,33 @@ var HealthCollection = require('./HealthCollection');
|
||||||
module.exports = Marionette.ItemView.extend({
|
module.exports = Marionette.ItemView.extend({
|
||||||
tagName : 'span',
|
tagName : 'span',
|
||||||
|
|
||||||
initialize : function(){
|
initialize : function() {
|
||||||
this.listenTo(HealthCollection, 'sync', this._healthSync);
|
this.listenTo(HealthCollection, 'sync', this._healthSync);
|
||||||
HealthCollection.fetch();
|
HealthCollection.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
render : function(){
|
render : function() {
|
||||||
this.$el.empty();
|
this.$el.empty();
|
||||||
if(HealthCollection.length === 0) {
|
|
||||||
|
if (HealthCollection.length === 0) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
var count = HealthCollection.length;
|
var count = HealthCollection.length;
|
||||||
var label = 'label-warning';
|
var label = 'label-warning';
|
||||||
var errors = HealthCollection.some(function(model){
|
var errors = HealthCollection.some(function(model) {
|
||||||
return model.get('type') === 'error';
|
return model.get('type') === 'error';
|
||||||
});
|
});
|
||||||
if(errors) {
|
|
||||||
|
if (errors) {
|
||||||
label = 'label-danger';
|
label = 'label-danger';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
|
this.$el.html('<span class="label {0}">{1}</span>'.format(label, count));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
_healthSync : function(){
|
_healthSync : function() {
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
|
@ -1,4 +1,4 @@
|
||||||
var vent = require('vent');
|
var vent = require('vent');
|
||||||
var Marionette = require('marionette');
|
var Marionette = require('marionette');
|
||||||
|
|
||||||
module.exports = Marionette.ItemView.extend({template : 'Hotkeys/HotkeysViewTemplate'});
|
module.exports = Marionette.ItemView.extend({template : 'Hotkeys/HotkeysViewTemplate'});
|
||||||
|
|
Loading…
Reference in New Issue