diff --git a/libs/vre/shared/app-segment-support/src/lib/segment.component.ts b/libs/vre/shared/app-segment-support/src/lib/segment.component.ts index 9be04f379d..d0db808579 100644 --- a/libs/vre/shared/app-segment-support/src/lib/segment.component.ts +++ b/libs/vre/shared/app-segment-support/src/lib/segment.component.ts @@ -8,7 +8,7 @@ import { Segment } from './segment';
`, styleUrls: ['./segment.component.scss'], @@ -20,8 +20,6 @@ export class SegmentComponent implements OnInit { width!: number; start!: number; - readonly rowHeight = 8; - readonly segmentRightMargin = 0.2; play = false; diff --git a/libs/vre/shared/app-segment-support/src/lib/segments-display.component.ts b/libs/vre/shared/app-segment-support/src/lib/segments-display.component.ts index e6c2f822b8..d51ad992f1 100644 --- a/libs/vre/shared/app-segment-support/src/lib/segments-display.component.ts +++ b/libs/vre/shared/app-segment-support/src/lib/segments-display.component.ts @@ -5,7 +5,9 @@ import { Segment } from './segment'; selector: 'app-segments-display', template: `
- +
+ +
`, }) @@ -13,10 +15,21 @@ export class SegmentsDisplayComponent implements OnChanges { @Input({ required: true }) segments!: Segment[]; @Input({ required: true }) videoLengthSecs!: number; + segmentInRow!: Segment[][]; height!: number; readonly rowHeight = 8; ngOnChanges() { - this.height = (this.segments[this.segments.length - 1].row + 1) * this.rowHeight; + this.segmentInRow = this.segments.reduce( + (array, current) => { + if (current.row === array.length - 1) { + array[array.length - 1].push(current); + } else { + array.push([current]); + } + return array; + }, + [[]] as Segment[][] + ); } } diff --git a/libs/vre/shared/app-segment-support/src/lib/segments.service.ts b/libs/vre/shared/app-segment-support/src/lib/segments.service.ts index 925dcf8a4a..a308f086d7 100644 --- a/libs/vre/shared/app-segment-support/src/lib/segments.service.ts +++ b/libs/vre/shared/app-segment-support/src/lib/segments.service.ts @@ -1,4 +1,4 @@ -import { Injectable } from '@angular/core'; +import { ChangeDetectorRef, Injectable } from '@angular/core'; import { BehaviorSubject, EMPTY } from 'rxjs'; import { expand, reduce } from 'rxjs/operators'; import { Segment } from './segment'; @@ -11,7 +11,10 @@ export class SegmentsService { private _highlightSegment = new BehaviorSubject(null); highlightSegment$ = this._highlightSegment.asObservable(); - constructor(private _segmentApi: SegmentApiService) {} + constructor( + private _segmentApi: SegmentApiService, + private _cdr: ChangeDetectorRef + ) {} onInit(resourceIri: string, type: 'VideoSegment' | 'AudioSegment') { this.getSegment(resourceIri, type); @@ -34,6 +37,7 @@ export class SegmentsService { ) .subscribe(v => { this.segments = v; + this._cdr.detectChanges(); }); }