From c34a2a2b59bcdfea6728c13ea09a77234fde2b09 Mon Sep 17 00:00:00 2001 From: Patrick Tasse Date: Fri, 20 Nov 2020 16:03:35 -0500 Subject: [PATCH] Add annotation model and tsp-client API for fetching annotations Signed-off-by: Patrick Tasse --- src/models/annotation.ts | 50 ++++++++++++++++++++++++++++++++++++++ src/protocol/tsp-client.ts | 24 ++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/models/annotation.ts diff --git a/src/models/annotation.ts b/src/models/annotation.ts new file mode 100644 index 0000000..f9a048c --- /dev/null +++ b/src/models/annotation.ts @@ -0,0 +1,50 @@ +import { OutputElementStyle } from './styles'; + +export enum Type { + TREE = 'TREE', + CHART = 'CHART' +} + +export interface AnnotationCategoriesModel { + annotationCategories: string[]; +} + +export interface AnnotationModel { + annotations: { [category: string]: Annotation[] }; +} + +/** + * Model for annotation + */ +export interface Annotation { + + /** + * Label of the annotation + */ + label: string; + + /** + * Time of the annotation + */ + time: number; + + /** + * Duration of the annotation + */ + duration: number; + + /** + * Entry Id of the annotation + */ + entryId: number; + + /** + * Type of the annotation + */ + type: string; + + /** + * Style of the annotation + */ + style?: OutputElementStyle; +} diff --git a/src/protocol/tsp-client.ts b/src/protocol/tsp-client.ts index a4f60a1..d2cb6ef 100644 --- a/src/protocol/tsp-client.ts +++ b/src/protocol/tsp-client.ts @@ -2,6 +2,7 @@ import { Query } from '../models/query/query'; import { GenericResponse } from '../models/response/responses'; import { XYModel } from '../models/xy'; import { TimeGraphEntry, TimeGraphArrow, TimeGraphModel } from '../models/timegraph'; +import { AnnotationCategoriesModel, AnnotationModel } from '../models/annotation'; import { TableModel, ColumnHeaderEntry } from '../models/table'; import { Trace } from '../models/trace'; import { RestClient } from './rest-client'; @@ -218,6 +219,29 @@ export class TspClient { return await RestClient.post>(url, parameters); } + /** + * Fetch annotations categories. + * @param expUUID Experiment UUID + * @param outputID Output ID + * @returns Generic response with the model + */ + public async fetchAnnotationsCategories(expUUID: string, outputID: string): Promise>> { + const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations'; + return await RestClient.get>(url); + } + + /** + * Fetch annotations. + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchAnnotations(expUUID: string, outputID: string, parameters: Query): Promise>> { + const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations'; + return await RestClient.post>(url, parameters); + } + /** * Fetch Time Graph tooltip for states and arrows * @param expUUID Experiment UUID