From db09b44e40ae8e4cdd1674a516e49fbc166cad1c Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 27 Mar 2024 17:07:45 -0400 Subject: [PATCH] NIFI-12950: Updating front end to use the uiOnly flag where possible (#8565) * NIFI-12950: - Updating front end to use the uiOnly flag where possible. * NIFI-12950: - Addressing review feedback. This closes #8565 --- .../service/controller-service.service.ts | 5 +++- .../flow-designer/service/flow.service.ts | 8 +++-- .../controller-services.effects.ts | 2 -- .../flow-designer/state/flow/flow.effects.ts | 29 +++++++++++++++++++ .../controller-service-state.service.ts | 5 +++- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/controller-service.service.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/controller-service.service.ts index 9ef906c5f7..d1f547c992 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/controller-service.service.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/controller-service.service.ts @@ -53,7 +53,10 @@ export class ControllerServiceService implements ControllerServiceCreator, Prope } getControllerService(id: string): Observable { - return this.httpClient.get(`${ControllerServiceService.API}/controller-services/${id}`); + const uiOnly: any = { uiOnly: true }; + return this.httpClient.get(`${ControllerServiceService.API}/controller-services/${id}`, { + params: uiOnly + }); } createControllerService(createControllerService: CreateControllerServiceRequest): Observable { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/flow.service.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/flow.service.ts index f3e640f766..fe23575a33 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/flow.service.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/flow.service.ts @@ -54,13 +54,15 @@ export class FlowService implements PropertyDescriptorRetriever { ) {} getFlow(processGroupId = 'root'): Observable { - // TODO - support uiOnly... this would mean that we need to load the entire resource prior to editing - return this.httpClient.get(`${FlowService.API}/flow/process-groups/${processGroupId}`); + const uiOnly: any = { uiOnly: true }; + return this.httpClient.get(`${FlowService.API}/flow/process-groups/${processGroupId}`, { + params: uiOnly + }); } getProcessGroupStatus(processGroupId = 'root', recursive = false): Observable { return this.httpClient.get(`${FlowService.API}/flow/process-groups/${processGroupId}/status`, { - params: { recursive: recursive } + params: { recursive } }); } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts index f8ee780901..62c10f1edf 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/controller-services/controller-services.effects.ts @@ -40,7 +40,6 @@ import { selectStatus } from './controller-services.selectors'; import { ControllerServiceService } from '../../service/controller-service.service'; -import { FlowService } from '../../service/flow.service'; import { EnableControllerService } from '../../../../ui/common/controller-service/enable-controller-service/enable-controller-service.component'; import { DisableControllerService } from '../../../../ui/common/controller-service/disable-controller-service/disable-controller-service.component'; import { PropertyTableHelperService } from '../../../../service/property-table-helper.service'; @@ -56,7 +55,6 @@ export class ControllerServicesEffects { private store: Store, private client: Client, private controllerServiceService: ControllerServiceService, - private flowService: FlowService, private errorHelper: ErrorHelper, private dialog: MatDialog, private router: Router, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts index 8c0716c826..77550447eb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/flow.effects.ts @@ -20,6 +20,7 @@ import { FlowService } from '../../service/flow.service'; import { Actions, concatLatestFrom, createEffect, ofType } from '@ngrx/effects'; import * as FlowActions from './flow.actions'; import * as StatusHistoryActions from '../../../../state/status-history/status-history.actions'; +import * as ErrorActions from '../../../../state/error/error.actions'; import { asyncScheduler, catchError, @@ -98,6 +99,7 @@ import { ImportFromRegistry } from '../../ui/canvas/items/flow/import-from-regis import { selectCurrentUser } from '../../../../state/current-user/current-user.selectors'; import { NoRegistryClientsDialog } from '../../ui/common/no-registry-clients-dialog/no-registry-clients-dialog.component'; import { EditRemoteProcessGroup } from '../../ui/canvas/items/remote-process-group/edit-remote-process-group/edit-remote-process-group.component'; +import { HttpErrorResponse } from '@angular/common/http'; @Injectable() export class FlowEffects { @@ -1069,6 +1071,33 @@ export class FlowEffects { this.actions$.pipe( ofType(FlowActions.openEditProcessorDialog), map((action) => action.request), + switchMap((request) => + from(this.flowService.getProcessor(request.entity.id)).pipe( + map((entity) => { + return { + ...request, + entity + }; + }), + tap({ + error: (errorResponse: HttpErrorResponse) => { + this.store.dispatch( + FlowActions.selectComponents({ + request: { + components: [ + { + id: request.entity.id, + componentType: request.type + } + ] + } + }) + ); + this.store.dispatch(ErrorActions.snackBarError({ error: errorResponse.error })); + } + }) + ) + ), concatLatestFrom(() => [ this.store.select(selectCurrentParameterContext), this.store.select(selectCurrentProcessGroupId) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/controller-service-state.service.ts b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/controller-service-state.service.ts index 213e2c4dea..6e82893494 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/controller-service-state.service.ts +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/service/controller-service-state.service.ts @@ -37,7 +37,10 @@ export class ControllerServiceStateService { ) {} getControllerService(id: string): Observable { - return this.httpClient.get(`${ControllerServiceStateService.API}/controller-services/${id}`); + const uiOnly: any = { uiOnly: true }; + return this.httpClient.get(`${ControllerServiceStateService.API}/controller-services/${id}`, { + params: uiOnly + }); } setEnable(controllerService: ControllerServiceEntity, enabled: boolean): Observable {