Skip to content

Commit

Permalink
NIFI-3785: removed need for second api call
Browse files Browse the repository at this point in the history
  • Loading branch information
Freedom9339 committed Oct 16, 2024
1 parent 89cc753 commit 5a00e3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import { Injectable } from '@angular/core';
import { EMPTY, Observable, of } from 'rxjs';
import { EMPTY, Observable } from 'rxjs';
import { HttpClient, HttpParams } from '@angular/common/http';
import { Client } from '../../../service/client.service';
import { NiFiCommon } from '@nifi/shared';
Expand Down Expand Up @@ -45,17 +45,13 @@ export class ControllerServiceService implements ControllerServiceCreator, Prope
) {}

getControllerServices(processGroupId: string): Observable<any> {
if (processGroupId != '') {
const uiOnly: any = { uiOnly: true };
return this.httpClient.get(
`${ControllerServiceService.API}/flow/process-groups/${processGroupId}/controller-services`,
{
params: uiOnly
}
);
} else {
return of([]);
}
const uiOnly: any = { uiOnly: true };
return this.httpClient.get(
`${ControllerServiceService.API}/flow/process-groups/${processGroupId}/controller-services`,
{
params: uiOnly
}
);
}

getFlow(processGroupId: string): Observable<any> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import {
selectCurrentProcessGroupId,
selectParameterContext,
selectSaving,
selectStatus
selectStatus,
selectServices
} from './controller-services.selectors';
import { ControllerServiceService } from '../../service/controller-service.service';
import { EnableControllerService } from '../../../../ui/common/controller-service/enable-controller-service/enable-controller-service.component';
Expand Down Expand Up @@ -661,22 +662,18 @@ export class ControllerServicesEffects {
map((action) => action.request),
concatLatestFrom(() => [
this.store.select(selectCurrentProcessGroupId),
this.store.select(selectProcessGroupFlow)
this.store.select(selectProcessGroupFlow),
this.store.select(selectServices)
]),
concatMap(([request, currentProcessGroupId, processGroupFlow]) =>
combineLatest([
this.flowService.getProcessGroupWithContent(currentProcessGroupId),
this.controllerServiceService.getControllerServices(
processGroupFlow?.breadcrumb.parentBreadcrumb?.id || ''
)
]).pipe(
map(([processGroupEntity, parentControllerServices]) => {
concatMap(([request, currentProcessGroupId, processGroupFlow, controllerServices]) =>
combineLatest([this.flowService.getProcessGroupWithContent(currentProcessGroupId)]).pipe(
map(([processGroupEntity]) => {
return {
request,
currentProcessGroupId,
processGroupFlow,
processGroupEntity,
parentControllerServices
controllerServices
};
})
)
Expand All @@ -685,7 +682,7 @@ export class ControllerServicesEffects {
const clone = Object.assign({}, request.request);
clone.processGroupEntity = request.processGroupEntity;
clone.processGroupFlow = request.processGroupFlow;
clone.parentControllerServices = request.parentControllerServices.controllerServices;
clone.parentControllerServices = request.controllerServices;
const serviceId: string = request.request.id;
const moveDialogReference = this.dialog.open(MoveControllerService, {
...LARGE_DIALOG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ export class MoveControllerService extends CloseOnEscapeDialog {
processGroups: new FormControl('Process Group', Validators.required)
});

const parentControllerServices = request.parentControllerServices.filter(
(cs) => cs.parentGroupId != request.controllerService.parentGroupId
);

if (request.processGroupFlow != null) {
const processGroups: SelectOption[] = [];
this.loadParentOption(request.processGroupFlow, request.parentControllerServices, processGroups);
this.loadParentOption(request.processGroupFlow, parentControllerServices, processGroups);
this.loadChildOptions(request.processGroupFlow, request.processGroupEntity, processGroups);
this.controllerServiceActionProcessGroups = processGroups;

Expand Down

0 comments on commit 5a00e3d

Please sign in to comment.