-
-
-
+ @if (predicatesFormArray.length) {
+
-
-
- @for (predicateControl of predicatesFormArray.controls; track predicateControl; let index = $index) {
-
- @if (index) {
-
- {{ complexOperationTranslations.get(operation) | translate }}
-
- }
-
-
-
-
-
+
+
+ @for (predicateControl of predicatesFormArray.controls; track predicateControl; let index = $index) {
+
+ @if (index) {
+
+ {{ complexOperationTranslations.get(operation) | translate }}
+
+ }
+
-
- }
- @if (!predicatesFormArray.length) {
-
- alarm-rule.no-filter
-
-
- }
+ }
+
-
-
+ } @else {
+
alarm-rule.no-filter
+ }
+
}
}
- @if (filterPredicateFormGroup.get('operation').value === stringOperation.NO_DATA) {
-
-
- } @else if (type !== filterPredicateType.COMPLEX) {
-
-
- }
+
+
+
+
diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts
index 2f542f048e..32791ade96 100644
--- a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts
+++ b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts
@@ -34,6 +34,7 @@ import {
alarmRuleNumericOperationTranslationMap,
AlarmRuleStringOperation,
alarmRuleStringOperationTranslationMap,
+ checkPredicates,
ComplexAlarmRuleFilterPredicate
} from "@shared/models/alarm-rule.models";
import { MatDialog } from "@angular/material/dialog";
@@ -111,6 +112,18 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
this.updateModel();
});
+ this.filterPredicateFormGroup.get('operation').valueChanges.pipe(
+ takeUntilDestroyed(this.destroyRef)
+ ).subscribe(value => {
+ if (value === 'NO_DATA') {
+ this.filterPredicateFormGroup.get('duration').enable({emitEvent: false});
+ this.filterPredicateFormGroup.get('value').disable({emitEvent: false});
+ } else {
+ this.filterPredicateFormGroup.get('duration').disable({emitEvent: false});
+ this.filterPredicateFormGroup.get('value').enable({emitEvent: false});
+ }
+ })
+
this.filterPredicateFormGroup.get('predicates').valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(predicates => {
@@ -140,25 +153,10 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
}
}
- private isPredicateArgumentsValid(predicates: any): boolean {
+ private isPredicateArgumentsValid(predicates: AlarmRuleFilterPredicate[]): boolean {
const validSet = new Set(Object.keys(this.arguments));
- function checkPredicates(predicates: any[]): boolean {
- for (const p of predicates) {
- if (p.value?.dynamicValueArgument) {
- if (!validSet.has(p.value.dynamicValueArgument)) {
- return false;
- }
- }
- if (p.type === 'COMPLEX' && Array.isArray(p.predicates)) {
- if (!checkPredicates(p.predicates)) {
- return false;
- }
- }
- }
- return true;
- }
if (Array.isArray(predicates)) {
- if (!checkPredicates(predicates)) {
+ if (!checkPredicates(predicates, validSet)) {
return false;
}
}
@@ -172,8 +170,12 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
}
if (predicate.type === AlarmRuleFilterPredicateType.NO_DATA) {
this.type = AlarmRuleFilterPredicateType[this.valueType];
+ this.filterPredicateFormGroup.get('duration').enable({emitEvent: false});
+ this.filterPredicateFormGroup.get('value').disable({emitEvent: false});
this.filterPredicateFormGroup.patchValue({operation: 'NO_DATA', duration: predicate}, {emitEvent: false});
} else {
+ this.filterPredicateFormGroup.get('duration').disable({emitEvent: false});
+ this.filterPredicateFormGroup.get('value').enable({emitEvent: false});
this.filterPredicateFormGroup.patchValue(predicate, {emitEvent: false});
}
}
@@ -183,30 +185,6 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
if (predicate.operation === 'NO_DATA') {
this.propagateChange(predicate.duration);
} else {
- if (!predicate.value) {
- switch (this.valueType) {
- case EntityKeyValueType.STRING:
- predicate.value = {
- staticValue: ''
- };
- break;
- case EntityKeyValueType.NUMERIC:
- predicate.value = {
- staticValue: 0
- };
- break;
- case EntityKeyValueType.DATE_TIME:
- predicate.value = {
- staticValue: Date.now()
- };
- break;
- case EntityKeyValueType.BOOLEAN:
- predicate.value = {
- staticValue: false
- };
- break;
- }
- }
this.propagateChange({type: this.type, ...predicate});
}
}
diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.html b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.html
index 4ecba0f3d2..d070c2de84 100644
--- a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.html
+++ b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.html
@@ -18,6 +18,7 @@
diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.scss b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.scss
index 8712fdfd32..dbaf7dd966 100644
--- a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.scss
+++ b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.scss
@@ -23,6 +23,9 @@
color: #f44336;
padding: 0;
}
+ &.disabled {
+ color: rgba(0,0,0,0.38);
+ }
&.nowrap {
white-space: nowrap;
text-overflow: ellipsis;
diff --git a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.ts b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.ts
index 703c41665e..aa8aa2bfec 100644
--- a/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.ts
+++ b/ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-text.component.ts
@@ -63,6 +63,10 @@ export class AlarmRuleFilterTextComponent {
@Input()
arguments: Record
;
+ @Input()
+ @coerceBoolean()
+ disabled = false;
+
private alarmRuleExpressionValue: AlarmRuleExpression;
get alarmRuleExpression(): AlarmRuleExpression {
return this.alarmRuleExpressionValue;
diff --git a/ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html b/ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html
index cd87bde8f2..0dc4e0a90f 100644
--- a/ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html
+++ b/ui-ngx/src/app/modules/home/components/attribute/add-attribute-dialog.component.html
@@ -30,16 +30,18 @@