diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.html
index ec25c80683..ba51cbc358 100644
--- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits-list.component.html
@@ -61,6 +61,6 @@
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 0c135d0d9a..e6ad1c5b20 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
@@ -19,7 +19,6 @@ import {
ControlValueAccessor,
FormArray,
FormBuilder,
- FormControl,
FormGroup,
NG_VALIDATORS,
NG_VALUE_ACCESSOR,
@@ -28,11 +27,7 @@ import {
Validators
} from '@angular/forms';
import { Subject, Subscription } from 'rxjs';
-import {
- RateLimits,
- rateLimitsArrayToString,
- stringToRateLimitsArray
-} from './rate-limits.models';
+import { RateLimits, rateLimitsArrayToString, stringToRateLimitsArray } from './rate-limits.models';
import { isDefinedAndNotNull } from '@core/utils';
import { takeUntil } from 'rxjs/operators';
@@ -59,11 +54,11 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
rateLimitsListFormGroup: FormGroup;
- rateLimitsControl: FormControl;
+ rateLimitsArray: Array;
- private propagateChange = (v: any) => { };
private valueChangeSubscription: Subscription = null;
private destroy$ = new Subject();
+ private propagateChange = (v: any) => { };
constructor(private fb: FormBuilder) {}
@@ -71,7 +66,6 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
this.rateLimitsListFormGroup = this.fb.group({
rateLimits: this.fb.array([])
});
- this.rateLimitsControl = this.fb.control(null);
this.valueChangeSubscription = this.rateLimitsListFormGroup.valueChanges
.pipe(takeUntil(this.destroy$))
.subscribe((value) => {
@@ -95,10 +89,6 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
return this.rateLimitsListFormGroup.get('rateLimits') as FormArray;
}
- get rateLimitsArray(): Array {
- return this.rateLimitsControl.value;
- }
-
registerOnChange(fn: any): void {
this.propagateChange = fn;
}
@@ -110,23 +100,21 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
this.disabled = isDisabled;
if (this.disabled) {
this.rateLimitsListFormGroup.disable({emitEvent: false});
- this.rateLimitsControl.disable({emitEvent: false});
} else {
this.rateLimitsListFormGroup.enable({emitEvent: false});
- this.rateLimitsControl.enable({emitEvent: false});
}
}
validate(): ValidationErrors | null {
- return this.rateLimitsListFormGroup.valid && this.rateLimitsControl.valid ? null : {
+ return this.rateLimitsListFormGroup.valid ? null : {
rateLimitsList: {valid: false}
};
}
- writeValue(value: string) {
+ writeValue(rateLimits: string) {
const rateLimitsControls: Array = [];
- if (value) {
- let rateLimitsArray = value.split(',');
+ if (rateLimits) {
+ const rateLimitsArray = rateLimits.split(',');
for (let i = 0; i < rateLimitsArray.length; i++) {
const [value, time] = rateLimitsArray[i].split(':');
const rateLimitsControl = this.fb.group({
@@ -140,7 +128,7 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
}
}
this.rateLimitsListFormGroup.setControl('rateLimits', this.fb.array(rateLimitsControls), {emitEvent: false});
- this.rateLimitsControl.patchValue(stringToRateLimitsArray(value), {emitEvent: false});
+ this.rateLimitsArray = stringToRateLimitsArray(rateLimits);
}
updateView(rateLimitsArray: Array) {
@@ -150,10 +138,10 @@ export class RateLimitsListComponent implements ControlValueAccessor, Validator,
);
const rateLimitsString = rateLimitsArrayToString(notNullRateLimits);
this.propagateChange(rateLimitsString);
- this.rateLimitsControl.patchValue(stringToRateLimitsArray(rateLimitsString), {emitEvent: false});
+ this.rateLimitsArray = stringToRateLimitsArray(rateLimitsString);
} else {
this.propagateChange(null);
- this.rateLimitsControl.patchValue(null, {emitEvent: false});
+ this.rateLimitsArray = null;
}
}
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 0b65e97d5d..9081acc208 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
@@ -33,7 +33,8 @@ export class RateLimitsTextComponent implements OnChanges {
rateLimitsText: string;
- constructor(private translate: TranslateService) {}
+ constructor(private translate: TranslateService) {
+ }
ngOnChanges(changes: SimpleChanges): void {
for (const propName of Object.keys(changes)) {
diff --git a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.html b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.html
index ac341c8b69..0ab20fc533 100644
--- a/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/tenant/rate-limits/rate-limits.component.html
@@ -21,7 +21,7 @@
-
+