diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html index 847aae7bf1..a3f285bece 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.html @@ -422,18 +422,18 @@ {{ 'tenant-profile.rate-limits.rate-limits' | translate }}
- -
- -
@@ -445,34 +445,34 @@
- -
- -
- -
- -
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts index d44715cc63..9649966bd1 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/default-tenant-profile-configuration.component.ts @@ -21,7 +21,7 @@ import { AppState } from '@app/core/core.state'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { DefaultTenantProfileConfiguration, TenantProfileConfiguration } from '@shared/models/tenant.model'; import { isDefinedAndNotNull } from '@core/utils'; -import { RateLimitsType } from '@shared/models/rate-limits.models'; +import { RateLimitsType } from './rate-limits/rate-limits.models'; @Component({ selector: 'tb-default-tenant-profile-configuration', diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.html index 751ffe0e2c..6cbe5472c2 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.html @@ -25,14 +25,11 @@ close - -
-
+
+ formControlName="rateLimits">
@@ -40,12 +37,11 @@
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.ts index 790ca57838..80b9e1ba34 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-details-dialog.component.ts @@ -19,7 +19,7 @@ import { ErrorStateMatcher } from '@angular/material/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { AppState } from '@core/core.state'; -import { FormBuilder, FormControl, FormGroup, FormGroupDirective, NgForm } from '@angular/forms'; +import { FormBuilder, FormGroup } from '@angular/forms'; import { Router } from '@angular/router'; import { DialogComponent } from '@app/shared/components/dialog.component'; import { TranslateService } from '@ngx-translate/core'; @@ -31,16 +31,12 @@ export interface RateLimitsDetailsDialogData { } @Component({ - templateUrl: './rate-limits-details-dialog.component.html', - providers: [{provide: ErrorStateMatcher, useExisting: RateLimitsDetailsDialogComponent}] + templateUrl: './rate-limits-details-dialog.component.html' }) -export class RateLimitsDetailsDialogComponent extends DialogComponent - implements OnInit, ErrorStateMatcher { +export class RateLimitsDetailsDialogComponent extends DialogComponent implements OnInit { editDetailsFormGroup: FormGroup; - submitted: boolean = false; - rateLimits: string = this.data.rateLimits; title: string = this.data.title; @@ -49,7 +45,7 @@ export class RateLimitsDetailsDialogComponent extends DialogComponent, + public dialogRef: MatDialogRef, private fb: FormBuilder, public translate: TranslateService) { super(store, router, dialogRef); @@ -65,18 +61,11 @@ export class RateLimitsDetailsDialogComponent extends DialogComponent -
-
-
+
+
+
tenant-profile.rate-limits.but-less-than
@@ -45,7 +45,7 @@
-
- -
+
tenant-profile.rate-limits.preview
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.ts index eb7a37cfde..dd5f52dbc2 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.ts @@ -32,7 +32,7 @@ import { RateLimits, rateLimitsArrayToString, stringToRateLimitsArray -} from '@shared/models/rate-limits.models'; +} from './rate-limits.models'; import { isDefinedAndNotNull } from '@core/utils'; @Component({ @@ -68,17 +68,17 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator, } ngOnInit(): void { - this.rateLimitsListFormGroup = this.fb.group({}); - this.rateLimitsListFormGroup.addControl('rateLimits', - this.fb.array([])); + this.rateLimitsListFormGroup = this.fb.group({ + rateLimits: this.fb.array([]) + }); this.rateLimitsControl = this.fb.control(null); - this.rateLimitsListFormGroup.valueChanges.subscribe((value) => { + this.valueChangeSubscription = this.rateLimitsListFormGroup.valueChanges.subscribe((value) => { this.updateView(value?.rateLimits); } ); } - rateLimitsFormArray(): FormArray { + get rateLimitsFormArray(): FormArray { return this.rateLimitsListFormGroup.get('rateLimits') as FormArray; } @@ -107,16 +107,11 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator, } writeValue(value: string) { - if (this.valueChangeSubscription) { - this.valueChangeSubscription.unsubscribe(); - } const rateLimitsControls: Array = []; if (value) { let rateLimitsArray = value.split(','); for (let i = 0; i < rateLimitsArray.length; i++) { - let valueTime = rateLimitsArray[i].split(':'); - let value = valueTime[0]; - let time = valueTime[1]; + const [value, time] = rateLimitsArray[i].split(':'); const rateLimitsControl = this.fb.group({ value: [value, [Validators.required]], time: [time, [Validators.required]] @@ -127,11 +122,8 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator, rateLimitsControls.push(rateLimitsControl); } } - this.rateLimitsListFormGroup.setControl('rateLimits', this.fb.array(rateLimitsControls)); + this.rateLimitsListFormGroup.setControl('rateLimits', this.fb.array(rateLimitsControls), {emitEvent: false}); this.rateLimitsControl.patchValue(stringToRateLimitsArray(value), {emitEvent: false}); - this.valueChangeSubscription = this.rateLimitsListFormGroup.valueChanges.subscribe((value) => { - this.updateView(value?.rateLimits); - }); } public removeRateLimits(index: number) { @@ -139,17 +131,17 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator, } public addRateLimits() { - const rateLimitsArray = this.rateLimitsListFormGroup.get('rateLimits') as FormArray; - rateLimitsArray.push(this.fb.group({ + this.rateLimitsFormArray.push(this.fb.group({ value: [null, [Validators.required]], time: [null, [Validators.required]] })); - this.rateLimitsListFormGroup.updateValueAndValidity(); } updateView(rateLimitsArray: Array) { if (rateLimitsArray.length > 0) { - const notNullRateLimits = rateLimitsArray.filter(rateLimits => isDefinedAndNotNull(rateLimits.value) && isDefinedAndNotNull(rateLimits.time)); + const notNullRateLimits = rateLimitsArray.filter(rateLimits => + isDefinedAndNotNull(rateLimits.value) && isDefinedAndNotNull(rateLimits.time) + ); const rateLimitsString = rateLimitsArrayToString(notNullRateLimits); this.propagateChange(rateLimitsString); this.rateLimitsControl.patchValue(stringToRateLimitsArray(rateLimitsString), {emitEvent: false}); diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.html index 98a30b055e..077ede2e0b 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.html +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.html @@ -15,5 +15,5 @@ limitations under the License. --> -
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.scss b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.scss index a8f8f8553f..b78f1033bd 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.scss +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.scss @@ -20,14 +20,6 @@ &.disabled { opacity: 0.7; } - &.required { - color: #f44336; - padding: 0 4px; - } - &.nowrap { - white-space: nowrap; - overflow: hidden; - } } } diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.ts index 9ab7e9b56b..604318d6fd 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-text.component.ts @@ -18,8 +18,7 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core'; import { ControlValueAccessor, FormBuilder, NG_VALUE_ACCESSOR } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; -import { coerceBooleanProperty } from '@angular/cdk/coercion'; -import { RateLimits, rateLimitsArrayToHtml } from '@shared/models/rate-limits.models'; +import { RateLimits, rateLimitsArrayToHtml } from './rate-limits.models'; @Component({ selector: 'tb-rate-limits-text', @@ -35,26 +34,11 @@ import { RateLimits, rateLimitsArrayToHtml } from '@shared/models/rate-limits.mo }) export class RateLimitsTextComponent implements ControlValueAccessor, OnInit { - private requiredValue: boolean; - get required(): boolean { - return this.requiredValue; - } - @Input() - set required(value: boolean) { - this.requiredValue = coerceBooleanProperty(value); - } - @Input() disabled: boolean; - @Input() noRateLimitsText = this.translate.instant('tenant-profile.rate-limits.not-set'); - @Input() - nowrap = false; - - requiredClass = false; - public rateLimitsText: string; private propagateChange = (v: any) => { }; @@ -83,15 +67,10 @@ export class RateLimitsTextComponent implements ControlValueAccessor, OnInit { } private updateText(value: Array) { - this.requiredClass = false; if (value && value.length) { this.rateLimitsText = rateLimitsArrayToHtml(this.translate, value); } else { - if (this.required && !this.disabled) { - this.requiredClass = true; - } else { - this.rateLimitsText = this.noRateLimitsText; - } + this.rateLimitsText = this.noRateLimitsText; } } diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.ts index 753ef133a9..dcf0403a22 100644 --- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.ts +++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.ts @@ -34,7 +34,7 @@ import { rateLimitsLabelTranslationMap, RateLimitsType, stringToRateLimitsArray -} from '@shared/models/rate-limits.models'; +} from './rate-limits.models'; @Component({ selector: 'tb-rate-limits', diff --git a/ui-ngx/src/app/shared/models/rate-limits.models.ts b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts similarity index 100% rename from ui-ngx/src/app/shared/models/rate-limits.models.ts rename to ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.models.ts