mcgilman commented on code in PR #8433:
URL: https://github.com/apache/nifi/pull/8433#discussion_r1503155760


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/service/manage-remote-port.service.ts:
##########
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Observable } from 'rxjs';
+import { HttpClient } from '@angular/common/http';
+import { NiFiCommon } from '../../../service/nifi-common.service';
+import { ConfigureRemotePortRequest, ToggleRemotePortTransmissionRequest } 
from '../state/manage-remote-ports';
+import { Client } from '../../../service/client.service';
+import { Storage } from '../../../service/storage.service';
+import { ComponentType } from '../../../state/shared';
+
+@Injectable({ providedIn: 'root' })
+export class ManageRemotePortService {
+    private static readonly API: string = '../nifi-api';
+
+    constructor(
+        private httpClient: HttpClient,
+        private client: Client,
+        private storage: Storage,
+        private nifiCommon: NiFiCommon
+    ) {}
+
+    getRemotePorts(rpgId: string): Observable<any> {
+        return 
this.httpClient.get(`${ManageRemotePortService.API}/remote-process-groups/${rpgId}`);
+    }
+
+    updateRemotePort(configureManageRemotePort: ConfigureRemotePortRequest): 
Observable<any> {
+        const type =
+            configureManageRemotePort.payload.type === ComponentType.InputPort 
? 'input-ports' : 'output-ports';
+        return this.httpClient.put(
+            
`${this.nifiCommon.stripProtocol(configureManageRemotePort.uri)}/${type}/${
+                configureManageRemotePort.payload.remoteProcessGroupPort.id
+            }`,
+            {
+                revision: configureManageRemotePort.payload.revision,
+                remoteProcessGroupPort: 
configureManageRemotePort.payload.remoteProcessGroupPort,
+                disconnectedNodeAcknowledged: 
configureManageRemotePort.payload.disconnectedNodeAcknowledged
+            }
+        );
+    }
+
+    togglePortTransmission(toggleRemotePortTransmissionRequest: 
ToggleRemotePortTransmissionRequest): Observable<any> {
+        let isTransmitting = false;
+        if (toggleRemotePortTransmissionRequest.port.connected) {
+            if (!toggleRemotePortTransmissionRequest.port.transmitting) {
+                if (toggleRemotePortTransmissionRequest.port.exists) {
+                    isTransmitting = true;
+                }
+            }
+        }

Review Comment:
   Can this be simplified to just assign the boolean value?



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Actions, concatLatestFrom, createEffect, ofType } from 
'@ngrx/effects';
+import * as ManageRemotePortsActions from './manage-remote-ports.actions';
+import { catchError, combineLatest, from, map, of, switchMap, tap } from 
'rxjs';
+import { MatDialog } from '@angular/material/dialog';
+import { Store } from '@ngrx/store';
+import { NiFiState } from '../../../../state';
+import { Router } from '@angular/router';
+import { selectRpg, selectRpgIdFromRoute, selectSaving, selectStatus } from 
'./manage-remote-ports.selectors';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { HttpErrorResponse } from '@angular/common/http';
+import { ManageRemotePortService } from 
'../../service/manage-remote-port.service';
+import { PortSummary } from './index';
+import { EditRemotePortComponent } from 
'../../ui/manage-remote-ports/edit-remote-port/edit-remote-port.component';
+import { EditComponentDialogRequest } from '../flow';
+import { ComponentType, isDefinedAndNotNull } from '../../../../state/shared';
+
+@Injectable()
+export class ManageRemotePortsEffects {
+    constructor(
+        private actions$: Actions,
+        private store: Store<NiFiState>,
+        private manageRemotePortService: ManageRemotePortService,
+        private errorHelper: ErrorHelper,
+        private dialog: MatDialog,
+        private router: Router
+    ) {}
+
+    loadRemotePorts$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.loadRemotePorts),
+            map((action) => action.request),
+            concatLatestFrom(() => this.store.select(selectStatus)),
+            switchMap(([request, status]) => {
+                return 
combineLatest([this.manageRemotePortService.getRemotePorts(request.rpgId)]).pipe(
+                    map(([response]) => {
+                        const ports: PortSummary[] = [];
+
+                        
response.component.contents.inputPorts.forEach((inputPort: PortSummary) => {
+                            const port = {
+                                ...inputPort,
+                                type: ComponentType.InputPort
+                            } as PortSummary;
+
+                            ports.push(port);
+                        });
+
+                        
response.component.contents.outputPorts.forEach((outputPort: PortSummary) => {
+                            const port = {
+                                ...outputPort,
+                                type: ComponentType.OutputPort
+                            } as PortSummary;
+
+                            ports.push(port);
+                        });
+
+                        return 
ManageRemotePortsActions.loadRemotePortsSuccess({
+                            response: {
+                                ports,
+                                loadedTimestamp: response.loadedTimestamp,
+                                rpg: response
+                            }
+                        });
+                    }),
+                    catchError((errorResponse: HttpErrorResponse) =>
+                        of(this.errorHelper.handleLoadingError(status, 
errorResponse))
+                    )
+                );
+            })
+        )
+    );
+
+    navigateToEditPort$ = createEffect(
+        () =>
+            this.actions$.pipe(
+                ofType(ManageRemotePortsActions.navigateToEditPort),
+                map((action) => action.id),
+                concatLatestFrom(() => 
this.store.select(selectRpgIdFromRoute)),
+                tap(([id, rpgId]) => {
+                    this.router.navigate(['/remote-process-group', rpgId, 
'manage-remote-ports', id, 'edit']);
+                })
+            ),
+        { dispatch: false }
+    );
+
+    remotePortsBannerApiError$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.remotePortsBannerApiError),
+            map((action) => action.error),
+            switchMap((error) => of(ErrorActions.addBannerError({ error })))
+        )
+    );
+
+    toggleRemotePortTransmission$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.toggleRemotePortTransmission),
+            map((action) => action.request),
+            concatLatestFrom(() => this.store.select(selectStatus)),
+            switchMap(([request, status]) => {
+                return combineLatest([
+                    this.manageRemotePortService.togglePortTransmission({
+                        rpg: request.rpg,
+                        port: request.port
+                    })
+                ]).pipe(
+                    map(([response]) => {
+                        return ManageRemotePortsActions.loadRemotePorts({
+                            request: {
+                                rpgId: response.remoteProcessGroupPort.groupId
+                            }
+                        });
+                    }),
+                    catchError((errorResponse: HttpErrorResponse) =>
+                        of(this.errorHelper.handleLoadingError(status, 
errorResponse))

Review Comment:
   Once the page loads we shouldn't use `handleLoadingError`. Maybe try
   
   `of(ErrorActions.snackBarError({ error: errorResponse.error }))`



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/manage-remote-ports/manage-remote-ports.component.ts:
##########
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, OnDestroy } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { filter, switchMap, take, tap } from 'rxjs';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import {
+    selectRemotePortsState,
+    selectPort,
+    selectPortIdFromRoute,
+    selectPorts,
+    selectRpg,
+    selectRpgIdFromRoute,
+    selectSingleEditedPort
+} from '../../state/manage-remote-ports/manage-remote-ports.selectors';
+import { RemotePortsState, PortSummary } from 
'../../state/manage-remote-ports';
+import {
+    loadRemotePorts,
+    navigateToEditPort,
+    openConfigureRemotePortDialog,
+    resetRemotePortsState,
+    selectRemotePort,
+    toggleRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { ComponentReferenceEntity, isDefinedAndNotNull, TextTipInput } from 
'../../../../state/shared';
+import { selectCurrentUser } from 
'../../../../state/current-user/current-user.selectors';
+import { NiFiState } from '../../../../state';
+import { NiFiCommon } from '../../../../service/nifi-common.service';
+import { MatTableDataSource } from '@angular/material/table';
+import { Sort } from '@angular/material/sort';
+import { TextTip } from 
'../../../../ui/common/tooltips/text-tip/text-tip.component';
+import { concatLatestFrom } from '@ngrx/effects';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnDestroy {
+    initialSortColumn: 'name' | 'type' | 'tasks' | 'count' | 'size' | 
'duration' | 'compression' | 'actions' = 'name';
+    initialSortDirection: 'asc' | 'desc' = 'asc';
+    activeSort: Sort = {
+        active: this.initialSortColumn,
+        direction: this.initialSortDirection
+    };
+    portsState$ = this.store.select(selectRemotePortsState);
+    selectedRpgId$ = this.store.select(selectRpgIdFromRoute);
+    selectedPortId!: string;
+    currentUser$ = this.store.select(selectCurrentUser);
+    displayedColumns: string[] = [
+        'moreDetails',
+        'name',
+        'type',
+        'tasks',
+        'count',
+        'size',
+        'duration',
+        'compression',
+        'actions'
+    ];
+    dataSource: MatTableDataSource<PortSummary> = new 
MatTableDataSource<PortSummary>([]);
+    protected readonly TextTip = TextTip;
+
+    private currentRpgId!: string;
+    protected currentRpg: ComponentReferenceEntity | null = null;
+
+    constructor(
+        private store: Store<NiFiState>,
+        private nifiCommon: NiFiCommon
+    ) {
+        // load the ports using the rpg id from the route
+        this.store
+            .select(selectRpgIdFromRoute)
+            .pipe(
+                filter((rpgId) => rpgId != null),
+                tap((rpgId) => (this.currentRpgId = rpgId)),
+                takeUntilDestroyed()
+            )
+            .subscribe((rpgId) => {
+                this.store.dispatch(
+                    loadRemotePorts({
+                        request: {
+                            rpgId
+                        }
+                    })
+                );
+            });
+
+        // track selection using the port id from the route
+        this.store
+            .select(selectPortIdFromRoute)
+            .pipe(
+                filter((portId) => portId != null),
+                takeUntilDestroyed()
+            )
+            .subscribe((portId) => {
+                this.selectedPortId = portId;
+            });
+
+        // data for table
+        this.store
+            .select(selectPorts)
+            .pipe(
+                filter((ports) => ports != null),
+                takeUntilDestroyed()
+            )
+            .subscribe((ports) => {
+                this.dataSource = new MatTableDataSource<PortSummary>(ports);
+            });
+
+        // the current RPG Entity
+        this.store
+            .select(selectRpg)
+            .pipe(
+                filter((rpg) => rpg != null),
+                tap((rpg) => (this.currentRpg = rpg)),
+                takeUntilDestroyed()
+            )
+            .subscribe();
+
+        // handle editing remote port deep link
+        this.store
+            .select(selectSingleEditedPort)
+            .pipe(
+                filter((id: string) => id != null),
+                switchMap((id: string) =>
+                    this.store.select(selectPort(id)).pipe(
+                        filter((entity) => entity != null),
+                        take(1)
+                    )
+                ),
+                concatLatestFrom(() => 
[this.store.select(selectRpg).pipe(isDefinedAndNotNull())]),
+                takeUntilDestroyed()
+            )
+            .subscribe(([entity, rpg]) => {
+                if (entity) {
+                    this.store.dispatch(
+                        openConfigureRemotePortDialog({
+                            request: {
+                                id: entity.id,
+                                port: entity,
+                                rpg
+                            }
+                        })
+                    );
+                }
+            });
+    }
+
+    isInitialLoading(state: RemotePortsState): boolean {
+        // using the current timestamp to detect the initial load event
+        return state.loadedTimestamp == initialState.loadedTimestamp;
+    }
+
+    refreshManageRemotePortsListing(): void {
+        this.store.dispatch(
+            loadRemotePorts({
+                request: {
+                    rpgId: this.currentRpgId
+                }
+            })
+        );
+    }
+
+    formatName(entity: PortSummary): string {
+        return entity.name;
+    }
+
+    formatTasks(entity: PortSummary): string {
+        return entity.concurrentlySchedulableTaskCount ? 
`${entity.concurrentlySchedulableTaskCount}` : 'No value set';
+    }
+
+    formatCount(entity: PortSummary): string {
+        return entity.batchSettings?.count ? `${entity.batchSettings?.count}` 
: 'No value set';
+    }
+
+    formatSize(entity: PortSummary): string {
+        return entity.batchSettings?.size ? `${entity.batchSettings?.size}` : 
'No value set';
+    }
+
+    formatDuration(entity: PortSummary): string {
+        return entity.batchSettings?.duration ? 
`${entity.batchSettings?.duration}` : 'No value set';
+    }
+
+    formatCompression(entity: PortSummary): string {
+        return entity.useCompression ? 'Yes' : 'No';
+    }
+
+    formatType(entity: PortSummary): string {
+        return entity.type || '';
+    }
+
+    configureClicked(port: PortSummary, event: MouseEvent): void {
+        event.stopPropagation();
+        this.store.dispatch(
+            navigateToEditPort({
+                id: port.id
+            })
+        );
+    }
+
+    hasComments(entity: PortSummary): boolean {
+        return !this.nifiCommon.isBlank(entity.comments);
+    }
+
+    getCommentsTipData(entity: PortSummary): TextTipInput {
+        return {
+            text: entity.comments
+        };
+    }
+
+    toggleTransmission(port: PortSummary): void {
+        if (this.currentRpg) {
+            if (port.transmitting) {
+                this.store.dispatch(
+                    toggleRemotePortTransmission({
+                        request: {
+                            rpg: this.currentRpg,
+                            port
+                        }
+                    })
+                );
+            } else {
+                if (port.connected && port.exists) {
+                    this.store.dispatch(
+                        toggleRemotePortTransmission({
+                            request: {
+                                rpg: this.currentRpg,
+                                port
+                            }
+                        })
+                    );
+                }
+            }
+        }
+    }
+
+    select(entity: PortSummary): void {
+        this.store.dispatch(
+            selectRemotePort({
+                request: {
+                    rpgId: this.currentRpgId,
+                    id: entity.id
+                }
+            })
+        );
+    }
+
+    isSelected(entity: any): boolean {
+        if (this.selectedPortId) {
+            return entity.id == this.selectedPortId;
+        }
+        return false;
+    }
+
+    selectControllerService(entity: any): void {

Review Comment:
   ```suggestion
       selectRemotePort(entity: any): void {
   ```



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Actions, concatLatestFrom, createEffect, ofType } from 
'@ngrx/effects';
+import * as ManageRemotePortsActions from './manage-remote-ports.actions';
+import { catchError, combineLatest, from, map, of, switchMap, tap } from 
'rxjs';
+import { MatDialog } from '@angular/material/dialog';
+import { Store } from '@ngrx/store';
+import { NiFiState } from '../../../../state';
+import { Router } from '@angular/router';
+import { selectRpg, selectRpgIdFromRoute, selectSaving, selectStatus } from 
'./manage-remote-ports.selectors';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { HttpErrorResponse } from '@angular/common/http';
+import { ManageRemotePortService } from 
'../../service/manage-remote-port.service';
+import { PortSummary } from './index';
+import { EditRemotePortComponent } from 
'../../ui/manage-remote-ports/edit-remote-port/edit-remote-port.component';
+import { EditComponentDialogRequest } from '../flow';
+import { ComponentType, isDefinedAndNotNull } from '../../../../state/shared';
+
+@Injectable()
+export class ManageRemotePortsEffects {
+    constructor(
+        private actions$: Actions,
+        private store: Store<NiFiState>,
+        private manageRemotePortService: ManageRemotePortService,
+        private errorHelper: ErrorHelper,
+        private dialog: MatDialog,
+        private router: Router
+    ) {}
+
+    loadRemotePorts$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.loadRemotePorts),
+            map((action) => action.request),
+            concatLatestFrom(() => this.store.select(selectStatus)),
+            switchMap(([request, status]) => {
+                return 
combineLatest([this.manageRemotePortService.getRemotePorts(request.rpgId)]).pipe(
+                    map(([response]) => {
+                        const ports: PortSummary[] = [];
+
+                        
response.component.contents.inputPorts.forEach((inputPort: PortSummary) => {
+                            const port = {
+                                ...inputPort,
+                                type: ComponentType.InputPort
+                            } as PortSummary;
+
+                            ports.push(port);
+                        });
+
+                        
response.component.contents.outputPorts.forEach((outputPort: PortSummary) => {
+                            const port = {
+                                ...outputPort,
+                                type: ComponentType.OutputPort
+                            } as PortSummary;
+
+                            ports.push(port);
+                        });
+
+                        return 
ManageRemotePortsActions.loadRemotePortsSuccess({
+                            response: {
+                                ports,
+                                loadedTimestamp: response.loadedTimestamp,
+                                rpg: response
+                            }
+                        });
+                    }),
+                    catchError((errorResponse: HttpErrorResponse) =>
+                        of(this.errorHelper.handleLoadingError(status, 
errorResponse))
+                    )
+                );
+            })
+        )
+    );
+
+    navigateToEditPort$ = createEffect(
+        () =>
+            this.actions$.pipe(
+                ofType(ManageRemotePortsActions.navigateToEditPort),
+                map((action) => action.id),
+                concatLatestFrom(() => 
this.store.select(selectRpgIdFromRoute)),
+                tap(([id, rpgId]) => {
+                    this.router.navigate(['/remote-process-group', rpgId, 
'manage-remote-ports', id, 'edit']);
+                })
+            ),
+        { dispatch: false }
+    );
+
+    remotePortsBannerApiError$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.remotePortsBannerApiError),
+            map((action) => action.error),
+            switchMap((error) => of(ErrorActions.addBannerError({ error })))
+        )
+    );
+
+    toggleRemotePortTransmission$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.toggleRemotePortTransmission),
+            map((action) => action.request),
+            concatLatestFrom(() => this.store.select(selectStatus)),
+            switchMap(([request, status]) => {
+                return combineLatest([
+                    this.manageRemotePortService.togglePortTransmission({
+                        rpg: request.rpg,
+                        port: request.port
+                    })
+                ]).pipe(

Review Comment:
   We don't need `combineLatest` with a single call. We should also be able to 
just pass in the `request` from the action.



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/state/shared/index.ts:
##########
@@ -451,6 +451,8 @@ export interface ComponentReference {
     id: string;
     parentGroupId?: string;
     name: string;
+    targetUri?: string;
+    flowRefreshed?: string;

Review Comment:
   Rather than updating this shared type, can we explicitly store the needed 
details for the RPG in the mange remote ports store?



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/manage-remote-ports/manage-remote-ports.effects.ts:
##########
@@ -0,0 +1,230 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Injectable } from '@angular/core';
+import { Actions, concatLatestFrom, createEffect, ofType } from 
'@ngrx/effects';
+import * as ManageRemotePortsActions from './manage-remote-ports.actions';
+import { catchError, combineLatest, from, map, of, switchMap, tap } from 
'rxjs';
+import { MatDialog } from '@angular/material/dialog';
+import { Store } from '@ngrx/store';
+import { NiFiState } from '../../../../state';
+import { Router } from '@angular/router';
+import { selectRpg, selectRpgIdFromRoute, selectSaving, selectStatus } from 
'./manage-remote-ports.selectors';
+import * as ErrorActions from '../../../../state/error/error.actions';
+import { ErrorHelper } from '../../../../service/error-helper.service';
+import { HttpErrorResponse } from '@angular/common/http';
+import { ManageRemotePortService } from 
'../../service/manage-remote-port.service';
+import { PortSummary } from './index';
+import { EditRemotePortComponent } from 
'../../ui/manage-remote-ports/edit-remote-port/edit-remote-port.component';
+import { EditComponentDialogRequest } from '../flow';
+import { ComponentType, isDefinedAndNotNull } from '../../../../state/shared';
+
+@Injectable()
+export class ManageRemotePortsEffects {
+    constructor(
+        private actions$: Actions,
+        private store: Store<NiFiState>,
+        private manageRemotePortService: ManageRemotePortService,
+        private errorHelper: ErrorHelper,
+        private dialog: MatDialog,
+        private router: Router
+    ) {}
+
+    loadRemotePorts$ = createEffect(() =>
+        this.actions$.pipe(
+            ofType(ManageRemotePortsActions.loadRemotePorts),
+            map((action) => action.request),
+            concatLatestFrom(() => this.store.select(selectStatus)),
+            switchMap(([request, status]) => {
+                return 
combineLatest([this.manageRemotePortService.getRemotePorts(request.rpgId)]).pipe(

Review Comment:
   We don't need the `combineLatest` with only a single call.



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/manage-remote-ports/manage-remote-ports.component.ts:
##########
@@ -0,0 +1,327 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { Component, OnDestroy } from '@angular/core';
+import { Store } from '@ngrx/store';
+import { filter, switchMap, take, tap } from 'rxjs';
+import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
+import {
+    selectRemotePortsState,
+    selectPort,
+    selectPortIdFromRoute,
+    selectPorts,
+    selectRpg,
+    selectRpgIdFromRoute,
+    selectSingleEditedPort
+} from '../../state/manage-remote-ports/manage-remote-ports.selectors';
+import { RemotePortsState, PortSummary } from 
'../../state/manage-remote-ports';
+import {
+    loadRemotePorts,
+    navigateToEditPort,
+    openConfigureRemotePortDialog,
+    resetRemotePortsState,
+    selectRemotePort,
+    toggleRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { ComponentReferenceEntity, isDefinedAndNotNull, TextTipInput } from 
'../../../../state/shared';
+import { selectCurrentUser } from 
'../../../../state/current-user/current-user.selectors';
+import { NiFiState } from '../../../../state';
+import { NiFiCommon } from '../../../../service/nifi-common.service';
+import { MatTableDataSource } from '@angular/material/table';
+import { Sort } from '@angular/material/sort';
+import { TextTip } from 
'../../../../ui/common/tooltips/text-tip/text-tip.component';
+import { concatLatestFrom } from '@ngrx/effects';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnDestroy {
+    initialSortColumn: 'name' | 'type' | 'tasks' | 'count' | 'size' | 
'duration' | 'compression' | 'actions' = 'name';
+    initialSortDirection: 'asc' | 'desc' = 'asc';
+    activeSort: Sort = {
+        active: this.initialSortColumn,
+        direction: this.initialSortDirection
+    };
+    portsState$ = this.store.select(selectRemotePortsState);
+    selectedRpgId$ = this.store.select(selectRpgIdFromRoute);
+    selectedPortId!: string;
+    currentUser$ = this.store.select(selectCurrentUser);
+    displayedColumns: string[] = [
+        'moreDetails',
+        'name',
+        'type',
+        'tasks',
+        'count',
+        'size',
+        'duration',
+        'compression',
+        'actions'
+    ];
+    dataSource: MatTableDataSource<PortSummary> = new 
MatTableDataSource<PortSummary>([]);
+    protected readonly TextTip = TextTip;
+
+    private currentRpgId!: string;
+    protected currentRpg: ComponentReferenceEntity | null = null;
+
+    constructor(
+        private store: Store<NiFiState>,
+        private nifiCommon: NiFiCommon
+    ) {
+        // load the ports using the rpg id from the route
+        this.store
+            .select(selectRpgIdFromRoute)
+            .pipe(
+                filter((rpgId) => rpgId != null),
+                tap((rpgId) => (this.currentRpgId = rpgId)),
+                takeUntilDestroyed()
+            )
+            .subscribe((rpgId) => {
+                this.store.dispatch(
+                    loadRemotePorts({
+                        request: {
+                            rpgId
+                        }
+                    })
+                );
+            });
+
+        // track selection using the port id from the route
+        this.store
+            .select(selectPortIdFromRoute)
+            .pipe(
+                filter((portId) => portId != null),
+                takeUntilDestroyed()
+            )
+            .subscribe((portId) => {
+                this.selectedPortId = portId;
+            });
+
+        // data for table
+        this.store
+            .select(selectPorts)
+            .pipe(
+                filter((ports) => ports != null),
+                takeUntilDestroyed()
+            )
+            .subscribe((ports) => {
+                this.dataSource = new MatTableDataSource<PortSummary>(ports);
+            });
+
+        // the current RPG Entity
+        this.store
+            .select(selectRpg)
+            .pipe(
+                filter((rpg) => rpg != null),
+                tap((rpg) => (this.currentRpg = rpg)),
+                takeUntilDestroyed()
+            )
+            .subscribe();
+
+        // handle editing remote port deep link
+        this.store
+            .select(selectSingleEditedPort)
+            .pipe(
+                filter((id: string) => id != null),
+                switchMap((id: string) =>
+                    this.store.select(selectPort(id)).pipe(
+                        filter((entity) => entity != null),
+                        take(1)
+                    )
+                ),
+                concatLatestFrom(() => 
[this.store.select(selectRpg).pipe(isDefinedAndNotNull())]),
+                takeUntilDestroyed()
+            )
+            .subscribe(([entity, rpg]) => {
+                if (entity) {
+                    this.store.dispatch(
+                        openConfigureRemotePortDialog({
+                            request: {
+                                id: entity.id,
+                                port: entity,
+                                rpg
+                            }
+                        })
+                    );
+                }
+            });
+    }
+
+    isInitialLoading(state: RemotePortsState): boolean {
+        // using the current timestamp to detect the initial load event
+        return state.loadedTimestamp == initialState.loadedTimestamp;
+    }
+
+    refreshManageRemotePortsListing(): void {
+        this.store.dispatch(
+            loadRemotePorts({
+                request: {
+                    rpgId: this.currentRpgId
+                }
+            })
+        );
+    }
+
+    formatName(entity: PortSummary): string {
+        return entity.name;
+    }
+
+    formatTasks(entity: PortSummary): string {
+        return entity.concurrentlySchedulableTaskCount ? 
`${entity.concurrentlySchedulableTaskCount}` : 'No value set';
+    }
+
+    formatCount(entity: PortSummary): string {
+        return entity.batchSettings?.count ? `${entity.batchSettings?.count}` 
: 'No value set';
+    }
+
+    formatSize(entity: PortSummary): string {
+        return entity.batchSettings?.size ? `${entity.batchSettings?.size}` : 
'No value set';
+    }
+
+    formatDuration(entity: PortSummary): string {
+        return entity.batchSettings?.duration ? 
`${entity.batchSettings?.duration}` : 'No value set';
+    }
+
+    formatCompression(entity: PortSummary): string {
+        return entity.useCompression ? 'Yes' : 'No';
+    }
+
+    formatType(entity: PortSummary): string {
+        return entity.type || '';
+    }
+
+    configureClicked(port: PortSummary, event: MouseEvent): void {
+        event.stopPropagation();
+        this.store.dispatch(
+            navigateToEditPort({
+                id: port.id
+            })
+        );
+    }
+
+    hasComments(entity: PortSummary): boolean {
+        return !this.nifiCommon.isBlank(entity.comments);
+    }
+
+    getCommentsTipData(entity: PortSummary): TextTipInput {
+        return {
+            text: entity.comments
+        };
+    }
+
+    toggleTransmission(port: PortSummary): void {
+        if (this.currentRpg) {
+            if (port.transmitting) {
+                this.store.dispatch(
+                    toggleRemotePortTransmission({
+                        request: {
+                            rpg: this.currentRpg,
+                            port
+                        }
+                    })
+                );
+            } else {
+                if (port.connected && port.exists) {
+                    this.store.dispatch(
+                        toggleRemotePortTransmission({
+                            request: {
+                                rpg: this.currentRpg,
+                                port
+                            }
+                        })
+                    );
+                }
+            }

Review Comment:
   Maybe add transmission state to the request and we can remove the additional 
logic from the manage remote port service's `toggle` method.



##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/state/flow/index.ts:
##########
@@ -268,6 +268,11 @@ export interface EditComponentDialogRequest {
     type: ComponentType;
     uri: string;
     entity: any;
+    rpg?: any;

Review Comment:
   Can this be moved to an `EditRemotePortDialogRequest` that extends from 
`EditComponentDialogRequest` and adds the new field?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to