Browse Source

Merge pull request #15825 from vvlladd28/merge/220626/rc

Merge rc into master
pull/15839/head
Vladyslav Prykhodko 4 weeks ago
committed by GitHub
parent
commit
c3da03c3d2
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 7
      ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts
  2. 10
      ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts
  3. 8
      ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts
  4. 16
      ui-ngx/src/app/shared/components/time-unit-input.component.ts

7
ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition.component.ts

@ -142,10 +142,9 @@ export class CfAlarmRuleConditionComponent implements ControlValueAccessor, Vali
}
ngOnChanges(changes: SimpleChanges) {
if (changes.arguments) {
if (changes.arguments && !changes.arguments.firstChange) {
this.recalculateArgumentValidity();
}
if (changes.arguments && !changes.arguments.firstChange) {
this.recalculateArgumentValidity();
this.onValidatorChange();
}
}

10
ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule.component.ts

@ -84,6 +84,7 @@ export class CfAlarmRuleComponent implements ControlValueAccessor, OnInit, Valid
});
private propagateChange = (v: any) => { };
private onValidatorChange = () => { };
constructor(private dialog: MatDialog,
private fb: FormBuilder,
@ -97,12 +98,21 @@ export class CfAlarmRuleComponent implements ControlValueAccessor, OnInit, Valid
registerOnTouched(fn: any): void {
}
registerOnValidatorChange(fn: () => void): void {
this.onValidatorChange = fn;
}
ngOnInit() {
this.alarmRuleFormGroup.valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => {
this.updateModel();
});
this.alarmRuleFormGroup.statusChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => {
this.onValidatorChange();
});
}
setDisabledState(isDisabled: boolean): void {

8
ui-ngx/src/app/modules/home/components/alarm-rules/create-cf-alarm-rules.component.ts

@ -77,12 +77,16 @@ export class CreateCfAlarmRulesComponent implements ControlValueAccessor, Valida
private usedSeverities: AlarmSeverity[] = [];
private propagateChange = (v: any) => { };
private onValidatorChange = () => { };
constructor(private fb: FormBuilder,
private destroyRef: DestroyRef) {
this.createAlarmRulesFormGroup.valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => this.updateModel());
this.createAlarmRulesFormGroup.statusChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(() => this.onValidatorChange());
}
registerOnChange(fn: any): void {
@ -92,6 +96,10 @@ export class CreateCfAlarmRulesComponent implements ControlValueAccessor, Valida
registerOnTouched(fn: any): void {
}
registerOnValidatorChange(fn: () => void): void {
this.onValidatorChange = fn;
}
createAlarmRulesFormArray(): UntypedFormArray {
return this.createAlarmRulesFormGroup.get('createAlarmRules') as UntypedFormArray;
}

16
ui-ngx/src/app/shared/components/time-unit-input.component.ts

@ -206,15 +206,13 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator,
writeValue(sec: number) {
if (sec !== this.modelValue) {
if (isDefinedAndNotNull(sec) && isNumeric(sec) && Number(sec) !== 0) {
this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: true});
this.timeInputForm.patchValue(this.parseTime(sec), {emitEvent: false});
this.modelValue = sec;
} else {
this.timeInputForm.patchValue({
time: 0,
timeUnit: TimeUnit.SECONDS
}, {emitEvent: false});
this.timeInputForm.patchValue(this.secondsModel(0), {emitEvent: false});
this.modelValue = 0;
}
this.refreshTimeValidators();
}
}
@ -242,6 +240,14 @@ export class TimeUnitInputComponent implements ControlValueAccessor, Validator,
}
}
}
return this.secondsModel(value);
}
private secondsModel(time: number): TimeUnitInputModel {
return {
time,
timeUnit: TimeUnit.SECONDS
};
}
private createStepMultipleOfValidator(): ValidatorFn {

Loading…
Cancel
Save