Browse Source

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

pull/4981/head
Vladyslav_Prykhodko 5 years ago
committed by Andrew Shvayka
parent
commit
06078a3163
  1. 2
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
  2. 9
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
  3. 11
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.html
  4. 8
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-object-list.component.ts
  5. 16
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts
  6. 1
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -23,11 +23,9 @@
<tb-profile-lwm2m-object-list
(addList)="addObjectsList($event)"
(removeList)="removeObjectsList($event)"
[required]="required"
formControlName="objectIds">
</tb-profile-lwm2m-object-list>
<tb-profile-lwm2m-observe-attr-telemetry
[required]="required"
formControlName="observeAttrTelemetry">
</tb-profile-lwm2m-observe-attr-telemetry>
</section>

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

@ -50,7 +50,7 @@ import {
TELEMETRY
} from './lwm2m-profile-config.models';
import { DeviceProfileService } from '@core/http/device-profile.service';
import { deepClone, isDefinedAndNotNull, isEmpty } from '@core/utils';
import { deepClone, isDefinedAndNotNull, isEmpty, isUndefined } from '@core/utils';
import { JsonArray, JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
import { Direction } from '@shared/models/page/sort-order';
import _ from 'lodash';
@ -100,8 +100,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
constructor(private fb: FormBuilder,
private deviceProfileService: DeviceProfileService) {
this.lwm2mDeviceProfileFormGroup = this.fb.group({
objectIds: [null, Validators.required],
observeAttrTelemetry: [null, Validators.required],
objectIds: [null],
observeAttrTelemetry: [null],
bootstrap: this.fb.group({
servers: this.fb.group({
binding: [DEFAULT_BINDING],
@ -183,7 +183,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
async writeValue(value: Lwm2mProfileConfigModels | null) {
if (isDefinedAndNotNull(value) && (value?.clientLwM2mSettings || value?.observeAttr || value?.bootstrap)) {
this.configurationValue = value;
const defaultFormSettings = !(value.observeAttr.attribute.length && value.observeAttr.telemetry.length);
const defaultFormSettings = value.clientLwM2mSettings.fwUpdateStrategy === 1 &&
isUndefined(value.clientLwM2mSettings.fwUpdateResource);
if (defaultFormSettings) {
await this.defaultProfileConfig();
}

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

@ -44,9 +44,14 @@
<span [innerHTML]="objectLwm2m.keyId + ': ' + (objectLwm2m.name | highlight: searchText)"></span>
</mat-option>
<mat-option *ngIf="!(filteredObjectsList | async)?.length" [value]="null">
<span>
{{ 'device-profile.lwm2m.no-objects-matching' | translate: {object: searchText} }}
</span>
<div *ngIf="!textIsNotEmpty(searchText); else searchNotEmpty">
<span translate>device-profile.lwm2m.no-objects-found</span>
</div>
<ng-template #searchNotEmpty>
<span>
{{ 'device-profile.lwm2m.no-objects-matching' | translate:{object: truncate.transform(searchText, true, 6, &apos;...&apos;)} }}
</span>
</ng-template>
</mat-option>
</mat-autocomplete>
<mat-error *ngIf="lwm2mListFormGroup.get('objectsList').hasError('required')">

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

@ -33,6 +33,7 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
import { Direction } from '@shared/models/page/sort-order';
import { isDefined, isDefinedAndNotNull, isString } from '@core/utils';
import { PageLink } from '@shared/models/page/page-link';
import { TruncatePipe } from '@shared/pipe/truncate.pipe';
@Component({
selector: 'tb-profile-lwm2m-object-list',
@ -82,7 +83,8 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
private propagateChange = (v: any) => {
}
constructor(private deviceProfileService: DeviceProfileService,
constructor(public truncate: TruncatePipe,
private deviceProfileService: DeviceProfileService,
private fb: FormBuilder) {
this.lwm2mListFormGroup = this.fb.group({
objectsList: [this.objectsList],
@ -196,6 +198,10 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
}
}
textIsNotEmpty(text: string): boolean {
return (text && text.length > 0);
}
private clear(value = '', emitEvent = true) {
this.objectInput.nativeElement.value = value;
this.lwm2mListFormGroup.get('objectLwm2m').patchValue(value, {emitEvent});

16
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts

@ -164,8 +164,8 @@ export interface ClientLwM2mSettings {
clientOnlyObserveAfterConnect: number;
fwUpdateStrategy: number;
swUpdateStrategy: number;
fwUpdateResource: string;
swUpdateResource: string;
fwUpdateResource?: string;
swUpdateResource?: string;
powerMode: PowerMode;
edrxCycle?: number;
pagingTransmissionWindow?: number;
@ -178,7 +178,7 @@ export interface ObservableAttributes {
attribute: string[];
telemetry: string[];
keyName: {};
attributeLwm2m?: AttributesNameValueMap[];
attributeLwm2m: AttributesNameValueMap;
}
export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig {
@ -193,13 +193,13 @@ export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecu
export function getDefaultBootstrapServerSecurityConfig(): ServerSecurityConfig {
return {
bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT,
clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME,
host: DEFAULT_LOCAL_HOST_NAME,
port: DEFAULT_PORT_BOOTSTRAP_NO_SEC,
securityMode: securityConfigMode.NO_SEC,
serverPublicKey: '',
clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME,
serverId: DEFAULT_ID_BOOTSTRAP,
bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT
serverPublicKey: ''
};
}
@ -216,7 +216,7 @@ export function getDefaultProfileObserveAttrConfig(): ObservableAttributes {
attribute: [],
telemetry: [],
keyName: {},
attributeLwm2m: []
attributeLwm2m: {}
};
}
@ -225,8 +225,6 @@ export function getDefaultProfileClientLwM2mSettingsConfig(): ClientLwM2mSetting
clientOnlyObserveAfterConnect: 1,
fwUpdateStrategy: 1,
swUpdateStrategy: 1,
fwUpdateResource: DEFAULT_FW_UPDATE_RESOURCE,
swUpdateResource: DEFAULT_SW_UPDATE_RESOURCE,
powerMode: PowerMode.DRX,
compositeOperationsSupport: false
};

1
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1244,6 +1244,7 @@
"lwm2m": {
"object-list": "Object list",
"object-list-empty": "No objects selected.",
"no-objects-found": "No objects found.",
"no-objects-matching": "No objects matching '{{object}}' were found.",
"model-tab": "LWM2M Model",
"add-new-instances": "Add new instances",

Loading…
Cancel
Save