NIFI-13969: Rerendering labels after the viewport is restored to ensure that calculations are performed after the transform is applied. (#9495)

This commit is contained in:
Matt Gilman 2024-11-06 11:45:48 -05:00 committed by GitHub
parent eb7c618788
commit 959196927e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 19 deletions

View File

@ -25,6 +25,8 @@ export const transformComplete = createAction(
export const restoreViewport = createAction('[Transform] Restore Viewport'); export const restoreViewport = createAction('[Transform] Restore Viewport');
export const restoreViewportComplete = createAction('[Transform] Restore Viewport Complete');
export const translate = createAction('[Transform] Translate', props<{ translate: [number, number] }>()); export const translate = createAction('[Transform] Translate', props<{ translate: [number, number] }>());
export const refreshBirdseyeView = createAction('[Transform] Refresh Birdseye View'); export const refreshBirdseyeView = createAction('[Transform] Refresh Birdseye View');

View File

@ -19,13 +19,14 @@ import { Injectable } from '@angular/core';
import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Actions, createEffect, ofType } from '@ngrx/effects';
import { concatLatestFrom } from '@ngrx/operators'; import { concatLatestFrom } from '@ngrx/operators';
import * as TransformActions from './transform.actions'; import * as TransformActions from './transform.actions';
import { map, tap } from 'rxjs'; import { map, of, switchMap, tap } from 'rxjs';
import { Storage } from '@nifi/shared'; import { Storage } from '@nifi/shared';
import { selectCurrentProcessGroupId } from '../flow/flow.selectors'; import { selectCurrentProcessGroupId } from '../flow/flow.selectors';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { CanvasState } from '../index'; import { CanvasState } from '../index';
import { CanvasView } from '../../service/canvas-view.service'; import { CanvasView } from '../../service/canvas-view.service';
import { BirdseyeView } from '../../service/birdseye-view.service'; import { BirdseyeView } from '../../service/birdseye-view.service';
import { LabelManager } from '../../service/manager/label-manager.service';
interface StorageTransform { interface StorageTransform {
scale: number; scale: number;
@ -42,11 +43,11 @@ export class TransformEffects {
private store: Store<CanvasState>, private store: Store<CanvasState>,
private storage: Storage, private storage: Storage,
private canvasView: CanvasView, private canvasView: CanvasView,
private birdseyeView: BirdseyeView private birdseyeView: BirdseyeView,
private labelManager: LabelManager
) {} ) {}
transformComplete$ = createEffect( transformComplete$ = createEffect(() =>
() =>
this.actions$.pipe( this.actions$.pipe(
ofType(TransformActions.transformComplete), ofType(TransformActions.transformComplete),
map((action) => action.transform), map((action) => action.transform),
@ -63,7 +64,16 @@ export class TransformEffects {
// store the item // store the item
this.storage.setItem(name, item); this.storage.setItem(name, item);
}) }),
switchMap(() => of(TransformActions.restoreViewportComplete()))
)
);
restoreViewportComplete$ = createEffect(
() =>
this.actions$.pipe(
ofType(TransformActions.restoreViewportComplete),
tap(() => this.labelManager.render())
), ),
{ dispatch: false } { dispatch: false }
); );