Commit 23373b055ea4341a4aadd6698be1b0fe5a00df0c
1 parent
8b23bd99
lwm2m: front fix bug profile updateObserve
Showing
2 changed files
with
15 additions
and
7 deletions
... | ... | @@ -55,12 +55,14 @@ |
55 | 55 | </div> |
56 | 56 | <div fxFlex="10"> |
57 | 57 | <mat-checkbox formControlName="attribute" color="warn" |
58 | + [checked]="updateObserve(i)" | |
58 | 59 | matTooltip="{{'device-profile.lwm2m.is-attr-tip' | translate}}" |
59 | 60 | matTooltipPosition="above"> |
60 | 61 | </mat-checkbox> |
61 | 62 | </div> |
62 | 63 | <div fxFlex="10"> |
63 | 64 | <mat-checkbox formControlName="telemetry" color="primary" |
65 | + [checked]="updateObserve(i)" | |
64 | 66 | matTooltip="{{'device-profile.lwm2m.is-telemetry-tip' | translate}}" |
65 | 67 | matTooltipPosition="above"> |
66 | 68 | </mat-checkbox> | ... | ... |
... | ... | @@ -14,13 +14,13 @@ |
14 | 14 | /// limitations under the License. |
15 | 15 | /// |
16 | 16 | |
17 | -import { Component, forwardRef, Input } from '@angular/core'; | |
18 | -import { ControlValueAccessor, FormArray, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms'; | |
19 | -import { ResourceLwM2M } from '@home/components/profile/device/lwm2m/profile-config.models'; | |
20 | -import { Store } from '@ngrx/store'; | |
21 | -import { AppState } from '@core/core.state'; | |
17 | +import {Component, forwardRef, Input} from '@angular/core'; | |
18 | +import {ControlValueAccessor, FormArray, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators} from '@angular/forms'; | |
19 | +import {ResourceLwM2M} from '@home/components/profile/device/lwm2m/profile-config.models'; | |
20 | +import {Store} from '@ngrx/store'; | |
21 | +import {AppState} from '@core/core.state'; | |
22 | 22 | import _ from 'lodash'; |
23 | -import { coerceBooleanProperty } from '@angular/cdk/coercion'; | |
23 | +import {coerceBooleanProperty} from '@angular/cdk/coercion'; | |
24 | 24 | |
25 | 25 | @Component({ |
26 | 26 | selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource', |
... | ... | @@ -95,7 +95,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA |
95 | 95 | } else { |
96 | 96 | this.resourceFormArray.clear(); |
97 | 97 | resourcesLwM2M.forEach(resourceLwM2M => { |
98 | - this.resourceFormArray.push(this.fb.group({ | |
98 | + this.resourceFormArray.push(this.fb.group( { | |
99 | 99 | id: resourceLwM2M.id, |
100 | 100 | name: resourceLwM2M.name, |
101 | 101 | observe: resourceLwM2M.observe, |
... | ... | @@ -124,4 +124,10 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA |
124 | 124 | trackByParams = (index: number): number => { |
125 | 125 | return index; |
126 | 126 | } |
127 | + | |
128 | + updateObserve = (index: number): void =>{ | |
129 | + if (this.resourceFormArray.at(index).value.attribute === false && this.resourceFormArray.at(index).value.telemetry === false) { | |
130 | + this.resourceFormArray.at(index).patchValue({observe: false}); | |
131 | + } | |
132 | + } | |
127 | 133 | } | ... | ... |