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


##########
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,369 @@
+/*
+ * 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, OnInit } 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,
+    startRemotePortTransmission,
+    stopRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { 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';
+import { loadFlowConfiguration } from 
'../../../../state/flow-configuration/flow-configuration.actions';
+import {
+    selectFlowConfiguration,
+    selectTimeOffset
+} from '../../../../state/flow-configuration/flow-configuration.selectors';
+import { selectAbout } from '../../../../state/about/about.selectors';
+import { loadAbout } from '../../../../state/about/about.actions';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnInit, 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);
+    flowConfiguration$ = 
this.store.select(selectFlowConfiguration).pipe(isDefinedAndNotNull());
+    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: any | null = null;
+    timeOffset = 0;

Review Comment:
   This appears to be unused (though I could have missed it).



##########
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,369 @@
+/*
+ * 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, OnInit } 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,
+    startRemotePortTransmission,
+    stopRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { 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';
+import { loadFlowConfiguration } from 
'../../../../state/flow-configuration/flow-configuration.actions';
+import {
+    selectFlowConfiguration,
+    selectTimeOffset
+} from '../../../../state/flow-configuration/flow-configuration.selectors';
+import { selectAbout } from '../../../../state/about/about.selectors';
+import { loadAbout } from '../../../../state/about/about.actions';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnInit, 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);
+    flowConfiguration$ = 
this.store.select(selectFlowConfiguration).pipe(isDefinedAndNotNull());
+    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: any | null = null;
+    timeOffset = 0;
+
+    constructor(
+        private store: Store<NiFiState>,
+        private nifiCommon: NiFiCommon
+    ) {
+        // load the ports after the flow configuration `timeOffset` and about 
`timezone` are loaded into the store
+        this.store
+            .select(selectTimeOffset)
+            .pipe(
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectAbout)),
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectRpgIdFromRoute)),
+                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(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((portId) => {
+                this.selectedPortId = portId;
+            });
+
+        // data for table
+        this.store
+            .select(selectPorts)
+            .pipe(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((ports) => {
+                this.dataSource = new 
MatTableDataSource<PortSummary>(this.sortEntities(ports, this.activeSort));
+            });
+
+        // the current RPG Entity
+        this.store
+            .select(selectRpg)
+            .pipe(
+                isDefinedAndNotNull(),
+                tap((rpg) => (this.currentRpg = rpg)),
+                takeUntilDestroyed()
+            )
+            .subscribe();
+
+        // handle editing remote port deep link
+        this.store
+            .select(selectSingleEditedPort)
+            .pipe(
+                isDefinedAndNotNull(),
+                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
+                            }
+                        })
+                    );
+                }
+            });
+    }
+
+    ngOnInit(): void {
+        this.store.dispatch(loadFlowConfiguration());
+        this.store.dispatch(loadAbout());
+    }
+
+    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 {
+        if (!this.isCountBlank(entity)) {
+            return `${entity.batchSettings?.count}`;
+        }
+        return 'No value set';
+    }
+
+    isCountBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            (!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.count) 
|| entity.batchSettings.count === '')
+        );
+    }
+
+    formatSize(entity: PortSummary): string {
+        if (!this.isSizeBlank(entity)) {
+            return `${entity.batchSettings?.size}`;
+        }
+        return 'No value set';
+    }
+
+    isSizeBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            (!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.size) 
|| entity.batchSettings.size === '')
+        );
+    }

Review Comment:
   We should be able to simplify this based on the updated type definition. I 
think it should just be
   
   `return this.nifiCommon.isBlank(entity.batchSettings.size);`



##########
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/index.ts:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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 { ComponentType } from '../../../../state/shared';
+
+export const remotePortsFeatureKey = 'remotePortListing';
+
+export interface PortSummary {
+    batchSettings: {
+        count?: number | string;
+        size?: number | string;
+        duration?: number | string;
+    };

Review Comment:
   `batchSettings` appears to always be populated. `count`, `size`, and 
`duration` will be undefined until the user sets them. Then the value will be 
the type laid out above.



##########
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,369 @@
+/*
+ * 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, OnInit } 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,
+    startRemotePortTransmission,
+    stopRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { 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';
+import { loadFlowConfiguration } from 
'../../../../state/flow-configuration/flow-configuration.actions';
+import {
+    selectFlowConfiguration,
+    selectTimeOffset
+} from '../../../../state/flow-configuration/flow-configuration.selectors';
+import { selectAbout } from '../../../../state/about/about.selectors';
+import { loadAbout } from '../../../../state/about/about.actions';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnInit, 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);
+    flowConfiguration$ = 
this.store.select(selectFlowConfiguration).pipe(isDefinedAndNotNull());
+    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: any | null = null;
+    timeOffset = 0;
+
+    constructor(
+        private store: Store<NiFiState>,
+        private nifiCommon: NiFiCommon
+    ) {
+        // load the ports after the flow configuration `timeOffset` and about 
`timezone` are loaded into the store
+        this.store
+            .select(selectTimeOffset)
+            .pipe(
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectAbout)),
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectRpgIdFromRoute)),
+                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(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((portId) => {
+                this.selectedPortId = portId;
+            });
+
+        // data for table
+        this.store
+            .select(selectPorts)
+            .pipe(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((ports) => {
+                this.dataSource = new 
MatTableDataSource<PortSummary>(this.sortEntities(ports, this.activeSort));
+            });
+
+        // the current RPG Entity
+        this.store
+            .select(selectRpg)
+            .pipe(
+                isDefinedAndNotNull(),
+                tap((rpg) => (this.currentRpg = rpg)),
+                takeUntilDestroyed()
+            )
+            .subscribe();
+
+        // handle editing remote port deep link
+        this.store
+            .select(selectSingleEditedPort)
+            .pipe(
+                isDefinedAndNotNull(),
+                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
+                            }
+                        })
+                    );
+                }
+            });
+    }
+
+    ngOnInit(): void {
+        this.store.dispatch(loadFlowConfiguration());
+        this.store.dispatch(loadAbout());
+    }
+
+    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 {
+        if (!this.isCountBlank(entity)) {
+            return `${entity.batchSettings?.count}`;
+        }
+        return 'No value set';
+    }
+
+    isCountBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            (!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.count) 
|| entity.batchSettings.count === '')
+        );
+    }

Review Comment:
   We should be able to simplify this based on the updated type definition. I 
think it should just be
   
   `return this.nifiCommon.isUndefined(entity.batchSettings.count);`



##########
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/index.ts:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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 { ComponentType } from '../../../../state/shared';
+
+export const remotePortsFeatureKey = 'remotePortListing';
+
+export interface PortSummary {
+    batchSettings: {
+        count?: number | string;
+        size?: number | string;
+        duration?: number | string;
+    };

Review Comment:
   Looking at the back end I believe these should be defined as:
   
   ```
   count?: number;
   size?: string;
   duration?: string;
   ```



##########
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/index.ts:
##########
@@ -0,0 +1,100 @@
+/*
+ * 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 { ComponentType } from '../../../../state/shared';
+
+export const remotePortsFeatureKey = 'remotePortListing';
+
+export interface PortSummary {
+    batchSettings: {
+        count?: number | string;
+        size?: number | string;
+        duration?: number | string;
+    };

Review Comment:
   Any usage of `batchSettings?` should be able to be updated to 
`batchSettings`.



##########
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,369 @@
+/*
+ * 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, OnInit } 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,
+    startRemotePortTransmission,
+    stopRemotePortTransmission
+} from '../../state/manage-remote-ports/manage-remote-ports.actions';
+import { initialState } from 
'../../state/manage-remote-ports/manage-remote-ports.reducer';
+import { 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';
+import { loadFlowConfiguration } from 
'../../../../state/flow-configuration/flow-configuration.actions';
+import {
+    selectFlowConfiguration,
+    selectTimeOffset
+} from '../../../../state/flow-configuration/flow-configuration.selectors';
+import { selectAbout } from '../../../../state/about/about.selectors';
+import { loadAbout } from '../../../../state/about/about.actions';
+
+@Component({
+    templateUrl: './manage-remote-ports.component.html',
+    styleUrls: ['./manage-remote-ports.component.scss']
+})
+export class ManageRemotePorts implements OnInit, 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);
+    flowConfiguration$ = 
this.store.select(selectFlowConfiguration).pipe(isDefinedAndNotNull());
+    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: any | null = null;
+    timeOffset = 0;
+
+    constructor(
+        private store: Store<NiFiState>,
+        private nifiCommon: NiFiCommon
+    ) {
+        // load the ports after the flow configuration `timeOffset` and about 
`timezone` are loaded into the store
+        this.store
+            .select(selectTimeOffset)
+            .pipe(
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectAbout)),
+                isDefinedAndNotNull(),
+                switchMap(() => this.store.select(selectRpgIdFromRoute)),
+                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(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((portId) => {
+                this.selectedPortId = portId;
+            });
+
+        // data for table
+        this.store
+            .select(selectPorts)
+            .pipe(isDefinedAndNotNull(), takeUntilDestroyed())
+            .subscribe((ports) => {
+                this.dataSource = new 
MatTableDataSource<PortSummary>(this.sortEntities(ports, this.activeSort));
+            });
+
+        // the current RPG Entity
+        this.store
+            .select(selectRpg)
+            .pipe(
+                isDefinedAndNotNull(),
+                tap((rpg) => (this.currentRpg = rpg)),
+                takeUntilDestroyed()
+            )
+            .subscribe();
+
+        // handle editing remote port deep link
+        this.store
+            .select(selectSingleEditedPort)
+            .pipe(
+                isDefinedAndNotNull(),
+                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
+                            }
+                        })
+                    );
+                }
+            });
+    }
+
+    ngOnInit(): void {
+        this.store.dispatch(loadFlowConfiguration());
+        this.store.dispatch(loadAbout());
+    }
+
+    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 {
+        if (!this.isCountBlank(entity)) {
+            return `${entity.batchSettings?.count}`;
+        }
+        return 'No value set';
+    }
+
+    isCountBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            (!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.count) 
|| entity.batchSettings.count === '')
+        );
+    }
+
+    formatSize(entity: PortSummary): string {
+        if (!this.isSizeBlank(entity)) {
+            return `${entity.batchSettings?.size}`;
+        }
+        return 'No value set';
+    }
+
+    isSizeBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            (!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.size) 
|| entity.batchSettings.size === '')
+        );
+    }
+
+    formatDuration(entity: PortSummary): string {
+        if (!this.isSizeBlank(entity)) {
+            return `${entity.batchSettings?.duration}`;
+        }
+        return 'No value set';
+    }
+
+    isDurationBlank(entity: PortSummary): boolean {
+        return (
+            entity.batchSettings &&
+            
(!this.nifiCommon.isDefinedAndNotNull(entity.batchSettings.duration) ||
+                entity.batchSettings.duration === '')
+        );
+    }

Review Comment:
   We should be able to simplify this based on the updated type definition. I 
think it should just be
   
   `return this.nifiCommon.isBlank(entity.batchSettings.duration);`



-- 
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