Browse Source

segmentId to string

master
Alexey Velikiy 6 years ago
parent
commit
eb56100133
  1. 4
      src/controllers/analytic_controller.ts
  2. 2
      src/graph_renderer.ts
  3. 6
      src/models/segment.ts
  4. 8
      src/services/analytic_service.ts

4
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) {

2
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),

6
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');

8
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));
}

Loading…
Cancel
Save