Skip to content

Commit

Permalink
Auto-fix linter errors
Browse files Browse the repository at this point in the history
Signed-off-by: Geneviève Bastien <gbastien+lttng@versatic.net>
  • Loading branch information
tahini committed Jul 7, 2020
1 parent 73604f0 commit 870a21d
Show file tree
Hide file tree
Showing 27 changed files with 244 additions and 294 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbstractViewContribution } from "@theia/core/lib/browser/shell/view-contribution";
import { TraceExplorerWidget, TRACE_EXPLORER_ID, TRACE_EXPLORER_LABEL } from "./trace-explorer-widget";
import { FrontendApplicationContribution, FrontendApplication } from "@theia/core/lib/browser";
import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution';
import { TraceExplorerWidget, TRACE_EXPLORER_ID, TRACE_EXPLORER_LABEL } from './trace-explorer-widget';
import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser';

export class TraceExplorerContribution extends AbstractViewContribution<TraceExplorerWidget> implements FrontendApplicationContribution {

Expand All @@ -19,4 +19,4 @@ export class TraceExplorerContribution extends AbstractViewContribution<TraceExp
await this.openView({ activate: false });
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from 'react';
import { List, ListRowProps } from 'react-virtualized';
import { OutputDescriptor } from 'tsp-typescript-client/lib/models/output-descriptor';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faShareSquare, faCopy } from '@fortawesome/free-solid-svg-icons'
import { faShareSquare, faCopy } from '@fortawesome/free-solid-svg-icons';
import * as ReactModal from 'react-modal';
import { Emitter } from '@theia/core';
import { SignalManager } from '../../common/signal-manager';
Expand Down Expand Up @@ -36,17 +36,17 @@ export class OutputAddedSignalPayload {

@injectable()
export class TraceExplorerWidget extends ReactWidget {
private OPENED_TRACE_TITLE: string = 'Opened experiments';
private OPENED_TRACE_TITLE = 'Opened experiments';
// private FILE_NAVIGATOR_TITLE: string = 'File navigator';
private ANALYSIS_TITLE: string = 'Available analysis';
private ANALYSIS_TITLE = 'Available analysis';

private openedExperiments: Array<Experiment> = new Array();
private selectedExperimentIndex: number = 0;
private lastSelectedOutputIndex: number = -1;
private openedExperiments: Array<Experiment> = [];
private selectedExperimentIndex = 0;
private lastSelectedOutputIndex = -1;
private availableOutputDescriptors: Map<string, OutputDescriptor[]> = new Map();

private showShareDialog: boolean = false;
private sharingLink: string = '';
private showShareDialog = false;
private sharingLink = '';

private tooltip: { [key: string]: string } = {};

Expand Down Expand Up @@ -162,13 +162,13 @@ export class TraceExplorerWidget extends ReactWidget {
keys.forEach(key => {
if (key === 'Source') {
const sourceCodeInfo = this.tooltip[key];
const matches = sourceCodeInfo.match('(.*):(\\d+)')
const matches = sourceCodeInfo.match('(.*):(\\d+)');
let fileLocation;
let line;
if(matches && matches.length === 3) {
fileLocation = matches[1];
line = matches[2];
}
}
tooltipArray.push(<p className='source-code-tooltip' key={key} onClick={this.handleSourcecodeLockup.bind(this, fileLocation, line)}>{key + ': ' + sourceCodeInfo}</p>);
} else {
tooltipArray.push(<p key={key}>{key + ': ' + this.tooltip[key]}</p>);
Expand All @@ -177,9 +177,7 @@ export class TraceExplorerWidget extends ReactWidget {
}

return <React.Fragment>
{tooltipArray.map(element => {
return element;
})}
{tooltipArray.map(element => element)}
</React.Fragment>;
}

Expand Down Expand Up @@ -218,7 +216,7 @@ export class TraceExplorerWidget extends ReactWidget {
const opts = {
...modeOpt,
...slectionOpt
}
};
this.editorManager.open(new URI(fileLocation), opts);
}
}
Expand All @@ -239,11 +237,11 @@ export class TraceExplorerWidget extends ReactWidget {
</button>
</div>
</div>
</div>
</div>;
}
return <div style={{ color: 'white' }}>
{'Cannot share this trace'}
</div>
</div>;
}

private experimentRowRenderer(props: ListRowProps): React.ReactNode {
Expand All @@ -253,7 +251,7 @@ export class TraceExplorerWidget extends ReactWidget {
traceName = this.openedExperiments[props.index].name;
// tracePath = this.openedTraces[props.index].path;
/*
TODO: Implement better visualization of experiment, e.g. a tree
TODO: Implement better visualization of experiment, e.g. a tree
with experiment name as root and traces (name and path) as children
*/
let prefix = '> ';
Expand Down Expand Up @@ -333,7 +331,7 @@ export class TraceExplorerWidget extends ReactWidget {

private outputClicked(index: number) {
this.lastSelectedOutputIndex = index;
const trace = this.openedExperiments[this.selectedExperimentIndex]
const trace = this.openedExperiments[this.selectedExperimentIndex];
const outputs = this.availableOutputDescriptors.get(trace.UUID);
if (outputs) {
TraceExplorerWidget.outputAddedEmitter.fire(new OutputAddedSignalPayload(outputs[index], trace));
Expand All @@ -353,7 +351,7 @@ export class TraceExplorerWidget extends ReactWidget {
this.availableOutputDescriptors.set(experiment.UUID, outputs);
} else {
if (this.openedExperiments.length) {
const outputs = await this.getOutputDescriptors(this.openedExperiments[0])
const outputs = await this.getOutputDescriptors(this.openedExperiments[0]);
this.availableOutputDescriptors.set(this.openedExperiments[0].UUID, outputs);
}
}
Expand All @@ -362,11 +360,11 @@ export class TraceExplorerWidget extends ReactWidget {
}

private async getOutputDescriptors(experiment: Experiment): Promise<OutputDescriptor[]> {
const outputDescriptors: OutputDescriptor[] = new Array();
const outputDescriptors: OutputDescriptor[] = [];
const descriptors = await this.experimentManager.getAvailableOutputs(experiment.UUID);
if (descriptors && descriptors.length) {
outputDescriptors.push(...descriptors);
}
return outputDescriptors;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TimeRange } from '../../../common/utils/time-range';
import { OutputComponentStyle } from './utils/output-component-style';
import { OutputStyleModel } from 'tsp-typescript-client/lib/models/styles';

export type AbstractOutputProps = {
export interface AbstractOutputProps {
tspClient: TspClient;
traceId: string;
range: TimeRange;
Expand All @@ -24,15 +24,15 @@ export type AbstractOutputProps = {
onViewRangeChange?: () => void;
}

export type AbstractOutputState = {
export interface AbstractOutputState {
outputStatus: string;
styleModel?: OutputStyleModel
}

export abstract class AbstractOutputComponent<P extends AbstractOutputProps, S extends AbstractOutputState> extends React.Component<P, S> {

private mainAreaContainer: React.RefObject<HTMLDivElement>;
private handleWidth: number = 30;
private handleWidth = 30;

constructor(props: P) {
super(props);
Expand All @@ -52,7 +52,7 @@ export abstract class AbstractOutputComponent<P extends AbstractOutputProps, S e
}

renderTitleBar(): React.ReactNode {
let outputName = this.props.outputDescriptor.name;
const outputName = this.props.outputDescriptor.name;
return <React.Fragment>
<button className='remove-component-button' onClick={this.closeComponent}>
<FontAwesomeIcon icon={faTimes} />
Expand All @@ -79,4 +79,4 @@ export abstract class AbstractOutputComponent<P extends AbstractOutputProps, S e
}

abstract renderMainArea(): React.ReactNode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper
import { ResponseStatus } from 'tsp-typescript-client/lib/models/response/responses';
import { Entry, EntryHeader } from 'tsp-typescript-client/lib/models/entry';


export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps, S extends AbstractOutputState> extends AbstractOutputComponent<P, S> {
renderMainArea(): React.ReactNode {
const treeWidth = this.props.style.width - this.props.style.chartWidth - this.getHandleWidth();
return <React.Fragment>
<div ref={this.treeRef} className='output-component-tree' onScroll={ev => { this.synchronizeTreeScroll() }} style={{ width: treeWidth, height: this.props.style.height }}>
<div ref={this.treeRef} className='output-component-tree' onScroll={ev => { this.synchronizeTreeScroll(); }} style={{ width: treeWidth, height: this.props.style.height }}>
{this.renderTree()}
</div>
<div className='output-component-chart' style={{ width: this.props.style.chartWidth, backgroundColor: '#3f3f3f' }}>
Expand All @@ -20,7 +19,7 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,

treeRef = React.createRef<any>();
chartRef = React.createRef<any>();

abstract renderTree(): React.ReactNode;

abstract renderChart(): React.ReactNode;
Expand Down Expand Up @@ -50,4 +49,4 @@ export abstract class AbstractTreeOutputComponent<P extends AbstractOutputProps,
return;
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ export class StyleProvider {
const styles = this.tmpStyleObject[this.outputId];
return styles ? styles : {};
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TspClient } from "tsp-typescript-client/lib/protocol/tsp-client";
import { TimeGraphEntry, TimeGraphRow, TimeGraphModel, TimeGraphState } from "tsp-typescript-client/lib/models/timegraph";
import { TimelineChart } from "timeline-chart/lib/time-graph-model";
import { QueryHelper } from "tsp-typescript-client/lib/models/query/query-helper";
import { EntryHeader } from "tsp-typescript-client/lib/models/entry";
import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client';
import { TimeGraphEntry, TimeGraphRow, TimeGraphModel, TimeGraphState } from 'tsp-typescript-client/lib/models/timegraph';
import { TimelineChart } from 'timeline-chart/lib/time-graph-model';
import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper';
import { EntryHeader } from 'tsp-typescript-client/lib/models/entry';

export class TspDataProvider {

Expand All @@ -17,8 +17,8 @@ export class TspDataProvider {
public totalRange: number;

constructor(client: TspClient, traceUUID: string, outputId: string, canvasDisplayWidth?: number) {
this.timeGraphEntries = new Array();
this.timeGraphRows = new Array();
this.timeGraphEntries = [];
this.timeGraphRows = [];
this.canvasDisplayWidth = canvasDisplayWidth;
this.client = client;
this.outputId = outputId;
Expand Down Expand Up @@ -51,7 +51,6 @@ export class TspDataProvider {
this.timeGraphRows = stateResponse.model.rows;
this.timeGraphRowsOrdering();


// the start time which is normalized to logical 0 in timeline chart.
const chartStart = this.timeGraphEntries[0].startTime;

Expand All @@ -71,7 +70,7 @@ export class TspDataProvider {
states
});
}
})
});

return {
id: 'model',
Expand All @@ -81,11 +80,11 @@ export class TspDataProvider {
data: {
originalStart: chartStart
}
}
};
}

private timeGraphRowsOrdering() {
const newTimeGraphRows: TimeGraphRow[] = new Array();
const newTimeGraphRows: TimeGraphRow[] = [];
this.timeGraphEntries.forEach(entry => {
const timeGraphRow = this.timeGraphRows.find(row => (row as any).entryID === entry.id);
if (timeGraphRow) {
Expand All @@ -99,10 +98,10 @@ export class TspDataProvider {
protected getStateModelByRow(row: TimeGraphRow, chartStart: number) {
const states: TimelineChart.TimeGraphRowElementModel[] = [];
row.states.forEach((state: TimeGraphState, idx: number) => {
const end = state.startTime + state.duration - chartStart
const end = state.startTime + state.duration - chartStart;
if (state.style || state.value >= 0) {
states.push({
id: (row as any).entryID + "-" + idx,
id: (row as any).entryID + '-' + idx,
label: state.label,
range: {
start: state.startTime - chartStart,
Expand All @@ -112,15 +111,15 @@ export class TspDataProvider {
stateValue: state.value,
style: state.style
}
})
});
this.totalRange = this.totalRange < end ? end : this.totalRange;
} else {
const nextIndex = idx + 1;
const nextState = row.states[nextIndex]
const nextState = row.states[nextIndex];
if (nextState && nextState.value < 0) {
// Add gap state
states.push({
id: (row as any).entryID + "-" + idx,
id: (row as any).entryID + '-' + idx,
label: 'GAP',
range: {
start: end,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { AbstractOutputComponent, AbstractOutputProps, AbstractOutputState } from "./abstract-output-component";
import { AbstractOutputComponent, AbstractOutputProps, AbstractOutputState } from './abstract-output-component';
import * as React from 'react';
import { AgGridReact } from 'ag-grid-react';
import { ColDef } from "ag-grid-community";
import { Entry, EntryHeader } from "tsp-typescript-client/lib/models/entry";
import { ColDef } from 'ag-grid-community';
import { Entry, EntryHeader } from 'tsp-typescript-client/lib/models/entry';
import { QueryHelper } from 'tsp-typescript-client/lib/models/query/query-helper';

type TableOuputState = AbstractOutputState & {
tableColumns: ColDef[];
tableLines: any[];
}
};

export class TableOutputComponent extends AbstractOutputComponent<AbstractOutputProps, TableOuputState> {

Expand Down Expand Up @@ -39,7 +39,7 @@ export class TableOutputComponent extends AbstractOutputComponent<AbstractOutput
// Fetch columns
const columnsResponse = (await tspClient.fetchTableColumns<Entry, EntryHeader>(traceUUID, outPutId, QueryHelper.timeQuery([0, 1]))).getModel();
const columnEntries = columnsResponse.model.entries;
const columnIds: Array<number> = new Array;
const columnIds: Array<number> = [];
const columnsArray = new Array<any>();
columnEntries.forEach(entry => {
columnIds.push(entry.id);
Expand Down Expand Up @@ -73,6 +73,6 @@ export class TableOutputComponent extends AbstractOutputComponent<AbstractOutput
outputStatus: lineResponse.status,
tableColumns: columnsArray,
tableLines: linesArray
})
});
}
}
}
Loading

0 comments on commit 870a21d

Please sign in to comment.