diff --git a/src/controllers/analytic_controller.ts b/src/controllers/analytic_controller.ts index bdb0a3b..49c3df5 100644 --- a/src/controllers/analytic_controller.ts +++ b/src/controllers/analytic_controller.ts @@ -346,9 +346,9 @@ export class AnalyticController { this._emitter.emit('anomaly-type-alert-change', anomalyType); } - public getIdForNewLabelSegment() { + public getNewTempSegmentId(): SegmentId { this._tempIdCounted--; - return this._tempIdCounted; + return this._tempIdCounted.toString(); } public toggleVisibility(id: AnalyticUnitId, value?: boolean) { diff --git a/src/graph_renderer.ts b/src/graph_renderer.ts index 1722b97..231aa5a 100644 --- a/src/graph_renderer.ts +++ b/src/graph_renderer.ts @@ -111,7 +111,7 @@ export class GraphRenderer { if(this._isAnomalyEvent(selectionEvent)) { this.plot.clearSelection(); - var id = this._ananlyticController.getIdForNewLabelSegment() + var id = this._ananlyticController.getNewTempSegmentId(); var segment = new Segment( id, Math.round(selectionEvent.xaxis.from), diff --git a/src/models/segment.ts b/src/models/segment.ts index 332dac0..fa17750 100644 --- a/src/models/segment.ts +++ b/src/models/segment.ts @@ -1,9 +1,9 @@ -export type SegmentId = number; +export type SegmentId = string; export class Segment { constructor(private _id: SegmentId, public from: number, public to: number) { - if(isNaN(this._id)) { - throw new Error('Key can`t be NaN'); + if(this._id === undefined) { + throw new Error('id is undefined'); } if(isNaN(+from)) { throw new Error('from can`t be NaN'); diff --git a/src/services/analytic_service.ts b/src/services/analytic_service.ts index 02de195..af18275 100644 --- a/src/services/analytic_service.ts +++ b/src/services/analytic_service.ts @@ -18,11 +18,11 @@ export class AnalyticService { return this._backendSrv.post( this._backendURL + '/analyticUnits', { + panelUrl: window.location.origin + window.location.pathname + `?panelId=${panelId}&fullscreen`, + type: newItem.type, name: newItem.name, metric: metric.toJSON(), - panelUrl: window.location.origin + window.location.pathname + `?panelId=${panelId}&fullscreen`, - datasource: datasourceRequest, - type: newItem.type + datasource: datasourceRequest } ).then(res => res.id as AnalyticUnitId); }; @@ -75,7 +75,7 @@ export class AnalyticService { if(data.segments === undefined) { throw new Error('Server didn`t return segments array'); } - var segments = data.segments as { id: number, start: number, finish: number, labeled: boolean }[]; + var segments = data.segments as { id: SegmentId, start: number, finish: number, labeled: boolean }[]; return segments.map(s => new AnalyticSegment(s.labeled, s.id, s.start, s.finish)); }