Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 4x 4x 4x 4x 3x 2x 2x 2x 4x 4x 80x 80x 2x | import { CommonModule } from '@angular/common'; import { Component, ElementRef, OnDestroy, OnInit, ViewChild } from '@angular/core'; import { InteractionHistory } from '@reflex/shared-types'; import { NEVER, Subscription } from 'rxjs'; import { startWith, switchMap } from 'rxjs/operators'; import { LogService } from 'src/app/log/log.service'; import { ProcessingService } from 'src/shared/services/processing.service'; @Component({ selector: 'app-history-visualization', templateUrl: './history-visualization.component.html', styleUrls: ['./history-visualization.component.scss'], imports: [CommonModule] }) export class HistoryVisualizationComponent implements OnInit, OnDestroy { @ViewChild('historyVis') public container?: ElementRef; public history: Array<InteractionHistory> = []; private historySubscription?: Subscription; public constructor(private readonly processingService: ProcessingService, private readonly logService: LogService) { } public ngOnInit(): void { const history$ = this.processingService.getHistory(); this.historySubscription = this.processingService.getStatus() .pipe( switchMap((processing) => processing ? history$ : NEVER.pipe<Array<InteractionHistory>>(startWith([]))) ) .subscribe( (result) => this.updateHistory(result), (error) => { console.error(error); this.logService.sendErrorLog(`${error}`); } ); } public ngOnDestroy(): void { this.historySubscription?.unsubscribe(); } private updateHistory(history: Array<InteractionHistory>): void { history.forEach((elem) => elem.items.forEach((frame) => { frame.interaction.position.x = frame.interaction.position.x * (this.container?.nativeElement.clientWidth ?? 0); frame.interaction.position.y = frame.interaction.position.y * (this.container?.nativeElement.clientHeight ?? 0); })); this.history = history; } } |