Skip to content

Commit 8b58e1b

Browse files
authored
Merge pull request #7 from PatrickTasse/master
Add annotation model and tsp-client API for fetching annotations
2 parents 339f1e7 + c34a2a2 commit 8b58e1b

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

src/models/annotation.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { OutputElementStyle } from './styles';
2+
3+
export enum Type {
4+
TREE = 'TREE',
5+
CHART = 'CHART'
6+
}
7+
8+
export interface AnnotationCategoriesModel {
9+
annotationCategories: string[];
10+
}
11+
12+
export interface AnnotationModel {
13+
annotations: { [category: string]: Annotation[] };
14+
}
15+
16+
/**
17+
* Model for annotation
18+
*/
19+
export interface Annotation {
20+
21+
/**
22+
* Label of the annotation
23+
*/
24+
label: string;
25+
26+
/**
27+
* Time of the annotation
28+
*/
29+
time: number;
30+
31+
/**
32+
* Duration of the annotation
33+
*/
34+
duration: number;
35+
36+
/**
37+
* Entry Id of the annotation
38+
*/
39+
entryId: number;
40+
41+
/**
42+
* Type of the annotation
43+
*/
44+
type: string;
45+
46+
/**
47+
* Style of the annotation
48+
*/
49+
style?: OutputElementStyle;
50+
}

src/protocol/tsp-client.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Query } from '../models/query/query';
22
import { GenericResponse } from '../models/response/responses';
33
import { XYModel } from '../models/xy';
44
import { TimeGraphEntry, TimeGraphArrow, TimeGraphModel } from '../models/timegraph';
5+
import { AnnotationCategoriesModel, AnnotationModel } from '../models/annotation';
56
import { TableModel, ColumnHeaderEntry } from '../models/table';
67
import { Trace } from '../models/trace';
78
import { RestClient } from './rest-client';
@@ -218,6 +219,29 @@ export class TspClient {
218219
return await RestClient.post<GenericResponse<TimeGraphArrow>>(url, parameters);
219220
}
220221

222+
/**
223+
* Fetch annotations categories.
224+
* @param expUUID Experiment UUID
225+
* @param outputID Output ID
226+
* @returns Generic response with the model
227+
*/
228+
public async fetchAnnotationsCategories(expUUID: string, outputID: string): Promise<TspClientResponse<GenericResponse<AnnotationCategoriesModel>>> {
229+
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations';
230+
return await RestClient.get<GenericResponse<AnnotationCategoriesModel>>(url);
231+
}
232+
233+
/**
234+
* Fetch annotations.
235+
* @param expUUID Experiment UUID
236+
* @param outputID Output ID
237+
* @param parameters Query object
238+
* @returns Generic response with the model
239+
*/
240+
public async fetchAnnotations(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<AnnotationModel>>> {
241+
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations';
242+
return await RestClient.post<GenericResponse<AnnotationModel>>(url, parameters);
243+
}
244+
221245
/**
222246
* Fetch Time Graph tooltip for states and arrows
223247
* @param expUUID Experiment UUID

0 commit comments

Comments
 (0)