sardell commented on a change in pull request #1356: METRON-2029: Configure
Table should have filter
URL: https://github.com/apache/metron/pull/1356#discussion_r265202997
##########
File path:
metron-interface/metron-alerts/src/app/alerts/configure-table/configure-table.component.ts
##########
@@ -91,6 +95,46 @@ export class ConfigureTableComponent implements OnInit {
});
}
+ ngAfterViewInit() {
+ fromEvent(this.filterColResults.nativeElement, 'keyup')
+ .pipe(debounceTime(250))
+ .subscribe(e => {
+ this.filterColumns(e['target'].value);
+ });
+ }
+
+ filterColumns(val) {
+ const words = val.trim().split(' ');
+ this.filteredColumns = this.allColumns.filter(col => {
+ if (col.displayName) {
+ if (this.colMissingFilterKeyword(words, col, true)) {
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ if (this.colMissingFilterKeyword(words, col)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ });
+ }
+
+ colMissingFilterKeyword(words, col, displayName = false) {
+ if (displayName) {
+ return words.map(word =>
col.displayName.toLowerCase().includes(word.toLowerCase())).includes(false);
+ } else {
+ return words.map(word =>
col.columnMetadata.name.toLowerCase().includes(word.toLowerCase())).includes(false);
+ }
+ }
Review comment:
I like both of these suggestions, especially the second one. Makes it much
more readable. I'm going to update with these changes asap. Thanks for the
feedback, @ruffle1986!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services