diff --git a/packages/base/src/signal-manager.ts b/packages/base/src/signal-manager.ts index 8706eb320..7e5f72558 100644 --- a/packages/base/src/signal-manager.ts +++ b/packages/base/src/signal-manager.ts @@ -4,29 +4,35 @@ export declare interface SignalManager { fireTooltipSignal(tooltip: { [key: string]: string }): void; fireThemeChangedSignal(theme: string): void; + fireSelectionChangedSignal(payload: { [key: string]: string }): void; } export const Signals = { - TRACE_OPENED : 'trace opened', - TRACE_CLOSED : 'trace closed', + TRACE_OPENED: 'trace opened', + TRACE_CLOSED: 'trace closed', EXPERIMENT_OPENED: 'experiment opened', EXPERIMENT_CLOSED: 'experiment closed', EXPERIMENT_SELECTED: 'experiment selected', TOOLTIP_UPDATED: 'tooltip updated', - THEME_CHANGED: 'theme changed' + THEME_CHANGED: 'theme changed', + SELECTION_CHANGED: 'selection changed' }; export class SignalManager extends EventEmitter implements SignalManager { fireTooltipSignal(tooltip: { [key: string]: string; }): void { - this.emit(Signals.TOOLTIP_UPDATED, {tooltip}); + this.emit(Signals.TOOLTIP_UPDATED, { tooltip }); } fireThemeChangedSignal(theme: string) { this.emit(Signals.THEME_CHANGED, theme); } + fireSelectionChangedSignal(payload: { [key: string]: string; }): void { + this.emit(Signals.SELECTION_CHANGED, { payload }); + } + } let instance: SignalManager = new SignalManager(); diff --git a/packages/react-components/src/components/table-output-component.tsx b/packages/react-components/src/components/table-output-component.tsx index da2c56723..e5bececa4 100644 --- a/packages/react-components/src/components/table-output-component.tsx +++ b/packages/react-components/src/components/table-output-component.tsx @@ -2,9 +2,10 @@ import { AbstractOutputComponent, AbstractOutputProps, AbstractOutputState } from './abstract-output-component'; import * as React from 'react'; import { AgGridReact } from 'ag-grid-react'; -import { ColDef, IDatasource, GridReadyEvent } from 'ag-grid-community'; +import { ColDef, IDatasource, GridReadyEvent, CellClickedEvent } from 'ag-grid-community'; import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper'; import { cloneDeep } from 'lodash'; +import { signalManager } from '@trace-viewer/base/lib/signal-manager'; type TableOuputState = AbstractOutputState & { tableColumns: ColDef[]; @@ -64,11 +65,25 @@ export class TableOutputComponent extends AbstractOutputComponent ; } + private onEventClick(event: CellClickedEvent) { + const columns = event.columnApi.getAllColumns(); + const timestampHeader = columns.find(column => column.getColDef().headerName === 'Timestamp ns'); + if (timestampHeader) { + const timestamp = timestampHeader.getColDef().field; + const payload = { + 'timestamp': (timestamp ? event.data[timestamp] : '') + }; + signalManager().fireSelectionChangedSignal(payload); + } + } + private async fetchTableLines(fetchIndex: number, linesToFetch: number) { const traceUUID = this.props.traceId; const tspClient = this.props.tspClient; diff --git a/packages/react-components/src/components/timegraph-output-component.tsx b/packages/react-components/src/components/timegraph-output-component.tsx index 6edb61dca..a2a3452b8 100644 --- a/packages/react-components/src/components/timegraph-output-component.tsx +++ b/packages/react-components/src/components/timegraph-output-component.tsx @@ -10,7 +10,7 @@ import { TimeGraphRowController } from 'timeline-chart/lib/time-graph-row-contro import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper'; import { ResponseStatus } from 'tsp-typescript-client/lib/models/response/responses'; import { TimeGraphEntry } from 'tsp-typescript-client/lib/models/timegraph'; -import { signalManager } from '@trace-viewer/base/lib/signal-manager'; +import { signalManager, Signals } from '@trace-viewer/base/lib/signal-manager'; import { AbstractOutputProps, AbstractOutputState } from './abstract-output-component'; import { AbstractTreeOutputComponent } from './abstract-tree-output-component'; import { StyleProvider } from './data-providers/style-provider'; @@ -37,6 +37,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent; private tspDataProvider: TspDataProvider; @@ -69,7 +70,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent { if (this.treeRef.current) { this.treeRef.current.scrollTop = this.rowController.verticalOffset; @@ -87,6 +88,7 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent this.onSelectionChanged(payload)); } synchronizeTreeScroll(): void { @@ -154,6 +156,19 @@ export class TimegraphOutputComponent extends AbstractTreeOutputComponent ;