Skip to content

Commit 4ac1813

Browse files
author
Robert Jackson
committed
Allow filtering by plugin name...
1 parent f25685c commit 4ac1813

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

app/components/slow-node-times.js

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,42 @@ const {
44
computed
55
} = Ember;
66

7-
function filterForAddonInitializationNodes(node) {
8-
return node.label.addonInitializationNode;
7+
function filterForAddonInitializationNodes(nodes) {
8+
return nodes.filter((node) => node.label.addonInitializationNode);
99
}
1010

11-
function filterForAddonDiscoveryNodes(node) {
12-
return node.label.addonDiscoveryNode;
11+
function filterForAddonDiscoveryNodes(nodes) {
12+
return nodes.filter((node) => node.label.addonDiscoveryNode);
1313
}
1414

15-
function filterForBroccoliNodes(node) {
16-
return node.label.broccoliNode;
15+
function filterForBroccoliNodes(nodes, instance) {
16+
let pluginName = instance.get('pluginNameFilter');
17+
18+
return nodes.filter((node) => {
19+
if (!node.label.broccoliNode) { return false; }
20+
if (pluginName && node.label.broccoliPluginName !== pluginName) { return false; }
21+
22+
return true;
23+
})
1724
}
1825

1926
export default Ember.Component.extend({
20-
filter: filterForAddonInitializationNodes,
27+
init() {
28+
this._super(...arguments);
29+
this.filterType = 'broccoli-node';
30+
},
31+
32+
filter: filterForBroccoliNodes,
2133

22-
nodes: computed('data', 'filter', function() {
34+
nodes: computed('data', 'filter', 'pluginNameFilter', function() {
2335
let data = this.get('data');
2436
let filter = this.get('filter');
2537
if (!data) { return []; }
2638

2739
let nodes = data.nodes;
2840

2941
if (filter) {
30-
nodes = nodes.filter(filter);
42+
nodes = filter(nodes, this);
3143
}
3244

3345
let addonNodes = nodes
@@ -49,8 +61,9 @@ export default Ember.Component.extend({
4961
actions: {
5062
updateFilter(event) {
5163
let filter;
64+
let filterType = event.target.value;
5265

53-
switch(event.target.value) {
66+
switch(filterType) {
5467
case 'addon-discovery':
5568
filter = filterForAddonDiscoveryNodes;
5669
break;
@@ -63,6 +76,7 @@ export default Ember.Component.extend({
6376
}
6477

6578
this.set('filter', filter);
79+
this.set('filterType', filterType);
6680
}
6781
}
6882
});

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
<option selected value="broccoli-node">Show Broccoli Nodes</option>
55
</select>
66

7+
{{#if (eq filterType 'broccoli-node')}}
8+
{{input value=pluginNameFilter placeholder="Filter by plugin name..."}}
9+
<button {{action (action (mut pluginNameFilter) '')}}>Clear</button>
10+
{{/if}}
11+
12+
713
<ul>
814
{{#each nodes as |node|}}
915
<li>{{node.label.name}} - {{ns-to-ms node.stats.time.self}}</li>

0 commit comments

Comments
 (0)