Commit ada0af2a4109b3f6a32eef9d821e4a6795ce57fc

Authored by Vladyslav_Prykhodko
Committed by Andrew Shvayka
1 parent d5b28222

UI: Added in device profile alarm rule condition to dynamic mode checkbox inherit from owner

... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <div fxFlex fxLayout="row" fxLayoutAlign="start start" fxLayoutGap="8px" [formGroup]="booleanFilterPredicateFormGroup">
19   - <mat-form-field floatLabel="always" hideRequiredMarker fxFlex="40" class="mat-block">
  19 + <mat-form-field floatLabel="always" hideRequiredMarker fxFlex="30" class="mat-block">
20 20 <mat-label></mat-label>
21 21 <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
22 22 <mat-option *ngFor="let operation of booleanOperations" [value]="operation">
... ... @@ -25,7 +25,7 @@
25 25 </mat-select>
26 26 </mat-form-field>
27 27 <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
28   - fxFlex="60"
  28 + fxFlex="70"
29 29 [valueType]="valueTypeEnum.BOOLEAN"
30 30 formControlName="value">
31 31 </tb-filter-predicate-value>
... ...
... ... @@ -26,12 +26,12 @@
26 26 <span fxFlex="8"></span>
27 27 <div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px" fxFlex="92">
28 28 <div fxFlex fxLayout="row" fxLayoutGap="8px">
29   - <div fxFlex="40" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
  29 + <div fxFlex="30" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
30 30 <label fxFlex translate class="tb-title no-padding">filter.operation.operation</label>
31 31 <label *ngIf="valueType === valueTypeEnum.STRING"
32 32 translate class="tb-title no-padding" style="min-width: 70px;">filter.ignore-case</label>
33 33 </div>
34   - <label fxFlex="60" translate class="tb-title no-padding">filter.value</label>
  34 + <label fxFlex="70" translate class="tb-title no-padding">filter.value</label>
35 35 </div>
36 36 <label *ngIf="displayUserParameters"
37 37 translate class="tb-title no-padding" style="width: 60px;">filter.user-parameters</label>
... ...
... ... @@ -61,6 +61,15 @@
61 61 </mat-form-field>
62 62 <div class="tb-hint" translate>filter.dynamic-source-type</div>
63 63 </div>
  64 + <div *ngIf="!allow"
  65 + [ngClass]="{invisible: !inheritMode}"
  66 + fxLayout="column"
  67 + fxLayoutAlign="center center">
  68 + <mat-checkbox formControlName="inherit"
  69 + style="min-width: 35px;"
  70 + ></mat-checkbox>
  71 + <div class="tb-hint">Inherit from owner</div>
  72 + </div>
64 73 <div fxFlex fxLayout="column">
65 74 <mat-form-field floatLabel="always" hideRequiredMarker class="mat-block">
66 75 <mat-label></mat-label>
... ...
... ... @@ -44,6 +44,9 @@ import {
44 44 })
45 45 export class FilterPredicateValueComponent implements ControlValueAccessor, OnInit {
46 46
  47 + private readonly inheritFromSources: DynamicValueSourceType[] = [DynamicValueSourceType.CURRENT_CUSTOMER,
  48 + DynamicValueSourceType.CURRENT_DEVICE];
  49 +
47 50 @Input() disabled: boolean;
48 51
49 52 @Input()
... ... @@ -72,6 +75,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
72 75
73 76 dynamicMode = false;
74 77
  78 + inheritMode = false;
  79 +
75 80 allow = true;
76 81
77 82 private propagateChange = null;
... ... @@ -105,7 +110,8 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
105 110 dynamicValue: this.fb.group(
106 111 {
107 112 sourceType: [null],
108   - sourceAttribute: [null]
  113 + sourceAttribute: [null],
  114 + inherit: [false]
109 115 }
110 116 )
111 117 });
... ... @@ -114,6 +120,7 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
114 120 if (!sourceType) {
115 121 this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(null, {emitEvent: false});
116 122 }
  123 + this.updateInheritValue(sourceType);
117 124 }
118 125 );
119 126 this.filterPredicateValueFormGroup.valueChanges.subscribe(() => {
... ... @@ -139,10 +146,13 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
139 146
140 147 writeValue(predicateValue: FilterPredicateValue<string | number | boolean>): void {
141 148 this.filterPredicateValueFormGroup.get('defaultValue').patchValue(predicateValue.defaultValue, {emitEvent: false});
142   - this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceType').patchValue(predicateValue.dynamicValue ?
  149 + this.filterPredicateValueFormGroup.get('dynamicValue.sourceType').patchValue(predicateValue.dynamicValue ?
143 150 predicateValue.dynamicValue.sourceType : null, {emitEvent: false});
144   - this.filterPredicateValueFormGroup.get('dynamicValue').get('sourceAttribute').patchValue(predicateValue.dynamicValue ?
  151 + this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(predicateValue.dynamicValue ?
  152 + predicateValue.dynamicValue.inherit : false, {emitEvent: false});
  153 + this.filterPredicateValueFormGroup.get('dynamicValue.sourceAttribute').patchValue(predicateValue.dynamicValue ?
145 154 predicateValue.dynamicValue.sourceAttribute : null, {emitEvent: false});
  155 + this.updateInheritValue(predicateValue?.dynamicValue?.sourceType);
146 156 }
147 157
148 158 private updateModel() {
... ... @@ -158,4 +168,12 @@ export class FilterPredicateValueComponent implements ControlValueAccessor, OnIn
158 168 this.propagateChange(predicateValue);
159 169 }
160 170
  171 + private updateInheritValue(sourceType: DynamicValueSourceType) {
  172 + if (this.inheritFromSources.includes(sourceType)) {
  173 + this.inheritMode = true;
  174 + } else {
  175 + this.filterPredicateValueFormGroup.get('dynamicValue.inherit').patchValue(false, {emitEvent: false});
  176 + this.inheritMode = false;
  177 + }
  178 + }
161 179 }
... ...
... ... @@ -17,6 +17,10 @@
17 17 .tb-hint {
18 18 padding-bottom: 0;
19 19 }
  20 +
  21 + .invisible{
  22 + visibility: hidden;
  23 + }
20 24 }
21 25
22 26 :host ::ng-deep {
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <div fxFlex fxLayout="row" fxLayoutAlign="start start" fxLayoutGap="8px" [formGroup]="numericFilterPredicateFormGroup">
19   - <mat-form-field floatLabel="always" hideRequiredMarker fxFlex="40" class="mat-block">
  19 + <mat-form-field floatLabel="always" hideRequiredMarker fxFlex="30" class="mat-block">
20 20 <mat-label></mat-label>
21 21 <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
22 22 <mat-option *ngFor="let operation of numericOperations" [value]="operation">
... ... @@ -25,7 +25,7 @@
25 25 </mat-select>
26 26 </mat-form-field>
27 27 <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
28   - fxFlex="60"
  28 + fxFlex="70"
29 29 [valueType]="valueType"
30 30 formControlName="value">
31 31 </tb-filter-predicate-value>
... ...
... ... @@ -16,7 +16,7 @@
16 16
17 17 -->
18 18 <div fxFlex fxLayout="row" fxLayoutAlign="start start" fxLayoutGap="8px" [formGroup]="stringFilterPredicateFormGroup">
19   - <div fxFlex="40" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
  19 + <div fxFlex="30" fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px">
20 20 <mat-form-field floatLabel="always" hideRequiredMarker fxFlex class="mat-block">
21 21 <mat-label></mat-label>
22 22 <mat-select required formControlName="operation" placeholder="{{'filter.operation.operation' | translate}}">
... ... @@ -29,7 +29,7 @@
29 29 </mat-checkbox>
30 30 </div>
31 31 <tb-filter-predicate-value [allowUserDynamicSource]="allowUserDynamicSource"
32   - fxFlex="60"
  32 + fxFlex="70"
33 33 [valueType]="valueTypeEnum.STRING"
34 34 formControlName="value">
35 35 </tb-filter-predicate-value>
... ...
... ... @@ -285,6 +285,7 @@ export const dynamicValueSourceTypeTranslationMap = new Map<DynamicValueSourceTy
285 285 export interface DynamicValue<T> {
286 286 sourceType: DynamicValueSourceType;
287 287 sourceAttribute: string;
  288 + inherit?: boolean;
288 289 }
289 290
290 291 export interface FilterPredicateValue<T> {
... ...