Skip to content

Commit

Permalink
Re-added target display after running task
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterl committed Aug 24, 2023
1 parent e670946 commit e55e1b7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions frontend/src/app/viewer/run-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
map,
pairwise,
shareReplay,
switchMap,
} from 'rxjs/operators';
switchMap, tap
} from "rxjs/operators";
import { AppConfig } from '../app.config';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Position } from './model/run-viewer-position';
Expand Down Expand Up @@ -147,7 +147,7 @@ export class RunViewerComponent implements OnInit, AfterViewInit, OnDestroy {
);

/* Basic observable that fires when a task starts. */
this.taskStarted = this.state.pipe(
this.taskStarted = merge(of(null as ApiEvaluationState), this.state).pipe(
pairwise(),
filter(([s1, s2]) => (s1 === null || s1.taskStatus === 'PREPARING') && s2.taskStatus === 'RUNNING'),
map(([s1, s2]) => s2),
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/viewer/task-viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ <h2 class="header">{{ currentTaskName | async }} (Task is about to start!)</h2>
<div *ngIf="(viewerState | async) === 4">
<h2 style="text-align: center">{{ currentTaskName | async }} ({{ toFormattedTime(timeLeft | async) }})</h2>
<div *ngIf="currentTaskHint | async">
<app-text-object-preview [queryContent]="currentTaskHint"></app-text-object-preview>
<app-video-object-preview [queryObject]="currentTaskHint" [muted]="(config.configAsObservable | async).effects.mute"></app-video-object-preview>
<app-image-object-preview [queryContent]="currentTaskHint"></app-image-object-preview>
<app-text-object-preview [queryContent]="currentTaskHint"></app-text-object-preview>
</div>
</div>

<!-- VIEWER_TASK_ENDED -->
<div *ngIf="(viewerState | async) === 5">
<h2 class="header">{{ currentTaskName | async }} (Task complete)</h2>
<div *ngIf="currentTaskTarget | async">
<app-text-object-preview [queryContent]="currentTaskTarget"></app-text-object-preview>
<app-video-object-preview [queryObject]="currentTaskTarget" [muted]="true"></app-video-object-preview>
<app-image-object-preview [queryContent]="currentTaskTarget"></app-image-object-preview>
</div>
Expand Down
18 changes: 10 additions & 8 deletions frontend/src/app/viewer/task-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ export class TaskViewerComponent implements AfterViewInit, OnDestroy {
/* Observable for the current query hint. */
const currentTaskHint = this.taskStarted.pipe(
withLatestFrom(this.evaluationId),
switchMap(([task, evaluationId]) =>
this.runService.getApiV2EvaluationByEvaluationIdByTaskIdHint(evaluationId, task.taskId).pipe(
catchError((e) => {
console.error('[TaskViewerComponent] Could not load current query hint due to an error.', e);
return of(null);
})
)
switchMap(([task, evaluationId]) => {
return this.runService.getApiV2EvaluationByEvaluationIdByTaskIdHint(evaluationId, task.taskId).pipe(
catchError((e) => {
console.error("[TaskViewerComponent] Could not load current query hint due to an error.", e);
return of(null);
})
);
}
),
tap((hint) => this.evaluationId.pipe(switchMap(evaluationId => this.runService.getApiV2EvaluationByEvaluationIdByTaskIdReady(evaluationId, hint.taskId))).subscribe()),
shareReplay({ bufferSize: 1, refCount: true })
Expand All @@ -143,6 +144,7 @@ export class TaskViewerComponent implements AfterViewInit, OnDestroy {
* IMPORTANT: Unsubscribe onDestroy.
*/
this.viewerStateSubscription = this.state.subscribe((s) => {
// this.timeElapsed = of(s.timeElapsed)
switch (s.taskStatus) {
case 'NO_TASK':
case 'CREATED':
Expand Down Expand Up @@ -187,7 +189,7 @@ export class TaskViewerComponent implements AfterViewInit, OnDestroy {
this.currentTaskHint = currentTaskHint.pipe(
mergeMap((hint) => {
return this.timeElapsed.pipe(
take(1),
take(1),
mergeMap((timeElapsed) => {
const actualTimeElapsed = Math.max(timeElapsed, 0);
const sequence = [];
Expand Down

0 comments on commit e55e1b7

Please sign in to comment.