Merge pull request #5187 from vvlladd28/bug/device-profile/alarm-rule/duration
[3.3.1] UI: Added protection for invalid device profile alarm condition data
This commit is contained in:
commit
f84c4fe3a6
@ -26,9 +26,8 @@ import {
|
|||||||
Validators
|
Validators
|
||||||
} from '@angular/forms';
|
} from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { deepClone, isUndefined } from '@core/utils';
|
import { deepClone, isDefinedAndNotNull } from '@core/utils';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DatePipe } from '@angular/common';
|
|
||||||
import { AlarmCondition, AlarmConditionType } from '@shared/models/device.models';
|
import { AlarmCondition, AlarmConditionType } from '@shared/models/device.models';
|
||||||
import {
|
import {
|
||||||
AlarmRuleConditionDialogComponent,
|
AlarmRuleConditionDialogComponent,
|
||||||
@ -73,8 +72,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit
|
|||||||
|
|
||||||
constructor(private dialog: MatDialog,
|
constructor(private dialog: MatDialog,
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService) {
|
||||||
private datePipe: DatePipe) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
registerOnChange(fn: any): void {
|
registerOnChange(fn: any): void {
|
||||||
@ -102,7 +100,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit
|
|||||||
|
|
||||||
writeValue(value: AlarmCondition): void {
|
writeValue(value: AlarmCondition): void {
|
||||||
this.modelValue = value;
|
this.modelValue = value;
|
||||||
if (this.modelValue !== null && isUndefined(this.modelValue?.spec)) {
|
if (this.modelValue !== null && !isDefinedAndNotNull(this.modelValue?.spec?.predicate)) {
|
||||||
this.modelValue = Object.assign(this.modelValue, {spec: {type: AlarmConditionType.SIMPLE}});
|
this.modelValue = Object.assign(this.modelValue, {spec: {type: AlarmConditionType.SIMPLE}});
|
||||||
}
|
}
|
||||||
this.updateConditionInfo();
|
this.updateConditionInfo();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user