Commit 82f44971c87229f1fc3234d9651651a02858daeb
1 parent
75817a16
UI: Added protection for invalid device profile alarm condition data
Showing
1 changed file
with
3 additions
and
5 deletions
@@ -26,9 +26,8 @@ import { | @@ -26,9 +26,8 @@ import { | ||
26 | Validators | 26 | Validators |
27 | } from '@angular/forms'; | 27 | } from '@angular/forms'; |
28 | import { MatDialog } from '@angular/material/dialog'; | 28 | import { MatDialog } from '@angular/material/dialog'; |
29 | -import { deepClone, isUndefined } from '@core/utils'; | 29 | +import { deepClone, isDefinedAndNotNull } from '@core/utils'; |
30 | import { TranslateService } from '@ngx-translate/core'; | 30 | import { TranslateService } from '@ngx-translate/core'; |
31 | -import { DatePipe } from '@angular/common'; | ||
32 | import { AlarmCondition, AlarmConditionType } from '@shared/models/device.models'; | 31 | import { AlarmCondition, AlarmConditionType } from '@shared/models/device.models'; |
33 | import { | 32 | import { |
34 | AlarmRuleConditionDialogComponent, | 33 | AlarmRuleConditionDialogComponent, |
@@ -73,8 +72,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit | @@ -73,8 +72,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit | ||
73 | 72 | ||
74 | constructor(private dialog: MatDialog, | 73 | constructor(private dialog: MatDialog, |
75 | private fb: FormBuilder, | 74 | private fb: FormBuilder, |
76 | - private translate: TranslateService, | ||
77 | - private datePipe: DatePipe) { | 75 | + private translate: TranslateService) { |
78 | } | 76 | } |
79 | 77 | ||
80 | registerOnChange(fn: any): void { | 78 | registerOnChange(fn: any): void { |
@@ -102,7 +100,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit | @@ -102,7 +100,7 @@ export class AlarmRuleConditionComponent implements ControlValueAccessor, OnInit | ||
102 | 100 | ||
103 | writeValue(value: AlarmCondition): void { | 101 | writeValue(value: AlarmCondition): void { |
104 | this.modelValue = value; | 102 | this.modelValue = value; |
105 | - if (this.modelValue !== null && isUndefined(this.modelValue?.spec)) { | 103 | + if (this.modelValue !== null && !isDefinedAndNotNull(this.modelValue?.spec?.predicate)) { |
106 | this.modelValue = Object.assign(this.modelValue, {spec: {type: AlarmConditionType.SIMPLE}}); | 104 | this.modelValue = Object.assign(this.modelValue, {spec: {type: AlarmConditionType.SIMPLE}}); |
107 | } | 105 | } |
108 | this.updateConditionInfo(); | 106 | this.updateConditionInfo(); |