Browse Source

Deleted segments

master
rozetko 6 years ago
parent
commit
483039aef0
  1. 7
      src/panel/graph_panel/controllers/analytic_controller.ts
  2. 3
      src/panel/graph_panel/models/analytic_unit.ts
  3. 12
      src/panel/graph_panel/services/analytic_service.ts

7
src/panel/graph_panel/controllers/analytic_controller.ts

@ -162,7 +162,7 @@ export class AnalyticController {
this.labelingUnit.segments.remove(s.id);
});
this._labelingDataDeletedSegments.getSegments().forEach(s => {
s.deleted = false;
this.labelingUnit.segments.addSegment(s);
});
this.dropLabeling();
}
@ -298,7 +298,7 @@ export class AnalyticController {
}
}
var expanded = s.expandDist(rangeDist, 0.01);
const expanded = s.expandDist(rangeDist, 0.01);
options.grid.markings.push({
xaxis: { from: expanded.from, to: expanded.to },
color: segmentFillColor
@ -317,11 +317,10 @@ export class AnalyticController {
}
deleteLabelingAnalyticUnitSegmentsInRange(from: number, to: number) {
let allRemovedSegs = this.labelingUnit.removeSegmentsInRange(from, to);
const allRemovedSegs = this.labelingUnit.removeSegmentsInRange(from, to);
allRemovedSegs.forEach(s => {
if(!this._labelingDataAddedSegments.has(s.id)) {
this._labelingDataDeletedSegments.addSegment(s);
this.labelingUnit.addLabeledSegment(s, true);
}
});
this._labelingDataAddedSegments.removeInRange(from, to);

3
src/panel/graph_panel/models/analytic_unit.ts

@ -88,9 +88,6 @@ export class AnalyticUnit {
removeSegmentsInRange(from: number, to: number): AnalyticSegment[] {
let deletedSegments = this._segmentSet.removeInRange(from, to);
deletedSegments.forEach(s => {
s.deleted = true;
});
return deletedSegments;
}

12
src/panel/graph_panel/services/analytic_service.ts

@ -66,20 +66,22 @@ export class AnalyticService {
}
async updateSegments(
id: AnalyticUnitId, addedSegments: SegmentsSet<Segment>, removedSegments: SegmentsSet<Segment>
id: AnalyticUnitId, addedSegments: SegmentsSet<AnalyticSegment>, removedSegments: SegmentsSet<AnalyticSegment>
): Promise<SegmentId[]> {
const getJSONs = (segs: SegmentsSet<Segment>) => segs.getSegments().map(segment => ({
const getJSONs = (segs: SegmentsSet<AnalyticSegment>) => segs.getSegments().map(segment => ({
from: segment.from,
to: segment.to
to: segment.to,
labeled: segment.labeled,
deleted: segment.deleted
}));
var payload = {
const payload = {
id,
addedSegments: getJSONs(addedSegments),
removedSegments: removedSegments.getSegments().map(s => s.id)
};
var data = await this.patch('/segments', payload);
const data = await this.patch('/segments', payload);
if(data.addedIds === undefined) {
throw new Error('Server didn`t send addedIds');
}

Loading…
Cancel
Save