Skip to content

Commit 2d1ae35

Browse files
updated node table display to fix width, set headers to bold, fix footer total positioning. Converted text entry for pluginNameFilter to a <select>, since plugin names are known when nodes are known.
1 parent 151f604 commit 2d1ae35

File tree

3 files changed

+73
-20
lines changed

3 files changed

+73
-20
lines changed

app/components/slow-node-times.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,14 @@ export default Ember.Component.extend({
5050
let pluginNameFilter = this.get('pluginNameFilter');
5151
if (pluginNameFilter) {
5252
nodes = nodes.filter((node) => {
53-
if (!node.label.broccoliNode) { return false; }
54-
if (node.label.broccoliPluginName !== pluginNameFilter) { return false; }
55-
56-
return true;
53+
return (node.label.broccoliNode &&
54+
node.label.broccoliPluginName &&
55+
pluginNameFilter === node.label.broccoliPluginName);
5756
});
5857
}
5958

6059
let groupByPluginName = this.get('groupByPluginName');
6160
if (groupByPluginName) {
62-
let pluginNameMap = nodes.reduce((memo, node) => {
63-
let pluginName = node.label.broccoliPluginName;
64-
memo[pluginName] = memo[pluginName] || { count: 0, time: 0 };
65-
memo[pluginName].time += node._stats.time.plugin;
66-
memo[pluginName].count++;
67-
return memo;
68-
}, {})
6961

7062
nodes = [];
7163
for (let pluginName in pluginNameMap) {
@@ -82,6 +74,27 @@ export default Ember.Component.extend({
8274
return nodes;
8375
}).readOnly(),
8476

77+
pluginNameMap: computed('nodes', function() {
78+
let nodes = this.get('nodes');
79+
return nodes.reduce((memo, node) => {
80+
let pluginName = node.label.broccoliPluginName;
81+
memo[pluginName] = memo[pluginName] || { count: 0, time: 0 };
82+
memo[pluginName].time += node._stats.time.plugin;
83+
memo[pluginName].count++;
84+
return memo;
85+
}, {});
86+
}).readOnly(),
87+
88+
pluginNames: computed('pluginNameMap', function() {
89+
var keys = Object.keys(this.get('pluginNameMap'));
90+
var undefIndex = keys.indexOf('undefined');
91+
if (undefIndex >= 0) {
92+
keys.splice(undefIndex, 1);
93+
}
94+
keys.sort();
95+
return keys;
96+
}).readOnly(),
97+
8598
sortedNodes: computed('nodes', 'sortDescending', function() {
8699
let sortDescending = this.get('sortDescending');
87100
return this.get('nodes').sort((a, b) => {
@@ -118,6 +131,10 @@ export default Ember.Component.extend({
118131

119132
toggleTime() {
120133
this.toggleProperty('sortDescending');
134+
},
135+
136+
selectFilter(value) {
137+
this.set('pluginNameFilter', (value === 'clearFilter' ? undefined : value));
121138
}
122139
}
123140
});

app/styles/app.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ body > [class="ember-view"],
7272
border-bottom: 1px solid #eee;
7373
}
7474

75+
.nodes-controls select {
76+
font-size: 1rem;
77+
}
78+
79+
.nodes-table {
80+
width:100%;
81+
table-layout: fixed;
82+
}
83+
7584
.nodes-table_header tr:hover {
7685
background-color: initial;
7786
}
@@ -80,6 +89,19 @@ body > [class="ember-view"],
8089
color: inherit;
8190
}
8291

92+
.nodes-table th:nth-child(1) {
93+
text-align: left;
94+
width: 60%;
95+
}
96+
.nodes-table th:nth-child(2) {
97+
text-align: left;
98+
width: 30%;
99+
}
100+
.nodes-table th:nth-child(3) {
101+
text-align: right;
102+
width: 10%;
103+
}
104+
83105
.table-row:hover {
84106
cursor: pointer;
85107
}
@@ -88,3 +110,10 @@ body > [class="ember-view"],
88110
text-align: right;
89111
font-family: "Lucida Console", Monaco, monospace;
90112
}
113+
114+
.nodes-table thead th,
115+
.nodes-table tfoot td {
116+
font-weight: bold;
117+
}
118+
119+

app/templates/components/slow-node-times.hbs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
<div class="level-left">
33
<div class="level-item">
44
<p class="control has-addons">
5-
{{input class="input" value=pluginNameFilter placeholder="Filter by plugin name..."}}
6-
7-
<button class="button is-primary {{if (not pluginNameFilter) 'is-disabled'}}" {{action (action (mut pluginNameFilter) '')}}>Clear</button>
5+
<select onchange={{action "selectFilter" value="target.value"}}>
6+
{{#unless pluginNameFilter}}
7+
<option disabled selected> - Filter by Plugin Name - </option>
8+
{{/unless}}
9+
{{#each pluginNames as |pluginName|}}
10+
<option value="{{pluginName}}">{{pluginName}}</option>
11+
{{/each}}
12+
{{#if pluginNameFilter}}
13+
<option value="clearFilter">Clear Filter</option>
14+
{{/if}}
15+
</select>
816
</p>
917
</div>
1018

@@ -22,11 +30,11 @@
2230
<table class="nodes-table table is-striped">
2331
<thead class="nodes-table_header">
2432
<tr>
25-
<td style="width: 65%">Description</td>
26-
<td>{{if groupByPluginName "Count" "Plugin Name"}}</td>
27-
<td class="td-time">
33+
<th>Description</th>
34+
<th>{{if groupByPluginName "Count" "Plugin Name"}}</th>
35+
<th class="td-time">
2836
<a href="#" class="nodes-table_toggle" {{action "toggleTime"}}>Time (ms) <i class="fa fa-caret-{{if sortDescending 'down' 'up'}}"></i></a>
29-
</td>
37+
</th>
3038
</tr>
3139
</thead>
3240

@@ -71,8 +79,7 @@
7179
</tbody>
7280
<tfoot>
7381
<tr>
74-
<td colspan=2 class="has-text-right">Total</td>
75-
<td>{{ns-to-ms totalTime}}</td>
82+
<td colspan="3" class="td-time">Total: {{ns-to-ms totalTime}}</td>
7683
</tr>
7784
</tfoot>
7885
</table>

0 commit comments

Comments
 (0)