NIFI-13204: (#8798)

- Adding the Enable/Disable All Controller Service context menu items.

This closes #8798
This commit is contained in:
Matt Gilman 2024-05-10 09:55:39 -04:00 committed by GitHub
parent 87776e369e
commit dcf66fd105
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 121 additions and 32 deletions

View File

@ -813,47 +813,33 @@ export class CanvasContextMenu implements ContextMenuDefinitionProvider {
isSeparator: true
},
{
condition: (selection: any) => {
// return this.canvasUtils.isProcessGroup(selection);
return false;
condition: (selection: d3.Selection<any, any, any, any>) => {
return this.canvasUtils.isProcessGroup(selection) || this.canvasUtils.emptySelection(selection);
},
clazz: 'fa fa-flash',
text: 'Enable All Controller Services',
action: () => {
// TODO - enableAllControllerServices
action: (selection: d3.Selection<any, any, any, any>) => {
if (selection.empty()) {
this.store.dispatch(FlowActions.enableControllerServicesInCurrentProcessGroup());
} else {
const d: any = selection.datum();
this.store.dispatch(FlowActions.enableControllerServicesInProcessGroup({ id: d.id }));
}
}
},
{
condition: (selection: any) => {
// return this.canvasUtils.emptySelection(selection);
return false;
},
clazz: 'fa fa-flash',
text: 'Enable All Controller Services',
action: () => {
// TODO - enableAllControllerServices
}
},
{
condition: (selection: any) => {
// return this.canvasUtils.isProcessGroup(selection);
return false;
condition: (selection: d3.Selection<any, any, any, any>) => {
return this.canvasUtils.isProcessGroup(selection) || this.canvasUtils.emptySelection(selection);
},
clazz: 'icon icon-enable-false',
text: 'Disable All Controller Services',
action: () => {
// TODO - disableAllControllerServices
}
},
{
condition: (selection: any) => {
// return this.canvasUtils.emptySelection(selection);
return false;
},
clazz: 'icon icon-enable-false',
text: 'Disable All Controller Services',
action: () => {
// TODO - disableAllControllerServices
action: (selection: d3.Selection<any, any, any, any>) => {
if (selection.empty()) {
this.store.dispatch(FlowActions.disableControllerServicesInCurrentProcessGroup());
} else {
const d: any = selection.datum();
this.store.dispatch(FlowActions.disableControllerServicesInProcessGroup({ id: d.id }));
}
}
},
{

View File

@ -20,6 +20,7 @@ import { Observable } from 'rxjs';
import { HttpClient, HttpParams } from '@angular/common/http';
import {
ComponentRunStatusRequest,
ControllerServiceStateRequest,
CreateComponentRequest,
CreateConnection,
CreatePortRequest,
@ -292,6 +293,24 @@ export class FlowService implements PropertyDescriptorRetriever {
return this.httpClient.put(`${this.nifiCommon.stripProtocol(request.uri)}/run-status`, disableRequest);
}
enableAllControllerServices(id: string): Observable<any> {
const enableRequest: ControllerServiceStateRequest = {
id,
state: 'ENABLED',
disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
};
return this.httpClient.put(`${FlowService.API}/flow/process-groups/${id}/controller-services`, enableRequest);
}
disableAllControllerServices(id: string): Observable<any> {
const disableRequest: ControllerServiceStateRequest = {
id,
state: 'DISABLED',
disconnectedNodeAcknowledged: this.clusterConnectionService.isDisconnectionAcknowledged()
};
return this.httpClient.put(`${FlowService.API}/flow/process-groups/${id}/controller-services`, disableRequest);
}
startComponent(request: StartComponentRequest): Observable<any> {
const startRequest: ComponentRunStatusRequest = {
revision: request.revision,

View File

@ -691,6 +691,24 @@ export const startCurrentProcessGroup = createAction(`${CANVAS_PREFIX} Start Cur
export const stopCurrentProcessGroup = createAction(`${CANVAS_PREFIX} Stop Current Process Group`);
export const enableControllerServicesInCurrentProcessGroup = createAction(
`${CANVAS_PREFIX} Enable Controller Services In Current Process Group`
);
export const disableControllerServicesInCurrentProcessGroup = createAction(
`${CANVAS_PREFIX} Disable Controller Services In Current Process Group`
);
export const enableControllerServicesInProcessGroup = createAction(
`${CANVAS_PREFIX} Enable Controller Services In Process Group`,
props<{ id: string }>()
);
export const disableControllerServicesInProcessGroup = createAction(
`${CANVAS_PREFIX} Disable Controller Services In Process Group`,
props<{ id: string }>()
);
export const openChangeVersionDialogRequest = createAction(
`${CANVAS_PREFIX} Open Change Flow Version Dialog Request`,
props<{ request: OpenChangeVersionDialogRequest }>()

View File

@ -2921,6 +2921,66 @@ export class FlowEffects {
)
);
enableControllerServicesInCurrentProcessGroup$ = createEffect(() =>
this.actions$.pipe(
ofType(FlowActions.enableControllerServicesInCurrentProcessGroup),
concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)),
switchMap(([, id]) =>
from(
this.flowService.enableAllControllerServices(id).pipe(
map(() => FlowActions.reloadFlow()),
catchError((errorResponse) => of(this.snackBarOrFullScreenError(errorResponse)))
)
)
)
)
);
disableControllerServicesInCurrentProcessGroup$ = createEffect(() =>
this.actions$.pipe(
ofType(FlowActions.disableControllerServicesInCurrentProcessGroup),
concatLatestFrom(() => this.store.select(selectCurrentProcessGroupId)),
switchMap(([, id]) =>
from(
this.flowService.disableAllControllerServices(id).pipe(
map(() => FlowActions.reloadFlow()),
catchError((errorResponse) => of(this.snackBarOrFullScreenError(errorResponse)))
)
)
)
)
);
enableControllerServicesInProcessGroup$ = createEffect(() =>
this.actions$.pipe(
ofType(FlowActions.enableControllerServicesInProcessGroup),
map((action) => action.id),
switchMap((id) =>
from(
this.flowService.enableAllControllerServices(id).pipe(
map(() => FlowActions.loadChildProcessGroup({ request: { id } })),
catchError((errorResponse) => of(this.snackBarOrFullScreenError(errorResponse)))
)
)
)
)
);
disableControllerServicesInProcessGroup$ = createEffect(() =>
this.actions$.pipe(
ofType(FlowActions.disableControllerServicesInProcessGroup),
map((action) => action.id),
switchMap((id) =>
from(
this.flowService.disableAllControllerServices(id).pipe(
map(() => FlowActions.loadChildProcessGroup({ request: { id } })),
catchError((errorResponse) => of(this.snackBarOrFullScreenError(errorResponse)))
)
)
)
)
);
stopComponents$ = createEffect(() =>
this.actions$.pipe(
ofType(FlowActions.stopComponents),

View File

@ -782,6 +782,12 @@ export interface StopComponentsRequest {
components: StopComponentRequest[];
}
export interface ControllerServiceStateRequest {
id: string;
state: string;
disconnectedNodeAcknowledged: boolean;
}
export interface TerminateThreadsRequest {
id: string;
uri: string;