Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIFI-12537] Open cluster/node dialog from Summary screen. #8454

Merged
merged 6 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
common component status table
  • Loading branch information
rfellows committed Feb 27, 2024
commit a1ad75d6a605922ad90dde70bd9e3d508c92b12b
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ export const componentClusterStatusReducer = createReducer(
case ComponentType.Processor:
loadedTimestamp = response.clusterStatusEntity.processorStatus?.statsLastRefreshed || '';
break;
case ComponentType.RemoteProcessGroup:
loadedTimestamp = response.clusterStatusEntity.remoteProcessGroupStatus?.statsLastRefreshed || '';
break;
case ComponentType.ProcessGroup:
loadedTimestamp = response.clusterStatusEntity.processGroupStatus?.statsLastRefreshed || '';
break;
case ComponentType.InputPort:
case ComponentType.OutputPort:
loadedTimestamp = response.clusterStatusEntity.portStatus?.statsLastRefreshed || '';
break;
case ComponentType.Connection:
loadedTimestamp = response.clusterStatusEntity.connectionStatus?.statsLastRefreshed || '';
break;
default:
loadedTimestamp = '';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { ProcessorStatus } from '../index';
import { ConnectionStatus, PortStatus, ProcessGroupStatus, ProcessorStatus, RemoteProcessGroupStatus } from '../index';
import { ComponentType } from '../../../../state/shared';

export const componentClusterStatusFeatureKey = 'component-cluster-status';
Expand All @@ -33,6 +33,10 @@ export interface ComponentClusterStatusResponse {
export interface ClusterStatusEntity {
canRead: boolean;
processorStatus?: ProcessorStatus;
portStatus?: PortStatus;
processGroupStatus?: ProcessGroupStatus;
remoteProcessGroupStatus?: RemoteProcessGroupStatus;
connectionStatus?: ConnectionStatus;
}

export interface ComponentClusterStatusState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,71 @@ export interface NodeStatusSnapshot {
export interface NodeProcessorStatusSnapshot extends NodeStatusSnapshot {
statusSnapshot: ProcessorStatusSnapshot;
}
export interface NodePortStatusSnapshot extends NodeStatusSnapshot {
statusSnapshot: PortStatusSnapshot;
}

export interface NodeProcessGroupStatusSnapshot extends NodeStatusSnapshot {
statusSnapshot: ProcessGroupStatusSnapshot;
}

export interface NodeRemoteProcessGroupStatusSnapshot extends NodeStatusSnapshot {
statusSnapshot: RemoteProcessGroupStatusSnapshot;
}

export interface NodeConnectionStatusSnapshot extends NodeStatusSnapshot {
statusSnapshot: ConnectionStatusSnapshot;
}

export interface ProcessorStatus {
groupId: string;
id: string;
name: string;
type: string;
runStatus: string;
statsLastRefreshed: string;
aggregateSnapshot: ProcessorStatusSnapshot;
nodeSnapshots: NodeProcessorStatusSnapshot[];
}

export interface PortStatus {
groupId: string;
id: string;
name: string;
runStatus: string;
statsLastRefreshed: string;
aggregateSnapshot: PortStatusSnapshot;
nodeSnapshots: NodePortStatusSnapshot[];
}

export interface ProcessGroupStatus {
id: string;
name: string;
statsLastRefreshed: string;
aggregateSnapshot: ProcessGroupStatusSnapshot;
nodeSnapshots: NodeProcessGroupStatusSnapshot[];
}

export interface RemoteProcessGroupStatus {
groupId: string;
id: string;
name: string;
statsLastRefreshed: string;
targetUri: string;
transmissionStatus: string;
validationStatus: string;
aggregateSnapshot: RemoteProcessGroupStatusSnapshot;
nodeSnapshots: NodeRemoteProcessGroupStatusSnapshot[];
}

export interface ConnectionStatus {
groupId: string;
id: string;
name: string;
destinationId: string;
destinationName: string;
sourceId: string;
sourceName: string;
statsLastRefreshed: string;
aggregateSnapshot: ConnectionStatusSnapshot;
nodeSnapshots: NodeConnectionStatusSnapshot[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ export class ClusterSummaryDialog {
this.componentHelper.getName = () => this.clusterStatusEntity?.processorStatus?.name || '';
break;
case ComponentType.RemoteProcessGroup:
this.componentHelper.getName = () => this.clusterStatusEntity?.remoteProcessGroupStatus?.name || '';
break;
case ComponentType.ProcessGroup:
this.componentHelper.getName = () => this.clusterStatusEntity?.processGroupStatus?.name || '';
break;
case ComponentType.InputPort:
case ComponentType.OutputPort:
this.componentHelper.getName = () => this.clusterStatusEntity?.portStatus?.name || '';
break;
case ComponentType.Connection:
this.componentHelper.getName = () => this.clusterStatusEntity?.connectionStatus?.name || '';
break;
default:
throw 'Unsupported Component Type';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { NodeStatusSnapshot } from '../../../../state';

@Component({
selector: 'component-cluster-table',
standalone: true,
imports: [MatTableModule, MatSortModule],
template: ''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/*
* 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 { AfterViewInit, Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { BaseSnapshotEntity } from '../../../state';
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
import { MatSortModule, Sort, SortDirection } from '@angular/material/sort';
import { MultiSort } from '../index';
import { SummaryTableFilterContext } from '../summary-table-filter/summary-table-filter.component';
import { MatPaginator } from '@angular/material/paginator';
import { NodeSearchResult } from '../../../../../state/cluster-summary';

@Component({
selector: 'component-status-table',
standalone: true,
imports: [MatTableModule, MatSortModule],
template: ''
})
export abstract class ComponentStatusTable<T extends BaseSnapshotEntity> implements AfterViewInit {
private _summaryListingStatus: string | null = null;
private _loadedTimestamp: string | null = null;
private _initialSortColumn!: string;
private _initialSortDirection: SortDirection = 'asc';
private _connectedToCluster: boolean = false;
private _clusterNodes: NodeSearchResult[] | null = null;
private _selectedClusterNode: NodeSearchResult | null = null;
private _selectedId: string | null = null;
private currentFilter: SummaryTableFilterContext | null = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to be used (though maybe I missed it).


totalCount = 0;
filteredCount = 0;

multiSort: MultiSort = {
active: this._initialSortColumn,
direction: this._initialSortDirection,
sortValueIndex: 0,
totalValues: 2
};

dataSource: MatTableDataSource<T> = new MatTableDataSource<T>();
@ViewChild(MatPaginator) paginator!: MatPaginator;

ngAfterViewInit(): void {
this.dataSource.paginator = this.paginator;
}

abstract sortEntities(data: T[], sort: Sort): T[];

abstract supportsMultiValuedSort(sort: Sort): boolean;

abstract filterPredicate(data: T, filter: string): boolean;

applyFilter(filter: SummaryTableFilterContext) {
if (!filter || !this.dataSource) {
return;
}

// determine if the filter changing is the selected cluster node, if so a new query needs issued to the backend
if (filter.changedField === 'clusterNode' && filter.clusterNode) {
// need to re-issue the query with the selected cluster node id
this.clusterNodeSelected.next(filter.clusterNode);
}

this.currentFilter = filter;

this.dataSource.filter = JSON.stringify(filter);
this.filteredCount = this.dataSource.filteredData.length;
this.resetPaginator();
this.selectNone();
}

@Input() set initialSortColumn(initialSortColumn: string) {
this._initialSortColumn = initialSortColumn;
this.multiSort = { ...this.multiSort, active: initialSortColumn };
}

get initialSortColumn() {
return this._initialSortColumn;
}

@Input() set initialSortDirection(initialSortDirection: SortDirection) {
this._initialSortDirection = initialSortDirection;
this.multiSort = { ...this.multiSort, direction: initialSortDirection };
}

get initialSortDirection() {
return this._initialSortDirection;
}

@Input({}) set components(components: T[]) {
if (components) {
this.dataSource.data = this.sortEntities(components, this.multiSort);
this.dataSource.filterPredicate = (data: T, filter: string) => this.filterPredicate(data, filter);

this.totalCount = components.length;
if (this.dataSource.filteredData.length > 0) {
this.filteredCount = this.dataSource.filteredData.length;
} else {
this.filteredCount = components.length;
}
}
}

@Input() set loadedTimestamp(value: string | null) {
this._loadedTimestamp = value;
}

get loadedTimestamp(): string | null {
return this._loadedTimestamp;
}

@Input() set summaryListingStatus(value: string | null) {
this._summaryListingStatus = value;
}

get summaryListingStatus(): string | null {
return this._summaryListingStatus;
}

@Input() set connectedToCluster(value: boolean) {
this._connectedToCluster = value;
}

get connectedToCluster(): boolean {
return this._connectedToCluster;
}

@Input() set clusterNodes(nodes: NodeSearchResult[] | null) {
this._clusterNodes = nodes;
}

get clusterNodes(): NodeSearchResult[] | null {
return this._clusterNodes;
}

@Input() set selectedClusterNode(selectedClusterNode: NodeSearchResult | null) {
this._selectedClusterNode = selectedClusterNode;
}

get selectedClusterNode(): NodeSearchResult | null {
return this._selectedClusterNode;
}

@Input() set selectedId(selectedId: string | null) {
this._selectedId = selectedId;
}

get selectedId(): string | null {
return this._selectedId;
}

@Output() refresh: EventEmitter<void> = new EventEmitter<void>();
@Output() viewStatusHistory: EventEmitter<T> = new EventEmitter<T>();
@Output() selectComponent: EventEmitter<T> = new EventEmitter<T>();
@Output() viewClusteredDetails: EventEmitter<T> = new EventEmitter<T>();
@Output() clearSelection: EventEmitter<void> = new EventEmitter<void>();
@Output() clusterNodeSelected: EventEmitter<NodeSearchResult> = new EventEmitter<NodeSearchResult>();

resetPaginator(): void {
if (this.dataSource.paginator) {
this.dataSource.paginator.firstPage();
}
}

paginationChanged(): void {
// clear out any selection
this.selectNone();
}

selectNone() {
this.clearSelection.next();
}

sortData(sort: Sort) {
this.setMultiSort(sort);
this.dataSource.data = this.sortEntities(this.dataSource.data, sort);
}

compare(a: number | string, b: number | string, isAsc: boolean) {
return (a < b ? -1 : a > b ? 1 : 0) * (isAsc ? 1 : -1);
}

select(item: T) {
this.selectComponent.next(item);
}

isSelected(item: T): boolean {
if (this.selectedId) {
return this.selectedId === item.id;
}
return false;
}

viewStatusHistoryClicked(event: MouseEvent, component: T): void {
event.stopPropagation();
this.viewStatusHistory.next(component);
}

viewClusteredDetailsClicked(event: MouseEvent, component: T): void {
event.stopPropagation();
this.viewClusteredDetails.next(component);
}

private setMultiSort(sort: Sort) {
const { active, direction, sortValueIndex, totalValues } = this.multiSort;

if (this.supportsMultiValuedSort(sort)) {
if (active === sort.active) {
// previous sort was of the same column
if (direction === 'desc' && sort.direction === 'asc') {
// change from previous index to the next
const newIndex = sortValueIndex + 1 >= totalValues ? 0 : sortValueIndex + 1;
this.multiSort = { ...sort, sortValueIndex: newIndex, totalValues };
} else {
this.multiSort = { ...sort, sortValueIndex, totalValues };
}
} else {
// sorting a different column, just reset
this.multiSort = { ...sort, sortValueIndex: 0, totalValues };
}
} else {
this.multiSort = { ...sort, sortValueIndex: 0, totalValues };
}
}
}
Loading