From 44928c8f6433732de4355a17fed85990586fbcb9 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 13 Feb 2015 22:05:54 +0100 Subject: [PATCH] UI Cleanup - Updated Health subtree. --- src/UI/Health/HealthCollection.js | 18 +++++++++--------- src/UI/Health/HealthView.js | 16 ++++++++++------ src/UI/Hotkeys/HotkeysView.js | 4 ++-- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/UI/Health/HealthCollection.js b/src/UI/Health/HealthCollection.js index 787132323..e0935a885 100644 --- a/src/UI/Health/HealthCollection.js +++ b/src/UI/Health/HealthCollection.js @@ -2,12 +2,12 @@ var Backbone = require('backbone'); var HealthModel = require('./HealthModel'); require('../Mixins/backbone.signalr.mixin'); -module.exports = (function(){ - var Collection = Backbone.Collection.extend({ - url : window.NzbDrone.ApiRoot + '/health', - model : HealthModel - }); - var collection = new Collection().bindSignalR(); - collection.fetch(); - return collection; -}).call(this); \ No newline at end of file +var Collection = Backbone.Collection.extend({ + url : window.NzbDrone.ApiRoot + '/health', + model : HealthModel +}); + +var collection = new Collection().bindSignalR(); +collection.fetch(); + +module.exports = collection; \ No newline at end of file diff --git a/src/UI/Health/HealthView.js b/src/UI/Health/HealthView.js index 6990c4c2d..61ebd525a 100644 --- a/src/UI/Health/HealthView.js +++ b/src/UI/Health/HealthView.js @@ -5,29 +5,33 @@ var HealthCollection = require('./HealthCollection'); module.exports = Marionette.ItemView.extend({ tagName : 'span', - initialize : function(){ + initialize : function() { this.listenTo(HealthCollection, 'sync', this._healthSync); HealthCollection.fetch(); }, - render : function(){ + render : function() { this.$el.empty(); - if(HealthCollection.length === 0) { + + if (HealthCollection.length === 0) { return this; } + var count = HealthCollection.length; var label = 'label-warning'; - var errors = HealthCollection.some(function(model){ + var errors = HealthCollection.some(function(model) { return model.get('type') === 'error'; }); - if(errors) { + + if (errors) { label = 'label-danger'; } + this.$el.html('{1}'.format(label, count)); return this; }, - _healthSync : function(){ + _healthSync : function() { this.render(); } }); \ No newline at end of file diff --git a/src/UI/Hotkeys/HotkeysView.js b/src/UI/Hotkeys/HotkeysView.js index 42236cba0..69a1764b0 100644 --- a/src/UI/Hotkeys/HotkeysView.js +++ b/src/UI/Hotkeys/HotkeysView.js @@ -1,4 +1,4 @@ -var vent = require('vent'); +var vent = require('vent'); var Marionette = require('marionette'); -module.exports = Marionette.ItemView.extend({template : 'Hotkeys/HotkeysViewTemplate'}); \ No newline at end of file +module.exports = Marionette.ItemView.extend({template : 'Hotkeys/HotkeysViewTemplate'});