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,12 +55,14 @@ | ||
55 | </div> | 55 | </div> |
56 | <div fxFlex="10"> | 56 | <div fxFlex="10"> |
57 | <mat-checkbox formControlName="attribute" color="warn" | 57 | <mat-checkbox formControlName="attribute" color="warn" |
58 | + [checked]="updateObserve(i)" | ||
58 | matTooltip="{{'device-profile.lwm2m.is-attr-tip' | translate}}" | 59 | matTooltip="{{'device-profile.lwm2m.is-attr-tip' | translate}}" |
59 | matTooltipPosition="above"> | 60 | matTooltipPosition="above"> |
60 | </mat-checkbox> | 61 | </mat-checkbox> |
61 | </div> | 62 | </div> |
62 | <div fxFlex="10"> | 63 | <div fxFlex="10"> |
63 | <mat-checkbox formControlName="telemetry" color="primary" | 64 | <mat-checkbox formControlName="telemetry" color="primary" |
65 | + [checked]="updateObserve(i)" | ||
64 | matTooltip="{{'device-profile.lwm2m.is-telemetry-tip' | translate}}" | 66 | matTooltip="{{'device-profile.lwm2m.is-telemetry-tip' | translate}}" |
65 | matTooltipPosition="above"> | 67 | matTooltipPosition="above"> |
66 | </mat-checkbox> | 68 | </mat-checkbox> |
@@ -14,13 +14,13 @@ | @@ -14,13 +14,13 @@ | ||
14 | /// limitations under the License. | 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 | import _ from 'lodash'; | 22 | import _ from 'lodash'; |
23 | -import { coerceBooleanProperty } from '@angular/cdk/coercion'; | 23 | +import {coerceBooleanProperty} from '@angular/cdk/coercion'; |
24 | 24 | ||
25 | @Component({ | 25 | @Component({ |
26 | selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource', | 26 | selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource', |
@@ -95,7 +95,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA | @@ -95,7 +95,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA | ||
95 | } else { | 95 | } else { |
96 | this.resourceFormArray.clear(); | 96 | this.resourceFormArray.clear(); |
97 | resourcesLwM2M.forEach(resourceLwM2M => { | 97 | resourcesLwM2M.forEach(resourceLwM2M => { |
98 | - this.resourceFormArray.push(this.fb.group({ | 98 | + this.resourceFormArray.push(this.fb.group( { |
99 | id: resourceLwM2M.id, | 99 | id: resourceLwM2M.id, |
100 | name: resourceLwM2M.name, | 100 | name: resourceLwM2M.name, |
101 | observe: resourceLwM2M.observe, | 101 | observe: resourceLwM2M.observe, |
@@ -124,4 +124,10 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA | @@ -124,4 +124,10 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA | ||
124 | trackByParams = (index: number): number => { | 124 | trackByParams = (index: number): number => { |
125 | return index; | 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 | } |