tiborm commented on a change in pull request #1514: METRON-2190: [UI] Alerts UI: Indicating loading and preventing parallel requests URL: https://github.com/apache/metron/pull/1514#discussion_r327004201
########## File path: metron-interface/metron-alerts/src/app/alerts/alerts-list/alerts-list.component.ts ########## @@ -386,31 +410,19 @@ export class AlertsListComponent implements OnInit, OnDestroy { this.setSearchRequestSize(); - if (this.hideQueryBuilder) { - const newSearch = new SearchRequest(); - newSearch.query = this.manualQuery.nativeElement.value; - newSearch.size = this.pagination.size; - newSearch.from = 0; - - this.searchService.search(newSearch).subscribe(results => { - this.setData(results); - this.staleDataState = false; - }, error => { - this.setData(new SearchResponse()); - this.dialogService.launchDialog(ElasticsearchUtils.extractESErrorMessage(error), DialogType.Error); - }); - - this.tryStartPolling(newSearch); - } else { - this.searchService.search(this.queryBuilder.searchRequest).subscribe(results => { + this.pendingSearch = this.searchService.search(this.queryBuilder.searchRequest).subscribe( + results => { this.setData(results); + this.pendingSearch = null; this.staleDataState = false; }, error => { this.setData(new SearchResponse()); - this.dialogService.launchDialog(ElasticsearchUtils.extractESErrorMessage(error), DialogType.Error); + this.pendingSearch = null; + this.dialogService.launchDialog('Server were unable to apply query string.', DialogType.Error); }); - this.tryStartPolling(); + if (this.autoPollingSvc.getIsPollingActive()) { + this.autoPollingSvc.dropNextAndContinue(); Review comment: This was a large block of code duplication. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services