Commit 06078a3163704942ee2bceeb4b92ac274754a7b7

Authored by Vladyslav_Prykhodko
Committed by Andrew Shvayka
1 parent f932a90b

UI: LwM2M remove required object list; change default setting; add text: no object found

... ... @@ -23,11 +23,9 @@
23 23 <tb-profile-lwm2m-object-list
24 24 (addList)="addObjectsList($event)"
25 25 (removeList)="removeObjectsList($event)"
26   - [required]="required"
27 26 formControlName="objectIds">
28 27 </tb-profile-lwm2m-object-list>
29 28 <tb-profile-lwm2m-observe-attr-telemetry
30   - [required]="required"
31 29 formControlName="observeAttrTelemetry">
32 30 </tb-profile-lwm2m-observe-attr-telemetry>
33 31 </section>
... ...
... ... @@ -50,7 +50,7 @@ import {
50 50 TELEMETRY
51 51 } from './lwm2m-profile-config.models';
52 52 import { DeviceProfileService } from '@core/http/device-profile.service';
53   -import { deepClone, isDefinedAndNotNull, isEmpty } from '@core/utils';
  53 +import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils';
54 54 import { JsonArray, JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
55 55 import { Direction } from '@shared/models/page/sort-order';
56 56 import _ from 'lodash';
... ... @@ -100,8 +100,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
100 100 constructor(private fb: FormBuilder,
101 101 private deviceProfileService: DeviceProfileService) {
102 102 this.lwm2mDeviceProfileFormGroup = this.fb.group({
103   - objectIds: [null, Validators.required],
104   - observeAttrTelemetry: [null, Validators.required],
  103 + objectIds: [null],
  104 + observeAttrTelemetry: [null],
105 105 bootstrap: this.fb.group({
106 106 servers: this.fb.group({
107 107 binding: [DEFAULT_BINDING],
... ... @@ -183,7 +183,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
183 183 async writeValue(value: Lwm2mProfileConfigModels | null) {
184 184 if (isDefinedAndNotNull(value) && (value?.clientLwM2mSettings || value?.observeAttr || value?.bootstrap)) {
185 185 this.configurationValue = value;
186   - const defaultFormSettings = !(value.observeAttr.attribute.length && value.observeAttr.telemetry.length);
  186 + const defaultFormSettings = value.clientLwM2mSettings.fwUpdateStrategy === 1 &&
  187 + isUndefined(value.clientLwM2mSettings.fwUpdateResource);
187 188 if (defaultFormSettings) {
188 189 await this.defaultProfileConfig();
189 190 }
... ...
... ... @@ -44,9 +44,14 @@
44 44 <span [innerHTML]="objectLwm2m.keyId + ': ' + (objectLwm2m.name | highlight: searchText)"></span>
45 45 </mat-option>
46 46 <mat-option *ngIf="!(filteredObjectsList | async)?.length" [value]="null">
47   - <span>
48   - {{ 'device-profile.lwm2m.no-objects-matching' | translate: {object: searchText} }}
49   - </span>
  47 + <div *ngIf="!textIsNotEmpty(searchText); else searchNotEmpty">
  48 + <span translate>device-profile.lwm2m.no-objects-found</span>
  49 + </div>
  50 + <ng-template #searchNotEmpty>
  51 + <span>
  52 + {{ 'device-profile.lwm2m.no-objects-matching' | translate:{object: truncate.transform(searchText, true, 6, &apos;...&apos;)} }}
  53 + </span>
  54 + </ng-template>
50 55 </mat-option>
51 56 </mat-autocomplete>
52 57 <mat-error *ngIf="lwm2mListFormGroup.get('objectsList').hasError('required')">
... ...
... ... @@ -33,6 +33,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
33 33 import { Direction } from '@shared/models/page/sort-order';
34 34 import { isDefined, isDefinedAndNotNull, isString } from '@core/utils';
35 35 import { PageLink } from '@shared/models/page/page-link';
  36 +import { TruncatePipe } from '@shared/pipe/truncate.pipe';
36 37
37 38 @Component({
38 39 selector: 'tb-profile-lwm2m-object-list',
... ... @@ -82,7 +83,8 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
82 83 private propagateChange = (v: any) => {
83 84 }
84 85
85   - constructor(private deviceProfileService: DeviceProfileService,
  86 + constructor(public truncate: TruncatePipe,
  87 + private deviceProfileService: DeviceProfileService,
86 88 private fb: FormBuilder) {
87 89 this.lwm2mListFormGroup = this.fb.group({
88 90 objectsList: [this.objectsList],
... ... @@ -196,6 +198,10 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
196 198 }
197 199 }
198 200
  201 + textIsNotEmpty(text: string): boolean {
  202 + return (text && text.length > 0);
  203 + }
  204 +
199 205 private clear(value = '', emitEvent = true) {
200 206 this.objectInput.nativeElement.value = value;
201 207 this.lwm2mListFormGroup.get('objectLwm2m').patchValue(value, {emitEvent});
... ...
... ... @@ -164,8 +164,8 @@ export interface ClientLwM2mSettings {
164 164 clientOnlyObserveAfterConnect: number;
165 165 fwUpdateStrategy: number;
166 166 swUpdateStrategy: number;
167   - fwUpdateResource: string;
168   - swUpdateResource: string;
  167 + fwUpdateResource?: string;
  168 + swUpdateResource?: string;
169 169 powerMode: PowerMode;
170 170 edrxCycle?: number;
171 171 pagingTransmissionWindow?: number;
... ... @@ -178,7 +178,7 @@ export interface ObservableAttributes {
178 178 attribute: string[];
179 179 telemetry: string[];
180 180 keyName: {};
181   - attributeLwm2m?: AttributesNameValueMap[];
  181 + attributeLwm2m: AttributesNameValueMap;
182 182 }
183 183
184 184 export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig {
... ... @@ -193,13 +193,13 @@ export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecu
193 193
194 194 export function getDefaultBootstrapServerSecurityConfig(): ServerSecurityConfig {
195 195 return {
  196 + bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT,
  197 + clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME,
196 198 host: DEFAULT_LOCAL_HOST_NAME,
197 199 port: DEFAULT_PORT_BOOTSTRAP_NO_SEC,
198 200 securityMode: securityConfigMode.NO_SEC,
199   - serverPublicKey: '',
200   - clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME,
201 201 serverId: DEFAULT_ID_BOOTSTRAP,
202   - bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT
  202 + serverPublicKey: ''
203 203 };
204 204 }
205 205
... ... @@ -216,7 +216,7 @@ export function getDefaultProfileObserveAttrConfig(): ObservableAttributes {
216 216 attribute: [],
217 217 telemetry: [],
218 218 keyName: {},
219   - attributeLwm2m: []
  219 + attributeLwm2m: {}
220 220 };
221 221 }
222 222
... ... @@ -225,8 +225,6 @@ export function getDefaultProfileClientLwM2mSettingsConfig(): ClientLwM2mSetting
225 225 clientOnlyObserveAfterConnect: 1,
226 226 fwUpdateStrategy: 1,
227 227 swUpdateStrategy: 1,
228   - fwUpdateResource: DEFAULT_FW_UPDATE_RESOURCE,
229   - swUpdateResource: DEFAULT_SW_UPDATE_RESOURCE,
230 228 powerMode: PowerMode.DRX,
231 229 compositeOperationsSupport: false
232 230 };
... ...
... ... @@ -1244,6 +1244,7 @@
1244 1244 "lwm2m": {
1245 1245 "object-list": "Object list",
1246 1246 "object-list-empty": "No objects selected.",
  1247 + "no-objects-found": "No objects found.",
1247 1248 "no-objects-matching": "No objects matching '{{object}}' were found.",
1248 1249 "model-tab": "LWM2M Model",
1249 1250 "add-new-instances": "Add new instances",
... ...