|
|
@ -45,12 +45,12 @@ export class AnalyticController { |
|
|
|
private _serverInfo: ServerInfo; |
|
|
|
private _serverInfo: ServerInfo; |
|
|
|
|
|
|
|
|
|
|
|
constructor(private _panelObject: any, private _analyticService: AnalyticService, private _emitter: Emitter) { |
|
|
|
constructor(private _panelObject: any, private _analyticService: AnalyticService, private _emitter: Emitter) { |
|
|
|
if(_panelObject.anomalyTypes === undefined) { |
|
|
|
if(_panelObject.analyticUnits === undefined) { |
|
|
|
_panelObject.anomalyTypes = []; |
|
|
|
_panelObject.analyticUnits = _panelObject.anomalyTypes || []; |
|
|
|
} |
|
|
|
} |
|
|
|
this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>(); |
|
|
|
this._labelingDataAddedSegments = new SegmentArray<AnalyticSegment>(); |
|
|
|
this._labelingDataDeletedSegments = new SegmentArray<AnalyticSegment>(); |
|
|
|
this._labelingDataDeletedSegments = new SegmentArray<AnalyticSegment>(); |
|
|
|
this._analyticUnitsSet = new AnalyticUnitsSet(this._panelObject.anomalyTypes); |
|
|
|
this._analyticUnitsSet = new AnalyticUnitsSet(this._panelObject.analyticUnits); |
|
|
|
// this.analyticUnits.forEach(a => this.runEnabledWaiter(a));
|
|
|
|
// this.analyticUnits.forEach(a => this.runEnabledWaiter(a));
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -101,15 +101,15 @@ export class AnalyticController { |
|
|
|
get graphLocked() { return this._graphLocked; } |
|
|
|
get graphLocked() { return this._graphLocked; } |
|
|
|
set graphLocked(value) { this._graphLocked = value; } |
|
|
|
set graphLocked(value) { this._graphLocked = value; } |
|
|
|
|
|
|
|
|
|
|
|
get labelingAnomaly(): AnalyticUnit { |
|
|
|
get labelingUnit(): AnalyticUnit { |
|
|
|
if(this._selectedAnalyticUnitId === null) { |
|
|
|
if(this._selectedAnalyticUnitId === null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return this._analyticUnitsSet.byId(this._selectedAnalyticUnitId); |
|
|
|
return this._analyticUnitsSet.byId(this._selectedAnalyticUnitId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async toggleAnomalyTypeLabelingMode(id: AnalyticUnitId) { |
|
|
|
async toggleUnitTypeLabelingMode(id: AnalyticUnitId) { |
|
|
|
if(this.labelingAnomaly && this.labelingAnomaly.saving) { |
|
|
|
if(this.labelingUnit && this.labelingUnit.saving) { |
|
|
|
throw new Error('Can`t toggle during saving'); |
|
|
|
throw new Error('Can`t toggle during saving'); |
|
|
|
} |
|
|
|
} |
|
|
|
if(this._selectedAnalyticUnitId === id) { |
|
|
|
if(this._selectedAnalyticUnitId === id) { |
|
|
@ -117,7 +117,7 @@ export class AnalyticController { |
|
|
|
} |
|
|
|
} |
|
|
|
await this.disableLabeling(); |
|
|
|
await this.disableLabeling(); |
|
|
|
this._selectedAnalyticUnitId = id; |
|
|
|
this._selectedAnalyticUnitId = id; |
|
|
|
this.labelingAnomaly.selected = true; |
|
|
|
this.labelingUnit.selected = true; |
|
|
|
this.toggleVisibility(id, true); |
|
|
|
this.toggleVisibility(id, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -125,22 +125,22 @@ export class AnalyticController { |
|
|
|
if(this._selectedAnalyticUnitId === null) { |
|
|
|
if(this._selectedAnalyticUnitId === null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
this.labelingAnomaly.saving = true; |
|
|
|
this.labelingUnit.saving = true; |
|
|
|
var newIds = await this._saveLabelingData(); |
|
|
|
var newIds = await this._saveLabelingData(); |
|
|
|
this._labelingDataAddedSegments.getSegments().forEach((s, i) => { |
|
|
|
this._labelingDataAddedSegments.getSegments().forEach((s, i) => { |
|
|
|
this.labelingAnomaly.segments.updateId(s.id, newIds[i]); |
|
|
|
this.labelingUnit.segments.updateId(s.id, newIds[i]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
this.labelingAnomaly.saving = false; |
|
|
|
this.labelingUnit.saving = false; |
|
|
|
|
|
|
|
|
|
|
|
var anomaly = this.labelingAnomaly; |
|
|
|
var anomaly = this.labelingUnit; |
|
|
|
this.dropLabeling(); |
|
|
|
this.dropLabeling(); |
|
|
|
this._runStatusWaiter(anomaly); |
|
|
|
this._runStatusWaiter(anomaly); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
undoLabeling() { |
|
|
|
undoLabeling() { |
|
|
|
this._labelingDataAddedSegments.getSegments().forEach(s => { |
|
|
|
this._labelingDataAddedSegments.getSegments().forEach(s => { |
|
|
|
this.labelingAnomaly.segments.remove(s.id); |
|
|
|
this.labelingUnit.segments.remove(s.id); |
|
|
|
}); |
|
|
|
}); |
|
|
|
this._labelingDataDeletedSegments.getSegments().forEach(s => { |
|
|
|
this._labelingDataDeletedSegments.getSegments().forEach(s => { |
|
|
|
s.deleted = false; |
|
|
|
s.deleted = false; |
|
|
@ -151,7 +151,7 @@ export class AnalyticController { |
|
|
|
dropLabeling() { |
|
|
|
dropLabeling() { |
|
|
|
this._labelingDataAddedSegments.clear(); |
|
|
|
this._labelingDataAddedSegments.clear(); |
|
|
|
this._labelingDataDeletedSegments.clear(); |
|
|
|
this._labelingDataDeletedSegments.clear(); |
|
|
|
this.labelingAnomaly.selected = false; |
|
|
|
this.labelingUnit.selected = false; |
|
|
|
this._selectedAnalyticUnitId = null; |
|
|
|
this._selectedAnalyticUnitId = null; |
|
|
|
this._tempIdCounted = -1; |
|
|
|
this._tempIdCounted = -1; |
|
|
|
} |
|
|
|
} |
|
|
@ -164,11 +164,11 @@ export class AnalyticController { |
|
|
|
if(!this.labelingMode) { |
|
|
|
if(!this.labelingMode) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
return this.labelingAnomaly.deleteMode; |
|
|
|
return this.labelingUnit.deleteMode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
addLabelSegment(segment: Segment) { |
|
|
|
addLabelSegment(segment: Segment) { |
|
|
|
var asegment = this.labelingAnomaly.addLabeledSegment(segment); |
|
|
|
var asegment = this.labelingUnit.addLabeledSegment(segment); |
|
|
|
this._labelingDataAddedSegments.addSegment(asegment); |
|
|
|
this._labelingDataAddedSegments.addSegment(asegment); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,11 +183,11 @@ export class AnalyticController { |
|
|
|
this._analyticUnitsSet.byId(id).color = value; |
|
|
|
this._analyticUnitsSet.byId(id).color = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fetchAnomalyTypesStatuses() { |
|
|
|
fetchAnalyticUnitsStatuses() { |
|
|
|
this.analyticUnits.forEach(a => this._runStatusWaiter(a)); |
|
|
|
this.analyticUnits.forEach(a => this._runStatusWaiter(a)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async fetchAnomalyTypesSegments(from: number, to: number) { |
|
|
|
async fetchAnalyticUnitsSegments(from: number, to: number) { |
|
|
|
if(!_.isNumber(+from)) { |
|
|
|
if(!_.isNumber(+from)) { |
|
|
|
throw new Error('from isn`t number'); |
|
|
|
throw new Error('from isn`t number'); |
|
|
|
} |
|
|
|
} |
|
|
@ -215,9 +215,9 @@ export class AnalyticController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async _saveLabelingData(): Promise<SegmentId[]> { |
|
|
|
private async _saveLabelingData(): Promise<SegmentId[]> { |
|
|
|
var anomaly = this.labelingAnomaly; |
|
|
|
var unit = this.labelingUnit; |
|
|
|
if(anomaly === null) { |
|
|
|
if(unit === null) { |
|
|
|
throw new Error('anomaly is not selected'); |
|
|
|
throw new Error('analytic unit is not selected'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( |
|
|
|
if( |
|
|
@ -228,7 +228,7 @@ export class AnalyticController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this._analyticService.updateSegments( |
|
|
|
return this._analyticService.updateSegments( |
|
|
|
anomaly.id, this._labelingDataAddedSegments, this._labelingDataDeletedSegments |
|
|
|
unit.id, this._labelingDataAddedSegments, this._labelingDataDeletedSegments |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -304,7 +304,7 @@ export class AnalyticController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deleteLabelingAnomalySegmentsInRange(from: number, to: number) { |
|
|
|
deleteLabelingAnomalySegmentsInRange(from: number, to: number) { |
|
|
|
var allRemovedSegs = this.labelingAnomaly.removeSegmentsInRange(from, to); |
|
|
|
var allRemovedSegs = this.labelingUnit.removeSegmentsInRange(from, to); |
|
|
|
allRemovedSegs.forEach(s => { |
|
|
|
allRemovedSegs.forEach(s => { |
|
|
|
if(!this._labelingDataAddedSegments.has(s.id)) { |
|
|
|
if(!this._labelingDataAddedSegments.has(s.id)) { |
|
|
|
this._labelingDataDeletedSegments.addSegment(s); |
|
|
|
this._labelingDataDeletedSegments.addSegment(s); |
|
|
@ -317,14 +317,17 @@ export class AnalyticController { |
|
|
|
if(!this.labelingMode) { |
|
|
|
if(!this.labelingMode) { |
|
|
|
throw new Error('Cant enter delete mode is labeling mode disabled'); |
|
|
|
throw new Error('Cant enter delete mode is labeling mode disabled'); |
|
|
|
} |
|
|
|
} |
|
|
|
this.labelingAnomaly.deleteMode = !this.labelingAnomaly.deleteMode; |
|
|
|
this.labelingUnit.deleteMode = !this.labelingUnit.deleteMode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
removeAnalyticUnit(id: AnalyticUnitId) { |
|
|
|
async removeAnalyticUnit(id: AnalyticUnitId, silent: boolean = false) { |
|
|
|
if(id === this._selectedAnalyticUnitId) { |
|
|
|
if(id === this._selectedAnalyticUnitId) { |
|
|
|
this.dropLabeling(); |
|
|
|
this.dropLabeling(); |
|
|
|
} |
|
|
|
} |
|
|
|
this._analyticUnitsSet.removeItem(id); |
|
|
|
this._analyticUnitsSet.removeItem(id); |
|
|
|
|
|
|
|
if(!silent) { |
|
|
|
|
|
|
|
await this._analyticService.removeAnalyticUnit(id); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async _runStatusWaiter(analyticUnit: AnalyticUnit) { |
|
|
|
private async _runStatusWaiter(analyticUnit: AnalyticUnit) { |
|
|
@ -354,7 +357,7 @@ export class AnalyticController { |
|
|
|
if(error !== undefined) { |
|
|
|
if(error !== undefined) { |
|
|
|
analyticUnit.error = error; |
|
|
|
analyticUnit.error = error; |
|
|
|
} |
|
|
|
} |
|
|
|
this._emitter.emit('anomaly-type-status-change', analyticUnit); |
|
|
|
this._emitter.emit('analytic-unit-status-change', analyticUnit); |
|
|
|
} |
|
|
|
} |
|
|
|
if(!analyticUnit.isActiveStatus) { |
|
|
|
if(!analyticUnit.isActiveStatus) { |
|
|
|
break; |
|
|
|
break; |
|
|
|