lwm2m: front fix bug profile updateObserve

This commit is contained in:
nickAS21 2021-03-29 11:13:26 +03:00
parent 8b23bd999f
commit 23373b055e
2 changed files with 15 additions and 7 deletions

View File

@ -55,12 +55,14 @@
</div>
<div fxFlex="10">
<mat-checkbox formControlName="attribute" color="warn"
[checked]="updateObserve(i)"
matTooltip="{{'device-profile.lwm2m.is-attr-tip' | translate}}"
matTooltipPosition="above">
</mat-checkbox>
</div>
<div fxFlex="10">
<mat-checkbox formControlName="telemetry" color="primary"
[checked]="updateObserve(i)"
matTooltip="{{'device-profile.lwm2m.is-telemetry-tip' | translate}}"
matTooltipPosition="above">
</mat-checkbox>

View File

@ -14,13 +14,13 @@
/// limitations under the License.
///
import { Component, forwardRef, Input } from '@angular/core';
import { ControlValueAccessor, FormArray, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { ResourceLwM2M } from '@home/components/profile/device/lwm2m/profile-config.models';
import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
import {Component, forwardRef, Input} from '@angular/core';
import {ControlValueAccessor, FormArray, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators} from '@angular/forms';
import {ResourceLwM2M} from '@home/components/profile/device/lwm2m/profile-config.models';
import {Store} from '@ngrx/store';
import {AppState} from '@core/core.state';
import _ from 'lodash';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
@Component({
selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource',
@ -95,7 +95,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
} else {
this.resourceFormArray.clear();
resourcesLwM2M.forEach(resourceLwM2M => {
this.resourceFormArray.push(this.fb.group({
this.resourceFormArray.push(this.fb.group( {
id: resourceLwM2M.id,
name: resourceLwM2M.name,
observe: resourceLwM2M.observe,
@ -124,4 +124,10 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
trackByParams = (index: number): number => {
return index;
}
updateObserve = (index: number): void =>{
if (this.resourceFormArray.at(index).value.attribute === false && this.resourceFormArray.at(index).value.telemetry === false) {
this.resourceFormArray.at(index).patchValue({observe: false});
}
}
}