From 2cd462482567e6be13cbee71b80d942933f0b68f Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 29 May 2024 16:23:15 -0400 Subject: [PATCH] NIFI-13299: (#8894) - Adding min validators where appropriate. This closes #8894 --- .../create-connection.component.html | 60 ++++++++++++++++--- .../create-connection.component.ts | 5 +- .../edit-connection.component.html | 3 +- .../edit-connection.component.ts | 5 +- .../edit-processor.component.html | 3 +- .../edit-processor.component.ts | 50 ++++++++++++++-- .../relationship-settings.component.html | 5 +- 7 files changed, 113 insertions(+), 18 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/create-connection/create-connection.component.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/create-connection/create-connection.component.html index 2626d70b1c..f06a5111f4 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/create-connection/create-connection.component.html +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/create-connection/create-connection.component.html @@ -100,20 +100,45 @@
- FlowFile Expiration + + FlowFile Expiration + +
- Back Pressure Object Threshold - + + Back Pressure Object Threshold + + +
- Size Threshold + + Size Threshold + +
@@ -121,7 +146,14 @@
- Load Balance Strategy + + Load Balance Strategy + + @@ -141,7 +173,14 @@ @if (loadBalancePartitionAttributeRequired) {
- Attribute Name + + Attribute Name + +
@@ -150,7 +189,14 @@ @if (loadBalanceCompressionRequired) {
- Load Balance Compression + + Load Balance Compression + + @for (option of loadBalanceCompressionStrategies; track option) { + tooltipInputData="The maximum number of objects that can be queued before back pressure is applied. Must be a non-negative integer.">
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/edit-connection/edit-connection.component.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/edit-connection/edit-connection.component.ts index 87de6ec284..20fb3b118c 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/edit-connection/edit-connection.component.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/connection/edit-connection/edit-connection.component.ts @@ -264,7 +264,10 @@ export class EditConnectionComponent extends TabbedDialog { this.editConnectionForm = this.formBuilder.group({ name: new FormControl(connection.name), flowFileExpiration: new FormControl(connection.flowFileExpiration, Validators.required), - backPressureObjectThreshold: new FormControl(connection.backPressureObjectThreshold, Validators.required), + backPressureObjectThreshold: new FormControl(connection.backPressureObjectThreshold, [ + Validators.required, + Validators.min(0) + ]), backPressureDataSizeThreshold: new FormControl( connection.backPressureDataSizeThreshold, Validators.required diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.html index 1574f57510..ac8c23d9b7 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.html +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.html @@ -151,7 +151,7 @@ class="fa fa-info-circle" nifiTooltip [tooltipComponentType]="TextTip" - tooltipInputData="The number of tasks that should be concurrently scheduled for this processor."> + tooltipInputData="The number of tasks that should be concurrently scheduled for this processor. Must be an integer greater than 0.">
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.ts index b435ecc61b..4a272c0012 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/edit-processor.component.ts @@ -17,7 +17,16 @@ import { Component, EventEmitter, Inject, Input, Output } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; -import { AbstractControl, FormBuilder, FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms'; +import { + AbstractControl, + FormBuilder, + FormControl, + FormGroup, + ReactiveFormsModule, + ValidationErrors, + ValidatorFn, + Validators +} from '@angular/forms'; import { MatInputModule } from '@angular/material/input'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { MatButtonModule } from '@angular/material/button'; @@ -226,14 +235,14 @@ export class EditProcessor extends TabbedDialog { yieldDuration: new FormControl(request.entity.component.config.yieldDuration, Validators.required), bulletinLevel: new FormControl(request.entity.component.config.bulletinLevel, Validators.required), schedulingStrategy: new FormControl(this.schedulingStrategy, Validators.required), - concurrentTasks: new FormControl(concurrentTasks, Validators.required), + concurrentTasks: new FormControl(concurrentTasks, [Validators.required, Validators.min(1)]), schedulingPeriod: new FormControl(schedulingPeriod, Validators.required), executionNode: new FormControl(request.entity.component.config.executionNode, Validators.required), properties: new FormControl({ value: properties, disabled: this.readonly }), - relationshipConfiguration: new FormControl( - { value: relationshipConfiguration, disabled: this.readonly }, - Validators.required - ), + relationshipConfiguration: new FormControl({ value: relationshipConfiguration, disabled: this.readonly }, [ + Validators.required, + this.relationshipConfigurationValidator() + ]), comments: new FormControl(request.entity.component.config.comments) }); @@ -245,6 +254,35 @@ export class EditProcessor extends TabbedDialog { } } + private relationshipConfigurationValidator(): ValidatorFn { + return (control: AbstractControl): ValidationErrors | null => { + const relationshipConfiguration: RelationshipConfiguration = control.value; + const retried: string[] = relationshipConfiguration.relationships + .filter((relationship) => relationship.retry) + .map((relationship) => relationship.name); + + if (retried.length > 0) { + let hasErrors = false; + const errors: ValidationErrors = {}; + + if (relationshipConfiguration.retryCount == null || relationshipConfiguration.retryCount < 0) { + errors['invalidRetry'] = true; + hasErrors = true; + } + if (this.nifiCommon.isBlank(relationshipConfiguration.maxBackoffPeriod)) { + errors['invalidBackoff'] = true; + hasErrors = true; + } + + if (hasErrors) { + return errors; + } + } + + return null; + }; + } + supportsBatching(): boolean { return this.request.entity.component.supportsBatching == true; } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/relationship-settings/relationship-settings.component.html b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/relationship-settings/relationship-settings.component.html index 7d63cc8472..7e80e7122c 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/relationship-settings/relationship-settings.component.html +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/items/processor/edit-processor/relationship-settings/relationship-settings.component.html @@ -71,14 +71,16 @@ class="fa fa-info-circle" nifiTooltip [tooltipComponentType]="TextTip" - tooltipInputData="For relationships set to retry, this number indicates how many times a FlowFile will attempt to reprocess before it is routed elsewhere."> + tooltipInputData="For relationships set to retry, this number indicates how many times a FlowFile will attempt to reprocess before it is routed elsewhere. Must be a non-negative integer.">
@@ -115,6 +117,7 @@ [(ngModel)]="maxBackoffPeriod" type="text" (keyup)="handleChanged()" + [required]="true" [readonly]="isDisabled" />