From ce9dcd17c6d94b279358656710295c7002c64afe Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Fri, 26 Feb 2021 16:02:57 +0200 Subject: [PATCH] UI: Add Constant keys in the Device Profile Alarm Rules --- ui-ngx/src/app/core/http/entity.service.ts | 1 + .../boolean-filter-predicate.component.html | 1 + .../boolean-filter-predicate.component.ts | 2 ++ ...lex-filter-predicate-dialog.component.html | 1 + ...mplex-filter-predicate-dialog.component.ts | 1 + .../complex-filter-predicate.component.ts | 5 ++- .../filter-predicate-list.component.html | 1 + .../filter/filter-predicate-list.component.ts | 5 ++- .../filter-predicate-value.component.html | 6 ++-- .../filter-predicate-value.component.ts | 2 ++ .../filter/filter-predicate.component.html | 4 +++ .../filter/filter-predicate.component.ts | 2 ++ .../filter/key-filter-dialog.component.html | 32 ++++++++++++++++-- .../filter/key-filter-dialog.component.ts | 33 ++++++++++++------- .../filter/key-filter-list.component.ts | 1 + .../numeric-filter-predicate.component.html | 1 + .../numeric-filter-predicate.component.ts | 2 ++ .../string-filter-predicate.component.html | 1 + .../string-filter-predicate.component.ts | 2 ++ .../app/shared/models/query/query.models.ts | 11 +++++-- .../assets/locale/locale.constant-en_US.json | 3 +- 21 files changed, 96 insertions(+), 21 deletions(-) diff --git a/ui-ngx/src/app/core/http/entity.service.ts b/ui-ngx/src/app/core/http/entity.service.ts index 463183d06e..1118307d06 100644 --- a/ui-ngx/src/app/core/http/entity.service.ts +++ b/ui-ngx/src/app/core/http/entity.service.ts @@ -414,6 +414,7 @@ export class EntityService { { key: nameField, valueType: EntityKeyValueType.STRING, + value: null, predicate: { type: FilterPredicateType.STRING, operation: StringOperation.STARTS_WITH, 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 253f7e2138..f7bae7d797 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 @@ -25,6 +25,7 @@ diff --git a/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.ts b/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.ts index fbd329dc16..c6c8a5ed51 100644 --- a/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.ts @@ -41,6 +41,8 @@ export class BooleanFilterPredicateComponent implements ControlValueAccessor, On @Input() allowUserDynamicSource = true; + @Input() onlyUserDynamicSource = false; + valueTypeEnum = EntityKeyValueType; booleanFilterPredicateFormGroup: FormGroup; diff --git a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html index bbf4887e5f..e2bee07a3f 100644 --- a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html @@ -39,6 +39,7 @@ [valueType]="data.valueType" [displayUserParameters]="data.displayUserParameters" [allowUserDynamicSource]="data.allowUserDynamicSource" + [onlyUserDynamicSource]="data.onlyUserDynamicSource" [operation]="complexFilterFormGroup.get('operation').value" [key]="data.key" formControlName="predicates"> diff --git a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts index 447546ba2f..3f1bb3cace 100644 --- a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts @@ -37,6 +37,7 @@ export interface ComplexFilterPredicateDialogData { valueType: EntityKeyValueType; displayUserParameters: boolean; allowUserDynamicSource: boolean; + onlyUserDynamicSource: boolean; } @Component({ diff --git a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate.component.ts b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate.component.ts index 0843583a52..9f4acfc3c6 100644 --- a/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate.component.ts @@ -52,6 +52,8 @@ export class ComplexFilterPredicateComponent implements ControlValueAccessor, On @Input() allowUserDynamicSource = true; + @Input() onlyUserDynamicSource = false; + private propagateChange = null; private complexFilterPredicate: ComplexFilterPredicateInfo; @@ -89,7 +91,8 @@ export class ComplexFilterPredicateComponent implements ControlValueAccessor, On isAdd: false, key: this.key, displayUserParameters: this.displayUserParameters, - allowUserDynamicSource: this.allowUserDynamicSource + allowUserDynamicSource: this.allowUserDynamicSource, + onlyUserDynamicSource: this.onlyUserDynamicSource } }).afterClosed().subscribe( (result) => { 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 c6aee52976..e5bb27f20c 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 @@ -53,6 +53,7 @@ [valueType]="valueType" [displayUserParameters]="displayUserParameters" [allowUserDynamicSource]="allowUserDynamicSource" + [onlyUserDynamicSource]="onlyUserDynamicSource" [key]="key" [formControl]="predicateControl"> diff --git a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.ts b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.ts index e89489e6bb..3c16b01319 100644 --- a/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.ts @@ -66,6 +66,8 @@ export class FilterPredicateListComponent implements ControlValueAccessor, OnIni @Input() allowUserDynamicSource = true; + @Input() onlyUserDynamicSource = false; + filterListFormGroup: FormGroup; valueTypeEnum = EntityKeyValueType; @@ -159,7 +161,8 @@ export class FilterPredicateListComponent implements ControlValueAccessor, OnIni key: this.key, isAdd: true, displayUserParameters: this.displayUserParameters, - allowUserDynamicSource: this.allowUserDynamicSource + allowUserDynamicSource: this.allowUserDynamicSource, + onlyUserDynamicSource: this.onlyUserDynamicSource } }).afterClosed().pipe( map((result) => { 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 dd1b92cf7f..4bc249837a 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 @@ -16,7 +16,7 @@ -->
-
+
@@ -45,7 +45,7 @@
filter.default-value
-
+
@@ -78,7 +78,7 @@
-
diff --git a/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.ts b/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.ts index b52f36a572..11b4dad275 100644 --- a/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.ts +++ b/ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.ts @@ -42,6 +42,8 @@ export class StringFilterPredicateComponent implements ControlValueAccessor, OnI @Input() allowUserDynamicSource = true; + @Input() onlyUserDynamicSource = false; + valueTypeEnum = EntityKeyValueType; stringFilterPredicateFormGroup: FormGroup; 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 dcc89852b7..b8dc2564bc 100644 --- a/ui-ngx/src/app/shared/models/query/query.models.ts +++ b/ui-ngx/src/app/shared/models/query/query.models.ts @@ -35,14 +35,16 @@ export enum EntityKeyType { SERVER_ATTRIBUTE = 'SERVER_ATTRIBUTE', TIME_SERIES = 'TIME_SERIES', ENTITY_FIELD = 'ENTITY_FIELD', - ALARM_FIELD = 'ALARM_FIELD' + ALARM_FIELD = 'ALARM_FIELD', + CONSTANT = 'CONSTANT' } export const entityKeyTypeTranslationMap = new Map( [ [EntityKeyType.ATTRIBUTE, 'filter.key-type.attribute'], [EntityKeyType.TIME_SERIES, 'filter.key-type.timeseries'], - [EntityKeyType.ENTITY_FIELD, 'filter.key-type.entity-field'] + [EntityKeyType.ENTITY_FIELD, 'filter.key-type.entity-field'], + [EntityKeyType.CONSTANT, 'filter.key-type.constant'] ] ); @@ -344,12 +346,14 @@ export interface KeyFilterPredicateInfo { export interface KeyFilter { key: EntityKey; valueType: EntityKeyValueType; + value: string | number | boolean; predicate: KeyFilterPredicate; } export interface KeyFilterInfo { key: EntityKey; valueType: EntityKeyValueType; + value: string | number | boolean; predicates: Array; } @@ -466,6 +470,7 @@ export function keyFilterInfosToKeyFilters(keyFilterInfos: Array) const keyFilter: KeyFilter = { key, valueType: keyFilterInfo.valueType, + value: keyFilterInfo.value, predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate) }; keyFilters.push(keyFilter); @@ -486,6 +491,7 @@ export function keyFiltersToKeyFilterInfos(keyFilters: Array): Array< keyFilterInfo = { key, valueType: keyFilter.valueType, + value: keyFilter.value, predicates: [] }; keyFilterInfoMap[infoKey] = keyFilterInfo; @@ -508,6 +514,7 @@ export function filterInfoToKeyFilters(filter: FilterInfo): Array { const keyFilter: KeyFilter = { key, valueType: keyFilterInfo.valueType, + value: keyFilterInfo.value, predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate) }; keyFilters.push(keyFilter); diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index dff58d17d0..216ae2c1b7 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1564,7 +1564,8 @@ "key-type": "Key type", "attribute": "Attribute", "timeseries": "Timeseries", - "entity-field": "Entity field" + "entity-field": "Entity field", + "constant": "Constant" }, "value-type": { "value-type": "Value type",