diff --git a/ui-ngx/src/app/core/http/device-profile.service.ts b/ui-ngx/src/app/core/http/device-profile.service.ts
index 1514b262aa..19aac62204 100644
--- a/ui-ngx/src/app/core/http/device-profile.service.ts
+++ b/ui-ngx/src/app/core/http/device-profile.service.ts
@@ -84,20 +84,22 @@ export class DeviceProfileService {
return this.getLwm2mBootstrapSecurityInfo(isBootstrapServer, config).pipe(
map(securityConfig => {
const serverSecurityConfigInfo = deepClone(securityConfig);
- switch (securityMode) {
- case Lwm2mSecurityType.PSK:
- serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort;
- serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost;
- serverSecurityConfigInfo.serverPublicKey = '';
- break;
- case Lwm2mSecurityType.RPK:
- case Lwm2mSecurityType.X509:
- serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort;
- serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost;
- break;
- case Lwm2mSecurityType.NO_SEC:
- serverSecurityConfigInfo.serverPublicKey = '';
- break;
+ if (serverSecurityConfigInfo) {
+ switch (securityMode) {
+ case Lwm2mSecurityType.PSK:
+ serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort;
+ serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost;
+ serverSecurityConfigInfo.serverPublicKey = '';
+ break;
+ case Lwm2mSecurityType.RPK:
+ case Lwm2mSecurityType.X509:
+ serverSecurityConfigInfo.port = serverSecurityConfigInfo.securityPort;
+ serverSecurityConfigInfo.host = serverSecurityConfigInfo.securityHost;
+ break;
+ case Lwm2mSecurityType.NO_SEC:
+ serverSecurityConfigInfo.serverPublicKey = '';
+ break;
+ }
}
return serverSecurityConfigInfo;
})
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html
index ebd80ef558..443264eead 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.html
@@ -20,7 +20,8 @@
+ (removeServer)="removeServerConfig($event, $index)"
+ (isTransportWasRunWithBootstrapChange)="updateIsTransportWasRunWithBootstrap($event)">
@@ -32,8 +33,8 @@
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.ts
index 9230195efe..b7786a5fa2 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-bootstrap-config-servers.component.ts
@@ -14,7 +14,7 @@
/// limitations under the License.
///
-import { ChangeDetectorRef, Component, forwardRef, Input, OnInit } from '@angular/core';
+import { Component, EventEmitter, forwardRef, Input, OnInit, Output } from '@angular/core';
import {
AbstractControl,
ControlValueAccessor,
@@ -57,6 +57,12 @@ export class Lwm2mBootstrapConfigServersComponent implements OnInit, ControlValu
@Input()
disabled: boolean;
+ @Input()
+ isTransportWasRunWithBootstrap: boolean;
+
+ @Output()
+ isTransportWasRunWithBootstrapChange = new EventEmitter();
+
public isBootstrapServerUpdateEnableValue: boolean;
@Input()
set isBootstrapServerUpdateEnable(value: boolean) {
@@ -147,7 +153,7 @@ export class Lwm2mBootstrapConfigServersComponent implements OnInit, ControlValu
}
addServerConfig(): void {
- const addDialogObs = (this.isBootstrapAdded() || !this.isBootstrapServerUpdateEnableValue) ? of(false) :
+ const addDialogObs = this.isBootstrapServerNotAvailable() ? of(false) :
this.matDialog.open(Lwm2mBootstrapAddConfigServerDialogComponent, {
disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog']
@@ -165,10 +171,18 @@ export class Lwm2mBootstrapConfigServersComponent implements OnInit, ControlValu
serverConfig.securityMode = Lwm2mSecurityType.NO_SEC;
this.serverConfigsFromArray().push(this.fb.control(serverConfig));
this.updateModel();
+ } else {
+ this.isTransportWasRunWithBootstrap = false;
+ this.isTransportWasRunWithBootstrapChange.emit(this.isTransportWasRunWithBootstrap);
}
});
}
+ updateIsTransportWasRunWithBootstrap(newValue: boolean): void {
+ this.isTransportWasRunWithBootstrap = newValue;
+ this.isTransportWasRunWithBootstrapChange.emit(this.isTransportWasRunWithBootstrap);
+ }
+
public validate(c: FormControl) {
return (this.bootstrapConfigServersFormGroup.valid) ? null : {
serverConfigs: {
@@ -177,7 +191,11 @@ export class Lwm2mBootstrapConfigServersComponent implements OnInit, ControlValu
};
}
- public isBootstrapAdded() {
+ public isBootstrapServerNotAvailable(): boolean {
+ return this.isBootstrapAdded() || !this.isBootstrapServerUpdateEnableValue || !this.isTransportWasRunWithBootstrap;
+ }
+
+ private isBootstrapAdded(): boolean {
const serverConfigsArray = this.serverConfigsFromArray().getRawValue();
for (let i = 0; i < serverConfigsArray.length; i++) {
if (serverConfigsArray[i].bootstrapServerIs) {
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
index c92cf9ef45..fa6d31153c 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-config-server.component.ts
@@ -71,10 +71,14 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
credentialTypeLwM2MNamesMap = Lwm2mSecurityTypeTranslationMap;
publicKeyOrIdTooltipNamesMap = Lwm2mPublicKeyOrIdTooltipTranslationsMap;
currentSecurityMode = null;
+ bootstrapDisabled = false;
@Output()
removeServer = new EventEmitter();
+ @Output()
+ isTransportWasRunWithBootstrapChange = new EventEmitter();
+
private propagateChange = (v: any) => { };
constructor(public fb: FormBuilder,
@@ -136,6 +140,11 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
if (!serverData) {
this.serverFormGroup.patchValue(value);
}
+ if (!value && this.serverFormGroup.get('bootstrapServerIs').value === true) {
+ this.isTransportWasRunWithBootstrapChange.emit(false);
+ this.bootstrapDisabled = true;
+ this.serverFormGroup.get('securityMode').disable({emitEvent: false});
+ }
});
}
}
@@ -150,6 +159,9 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
this.serverFormGroup.disable({emitEvent: false});
} else {
this.serverFormGroup.enable({emitEvent: false});
+ if (this.bootstrapDisabled) {
+ this.serverFormGroup.get('securityMode').disable({emitEvent: false});
+ }
}
}
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
index 05643ae497..4133600ba8 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
@@ -33,12 +33,17 @@
+
+ warning
+ LwM2M transport was run without bootstrap server
+
{{ 'device-profile.lwm2m.include-bootstrap-server' | translate }}
+ [isBootstrapServerUpdateEnable]="isBootstrapServerUpdateEnable"
+ [(isTransportWasRunWithBootstrap)]="isTransportWasRunWithBootstrap">
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
index d8fc933fdb..7da250fa4e 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
@@ -74,6 +74,7 @@ import { TranslateService } from '@ngx-translate/core';
export class Lwm2mDeviceProfileTransportConfigurationComponent implements ControlValueAccessor, Validator, OnDestroy {
public disabled = false;
+ public isTransportWasRunWithBootstrap = true;
public isBootstrapServerUpdateEnable: boolean;
private requiredValue: boolean;
private destroy$ = new Subject();
@@ -226,10 +227,16 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
}
private async defaultProfileConfig(): Promise {
- const lwm2m: ServerSecurityConfig = await this.deviceProfileService.getLwm2mBootstrapSecurityInfoBySecurityType(false).toPromise();
+ let lwm2m: ServerSecurityConfig;
+ let bootstrap: ServerSecurityConfig;
+ [bootstrap, lwm2m] = await Promise.all([
+ this.deviceProfileService.getLwm2mBootstrapSecurityInfoBySecurityType(true).toPromise(),
+ this.deviceProfileService.getLwm2mBootstrapSecurityInfoBySecurityType(false).toPromise(),
+ ]);
if (lwm2m) {
lwm2m.securityMode = Lwm2mSecurityType.NO_SEC;
}
+ this.isTransportWasRunWithBootstrap = !!bootstrap;
this.configurationValue.bootstrap = [lwm2m];
this.lwm2mDeviceProfileFormGroup.patchValue({
bootstrap: this.configurationValue.bootstrap