Skip to content

Commit

Permalink
Persist events table selection after pin/unpin
Browse files Browse the repository at this point in the history
helps fix #762

Signed-off-by: hriday-panchasara <hriday.panchasara@ericsson.com>
  • Loading branch information
hriday-panchasara committed Jul 22, 2022
1 parent 48a9336 commit 52c3805
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { BIMath } from 'timeline-chart/lib/bigint-utils';
import { XYChartFactoryParams, xyChartFactory, GetClosestPointParam, getClosestPointForScatterPlot } from './utils/xy-output-component-utils';
import { ChartOptions } from 'chart.js';
import { Line, Scatter } from 'react-chartjs-2';
import { signalManager, Signals } from 'traceviewer-base/lib/signals/signal-manager';
import { getAllExpandedNodeIds } from './utils/filter-tree/utils';
import { throttle } from 'lodash';

Expand Down Expand Up @@ -98,8 +97,6 @@ export abstract class AbstractXYOutputComponent<P extends AbstractOutputProps, S
protected positionXMove = 0;
protected startPositionMouseRightClick = BigInt(0);

// Event handlers
protected onSelectionChanged = (payload: { [key: string]: string; }) => this.doHandleSelectionChangedSignal(payload);
protected endSelection = (event: MouseEvent): void => {
if (this.clickedMouseButton === MouseButton.RIGHT) {
this.applySelectionZoom();
Expand Down Expand Up @@ -136,7 +133,6 @@ export abstract class AbstractXYOutputComponent<P extends AbstractOutputProps, S
this.divRef = React.createRef();
this.chartRef = React.createRef();

signalManager().on(Signals.SELECTION_CHANGED, this.onSelectionChanged);
this.afterChartDraw = this.afterChartDraw.bind(this);
}

Expand Down Expand Up @@ -186,20 +182,6 @@ export abstract class AbstractXYOutputComponent<P extends AbstractOutputProps, S
this.setState({checkedSeries: newList});
}

private doHandleSelectionChangedSignal(payload: { [key: string]: string }) {
const offset = this.props.viewRange.getOffset() || BigInt(0);
const startTimestamp = payload['startTimestamp'];
const endTimestamp = payload['endTimestamp'];
if (startTimestamp !== undefined && endTimestamp !== undefined) {
const selectionRangeStart = BigInt(startTimestamp) - offset;
const selectionRangeEnd = BigInt(endTimestamp) - offset;
this.props.unitController.selectionRange = {
start: selectionRangeStart,
end: selectionRangeEnd
};
}
}

private updateRange(rangeStart: bigint, rangeEnd: bigint): void {
if (rangeEnd < rangeStart) {
const temp = rangeStart;
Expand Down Expand Up @@ -264,7 +246,6 @@ export abstract class AbstractXYOutputComponent<P extends AbstractOutputProps, S

componentWillUnmount(): void {
super.componentWillUnmount();
signalManager().off(Signals.SELECTION_CHANGED, this.onSelectionChanged);
}

async fetchTree(): Promise<ResponseStatus> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,25 @@ export class TableOutputComponent extends AbstractOutputComponent<TableOutputPro
const payload = { startTimestamp, endTimestamp, load };
this.prevStartTimestamp = BigInt(startTimestamp);
this.eventSignal = true;
this.handleSelectionRangeUpdate(payload);
signalManager().fireSelectionChangedSignal(payload);
}
}

private handleSelectionRangeUpdate(payload: { [key: string]: string; }) {
const offset = this.props.viewRange.getOffset() || BigInt(0);
const startTimestamp = payload['startTimestamp'];
const endTimestamp = payload['endTimestamp'];
if (startTimestamp !== undefined && endTimestamp !== undefined) {
const selectionRangeStart = BigInt(startTimestamp) - offset;
const selectionRangeEnd = BigInt(endTimestamp) - offset;
this.props.unitController.selectionRange = {
start: selectionRangeStart,
end: selectionRangeEnd
};
}
}

private async handleTimeSelectionChange(range?: TimelineChart.TimeGraphRange) {
if (range) {
if (this.eventSignal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,9 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
}

private doHandleSelectionChangedSignal(payload: { [key: string]: string }) {
const offset = this.props.viewRange.getOffset() || BigInt(0);
const startTimestamp = payload['startTimestamp'];
const endTimestamp = payload['endTimestamp'];
if (startTimestamp !== undefined && endTimestamp !== undefined) {
const selectionRangeStart = BigInt(startTimestamp) - offset;
const selectionRangeEnd = BigInt(endTimestamp) - offset;
const foundElement = this.findElement(payload);

// Scroll vertically
Expand All @@ -302,12 +299,6 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent<Timegr
this.pendingSelection = foundElement;
}
}

// Scroll horizontally
this.props.unitController.selectionRange = {
start: selectionRangeStart,
end: selectionRangeEnd
};
this.chartCursors.maybeCenterCursor();
}
}
Expand Down

0 comments on commit 52c3805

Please sign in to comment.