mcgilman commented on code in PR #8399: URL: https://github.com/apache/nifi/pull/8399#discussion_r1486949253
########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/feature/flow-configuration-history.component.html: ########## @@ -0,0 +1,26 @@ +<!-- + ~ 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. + --> + +<div class="pb-5 flex flex-col h-screen justify-between gap-y-5"> + <header class="nifi-header"> + <navigation></navigation> + </header> + <div class="px-5 flex-1 flex flex-col"> Review Comment: The spacing between the header and the listing looks a little tight. I didn't compare it every other page but we may want to consider some `gap-y` here. ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/state/flow-configuration-history-listing/flow-configuration-history-listing.effects.ts: ########## @@ -0,0 +1,172 @@ +/* + * 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 { Store } from '@ngrx/store'; +import { NiFiState } from '../../../../state'; +import { ErrorHelper } from '../../../../service/error-helper.service'; +import { MatDialog } from '@angular/material/dialog'; +import * as HistoryActions from './flow-configuration-history-listing.actions'; +import { catchError, from, map, of, switchMap, take, tap } from 'rxjs'; +import { selectHistoryQuery, selectHistoryStatus } from './flow-configuration-history-listing.selectors'; +import { FlowConfigurationHistoryService } from '../../service/flow-configuration-history.service'; +import { HistoryEntity, PurgeHistoryRequest } from './index'; +import { HttpErrorResponse } from '@angular/common/http'; +import { Router } from '@angular/router'; +import { ActionDetails } from '../../ui/flow-configuration-history-listing/action-details/action-details.component'; +import { PurgeHistory } from '../../ui/flow-configuration-history-listing/purge-history/purge-history.component'; +import { YesNoDialog } from '../../../../ui/common/yes-no-dialog/yes-no-dialog.component'; +import { isDefinedAndNotNull } from '../../../../state/shared'; + +@Injectable() +export class FlowConfigurationHistoryListingEffects { + constructor( + private actions$: Actions, + private store: Store<NiFiState>, + private errorHelper: ErrorHelper, + private dialog: MatDialog, + private historyService: FlowConfigurationHistoryService, + private router: Router + ) {} + + loadHistory$ = createEffect(() => + this.actions$.pipe( + ofType(HistoryActions.loadHistory), + map((action) => action.request), + concatLatestFrom(() => this.store.select(selectHistoryStatus)), + switchMap(([request, status]) => + from(this.historyService.getHistory(request)).pipe( + map((response: HistoryEntity) => + HistoryActions.loadHistorySuccess({ + response: response + }) + ), + catchError((errorResponse: HttpErrorResponse) => + of(this.errorHelper.handleLoadingError(status, errorResponse)) + ) + ) + ) + ) + ); + + flowConfigurationHistorySnackbarError = createEffect(() => + this.actions$.pipe( + ofType(HistoryActions.flowConfigurationHistorySnackbarError), + map((action) => action.errorResponse), + concatLatestFrom(() => this.store.select(selectHistoryStatus)), + switchMap(([errorResponse, status]) => of(this.errorHelper.handleLoadingError(status, errorResponse))) Review Comment: Was this intended `ErrorActions.snackbarError(...)`? ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/feature/flow-configuration-history-routing.module.ts: ########## @@ -0,0 +1,39 @@ +/* + * 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 { RouterModule, Routes } from '@angular/router'; +import { FlowConfigurationHistory } from './flow-configuration-history.component'; +import { NgModule } from '@angular/core'; + +const routes: Routes = [ + { + path: '', + component: FlowConfigurationHistory, + children: [ + { + path: ':id', Review Comment: If this record is not present in the current page nothing is selected and the URL still shows the `id`. We haven't considered some of our route error handling yet so it's ok if we punt this. But if you navigate to any page but the first, select a row (which changes the route), and then refresh the page the user is taken back to the first page but with the `id` in the route. ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/ui/flow-configuration-history-listing/flow-configuration-history-table/flow-configuration-history-table.component.ts: ########## @@ -0,0 +1,110 @@ +/* + * 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, EventEmitter, Input, Output } from '@angular/core'; +import { CommonModule } from '@angular/common'; +import { MatTableDataSource, MatTableModule } from '@angular/material/table'; +import { MatSortModule, Sort } from '@angular/material/sort'; +import { ActionEntity } from '../../../state/flow-configuration-history-listing'; +import { NiFiCommon } from '../../../../../service/nifi-common.service'; + +@Component({ + selector: 'flow-configuration-history-table', + standalone: true, + imports: [CommonModule, MatTableModule, MatSortModule], + templateUrl: './flow-configuration-history-table.component.html', + styleUrls: ['./flow-configuration-history-table.component.scss'] +}) +export class FlowConfigurationHistoryTable { + @Input() selectedHistoryActionId: string | null = null; + @Input() initialSortColumn: 'timestamp' | 'sourceName' | 'sourceType' | 'operation' | 'userIdentity' = 'timestamp'; + @Input() initialSortDirection: 'asc' | 'desc' = 'desc'; + + @Input() set historyActions(historyActions: ActionEntity[]) { + if (historyActions) { + this.dataSource.data = historyActions; + } + } + + @Output() selectionChanged: EventEmitter<ActionEntity> = new EventEmitter<ActionEntity>(); + @Output() sortChanged: EventEmitter<Sort> = new EventEmitter<Sort>(); + @Output() moreDetailsClicked: EventEmitter<ActionEntity> = new EventEmitter<ActionEntity>(); + + activeSort: Sort = { + active: this.initialSortColumn, + direction: this.initialSortDirection + }; + + displayedColumns: string[] = ['moreDetails', 'timestamp', 'sourceName', 'sourceType', 'operation', 'userIdentity']; + dataSource: MatTableDataSource<ActionEntity> = new MatTableDataSource<ActionEntity>(); + + constructor(private nifiCommon: NiFiCommon) {} + + sortData(sort: Sort) { + this.sortChanged.next(sort); + } + + canRead(item: ActionEntity): boolean { + return item.canRead; + } + + private format(item: ActionEntity, property: string): string { + if (this.canRead(item) && Object.hasOwn(item.action, property)) { + const value = (item.action as any)[property]; + if (!value) { + return 'Empty String Set'; + } + return value; + } + return 'Not Authorized'; + } + + formatTimestamp(item: ActionEntity): string { + return this.format(item, 'timestamp'); + } + + formatName(item: ActionEntity): string { + return this.format(item, 'sourceName'); + } + + formatType(item: ActionEntity): string { + return this.format(item, 'sourceType'); + } + + formatOperation(item: ActionEntity): string { + return this.format(item, 'operation'); + } + + formatUser(item: ActionEntity): string { + return this.format(item, 'userIdentity'); + } + + select(item: ActionEntity) { + this.selectionChanged.next(item); + } + + isSelected(item: ActionEntity): boolean { + if (this.selectedHistoryActionId) { + return `${item.id}` === this.selectedHistoryActionId; Review Comment: Is the template string needed here? ########## nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-configuration-history/ui/flow-configuration-history-listing/flow-configuration-history-listing.component.html: ########## @@ -0,0 +1,131 @@ +<!-- + ~ 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. + --> + +<ng-container *ngIf="historyListingState$ | async; let state"> + <div *ngIf="isInitialLoading(state); else loaded"> + <ngx-skeleton-loader count="3"></ngx-skeleton-loader> + </div> + + <ng-template #loaded> + <div class="flow-configuration-history-listing flex flex-col h-full gap-y-2"> + <div class="flex align-middle justify-between"> + <div class="flow-configuration-filter flex-1"> + <form [formGroup]="filterForm"> + <div class="flex pt-1 gap-1 items-baseline"> + <div> + <mat-form-field> + <mat-label>Filter</mat-label> + <input matInput type="text" class="small" formControlName="filterTerm" /> + </mat-form-field> + </div> + <div> + <mat-form-field> + <mat-label>Filter By</mat-label> + <mat-select formControlName="filterColumn"> + <ng-container *ngFor="let option of filterableColumns"> + <mat-option [value]="option.key"> {{ option.label }} </mat-option> + </ng-container> + </mat-select> + </mat-form-field> + </div> + <div class="flex ml-6 gap-x-2"> + <mat-form-field> + <mat-label>Date Range</mat-label> + <mat-date-range-input [rangePicker]="picker"> + <input + matStartDate + formControlName="filterStartDate" + placeholder="Start date" + title="The start date in the format 'mm/dd/yyyy'. Must also specify start time." /> + <input + matEndDate + formControlName="filterEndDate" + placeholder="End date" + title="The end date in the format 'mm/dd/yyyy'. Must also specify end time." /> + </mat-date-range-input> + <mat-datepicker-toggle matIconSuffix [for]="picker"></mat-datepicker-toggle> + <mat-date-range-picker #picker></mat-date-range-picker> + </mat-form-field> + <div> + <mat-form-field> + <mat-label>Start Time ({{ (about$ | async)?.timezone }})</mat-label> + <input + matInput + type="time" Review Comment: 👍 -- 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]
