Skip to content

Commit

Permalink
TableOutputComponent: Separate search and matching
Browse files Browse the repository at this point in the history
Further isolate these two related methods so they don't concurrently
interfere with each other. This might happen as user almost
simultaneously searches and navigates the table entry selection.

Remove extra blank lines while in that file.

Contributes to fixing #859.

Signed-off-by: Marco Miller <marco.miller@ericsson.com>
  • Loading branch information
marco-miller committed Nov 1, 2022
1 parent 21fa207 commit a4726e0
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
private showIndexColumn = false;
private frameworkComponents: any;
private gridApi: GridApi | undefined = undefined;
private gridMatched = false;
private gridRedrawn = false;
private gridSearched = false;
private columnApi: ColumnApi | undefined = undefined;
Expand Down Expand Up @@ -500,7 +501,6 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
this.selectRows();
}
}

}

private async fetchTableIndex(timestamp: bigint) {
Expand Down Expand Up @@ -537,7 +537,6 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
}
}
return additionalParams;

}

private async fetchTableLines(fetchIndex: number, linesToFetch: number) {
Expand Down Expand Up @@ -587,7 +586,12 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
}
};

private searchEvents(colName: string, filterValue: string) {
private async searchEvents(colName: string, filterValue: string) {
const msBetweenChecks = 100;
while (this.gridMatched) {
// wait for grid to be done being matched -elsewhere (concurrently)
await new Promise(cb => setTimeout(cb, msBetweenChecks));
}
this.gridRedrawn = true;
if (filterValue === '') {
this.filterModel.delete(colName);
Expand Down Expand Up @@ -636,10 +640,15 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
let isFound = false;
if (this.gridApi) {
const msBetweenChecks = 100;
while (this.gridMatched) {
// wait for grid to be done being matched -from elsewhere (concurrently)
await new Promise(cb => setTimeout(cb, msBetweenChecks));
}
while (this.gridRedrawn) {
// wait for grid to be done being redrawn -elsewhere (before assuming it)
await new Promise(cb => setTimeout(cb, msBetweenChecks));
}
this.gridMatched = true;
if (this.gridSearched) {
// reset the selection once, upon new search filter just applied
this.selectStartIndex = this.selectEndIndex = -1;
Expand All @@ -662,11 +671,13 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
currRowIndex = Math.min(this.selectStartIndex, this.selectEndIndex) - 1;
if (currRowIndex < 0) {
// no backward search if already at index 0
this.gridMatched = false;
return;
}
}
} else if (direction === Direction.PREVIOUS) {
// no backward search if there is no selection
this.gridMatched = false;
return;
}

Expand Down Expand Up @@ -726,7 +737,7 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
this.gridApi.paginationGoToPage(indexPage);
this.gridApi.ensureIndexVisible(indexRow);
}

this.gridMatched = false;
return;
}
// find match outside the cache
Expand Down Expand Up @@ -761,6 +772,7 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
signalManager().fireTooltipSignal(itemPropsObj);
this.selectRows();
}
this.gridMatched = false;
}
}

Expand Down

0 comments on commit a4726e0

Please sign in to comment.