Logs: Fix pagination skipping entries (#48413)

* Logs: Add pagination range to prevent pagination from skipping entries

* Revert "Logs: Add pagination range to prevent pagination from skipping entries"

This reverts commit 2e7a6b3870.

* Refactor

* Update
This commit is contained in:
Ivana Huckova 2022-05-02 16:46:47 +02:00 committed by GitHub
parent 2533f21015
commit 656cd4c8dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -85,6 +85,7 @@ export interface LogsModel {
meta?: LogsMetaItem[];
rows: LogRowModel[];
series?: DataFrame[];
// visibleRange is time range for histogram created from log results
visibleRange?: AbsoluteTimeRange;
queries?: DataQuery[];
}

View File

@ -163,7 +163,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
}
};
onChangewrapLogMessage = (event: React.ChangeEvent<HTMLInputElement>) => {
onChangeWrapLogMessage = (event: React.ChangeEvent<HTMLInputElement>) => {
const { target } = event;
if (target) {
const wrapLogMessage = target.checked;
@ -249,6 +249,20 @@ class UnthemedLogs extends PureComponent<Props, State> {
return filterLogLevels(logRows, new Set(hiddenLogLevels));
});
createNavigationRange = memoizeOne((logRows: LogRowModel[]): { from: number; to: number } | undefined => {
if (!logRows || logRows.length === 0) {
return undefined;
}
const firstTimeStamp = logRows[0].timeEpochMs;
const lastTimeStamp = logRows[logRows.length - 1].timeEpochMs;
if (lastTimeStamp < firstTimeStamp) {
return { from: lastTimeStamp, to: firstTimeStamp };
}
return { from: firstTimeStamp, to: lastTimeStamp };
});
scrollToTopLogs = () => this.topLogsRef.current?.scrollIntoView();
render() {
@ -295,8 +309,10 @@ class UnthemedLogs extends PureComponent<Props, State> {
const filteredLogs = this.filterRows(logRows, hiddenLogLevels);
const { dedupedRows, dedupCount } = this.dedupRows(filteredLogs, dedupStrategy);
const navigationRange = this.createNavigationRange(logRows);
const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...';
return (
<>
{logsSeries && logsSeries.length ? (
@ -342,7 +358,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
<InlineField label="Wrap lines" className={styles.horizontalInlineLabel} transparent>
<InlineSwitch
value={wrapLogMessage}
onChange={this.onChangewrapLogMessage}
onChange={this.onChangeWrapLogMessage}
className={styles.horizontalInlineSwitch}
transparent
id={`wrap-lines_${exploreId}`}
@ -430,7 +446,7 @@ class UnthemedLogs extends PureComponent<Props, State> {
</div>
<LogsNavigation
logsSortOrder={logsSortOrder}
visibleRange={visibleRange ?? absoluteRange}
visibleRange={navigationRange ?? absoluteRange}
absoluteRange={absoluteRange}
timeZone={timeZone}
onChangeTime={onChangeTime}