ui/controllers: jshint

This commit is contained in:
Jack Pearkes 2014-08-20 16:51:40 -07:00
parent 1e4bdf6820
commit ab0c397439

View File

@ -9,20 +9,20 @@ App.DcController = Ember.Controller.extend({
isDropdownVisible: false, isDropdownVisible: false,
datacenter: function() { datacenter: function() {
return this.get('content') return this.get('content');
}.property('Content'), }.property('Content'),
checks: function() { checks: function() {
var nodes = this.get('nodes'); var nodes = this.get('nodes');
var checks = Ember.A() var checks = Ember.A();
// Combine the checks from all of our nodes // Combine the checks from all of our nodes
// into one. // into one.
nodes.forEach(function(item) { nodes.forEach(function(item) {
checks = checks.concat(item.Checks) checks = checks.concat(item.Checks);
}); });
return checks return checks;
}.property('nodes'), }.property('nodes'),
// Returns the total number of failing checks. // Returns the total number of failing checks.
@ -30,20 +30,20 @@ App.DcController = Ember.Controller.extend({
// We treat any non-passing checks as failing // We treat any non-passing checks as failing
// //
totalChecksFailing: function() { totalChecksFailing: function() {
var checks = this.get('checks') var checks = this.get('checks');
return (checks.filterBy('Status', 'critical').get('length') + return (checks.filterBy('Status', 'critical').get('length') +
checks.filterBy('Status', 'warning').get('length')) checks.filterBy('Status', 'warning').get('length'));
}.property('nodes'), }.property('nodes'),
// //
// Returns the human formatted message for the button state // Returns the human formatted message for the button state
// //
checkMessage: function() { checkMessage: function() {
var checks = this.get('checks') var checks = this.get('checks');
var failingChecks = this.get('totalChecksFailing'); var failingChecks = this.get('totalChecksFailing');
var passingChecks = checks.filterBy('Status', 'passing').get('length'); var passingChecks = checks.filterBy('Status', 'passing').get('length');
if (this.get('hasFailingChecks') == true) { if (this.get('hasFailingChecks') === true) {
return failingChecks + ' checks failing'; return failingChecks + ' checks failing';
} else { } else {
return passingChecks + ' checks passing'; return passingChecks + ' checks passing';
@ -55,7 +55,7 @@ App.DcController = Ember.Controller.extend({
// //
// //
checkStatus: function() { checkStatus: function() {
if (this.get('hasFailingChecks') == true) { if (this.get('hasFailingChecks') === true) {
return "failing"; return "failing";
} else { } else {
return "passing"; return "passing";
@ -67,7 +67,7 @@ App.DcController = Ember.Controller.extend({
// Boolean if the datacenter has any failing checks. // Boolean if the datacenter has any failing checks.
// //
hasFailingChecks: function() { hasFailingChecks: function() {
var failingChecks = this.get('totalChecksFailing') var failingChecks = this.get('totalChecksFailing');
return (failingChecks > 0); return (failingChecks > 0);
}.property('nodes'), }.property('nodes'),
@ -81,7 +81,7 @@ App.DcController = Ember.Controller.extend({
this.set('isDropdownVisible', false); this.set('isDropdownVisible', false);
} }
} }
}) });
KvBaseController = Ember.ObjectController.extend({ KvBaseController = Ember.ObjectController.extend({
getParentKeyRoute: function() { getParentKeyRoute: function() {
@ -134,7 +134,7 @@ App.KvShowController.reopen({
// If we don't have a previous model to base // If we don't have a previous model to base
// on our parent, or we're not at the root level, // on our parent, or we're not at the root level,
// add the prefix // add the prefix
if (parentKey != undefined && parentKey != "/") { if (parentKey !== undefined && parentKey !== "/") {
newKey.set('Key', (parentKey + newKey.get('Key'))); newKey.set('Key', (parentKey + newKey.get('Key')));
} }
@ -145,15 +145,15 @@ App.KvShowController.reopen({
data: newKey.get('Value') data: newKey.get('Value')
}).then(function(response) { }).then(function(response) {
// transition to the right place // transition to the right place
if (newKey.get('isFolder') == true) { if (newKey.get('isFolder') === true) {
controller.transitionToRoute('kv.show', newKey.get('Key')); controller.transitionToRoute('kv.show', newKey.get('Key'));
} else { } else {
controller.transitionToRoute('kv.edit', newKey.get('Key')); controller.transitionToRoute('kv.edit', newKey.get('Key'));
} }
controller.set('isLoading', false) controller.set('isLoading', false);
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed
controller.set('errorMessage', 'Received error while processing: ' + response.statusText) controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
}); });
}, },
@ -172,7 +172,7 @@ App.KvShowController.reopen({
controller.transitionToNearestParent(grandParent); controller.transitionToNearestParent(grandParent);
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed
controller.set('errorMessage', 'Received error while processing: ' + response.statusText) controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
}); });
} }
} }
@ -200,11 +200,11 @@ App.KvEditController = KvBaseController.extend({
data: key.get('valueDecoded') data: key.get('valueDecoded')
}).then(function(response) { }).then(function(response) {
// If success, just reset the loading state. // If success, just reset the loading state.
controller.set('isLoading', false) controller.set('isLoading', false);
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed
controller.set('errorMessage', 'Received error while processing: ' + response.statusText) controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
}) });
}, },
cancelEdit: function() { cancelEdit: function() {
@ -229,8 +229,8 @@ App.KvEditController = KvBaseController.extend({
controller.transitionToNearestParent(parent); controller.transitionToNearestParent(parent);
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed
controller.set('errorMessage', 'Received error while processing: ' + response.statusText) controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
}) });
} }
} }
@ -260,20 +260,18 @@ ItemBaseController = Ember.ArrayController.extend({
switch (status) { switch (status) {
case "passing": case "passing":
return items.filterBy('hasFailingChecks', false) return items.filterBy('hasFailingChecks', false);
break;
case "failing": case "failing":
return items.filterBy('hasFailingChecks', true) return items.filterBy('hasFailingChecks', true);
break;
default: default:
return items return items;
} }
}.property('filter', 'status', 'items.@each'), }.property('filter', 'status', 'items.@each'),
actions: { actions: {
toggleCondensed: function() { toggleCondensed: function() {
this.set('condensed', !this.get('condensed')) this.set('condensed', !this.get('condensed'));
} }
} }
}); });
@ -296,11 +294,11 @@ App.NodesShowController = Ember.ObjectController.extend({
type: 'PUT' type: 'PUT'
}).then(function(response) { }).then(function(response) {
return Ember.$.getJSON('/v1/session/node/' + node.Node + '?dc=' + dc).then(function(data) { return Ember.$.getJSON('/v1/session/node/' + node.Node + '?dc=' + dc).then(function(data) {
controller.set('sessions', data) controller.set('sessions', data);
}); });
}).fail(function(response) { }).fail(function(response) {
// Render the error message on the form if the request failed // Render the error message on the form if the request failed
controller.set('errorMessage', 'Received error while processing: ' + response.statusText) controller.set('errorMessage', 'Received error while processing: ' + response.statusText);
}); });
} }
} }