Browse Source

UI: added workaround for lwm2m object list component propagating array of strings instead of objects

pull/11010/head
rusikv 2 years ago
parent
commit
1ec30b92ea
  1. 22
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
  2. 14
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts

22
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html

@ -18,16 +18,18 @@
<section style="padding-bottom: 16px; margin: 0"> <section style="padding-bottom: 16px; margin: 0">
<mat-tab-group dynamicHeight> <mat-tab-group dynamicHeight>
<mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}"> <mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
<section [formGroup]="lwm2mDeviceProfileFormGroup"> <ng-template matTabContent>
<tb-profile-lwm2m-object-list <section [formGroup]="lwm2mDeviceProfileFormGroup">
(addList)="addObjectsList($event)" <tb-profile-lwm2m-object-list
(removeList)="removeObjectsList($event)" (addList)="addObjectsList($event)"
formControlName="objectIds"> (removeList)="removeObjectsList($event)"
</tb-profile-lwm2m-object-list> formControlName="objectIds">
<tb-profile-lwm2m-observe-attr-telemetry </tb-profile-lwm2m-object-list>
formControlName="observeAttrTelemetry"> <tb-profile-lwm2m-observe-attr-telemetry
</tb-profile-lwm2m-observe-attr-telemetry> formControlName="observeAttrTelemetry">
</section> </tb-profile-lwm2m-observe-attr-telemetry>
</section>
</ng-template>
</mat-tab> </mat-tab>
<mat-tab label="{{ 'device-profile.lwm2m.bootstrap-tab' | translate }}"> <mat-tab label="{{ 'device-profile.lwm2m.bootstrap-tab' | translate }}">
<section [formGroup]="lwm2mDeviceProfileFormGroup"> <section [formGroup]="lwm2mDeviceProfileFormGroup">

14
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts

@ -31,7 +31,7 @@ import { distinctUntilChanged, filter, mergeMap, share, tap } from 'rxjs/operato
import { ObjectLwM2M, PAGE_SIZE_LIMIT } from './lwm2m-profile-config.models'; import { ObjectLwM2M, PAGE_SIZE_LIMIT } from './lwm2m-profile-config.models';
import { DeviceProfileService } from '@core/http/device-profile.service'; import { DeviceProfileService } from '@core/http/device-profile.service';
import { Direction } from '@shared/models/page/sort-order'; import { Direction } from '@shared/models/page/sort-order';
import { isDefined, isDefinedAndNotNull, isString } from '@core/utils'; import { isDefined, isDefinedAndNotNull, isObject, isString } from '@core/utils';
import { PageLink } from '@shared/models/page/page-link'; import { PageLink } from '@shared/models/page/page-link';
import { TruncatePipe } from '@shared/pipe/truncate.pipe'; import { TruncatePipe } from '@shared/pipe/truncate.pipe';
@ -90,12 +90,14 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
objectsList: [this.objectsList], objectsList: [this.objectsList],
objectLwm2m: [''] objectLwm2m: ['']
}); });
this.lwm2mListFormGroup.valueChanges.subscribe((value) => { this.lwm2mListFormGroup.get('objectsList').valueChanges.subscribe((value) => {
let formValue = null; if (!value.length || (value.length && isObject(value[0]))) {
if (this.lwm2mListFormGroup.valid) { let formValue = null;
formValue = value.objectsList; if (this.lwm2mListFormGroup.valid) {
formValue = value;
}
this.propagateChange(formValue);
} }
this.propagateChange(formValue);
}); });
} }

Loading…
Cancel
Save