Skip to content

Commit

Permalink
Merge pull request #194 from hashicorp/f-ui-improvements
Browse files Browse the repository at this point in the history
UI Improvements
  • Loading branch information
pearkes committed Jun 5, 2014
2 parents 4bb424d + e54026c commit 2877124
Show file tree
Hide file tree
Showing 21 changed files with 1,323 additions and 289 deletions.
453 changes: 262 additions & 191 deletions ui/index.html

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions ui/javascripts/app/controllers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
App.ApplicationController = Ember.ObjectController.extend({
updateCurrentPath: function() {
App.set('currentPath', this.get('currentPath'));
}.observes('currentPath')
});

App.DcController = Ember.Controller.extend({
// Whether or not the dropdown menu can be seen
isDropdownVisible: false,
Expand Down Expand Up @@ -45,6 +51,18 @@ App.DcController = Ember.Controller.extend({

}.property('nodes'),

//
//
//
checkStatus: function() {
if (this.get('hasFailingChecks') == true) {
return "failing";
} else {
return "passing";
}

}.property('nodes'),

//
// Boolean if the datacenter has any failing checks.
//
Expand Down Expand Up @@ -216,3 +234,54 @@ App.KvEditController = KvBaseController.extend({
}

});

ItemBaseController = Ember.ArrayController.extend({
needs: ["dc", "application"],
queryParams: ["filter", "status", "condensed"],
dc: Ember.computed.alias("controllers.dc"),
condensed: true,
filter: "", // default
status: "any status", // default
statuses: ["any status", "passing", "failing"],

isShowingItem: function() {
var currentPath = this.get('controllers.application.currentPath');
return (currentPath === "dc.nodes.show" || currentPath === "dc.services.show");
}.property('controllers.application.currentPath'),

filteredContent: function() {
var filter = this.get('filter');
var status = this.get('status');

var items = this.get('items').filter(function(item, index, enumerable){
return item.get('filterKey').toLowerCase().match(filter.toLowerCase());
});

switch (status) {
case "passing":
return items.filterBy('hasFailingChecks', false)
break;
case "failing":
return items.filterBy('hasFailingChecks', true)
break;
default:
return items
}

}.property('filter', 'status', 'items.@each'),

actions: {
toggleCondensed: function() {
this.set('condensed', !this.get('condensed'))
}
}
});

App.NodesController = ItemBaseController.extend({
items: Ember.computed.alias("nodes"),
});

App.ServicesController = ItemBaseController.extend({
items: Ember.computed.alias("services"),
});

11 changes: 11 additions & 0 deletions ui/javascripts/app/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ Ember.Handlebars.helper('panelBar', function(status) {
}
return new Handlebars.SafeString('<div class="panel-bar ' + highlightClass + '"></div>');
});

Ember.Handlebars.helper('listBar', function(status) {
var highlightClass;

if (status == "passing") {
highlightClass = "bg-green";
} else {
highlightClass = "bg-orange";
}
return new Handlebars.SafeString('<div class="list-bar-horizontal ' + highlightClass + '"></div>');
});
57 changes: 53 additions & 4 deletions ui/javascripts/app/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ App.Service = Ember.Object.extend({
// Otherwise, we need to filter the child checks by both failing
// states
} else {
return (checks.filterBy('Status', 'critical').get('length') +
checks.filterBy('Status', 'warning').get('length'))
var checks = this.get('Checks');
return (checks.filterBy('Status', 'critical').get('length') +
checks.filterBy('Status', 'warning').get('length'))
}
}.property('Checks'),

Expand Down Expand Up @@ -45,13 +46,25 @@ App.Service = Ember.Object.extend({
}
}.property('Checks'),

nodes: function() {
return (this.get('Nodes'))
}.property('Nodes'),

//
// Boolean of whether or not there are failing checks in the service.
// This is used to set color backgrounds and so on.
//
hasFailingChecks: function() {
return (this.get('failingChecks') > 0);
}.property('Checks')
}.property('Checks'),

//
// Key used for filtering through an array of this model, i.e s
// searching
//
filterKey: function() {
return this.get('Name')
}.property('Name'),
});

//
Expand Down Expand Up @@ -93,7 +106,43 @@ App.Node = Ember.Object.extend({
//
hasFailingChecks: function() {
return (this.get('failingChecks') > 0);
}.property('Checks')
}.property('Checks'),

//
// The number of services on the node
//
numServices: function() {
return (this.get('Services').length)
}.property('Services'),
// The number of services on the node
//

services: function() {
return (this.get('Services'))
}.property('Services'),

filterKey: function() {
return this.get('Node')
}.property('Node'),

//
// Returns a combined and distinct list of the tags on the services
// running on the node
//
nodeTags: function() {
var tags = [];

// Collect the services tags
this.get('Services').map(function(Service){
tags.push(Service.Tags)
})

// strip nulls
tags = tags.filter(function(n){ return n != undefined });

// only keep unique tags and convert to comma sep
return tags.uniq().join(', ')
}.property('Services')
});


Expand Down
3 changes: 2 additions & 1 deletion ui/javascripts/app/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
window.App = Ember.Application.create({
rootElement: "#app"
rootElement: "#app",
currentPath: ''
});


Expand Down
9 changes: 9 additions & 0 deletions ui/javascripts/app/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
//
App.BaseRoute = Ember.Route.extend({
rootKey: '',
condensedView: false,

// Don't record characters in browser history
// for the "search" query item (filter)
queryParams: {
filter: {
replace: true
}
},

getParentAndGrandparent: function(key) {
var parentKey = this.rootKey,
Expand Down
14 changes: 14 additions & 0 deletions ui/javascripts/app/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ App.DcView = Ember.View.extend({
}
})


App.ItemView = Ember.View.extend({
templateName: 'item'
})

//
// Services
//
Expand Down Expand Up @@ -45,6 +50,15 @@ App.NodesLoadingView = Ember.View.extend({
templateName: 'item/loading'
})


// KV

App.KvListView = Ember.View.extend({
templateName: 'kv'
})

// Actions

App.ActionBarView = Ember.View.extend({
templateName: 'actionbar'
})
29 changes: 0 additions & 29 deletions ui/javascripts/libs/ember-1.5.1.min.js

This file was deleted.

Loading

0 comments on commit 2877124

Please sign in to comment.