-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Kenneth Marut <kenneth.marut@ericsson.com>
- Loading branch information
1 parent
5b8c4bc
commit d5cc7a3
Showing
15 changed files
with
817 additions
and
516 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
viewer-prototype/src/browser/trace-explorer/output-added-signal-payload.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { OutputDescriptor } from 'tsp-typescript-client/lib/models/output-descriptor'; | ||
import { Experiment } from 'tsp-typescript-client/lib/models/experiment'; | ||
|
||
export class OutputAddedSignalPayload { | ||
private outputDescriptor: OutputDescriptor; | ||
private experiment: Experiment; | ||
|
||
constructor(outputDescriptor: OutputDescriptor, trace: Experiment) { | ||
this.outputDescriptor = outputDescriptor; | ||
this.experiment = trace; | ||
} | ||
|
||
public getOutputDescriptor(): OutputDescriptor { | ||
return this.outputDescriptor; | ||
} | ||
|
||
public getExperiment(): Experiment { | ||
return this.experiment; | ||
} | ||
} |
13 changes: 7 additions & 6 deletions
13
viewer-prototype/src/browser/trace-explorer/trace-explorer-contribution.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import { injectable } from 'inversify'; | ||
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; | ||
import { TraceExplorerWidget, TRACE_EXPLORER_ID, TRACE_EXPLORER_LABEL } from './trace-explorer-widget'; | ||
import { TraceExplorerWidget, } from './trace-explorer-widget'; | ||
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser'; | ||
|
||
@injectable() | ||
export class TraceExplorerContribution extends AbstractViewContribution<TraceExplorerWidget> implements FrontendApplicationContribution { | ||
|
||
constructor() { | ||
super({ | ||
widgetId: TRACE_EXPLORER_ID, | ||
widgetName: TRACE_EXPLORER_LABEL, | ||
widgetId: TraceExplorerWidget.ID, | ||
widgetName: TraceExplorerWidget.LABEL, | ||
defaultWidgetOptions: { | ||
area: 'left' | ||
}, | ||
toggleCommandId: 'trace-explorer:toggle' | ||
}); | ||
} | ||
|
||
async initializeLayout(_app: FrontendApplication): Promise<void> { | ||
await this.openView({ activate: false }); | ||
initializeLayout(_app: FrontendApplication): void { | ||
this.openView({ activate: false }); | ||
} | ||
|
||
} |
133 changes: 133 additions & 0 deletions
133
.../src/browser/trace-explorer/trace-explorer-sub-widgets/trace-explorer-analysis-widget.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { inject, injectable, postConstruct } from 'inversify'; | ||
import { ReactWidget, Widget, Message } from '@theia/core/lib/browser'; | ||
import * as React from 'react'; | ||
import { List, ListRowProps, AutoSizer } from 'react-virtualized'; | ||
import { TraceExplorerOpenedTracesWidget } from './trace-explorer-opened-traces-widget'; | ||
import { Emitter } from '@theia/core'; | ||
import { OutputAddedSignalPayload } from '../output-added-signal-payload'; | ||
|
||
@injectable() | ||
export class TraceExplorerAnalysisWidget extends ReactWidget { | ||
static ID = 'trace-explorer-analysis-widget'; | ||
static LABEL = 'Available Analysis'; | ||
static LIST_MARGIN = 2; | ||
static LINE_HEIGHT = 16; | ||
static ROW_HEIGHT = (2 * TraceExplorerAnalysisWidget.LINE_HEIGHT) + TraceExplorerAnalysisWidget.LIST_MARGIN; | ||
|
||
protected forceUpdateKey = false; | ||
|
||
protected outputAddedEmitter = new Emitter<OutputAddedSignalPayload>(); | ||
outputAddedSignal = this.outputAddedEmitter.event; | ||
|
||
@inject(TraceExplorerOpenedTracesWidget) protected readonly openedTracesWidget!: TraceExplorerOpenedTracesWidget; | ||
|
||
@postConstruct() | ||
init(): void { | ||
this.id = TraceExplorerAnalysisWidget.ID; | ||
this.title.label = TraceExplorerAnalysisWidget.LABEL; | ||
this.toDispose.push(this.openedTracesWidget.availableOutputDescriptorsDidChange(() => { | ||
this.update(); | ||
})); | ||
this.toDispose.push(this.outputAddedEmitter); | ||
this.update(); | ||
} | ||
|
||
render(): React.ReactNode { | ||
this.forceUpdateKey = !this.forceUpdateKey; | ||
const key = Number(this.forceUpdateKey); | ||
const { openedExperiments, availableOutputDescriptors, selectedExperimentIndex } = this.openedTracesWidget; | ||
let outputsRowCount = 0; | ||
const outputs = availableOutputDescriptors.get(openedExperiments[selectedExperimentIndex]?.UUID); | ||
if (outputs) { | ||
outputsRowCount = outputs.length; | ||
} | ||
const totalHeight = this.getTotalHeight(); | ||
return ( | ||
<div className='trace-explorer-analysis'> | ||
<div className='trace-explorer-panel-content'> | ||
<AutoSizer> | ||
{({ width }) => | ||
<List | ||
key={key} | ||
height={totalHeight} | ||
width={width} | ||
rowCount={outputsRowCount} | ||
rowHeight={TraceExplorerAnalysisWidget.ROW_HEIGHT} | ||
rowRenderer={this.renderRowOutputs} | ||
/> | ||
} | ||
</AutoSizer> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
protected renderRowOutputs = (props: ListRowProps): React.ReactNode => this.doRenderRowOutputs(props); | ||
|
||
private doRenderRowOutputs(props: ListRowProps): React.ReactNode { | ||
let outputName = ''; | ||
let outputDescription = ''; | ||
const { openedExperiments, availableOutputDescriptors, selectedExperimentIndex, lastSelectedOutputIndex } = this.openedTracesWidget; | ||
const selectedTrace = openedExperiments[selectedExperimentIndex]; | ||
if (selectedTrace) { | ||
const outputDescriptors = availableOutputDescriptors.get(selectedTrace.UUID); | ||
if (outputDescriptors && outputDescriptors.length && props.index < outputDescriptors.length) { | ||
outputName = outputDescriptors[props.index].name; | ||
outputDescription = outputDescriptors[props.index].description; | ||
} | ||
} | ||
let traceContainerClassName = 'outputs-list-container'; | ||
if (props.index === lastSelectedOutputIndex) { | ||
traceContainerClassName = traceContainerClassName + ' theia-mod-selected'; | ||
} | ||
return <div className={traceContainerClassName} | ||
id={`${traceContainerClassName}-${props.index}`} | ||
key={props.key} | ||
style={props.style} | ||
onClick={this.handleOutputClicked} | ||
data-id={`${props.index}`} | ||
> | ||
<h4 className='outputs-element-name'> | ||
{outputName} | ||
</h4> | ||
<div className='outputs-element-description child-element'> | ||
{outputDescription} | ||
</div> | ||
</div>; | ||
} | ||
|
||
protected getTotalHeight(): number { | ||
let totalHeight = 0; | ||
const { openedExperiments, availableOutputDescriptors, selectedExperimentIndex } = this.openedTracesWidget; | ||
const selectedTrace = openedExperiments[selectedExperimentIndex]; | ||
if (selectedTrace) { | ||
const outputDescriptors = availableOutputDescriptors.get(selectedTrace.UUID); | ||
outputDescriptors?.forEach(() => totalHeight += TraceExplorerAnalysisWidget.ROW_HEIGHT); | ||
} | ||
return totalHeight; | ||
} | ||
|
||
protected handleOutputClicked = (e: React.MouseEvent<HTMLDivElement>): void => this.doHandleOutputClicked(e); | ||
|
||
private doHandleOutputClicked(e: React.MouseEvent<HTMLDivElement>) { | ||
const index = Number(e.currentTarget.getAttribute('data-id')); | ||
const { openedExperiments, selectedExperimentIndex, availableOutputDescriptors } = this.openedTracesWidget; | ||
this.openedTracesWidget.lastSelectedOutputIndex = index; | ||
const trace = openedExperiments[selectedExperimentIndex]; | ||
const outputs = availableOutputDescriptors.get(trace.UUID); | ||
if (outputs) { | ||
this.outputAddedEmitter.fire(new OutputAddedSignalPayload(outputs[index], trace)); | ||
} | ||
this.update(); | ||
} | ||
|
||
protected onResize(msg: Widget.ResizeMessage): void { | ||
super.onResize(msg); | ||
this.update(); | ||
} | ||
|
||
protected onAfterShow(msg: Message): void { | ||
super.onAfterShow(msg); | ||
this.update(); | ||
} | ||
} |
Oops, something went wrong.