From d5b28222a37d87703531da0c7134060e96c9dd2f Mon Sep 17 00:00:00 2001 From: YevhenBondarenko Date: Mon, 15 Feb 2021 15:16:11 +0200 Subject: [PATCH 01/11] fixed unlimited error messages in TbMsgGeneratorNode --- .../org/thingsboard/rule/engine/debug/TbMsgGeneratorNode.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/debug/TbMsgGeneratorNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/debug/TbMsgGeneratorNode.java index 69482a7b89..6047370193 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/debug/TbMsgGeneratorNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/debug/TbMsgGeneratorNode.java @@ -104,9 +104,10 @@ public class TbMsgGeneratorNode implements TbNode { } }, t -> { - if (initialized) { + if (initialized && (config.getMsgCount() == TbMsgGeneratorNodeConfiguration.UNLIMITED_MSG_COUNT || currentMsgCount < config.getMsgCount())) { ctx.tellFailure(msg, t); scheduleTickMsg(ctx); + currentMsgCount++; } }); } From ada0af2a4109b3f6a32eef9d821e4a6795ce57fc Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 11 Feb 2021 13:38:18 +0200 Subject: [PATCH 02/11] UI: Added in device profile alarm rule condition to dynamic mode checkbox inherit from owner --- .../boolean-filter-predicate.component.html | 4 ++-- .../filter-predicate-list.component.html | 4 ++-- .../filter-predicate-value.component.html | 9 +++++++ .../filter-predicate-value.component.ts | 24 ++++++++++++++++--- .../components/filter/filter-predicate.scss | 4 ++++ .../numeric-filter-predicate.component.html | 4 ++-- .../string-filter-predicate.component.html | 4 ++-- .../app/shared/models/query/query.models.ts | 1 + 8 files changed, 43 insertions(+), 11 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html b/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html index 6194581625..253f7e2138 100644 --- a/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html @@ -16,7 +16,7 @@ -->
- + @@ -25,7 +25,7 @@ diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html index 41c04ea238..c6aee52976 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html @@ -26,12 +26,12 @@
-
+
- +
diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html index adda4bea1a..8365e2ec8c 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html @@ -61,6 +61,15 @@
filter.dynamic-source-type
+
+ +
Inherit from owner
+
diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts index b5406c9e9b..437a5993e7 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts @@ -44,6 +44,9 @@ import { }) export class FilterPredicateValueComponent implements ControlValueAccessor, OnInit { + private readonly inheritFromSources: DynamicValueSourceType[] = [DynamicValueSourceType.CURRENT_CUSTOMER, + DynamicValueSourceType.CURRENT_DEVICE]; + @Input() disabled: boolean; @Input() @@ -72,6 +75,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn dynamicMode = false; + inheritMode = false; + allow = true; private propagateChange = null; @@ -105,7 +110,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn dynamicValue: this.fb.group( { sourceType: [null], - sourceAttribute: [null] + sourceAttribute: [null], + inherit: [false] } ) }); @@ -114,6 +120,7 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn if (!sourceType) { this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(null, {emitEvent: false}); } + this.updateInheritValue(sourceType); } ); this.filterPredicateValueFormGroup.valueChanges.subscribe(() => { @@ -139,10 +146,13 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn writeValue(predicateValue: FilterPredicateValue): void { this.filterPredicateValueFormGroup.get('defaultValue').patchValue(predicateValue.defaultValue, {emitEvent: false}); - this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceType').patchValue(predicateValue.dynamicValue ? + this.filterPredicateValueFormGroup.get('dynamicValue.sourceType').patchValue(predicateValue.dynamicValue ? predicateValue.dynamicValue.sourceType : null, {emitEvent: false}); - this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(predicateValue.dynamicValue ? + this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(predicateValue.dynamicValue ? + predicateValue.dynamicValue.inherit : false, {emitEvent: false}); + this.filterPredicateValueFormGroup.get('dynamicValue.sourceAttribute').patchValue(predicateValue.dynamicValue ? predicateValue.dynamicValue.sourceAttribute : null, {emitEvent: false}); + this.updateInheritValue(predicateValue?.dynamicValue?.sourceType); } private updateModel() { @@ -158,4 +168,12 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn this.propagateChange(predicateValue); } + private updateInheritValue(sourceType: DynamicValueSourceType) { + if (this.inheritFromSources.includes(sourceType)) { + this.inheritMode = true; + } else { + this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(false, {emitEvent: false}); + this.inheritMode = false; + } + } } diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate.scss b/ui-ngx/src/app/modules/home/components/filter/filter-predicate.scss index e88454b8b3..6230a3da0f 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate.scss +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate.scss @@ -17,6 +17,10 @@ .tb-hint { padding-bottom: 0; } + + .invisible{ + visibility: hidden; + } } :host ::ng-deep { diff --git a/ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html b/ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html index ffbdaa01c1..678df9c3f9 100644 --- a/ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html @@ -16,7 +16,7 @@ -->
- + @@ -25,7 +25,7 @@ diff --git a/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html b/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html index f1913149e5..53f5dee077 100644 --- a/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html @@ -16,7 +16,7 @@ -->
-
+
@@ -29,7 +29,7 @@
diff --git a/ui-ngx/src/app/shared/models/query/query.models.ts b/ui-ngx/src/app/shared/models/query/query.models.ts index 86d2ddd89b..dcc89852b7 100644 --- a/ui-ngx/src/app/shared/models/query/query.models.ts +++ b/ui-ngx/src/app/shared/models/query/query.models.ts @@ -285,6 +285,7 @@ export const dynamicValueSourceTypeTranslationMap = new Map { sourceType: DynamicValueSourceType; sourceAttribute: string; + inherit?: boolean; } export interface FilterPredicateValue { From 5e990da0ba785cf7716d3acb2e61495127852e88 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 11 Feb 2021 16:16:06 +0200 Subject: [PATCH 03/11] UI: Refactoring alarm-rule inherit --- .../filter-predicate-value.component.html | 19 +++++++++---------- .../filter-predicate-value.component.ts | 15 ++++++++------- .../components/filter/filter-predicate.scss | 4 ---- .../assets/locale/locale.constant-en_US.json | 4 +++- 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html index 8365e2ec8c..dd1b92cf7f 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html @@ -47,7 +47,7 @@
-
+
@@ -61,15 +61,6 @@
filter.dynamic-source-type
-
- -
Inherit from owner
-
@@ -77,6 +68,14 @@
filter.source-attribute
+
+ + {{ 'filter.inherit-owner' | translate}} + +
filter.source-attribute-not-set
+