Skip to content

Commit

Permalink
Split viewer-prototype in packages
Browse files Browse the repository at this point in the history
In prevision of the development of a vscode extension, the code in the
viewer-prototype has been mostly moved to 2 new packages:

* @trace-viewer/base: Queries the trace server for traces, experiments
and possible outputs
* @trace-viewer/react-components: Contains the various types of
visualization for trace data, queries the trace server for output data
to display

Those 2 packages can eventually be published to npm.

In the viewer-prototype directory only remains the theia specific module
contributions. So the application still works as before using theia,
it's just that most of the classes used by the trace-viewer have been
moved to new npm packages.

Signed-off-by: Geneviève Bastien <gbastien@versatic.net>
  • Loading branch information
tahini committed Oct 27, 2020
1 parent 9d637dd commit 879b1a1
Show file tree
Hide file tree
Showing 62 changed files with 430 additions and 280 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,3 @@ Now, you will see 3 sections: **Opened experiments**, **Available analysis** and

### Navigation and zooming
There is only a limited number of such operations and they are only implemented in the Time Graph views (the ones looking like Gantt charts). For Zoom-in/out use CTRL+mouse wheel. Or use left mouse drag on time axis on top. Navigating the trace you can use the scrollbar at the bottom of the experiment container.

### Time Graph Tooltip
Currently, the **Time Graph Tooltip** is populated when selecting a state in a Time Graph view.

2 changes: 1 addition & 1 deletion browser-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@theia/vsx-registry": "latest",
"@theia/keymaps": "latest",
"@theia/getting-started": "latest",
"trace-viewer": "0.0.0"
"theia-trace-viewer": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest"
Expand Down
2 changes: 1 addition & 1 deletion electron-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@theia/keymaps": "latest",
"@theia/getting-started": "latest",
"@theia/electron": "latest",
"trace-viewer": "0.0.0"
"theia-trace-viewer": "0.0.0"
},
"devDependencies": {
"@theia/cli": "latest",
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"private": true,
"scripts": {
"reinstall": "rimraf ./**/node_modules && yarn install",
"prepare": "lerna run prepare",
"build": "lerna run build",
"rebuild:browser": "theia rebuild:browser",
"rebuild:electron": "theia rebuild:electron",
"start:browser": "yarn rebuild:browser ; yarn --cwd browser-app start",
Expand All @@ -11,13 +13,16 @@
"start:server": "./trace-compass-server/tracecompass-server",
"start-all:browser": "yarn start:server & yarn start:browser",
"start-all:electron": "yarn start:server & yarn start:electron",
"lint": "yarn workspace trace-viewer run lint",
"test": "echo test"
"lint": "lerna run lint",
"test": "lerna run test"
},
"devDependencies": {
"lerna": "2.4.0"
"lerna": "2.4.0",
"rimraf": "^3.0.2"
},
"workspaces": [
"packages/base",
"packages/react-components",
"viewer-prototype",
"browser-app",
"electron-app"
Expand Down
26 changes: 26 additions & 0 deletions packages/base/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
root: true,
parser: "@typescript-eslint/parser", // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 2020, // Allows for the parsing of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
tsconfigRootDir: __dirname,
project: 'tsconfig.json',
projectFolderIgnoreList: [
'/lib/'
]
},
extends: [
'plugin:@typescript-eslint/recommended',
'../../configs/base.eslintrc.json',
'../../configs/warnings.eslintrc.json',
'../../configs/errors.eslintrc.json'
],
ignorePatterns: [
'node_modules',
'lib',
'.eslintrc.js',
'plugins'
]
};
34 changes: 34 additions & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@trace-viewer/base",
"version": "0.0.0",
"description": "Trace Compass base package, contains trace management utilities",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/theia-ide/theia-trace-extension"
},
"files": [
"lib",
"src"
],
"dependencies": {
"tsp-typescript-client": "next"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^3.4.0",
"@typescript-eslint/parser": "^3.4.0",
"eslint": "^7.3.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-react": "^7.20.0",
"rimraf": "latest",
"typescript": "latest"
},
"scripts": {
"prepare": "yarn clean && yarn build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc -w",
"lint": "eslint ."
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import { Trace } from 'tsp-typescript-client/lib/models/trace';
import { Emitter } from '@theia/core';
import { TspClient } from 'tsp-typescript-client/lib/protocol/tsp-client';
import { Query } from 'tsp-typescript-client/lib/models/query/query';
import { injectable, inject } from 'inversify';
import { OutputDescriptor } from 'tsp-typescript-client/lib/models/output-descriptor';
import { Experiment } from 'tsp-typescript-client/lib/models/experiment';
import { TspClientResponse } from 'tsp-typescript-client/lib/protocol/tsp-client-response';
import { signalManager, Signals } from './signal-manager';

@injectable()
export class ExperimentManager {
// Open signal
private experimentOpenedEmitter = new Emitter<Experiment>();
public experimentOpenedSignal = this.experimentOpenedEmitter.event;

// Close signal
private experimentClosedEmitter = new Emitter<Experiment>();
public experimentClosedSignal = this.experimentClosedEmitter.event;

private fOpenExperiments: Map<string, Experiment> = new Map();
private fTspClient: TspClient;

private constructor(
@inject(TspClient) private tspClient: TspClient
) { }
constructor(
tspClient: TspClient
) {
this.fTspClient = tspClient;
}

/**
* Get an array of opened experiments
Expand All @@ -30,7 +24,7 @@ export class ExperimentManager {
async getOpenedExperiments(): Promise<Experiment[]> {
const openedExperiments: Array<Experiment> = [];
// Look on the server for opened experiments
const experimentResponse = await this.tspClient.fetchExperiments();
const experimentResponse = await this.fTspClient.fetchExperiments();
if (experimentResponse.isOk()) {
openedExperiments.push(...experimentResponse.getModel());
}
Expand All @@ -47,7 +41,7 @@ export class ExperimentManager {

// If the experiment is undefined, check on the server
if (!experiment) {
const experimentResponse = await this.tspClient.fetchExperiment(experimentUUID);
const experimentResponse = await this.fTspClient.fetchExperiment(experimentUUID);
if (experimentResponse.isOk()) {
experiment = experimentResponse.getModel();
}
Expand All @@ -63,7 +57,7 @@ export class ExperimentManager {
// Check if the experiment is opened
const experiment = this.fOpenExperiments.get(experimentUUID);
if (experiment) {
const outputsResponse = await this.tspClient.experimentOutputs(experiment.UUID);
const outputsResponse = await this.fTspClient.experimentOutputs(experiment.UUID);
return outputsResponse.getModel();
}
return undefined;
Expand All @@ -83,14 +77,14 @@ export class ExperimentManager {
traceURIs.push(traces[i].UUID);
}

const experimentResponse = await this.tspClient.createExperiment(new Query({
const experimentResponse = await this.fTspClient.createExperiment(new Query({
'name': name,
'traces': traceURIs
}));
const opendExperiment = experimentResponse.getModel();
if (opendExperiment && experimentResponse.isOk()) {
this.addExperiment(opendExperiment);
this.experimentOpenedEmitter.fire(opendExperiment);
signalManager().emit(Signals.EXPERIMENT_OPENED, {experiment: opendExperiment});
return opendExperiment;
} else if (opendExperiment && experimentResponse.getStatusCode() === 409) {
// Repost with a suffix as long as there are conflicts
Expand All @@ -104,13 +98,13 @@ export class ExperimentManager {
let conflictResolutionResponse = experimentResponse;
let i = 1;
while (conflictResolutionResponse.getStatusCode() === 409) {
conflictResolutionResponse = await handleConflict(this.tspClient, i);
conflictResolutionResponse = await handleConflict(this.fTspClient, i);
i++;
}
const experiment = conflictResolutionResponse.getModel();
if (experiment && conflictResolutionResponse.isOk()) {
this.addExperiment(experiment);
this.experimentOpenedEmitter.fire(experiment);
signalManager().emit(Signals.EXPERIMENT_OPENED, {experiment: experiment});
return experiment;
}
}
Expand All @@ -126,7 +120,7 @@ export class ExperimentManager {
async updateExperiment(experimentUUID: string): Promise<Experiment | undefined> {
const currentExperiment = this.fOpenExperiments.get(experimentUUID);
if (currentExperiment) {
const experimentResponse = await this.tspClient.fetchExperiment(currentExperiment.UUID);
const experimentResponse = await this.fTspClient.fetchExperiment(currentExperiment.UUID);
const experiment = experimentResponse.getModel();
if (experiment && experimentResponse.isOk) {
this.fOpenExperiments.set(experimentUUID, experiment);
Expand All @@ -144,10 +138,10 @@ export class ExperimentManager {
async closeExperiment(experimentUUID: string): Promise<void> {
const experimentToClose = this.fOpenExperiments.get(experimentUUID);
if (experimentToClose) {
await this.tspClient.deleteExperiment(experimentUUID);
await this.fTspClient.deleteExperiment(experimentUUID);
const deletedExperiment = this.removeExperiment(experimentUUID);
if (deletedExperiment) {
this.experimentClosedEmitter.fire(deletedExperiment);
signalManager().emit(Signals.EXPERIMENT_CLOSED, {experiment: deletedExperiment});
}
}
}
Expand Down
39 changes: 39 additions & 0 deletions packages/base/src/message-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
export enum MessageCategory {
TRACE_CONTEXT,
SERVER_MESSAGE,
SERVER_STATUS,
}

export enum MessageSeverity {
ERROR,
WARNING,
INFO,
DEBUG
}

export interface StatusMessage {
text: string;
category?: MessageCategory;
severity?: MessageSeverity;
}

export declare interface MessageManager {

addStatusMessage(messageKey: string, message: StatusMessage): void;
removeStatusMessage(messageKey: string): void;

}

export class MessageManager implements MessageManager {

addStatusMessage(messageKey: string, {text,
category = MessageCategory.SERVER_MESSAGE,
severity = MessageSeverity.INFO }: StatusMessage): void {
console.log('New status message', messageKey, text, category, severity);
}

removeStatusMessage(messageKey: string): void {
console.log('Removing status message status message', messageKey);
}

}
30 changes: 30 additions & 0 deletions packages/base/src/signal-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { EventEmitter } from 'events';

export declare interface SignalManager {

fireTooltipSignal(payload: { [key: string]: string }): void;

}

export const Signals = {
TRACE_OPENED : 'trace opened',
TRACE_CLOSED : 'trace closed',
EXPERIMENT_OPENED: 'experiment opened',
EXPERIMENT_CLOSED: 'experiment closed'
};

export class SignalManager extends EventEmitter implements SignalManager {

fireTooltipSignal(payload: { [key: string]: string; }): void {
/* To be implemented by extending clases */
}

}

let instance: SignalManager = new SignalManager();

export const setSignalManagerInstance = (sm: SignalManager) => {
instance = sm;
};

export const signalManager = (): SignalManager => instance;
Loading

0 comments on commit 879b1a1

Please sign in to comment.