Browse Source

UI: Add Constant keys in the Device Profile Alarm Rules

pull/4180/head
Vladyslav_Prykhodko 6 years ago
committed by Andrew Shvayka
parent
commit
ce9dcd17c6
  1. 1
      ui-ngx/src/app/core/http/entity.service.ts
  2. 1
      ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html
  3. 2
      ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.ts
  4. 1
      ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html
  5. 1
      ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts
  6. 5
      ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate.component.ts
  7. 1
      ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html
  8. 5
      ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.ts
  9. 6
      ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html
  10. 2
      ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts
  11. 4
      ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.html
  12. 2
      ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts
  13. 32
      ui-ngx/src/app/modules/home/components/filter/key-filter-dialog.component.html
  14. 33
      ui-ngx/src/app/modules/home/components/filter/key-filter-dialog.component.ts
  15. 1
      ui-ngx/src/app/modules/home/components/filter/key-filter-list.component.ts
  16. 1
      ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html
  17. 2
      ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.ts
  18. 1
      ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html
  19. 2
      ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.ts
  20. 11
      ui-ngx/src/app/shared/models/query/query.models.ts
  21. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

1
ui-ngx/src/app/core/http/entity.service.ts

@ -414,6 +414,7 @@ export class EntityService {
{ {
key: nameField, key: nameField,
valueType: EntityKeyValueType.STRING, valueType: EntityKeyValueType.STRING,
value: null,
predicate: { predicate: {
type: FilterPredicateType.STRING, type: FilterPredicateType.STRING,
operation: StringOperation.STARTS_WITH, operation: StringOperation.STARTS_WITH,

1
ui-ngx/src/app/modules/home/components/filter/boolean-filter-predicate.component.html

@ -25,6 +25,7 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource" <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
fxFlex="70" fxFlex="70"
[valueType]="valueTypeEnum.BOOLEAN" [valueType]="valueTypeEnum.BOOLEAN"
formControlName="value"> formControlName="value">

2
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() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
valueTypeEnum = EntityKeyValueType; valueTypeEnum = EntityKeyValueType;
booleanFilterPredicateFormGroup: FormGroup; booleanFilterPredicateFormGroup: FormGroup;

1
ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.html

@ -39,6 +39,7 @@
[valueType]="data.valueType" [valueType]="data.valueType"
[displayUserParameters]="data.displayUserParameters" [displayUserParameters]="data.displayUserParameters"
[allowUserDynamicSource]="data.allowUserDynamicSource" [allowUserDynamicSource]="data.allowUserDynamicSource"
[onlyUserDynamicSource]="data.onlyUserDynamicSource"
[operation]="complexFilterFormGroup.get('operation').value" [operation]="complexFilterFormGroup.get('operation').value"
[key]="data.key" [key]="data.key"
formControlName="predicates"> formControlName="predicates">

1
ui-ngx/src/app/modules/home/components/filter/complex-filter-predicate-dialog.component.ts

@ -37,6 +37,7 @@ export interface ComplexFilterPredicateDialogData {
valueType: EntityKeyValueType; valueType: EntityKeyValueType;
displayUserParameters: boolean; displayUserParameters: boolean;
allowUserDynamicSource: boolean; allowUserDynamicSource: boolean;
onlyUserDynamicSource: boolean;
} }
@Component({ @Component({

5
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() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
private propagateChange = null; private propagateChange = null;
private complexFilterPredicate: ComplexFilterPredicateInfo; private complexFilterPredicate: ComplexFilterPredicateInfo;
@ -89,7 +91,8 @@ export class ComplexFilterPredicateComponent implements ControlValueAccessor, On
isAdd: false, isAdd: false,
key: this.key, key: this.key,
displayUserParameters: this.displayUserParameters, displayUserParameters: this.displayUserParameters,
allowUserDynamicSource: this.allowUserDynamicSource allowUserDynamicSource: this.allowUserDynamicSource,
onlyUserDynamicSource: this.onlyUserDynamicSource
} }
}).afterClosed().subscribe( }).afterClosed().subscribe(
(result) => { (result) => {

1
ui-ngx/src/app/modules/home/components/filter/filter-predicate-list.component.html

@ -53,6 +53,7 @@
[valueType]="valueType" [valueType]="valueType"
[displayUserParameters]="displayUserParameters" [displayUserParameters]="displayUserParameters"
[allowUserDynamicSource]="allowUserDynamicSource" [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
[key]="key" [key]="key"
[formControl]="predicateControl"> [formControl]="predicateControl">
</tb-filter-predicate> </tb-filter-predicate>

5
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() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
filterListFormGroup: FormGroup; filterListFormGroup: FormGroup;
valueTypeEnum = EntityKeyValueType; valueTypeEnum = EntityKeyValueType;
@ -159,7 +161,8 @@ export class FilterPredicateListComponent implements ControlValueAccessor, OnIni
key: this.key, key: this.key,
isAdd: true, isAdd: true,
displayUserParameters: this.displayUserParameters, displayUserParameters: this.displayUserParameters,
allowUserDynamicSource: this.allowUserDynamicSource allowUserDynamicSource: this.allowUserDynamicSource,
onlyUserDynamicSource: this.onlyUserDynamicSource
} }
}).afterClosed().pipe( }).afterClosed().pipe(
map((result) => { map((result) => {

6
ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.html

@ -16,7 +16,7 @@
--> -->
<div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px" [formGroup]="filterPredicateValueFormGroup"> <div fxFlex fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px" [formGroup]="filterPredicateValueFormGroup">
<div fxFlex fxLayout="column" [fxShow]="!dynamicMode"> <div fxFlex fxLayout="column" [fxShow]="!dynamicMode && !onlyUserDynamicSource">
<div fxLayout="column" [ngSwitch]="valueType"> <div fxLayout="column" [ngSwitch]="valueType">
<ng-template [ngSwitchCase]="valueTypeEnum.STRING"> <ng-template [ngSwitchCase]="valueTypeEnum.STRING">
<mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block">
@ -45,7 +45,7 @@
</div> </div>
<div class="tb-hint" translate>filter.default-value</div> <div class="tb-hint" translate>filter.default-value</div>
</div> </div>
<div fxFlex fxLayout="column" [fxShow]="dynamicMode"> <div fxFlex fxLayout="column" [fxShow]="dynamicMode || onlyUserDynamicSource">
<div formGroupName="dynamicValue" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"> <div formGroupName="dynamicValue" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
<div fxFlex="35" fxLayout="column"> <div fxFlex="35" fxLayout="column">
<mat-form-field floatLabel="always" hideRequiredMarker class="mat-block"> <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block">
@ -78,7 +78,7 @@
</div> </div>
</div> </div>
</div> </div>
<button mat-icon-button <button mat-icon-button *ngIf="!onlyUserDynamicSource"
class="mat-elevation-z1 tb-mat-32" class="mat-elevation-z1 tb-mat-32"
color="primary" color="primary"
type="button" type="button"

2
ui-ngx/src/app/modules/home/components/filter/filter-predicate-value.component.ts

@ -62,6 +62,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
} }
} }
@Input() onlyUserDynamicSource = false;
@Input() @Input()
valueType: EntityKeyValueType; valueType: EntityKeyValueType;

4
ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.html

@ -20,12 +20,14 @@
<ng-template [ngSwitchCase]="filterPredicateType.STRING"> <ng-template [ngSwitchCase]="filterPredicateType.STRING">
<tb-string-filter-predicate <tb-string-filter-predicate
[allowUserDynamicSource]="allowUserDynamicSource" [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
formControlName="predicate"> formControlName="predicate">
</tb-string-filter-predicate> </tb-string-filter-predicate>
</ng-template> </ng-template>
<ng-template [ngSwitchCase]="filterPredicateType.NUMERIC"> <ng-template [ngSwitchCase]="filterPredicateType.NUMERIC">
<tb-numeric-filter-predicate <tb-numeric-filter-predicate
[allowUserDynamicSource]="allowUserDynamicSource" [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
[valueType]="valueType" [valueType]="valueType"
formControlName="predicate"> formControlName="predicate">
</tb-numeric-filter-predicate> </tb-numeric-filter-predicate>
@ -33,12 +35,14 @@
<ng-template [ngSwitchCase]="filterPredicateType.BOOLEAN"> <ng-template [ngSwitchCase]="filterPredicateType.BOOLEAN">
<tb-boolean-filter-predicate <tb-boolean-filter-predicate
[allowUserDynamicSource]="allowUserDynamicSource" [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
formControlName="predicate"> formControlName="predicate">
</tb-boolean-filter-predicate> </tb-boolean-filter-predicate>
</ng-template> </ng-template>
<ng-template [ngSwitchCase]="filterPredicateType.COMPLEX"> <ng-template [ngSwitchCase]="filterPredicateType.COMPLEX">
<tb-complex-filter-predicate <tb-complex-filter-predicate
[allowUserDynamicSource]="allowUserDynamicSource" [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
[key]="key" [key]="key"
[valueType]="valueType" [valueType]="valueType"
[displayUserParameters]="displayUserParameters" [displayUserParameters]="displayUserParameters"

2
ui-ngx/src/app/modules/home/components/filter/filter-predicate.component.ts

@ -45,6 +45,8 @@ export class FilterPredicateComponent implements ControlValueAccessor, OnInit {
@Input() allowUserDynamicSource = true; @Input() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
filterPredicateFormGroup: FormGroup; filterPredicateFormGroup: FormGroup;
type: FilterPredicateType; type: FilterPredicateType;

32
ui-ngx/src/app/modules/home/components/filter/key-filter-dialog.component.html

@ -28,7 +28,7 @@
<div mat-dialog-content> <div mat-dialog-content>
<fieldset [disabled]="isLoading$ | async" fxLayout="column"> <fieldset [disabled]="isLoading$ | async" fxLayout="column">
<section fxLayout="row" fxLayoutGap="8px" class="entity-key"> <section fxLayout="row" fxLayoutGap="8px" class="entity-key">
<section fxFlex="70" fxLayout="row" formGroupName="key" fxLayoutGap="8px"> <section [fxFlex]="isConstantKeyType ? 45 : 70" fxLayout="row" formGroupName="key" fxLayoutGap="8px">
<mat-form-field fxFlex="40" class="mat-block"> <mat-form-field fxFlex="40" class="mat-block">
<mat-label translate>filter.key-type.key-type</mat-label> <mat-label translate>filter.key-type.key-type</mat-label>
<mat-select required formControlName="type"> <mat-select required formControlName="type">
@ -60,7 +60,7 @@
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
</section> </section>
<mat-form-field fxFlex="30" class="mat-block"> <mat-form-field [fxFlex]="isConstantKeyType ? 20 : 30" class="mat-block">
<mat-label translate>filter.value-type.value-type</mat-label> <mat-label translate>filter.value-type.value-type</mat-label>
<mat-select formControlName="valueType"> <mat-select formControlName="valueType">
<mat-select-trigger> <mat-select-trigger>
@ -76,9 +76,37 @@
{{ 'filter.value-type-required' | translate }} {{ 'filter.value-type-required' | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
<div fxFlex *ngIf="isConstantKeyType">
<div fxLayout="column" [ngSwitch]="keyFilterFormGroup.get('valueType').value">
<ng-template [ngSwitchCase]="entityKeyValueTypeEnum.STRING">
<mat-form-field class="mat-block">
<mat-label translate>filter.value</mat-label>
<input matInput required formControlName="value" placeholder="{{'filter.value' | translate}}">
</mat-form-field>
</ng-template>
<ng-template [ngSwitchCase]="entityKeyValueTypeEnum.NUMERIC">
<mat-form-field class="mat-block">
<mat-label translate>filter.value</mat-label>
<input required type="number" matInput formControlName="value">
</mat-form-field>
</ng-template>
<ng-template [ngSwitchCase]="entityKeyValueTypeEnum.DATE_TIME">
<tb-datetime formControlName="value"
dateText="filter.date"
timeText="filter.time"
required></tb-datetime>
</ng-template>
<ng-template [ngSwitchCase]="entityKeyValueTypeEnum.BOOLEAN">
<mat-checkbox formControlName="value" style="margin-top: 20px">
{{ (keyFilterFormGroup.get('value').value ? 'value.true' : 'value.false') | translate }}
</mat-checkbox>
</ng-template>
</div>
</div>
</section> </section>
<tb-filter-predicate-list *ngIf="keyFilterFormGroup.get('valueType').value" <tb-filter-predicate-list *ngIf="keyFilterFormGroup.get('valueType').value"
[allowUserDynamicSource]="data.allowUserDynamicSource" [allowUserDynamicSource]="data.allowUserDynamicSource"
[onlyUserDynamicSource]="isConstantKeyType"
[displayUserParameters]="data.displayUserParameters" [displayUserParameters]="data.displayUserParameters"
[valueType]="keyFilterFormGroup.get('valueType').value" [valueType]="keyFilterFormGroup.get('valueType').value"
[key]="keyFilterFormGroup.get('key.key').value" [key]="keyFilterFormGroup.get('key.key').value"

33
ui-ngx/src/app/modules/home/components/filter/key-filter-dialog.component.ts

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { Component, ElementRef, Inject, OnDestroy, OnInit, SkipSelf, ViewChild } from '@angular/core'; import { Component, ElementRef, Inject, OnDestroy, SkipSelf, ViewChild } from '@angular/core';
import { ErrorStateMatcher } from '@angular/material/core'; import { ErrorStateMatcher } from '@angular/material/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@ -57,7 +57,7 @@ export interface KeyFilterDialogData {
}) })
export class KeyFilterDialogComponent extends export class KeyFilterDialogComponent extends
DialogComponent<KeyFilterDialogComponent, KeyFilterInfo> DialogComponent<KeyFilterDialogComponent, KeyFilterInfo>
implements OnInit, OnDestroy, ErrorStateMatcher { implements OnDestroy, ErrorStateMatcher {
@ViewChild('keyNameInput', {static: true}) private keyNameInput: ElementRef; @ViewChild('keyNameInput', {static: true}) private keyNameInput: ElementRef;
@ -69,7 +69,7 @@ export class KeyFilterDialogComponent extends
entityKeyTypes = entityKeyTypes =
this.data.telemetryKeysOnly ? this.data.telemetryKeysOnly ?
[EntityKeyType.ATTRIBUTE, EntityKeyType.TIME_SERIES] : [EntityKeyType.ATTRIBUTE, EntityKeyType.TIME_SERIES, EntityKeyType.CONSTANT] :
[EntityKeyType.ENTITY_FIELD, EntityKeyType.ATTRIBUTE, EntityKeyType.TIME_SERIES]; [EntityKeyType.ENTITY_FIELD, EntityKeyType.ATTRIBUTE, EntityKeyType.TIME_SERIES];
entityKeyTypeTranslations = entityKeyTypeTranslationMap; entityKeyTypeTranslations = entityKeyTypeTranslationMap;
@ -107,6 +107,7 @@ export class KeyFilterDialogComponent extends
key: [this.data.keyFilter.key.key, [Validators.required]] key: [this.data.keyFilter.key.key, [Validators.required]]
} }
), ),
value: [this.data.keyFilter.value],
valueType: [this.data.keyFilter.valueType, [Validators.required]], valueType: [this.data.keyFilter.valueType, [Validators.required]],
predicates: [this.data.keyFilter.predicates, [Validators.required]] predicates: [this.data.keyFilter.predicates, [Validators.required]]
} }
@ -143,6 +144,13 @@ export class KeyFilterDialogComponent extends
} else { } else {
this.showAutocomplete = false; this.showAutocomplete = false;
} }
if (type === EntityKeyType.CONSTANT) {
this.keyFilterFormGroup.get('value').setValidators(Validators.required);
this.keyFilterFormGroup.get('value').updateValueAndValidity();
} else {
this.keyFilterFormGroup.get('value').clearValidators();
this.keyFilterFormGroup.get('value').updateValueAndValidity();
}
}); });
this.keyFilterFormGroup.get('key.key').valueChanges.pipe( this.keyFilterFormGroup.get('key.key').valueChanges.pipe(
@ -156,19 +164,18 @@ export class KeyFilterDialogComponent extends
this.keyFilterFormGroup.get('valueType').patchValue(newValueType, {emitEvent: false}); this.keyFilterFormGroup.get('valueType').patchValue(newValueType, {emitEvent: false});
} }
}); });
this.filteredKeysName = this.keyFilterFormGroup.get('key.key').valueChanges
.pipe(
map(value => value ? value : ''),
mergeMap(name => this.fetchEntityName(name)),
takeUntil(this.destroy$)
);
} else { } else {
this.keyFilterFormGroup.disable({emitEvent: false}); this.keyFilterFormGroup.disable({emitEvent: false});
} }
} }
ngOnInit() {
this.filteredKeysName = this.keyFilterFormGroup.get('key.key').valueChanges
.pipe(
map(value => value ? value : ''),
mergeMap(name => this.fetchEntityName(name))
);
}
ngOnDestroy() { ngOnDestroy() {
super.ngOnDestroy(); super.ngOnDestroy();
this.destroy$.next(); this.destroy$.next();
@ -208,6 +215,10 @@ export class KeyFilterDialogComponent extends
} }
} }
get isConstantKeyType(): boolean {
return this.keyFilterFormGroup.get('key.type').value === EntityKeyType.CONSTANT;
}
private fetchEntityName(searchText?: string): Observable<Array<string>> { private fetchEntityName(searchText?: string): Observable<Array<string>> {
this.searchText = searchText; this.searchText = searchText;
return this.getEntityKeys().pipe( return this.getEntityKeys().pipe(

1
ui-ngx/src/app/modules/home/components/filter/key-filter-list.component.ts

@ -161,6 +161,7 @@ export class KeyFilterListComponent implements ControlValueAccessor, OnInit {
type: EntityKeyType.ATTRIBUTE type: EntityKeyType.ATTRIBUTE
}, },
valueType: null, valueType: null,
value: null,
predicates: [] predicates: []
}; };
} }

1
ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.html

@ -25,6 +25,7 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource" <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
fxFlex="70" fxFlex="70"
[valueType]="valueType" [valueType]="valueType"
formControlName="value"> formControlName="value">

2
ui-ngx/src/app/modules/home/components/filter/numeric-filter-predicate.component.ts

@ -42,6 +42,8 @@ export class NumericFilterPredicateComponent implements ControlValueAccessor, On
@Input() allowUserDynamicSource = true; @Input() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
@Input() valueType: EntityKeyValueType; @Input() valueType: EntityKeyValueType;
numericFilterPredicateFormGroup: FormGroup; numericFilterPredicateFormGroup: FormGroup;

1
ui-ngx/src/app/modules/home/components/filter/string-filter-predicate.component.html

@ -29,6 +29,7 @@
</mat-checkbox> </mat-checkbox>
</div> </div>
<tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource" <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
[onlyUserDynamicSource]="onlyUserDynamicSource"
fxFlex="70" fxFlex="70"
[valueType]="valueTypeEnum.STRING" [valueType]="valueTypeEnum.STRING"
formControlName="value"> formControlName="value">

2
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() allowUserDynamicSource = true;
@Input() onlyUserDynamicSource = false;
valueTypeEnum = EntityKeyValueType; valueTypeEnum = EntityKeyValueType;
stringFilterPredicateFormGroup: FormGroup; stringFilterPredicateFormGroup: FormGroup;

11
ui-ngx/src/app/shared/models/query/query.models.ts

@ -35,14 +35,16 @@ export enum EntityKeyType {
SERVER_ATTRIBUTE = 'SERVER_ATTRIBUTE', SERVER_ATTRIBUTE = 'SERVER_ATTRIBUTE',
TIME_SERIES = 'TIME_SERIES', TIME_SERIES = 'TIME_SERIES',
ENTITY_FIELD = 'ENTITY_FIELD', ENTITY_FIELD = 'ENTITY_FIELD',
ALARM_FIELD = 'ALARM_FIELD' ALARM_FIELD = 'ALARM_FIELD',
CONSTANT = 'CONSTANT'
} }
export const entityKeyTypeTranslationMap = new Map<EntityKeyType, string>( export const entityKeyTypeTranslationMap = new Map<EntityKeyType, string>(
[ [
[EntityKeyType.ATTRIBUTE, 'filter.key-type.attribute'], [EntityKeyType.ATTRIBUTE, 'filter.key-type.attribute'],
[EntityKeyType.TIME_SERIES, 'filter.key-type.timeseries'], [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 { export interface KeyFilter {
key: EntityKey; key: EntityKey;
valueType: EntityKeyValueType; valueType: EntityKeyValueType;
value: string | number | boolean;
predicate: KeyFilterPredicate; predicate: KeyFilterPredicate;
} }
export interface KeyFilterInfo { export interface KeyFilterInfo {
key: EntityKey; key: EntityKey;
valueType: EntityKeyValueType; valueType: EntityKeyValueType;
value: string | number | boolean;
predicates: Array<KeyFilterPredicateInfo>; predicates: Array<KeyFilterPredicateInfo>;
} }
@ -466,6 +470,7 @@ export function keyFilterInfosToKeyFilters(keyFilterInfos: Array<KeyFilterInfo>)
const keyFilter: KeyFilter = { const keyFilter: KeyFilter = {
key, key,
valueType: keyFilterInfo.valueType, valueType: keyFilterInfo.valueType,
value: keyFilterInfo.value,
predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate) predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate)
}; };
keyFilters.push(keyFilter); keyFilters.push(keyFilter);
@ -486,6 +491,7 @@ export function keyFiltersToKeyFilterInfos(keyFilters: Array<KeyFilter>): Array<
keyFilterInfo = { keyFilterInfo = {
key, key,
valueType: keyFilter.valueType, valueType: keyFilter.valueType,
value: keyFilter.value,
predicates: [] predicates: []
}; };
keyFilterInfoMap[infoKey] = keyFilterInfo; keyFilterInfoMap[infoKey] = keyFilterInfo;
@ -508,6 +514,7 @@ export function filterInfoToKeyFilters(filter: FilterInfo): Array<KeyFilter> {
const keyFilter: KeyFilter = { const keyFilter: KeyFilter = {
key, key,
valueType: keyFilterInfo.valueType, valueType: keyFilterInfo.valueType,
value: keyFilterInfo.value,
predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate) predicate: keyFilterPredicateInfoToKeyFilterPredicate(predicate)
}; };
keyFilters.push(keyFilter); keyFilters.push(keyFilter);

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1564,7 +1564,8 @@
"key-type": "Key type", "key-type": "Key type",
"attribute": "Attribute", "attribute": "Attribute",
"timeseries": "Timeseries", "timeseries": "Timeseries",
"entity-field": "Entity field" "entity-field": "Entity field",
"constant": "Constant"
}, },
"value-type": { "value-type": {
"value-type": "Value type", "value-type": "Value type",

Loading…
Cancel
Save