Commit cfa9a5778a9ae7b26c92dc80cb7e4d9265a8a11f

Authored by nickAS21
1 parent efb671f4

Lwm2m: front: refactoring

Showing 19 changed files with 778 additions and 718 deletions
@@ -90,9 +90,14 @@ @@ -90,9 +90,14 @@
90 serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509"> 90 serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509">
91 <mat-form-field class="mat-block"> 91 <mat-form-field class="mat-block">
92 <mat-label>{{ 'device-profile.lwm2m.server-public-key' | translate }}</mat-label> 92 <mat-label>{{ 'device-profile.lwm2m.server-public-key' | translate }}</mat-label>
93 - <textarea matInput type="text" rows="3" cols="1" required  
94 - formControlName="serverPublicKey" #serverPublicKey 93 + <textarea matInput
  94 + #serverPublicKey
95 maxlength="{{lenMaxServerPublicKey}}" 95 maxlength="{{lenMaxServerPublicKey}}"
  96 + cdkTextareaAutosize
  97 + cdkAutosizeMinRows="1"
  98 + cols="1" required
  99 + style="overflow:hidden"
  100 + formControlName="serverPublicKey"
96 matTooltip="{{'device-profile.lwm2m.server-public-key-tip' | translate}}" 101 matTooltip="{{'device-profile.lwm2m.server-public-key-tip' | translate}}"
97 ></textarea> 102 ></textarea>
98 <mat-hint align="end">{{serverPublicKey.value?.length || 0}}/{{lenMaxServerPublicKey}}</mat-hint> 103 <mat-hint align="end">{{serverPublicKey.value?.length || 0}}/{{lenMaxServerPublicKey}}</mat-hint>
@@ -101,14 +106,18 @@ @@ -101,14 +106,18 @@
101 <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong> 106 <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>
102 </mat-error> 107 </mat-error>
103 <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('pattern') && 108 <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('pattern') &&
104 - serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK">  
105 - {{ 'device-profile.lwm2m.client-key' | translate }}  
106 - <strong>{{ 'device-profile.lwm2m.pattern_hex_dec_182' | translate }}</strong> 109 + (serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK ||
  110 + serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509)">
  111 + {{ 'device-profile.lwm2m.server-public-key' | translate }}
  112 + <strong>{{ translate.get('device-profile.lwm2m.pattern_hex_dec', {
  113 + count: 0}) | async }}</strong>
107 </mat-error> 114 </mat-error>
108 - <mat-error *ngIf="serverFormGroup.get('serverPublicKey').hasError('pattern') &&  
109 - serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509">  
110 - {{ 'device-profile.lwm2m.client-key' | translate }}  
111 - <strong>{{ 'device-profile.lwm2m.pattern_hex_dec' | translate }}</strong> 115 + <mat-error *ngIf="(serverFormGroup.get('serverPublicKey').hasError('maxlength') ||
  116 + serverFormGroup.get('serverPublicKey').hasError('minlength')) &&
  117 + serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK">
  118 + {{ 'device-profile.lwm2m.server-public-key' | translate }}
  119 + <strong>{{ translate.get('device-profile.lwm2m.pattern_hex_dec', {
  120 + count: lenMaxServerPublicKey }) | async }}</strong>
112 </mat-error> 121 </mat-error>
113 </mat-form-field> 122 </mat-form-field>
114 </div> 123 </div>
@@ -14,31 +14,28 @@ @@ -14,31 +14,28 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import { Component, forwardRef, Inject, Input, OnInit } from "@angular/core"; 17 +import { Component, forwardRef, Inject, Input, OnInit } from '@angular/core';
18 18
19 import { 19 import {
20 ControlValueAccessor, 20 ControlValueAccessor,
21 - FormBuilder, FormGroup, NG_VALUE_ACCESSOR, NgModel, Validators  
22 -} from "@angular/forms"; 21 + FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators
  22 +} from '@angular/forms';
23 import { 23 import {
24 SECURITY_CONFIG_MODE, 24 SECURITY_CONFIG_MODE,
25 SECURITY_CONFIG_MODE_NAMES, 25 SECURITY_CONFIG_MODE_NAMES,
26 - KEY_PUBLIC_REGEXP_PSK,  
27 ServerSecurityConfig, 26 ServerSecurityConfig,
28 - LEN_MAX_PUBLIC_KEY_PSK,  
29 - LEN_MAX_PUBLIC_KEY_RPK_X509,  
30 - KEY_PUBLIC_REGEXP_X509,  
31 DEFAULT_PORT_BOOTSTRAP_NO_SEC, 27 DEFAULT_PORT_BOOTSTRAP_NO_SEC,
32 DEFAULT_PORT_SERVER_NO_SEC, 28 DEFAULT_PORT_SERVER_NO_SEC,
33 DEFAULT_CLIENT_HOLD_OFF_TIME, 29 DEFAULT_CLIENT_HOLD_OFF_TIME,
34 - DEFAULT_ID_SERVER  
35 -} from "./profile-config.models";  
36 -import { Store } from "@ngrx/store";  
37 -import { AppState } from "@core/core.state";  
38 -import { coerceBooleanProperty } from "@angular/cdk/coercion";  
39 -import { WINDOW } from "@core/services/window.service"; 30 + DEFAULT_ID_SERVER, LEN_MAX_PUBLIC_KEY_RPK, LEN_MAX_PUBLIC_KEY_X509, KEY_REGEXP_HEX_DEC
  31 +} from './profile-config.models';
  32 +import { Store } from '@ngrx/store';
  33 +import { AppState } from '@core/core.state';
  34 +import { coerceBooleanProperty } from '@angular/cdk/coercion';
  35 +import { WINDOW } from '@core/services/window.service';
40 import { pairwise, startWith } from 'rxjs/operators'; 36 import { pairwise, startWith } from 'rxjs/operators';
41 import { DeviceProfileService } from '@core/http/device-profile.service'; 37 import { DeviceProfileService } from '@core/http/device-profile.service';
  38 +import { TranslateService } from '@ngx-translate/core';
42 39
43 @Component({ 40 @Component({
44 selector: 'tb-profile-lwm2m-device-config-server', 41 selector: 'tb-profile-lwm2m-device-config-server',
@@ -55,12 +52,14 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; @@ -55,12 +52,14 @@ import { DeviceProfileService } from '@core/http/device-profile.service';
55 export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAccessor, Validators { 52 export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAccessor, Validators {
56 53
57 private requiredValue: boolean; 54 private requiredValue: boolean;
  55 +
58 valuePrev = null; 56 valuePrev = null;
59 serverFormGroup: FormGroup; 57 serverFormGroup: FormGroup;
60 securityConfigLwM2MType = SECURITY_CONFIG_MODE; 58 securityConfigLwM2MType = SECURITY_CONFIG_MODE;
61 securityConfigLwM2MTypes = Object.keys(SECURITY_CONFIG_MODE); 59 securityConfigLwM2MTypes = Object.keys(SECURITY_CONFIG_MODE);
62 credentialTypeLwM2MNamesMap = SECURITY_CONFIG_MODE_NAMES; 60 credentialTypeLwM2MNamesMap = SECURITY_CONFIG_MODE_NAMES;
63 - lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_PSK; 61 + lenMinServerPublicKey = 0;
  62 + lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK;
64 currentSecurityMode = null; 63 currentSecurityMode = null;
65 64
66 65
@@ -80,6 +79,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -80,6 +79,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
80 } 79 }
81 80
82 constructor(protected store: Store<AppState>, 81 constructor(protected store: Store<AppState>,
  82 + public translate: TranslateService,
83 public fb: FormBuilder, 83 public fb: FormBuilder,
84 private deviceProfileService: DeviceProfileService, 84 private deviceProfileService: DeviceProfileService,
85 @Inject(WINDOW) private window: Window) { 85 @Inject(WINDOW) private window: Window) {
@@ -105,7 +105,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -105,7 +105,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
105 ngOnInit(): void { 105 ngOnInit(): void {
106 } 106 }
107 107
108 - updateValueFields(serverData: ServerSecurityConfig): void { 108 + private updateValueFields = (serverData: ServerSecurityConfig): void => {
109 serverData.bootstrapServerIs = this.bootstrapServerIs; 109 serverData.bootstrapServerIs = this.bootstrapServerIs;
110 this.serverFormGroup.patchValue(serverData, {emitEvent: false}); 110 this.serverFormGroup.patchValue(serverData, {emitEvent: false});
111 this.serverFormGroup.get('bootstrapServerIs').disable(); 111 this.serverFormGroup.get('bootstrapServerIs').disable();
@@ -113,40 +113,38 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -113,40 +113,38 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
113 this.updateValidate(securityMode); 113 this.updateValidate(securityMode);
114 } 114 }
115 115
116 - updateValidate(securityMode: SECURITY_CONFIG_MODE): void { 116 + private updateValidate = (securityMode: SECURITY_CONFIG_MODE): void => {
117 switch (securityMode) { 117 switch (securityMode) {
118 case SECURITY_CONFIG_MODE.NO_SEC: 118 case SECURITY_CONFIG_MODE.NO_SEC:
119 - this.serverFormGroup.get('serverPublicKey').setValidators([]); 119 + this.setValidatorsNoSecPsk();
120 break; 120 break;
121 case SECURITY_CONFIG_MODE.PSK: 121 case SECURITY_CONFIG_MODE.PSK:
122 - this.lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_PSK;  
123 - this.serverFormGroup.get('serverPublicKey').setValidators([]); 122 + this.setValidatorsNoSecPsk();
124 break; 123 break;
125 case SECURITY_CONFIG_MODE.RPK: 124 case SECURITY_CONFIG_MODE.RPK:
126 - this.lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK_X509;  
127 - this.serverFormGroup.get('serverPublicKey').setValidators([Validators.required, Validators.pattern(KEY_PUBLIC_REGEXP_PSK)]); 125 + this.lenMinServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK;
  126 + this.lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK;
  127 + this.setValidatorsRpkX509();
128 break; 128 break;
129 case SECURITY_CONFIG_MODE.X509: 129 case SECURITY_CONFIG_MODE.X509:
130 - this.lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_RPK_X509;  
131 - this.serverFormGroup.get('serverPublicKey').setValidators([Validators.required, Validators.pattern(KEY_PUBLIC_REGEXP_X509)]); 130 + this.lenMinServerPublicKey = 0;
  131 + this.lenMaxServerPublicKey = LEN_MAX_PUBLIC_KEY_X509;
  132 + this.setValidatorsRpkX509();
132 break; 133 break;
133 } 134 }
134 this.serverFormGroup.updateValueAndValidity(); 135 this.serverFormGroup.updateValueAndValidity();
135 - // this.checkValueWithNewValidate();  
136 } 136 }
137 137
138 - // checkValueWithNewValidate(): void {  
139 - // this.serverFormGroup.patchValue({  
140 - // host: this.serverFormGroup.get('host').value,  
141 - // port: this.serverFormGroup.get('port').value,  
142 - // bootstrapServerIs: this.serverFormGroup.get('bootstrapServerIs').value,  
143 - // serverPublicKey: this.serverFormGroup.get('serverPublicKey').value,  
144 - // clientHoldOffTime: this.serverFormGroup.get('clientHoldOffTime').value,  
145 - // serverId: this.serverFormGroup.get('serverId').value,  
146 - // bootstrapServerAccountTimeout: this.serverFormGroup.get('bootstrapServerAccountTimeout').value,  
147 - // },  
148 - // {emitEvent: true});  
149 - // } 138 + private setValidatorsNoSecPsk = (): void => {
  139 + this.serverFormGroup.get('serverPublicKey').setValidators([]);
  140 + }
  141 +
  142 + private setValidatorsRpkX509 = (): void => {
  143 + this.serverFormGroup.get('serverPublicKey').setValidators([Validators.required,
  144 + Validators.pattern(KEY_REGEXP_HEX_DEC),
  145 + Validators.minLength(this.lenMinServerPublicKey),
  146 + Validators.maxLength(this.lenMaxServerPublicKey)]);
  147 + }
150 148
151 writeValue(value: any): void { 149 writeValue(value: any): void {
152 if (value) { 150 if (value) {
@@ -160,7 +158,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -160,7 +158,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
160 this.propagateChange = fn; 158 this.propagateChange = fn;
161 } 159 }
162 160
163 - private propagateChangeState(value: any): void { 161 + private propagateChangeState = (value: any): void => {
164 if (value !== undefined) { 162 if (value !== undefined) {
165 if (this.valuePrev === null) { 163 if (this.valuePrev === null) {
166 this.valuePrev = 'init'; 164 this.valuePrev = 'init';
@@ -190,7 +188,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -190,7 +188,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
190 registerOnTouched(fn: any): void { 188 registerOnTouched(fn: any): void {
191 } 189 }
192 190
193 - getServerGroup(): FormGroup { 191 + private getServerGroup = (): FormGroup => {
194 const port = this.bootstrapServerIs ? DEFAULT_PORT_BOOTSTRAP_NO_SEC : DEFAULT_PORT_SERVER_NO_SEC; 192 const port = this.bootstrapServerIs ? DEFAULT_PORT_BOOTSTRAP_NO_SEC : DEFAULT_PORT_SERVER_NO_SEC;
195 return this.fb.group({ 193 return this.fb.group({
196 host: [this.window.location.hostname, this.required ? [Validators.required] : []], 194 host: [this.window.location.hostname, this.required ? [Validators.required] : []],
@@ -204,7 +202,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc @@ -204,7 +202,7 @@ export class Lwm2mDeviceConfigServerComponent implements OnInit, ControlValueAcc
204 }); 202 });
205 } 203 }
206 204
207 - getLwm2mBootstrapSecurityInfo(mode: string) { 205 + private getLwm2mBootstrapSecurityInfo = (mode: string): void => {
208 this.deviceProfileService.getLwm2mBootstrapSecurityInfo(mode, this.serverFormGroup.get('bootstrapServerIs').value).subscribe( 206 this.deviceProfileService.getLwm2mBootstrapSecurityInfo(mode, this.serverFormGroup.get('bootstrapServerIs').value).subscribe(
209 (serverSecurityConfig) => { 207 (serverSecurityConfig) => {
210 this.serverFormGroup.patchValue({ 208 this.serverFormGroup.patchValue({
@@ -19,118 +19,126 @@ @@ -19,118 +19,126 @@
19 <div mat-dialog-content> 19 <div mat-dialog-content>
20 <mat-tab-group dynamicHeight> 20 <mat-tab-group dynamicHeight>
21 <mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}"> 21 <mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
22 - <div class="mat-padding">  
23 - <tb-profile-lwm2m-object-list  
24 - (addList)="addObjectsList($event)"  
25 - (removeList)="removeObjectsList($event)"  
26 - [required]="required"  
27 - formControlName="objectIds">  
28 - </tb-profile-lwm2m-object-list>  
29 - </div>  
30 - <div class="mat-padding">  
31 - <tb-profile-lwm2m-observe-attr-telemetry  
32 - [required]="required"  
33 - formControlName="observeAttrTelemetry">  
34 - </tb-profile-lwm2m-observe-attr-telemetry>  
35 - </div> 22 + <ng-template matTabContent>
  23 + <div class="mat-padding">
  24 + <tb-profile-lwm2m-object-list
  25 + (addList)="addObjectsList($event)"
  26 + (removeList)="removeObjectsList($event)"
  27 + [required]="required"
  28 + formControlName="objectIds">
  29 + </tb-profile-lwm2m-object-list>
  30 + </div>
  31 + <div class="mat-padding">
  32 + <tb-profile-lwm2m-observe-attr-telemetry
  33 + [required]="required"
  34 + formControlName="observeAttrTelemetry">
  35 + </tb-profile-lwm2m-observe-attr-telemetry>
  36 + </div>
  37 + </ng-template>
36 </mat-tab> 38 </mat-tab>
37 <mat-tab label="{{ 'device-profile.lwm2m.bootstrap-tab' | translate }}"> 39 <mat-tab label="{{ 'device-profile.lwm2m.bootstrap-tab' | translate }}">
38 - <div class="mat-padding">  
39 - <mat-accordion multi="true" class="mat-body-1">  
40 - <mat-expansion-panel>  
41 - <mat-expansion-panel-header>  
42 - <mat-panel-title>  
43 - <div class="tb-panel-title">{{ 'device-profile.lwm2m.servers' | translate | uppercase }}</div>  
44 - </mat-panel-title>  
45 - </mat-expansion-panel-header>  
46 - <div fxLayout="column">  
47 - <div fxLayout="row" fxLayoutGap="8px">  
48 - <mat-form-field fxFlex>  
49 - <mat-label>{{ 'device-profile.lwm2m.short-id' | translate }}</mat-label>  
50 - <input matInput type="number" formControlName="shortId" required>  
51 - <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('shortId').hasError('required')">  
52 - {{ 'device-profile.lwm2m.short-id' | translate }}  
53 - <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>  
54 - </mat-error>  
55 - </mat-form-field>  
56 - <mat-form-field fxFlex>  
57 - <mat-label>{{ 'device-profile.lwm2m.lifetime' | translate }}</mat-label>  
58 - <input matInput type="number" formControlName="lifetime" required>  
59 - <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('lifetime').hasError('required')">  
60 - {{ 'device-profile.lwm2m.lifetime' | translate }}  
61 - <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>  
62 - </mat-error>  
63 - </mat-form-field> 40 + <ng-template matTabContent>
  41 + <div class="mat-padding">
  42 + <mat-accordion multi="true" class="mat-body-1">
  43 + <mat-expansion-panel>
  44 + <mat-expansion-panel-header>
  45 + <mat-panel-title>
  46 + <div class="tb-panel-title">{{ 'device-profile.lwm2m.servers' | translate | uppercase }}</div>
  47 + </mat-panel-title>
  48 + </mat-expansion-panel-header>
  49 + <div fxLayout="column">
  50 + <div fxLayout="row" fxLayoutGap="8px">
  51 + <mat-form-field fxFlex>
  52 + <mat-label>{{ 'device-profile.lwm2m.short-id' | translate }}</mat-label>
  53 + <input matInput type="number" formControlName="shortId" required>
  54 + <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('shortId').hasError('required')">
  55 + {{ 'device-profile.lwm2m.short-id' | translate }}
  56 + <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>
  57 + </mat-error>
  58 + </mat-form-field>
  59 + <mat-form-field fxFlex>
  60 + <mat-label>{{ 'device-profile.lwm2m.lifetime' | translate }}</mat-label>
  61 + <input matInput type="number" formControlName="lifetime" required>
  62 + <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('lifetime').hasError('required')">
  63 + {{ 'device-profile.lwm2m.lifetime' | translate }}
  64 + <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>
  65 + </mat-error>
  66 + </mat-form-field>
  67 + </div>
  68 + <div fxLayout="row" fxLayoutGap="8px">
  69 + <mat-form-field fxFlex>
  70 + <mat-label>{{ 'device-profile.lwm2m.default-min-period' | translate }}</mat-label>
  71 + <input matInput type="number" formControlName="defaultMinPeriod" required>
  72 + <mat-error
  73 + *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('defaultMinPeriod').hasError('required')">
  74 + {{ 'device-profile.lwm2m.default-min-period' | translate }}
  75 + <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>
  76 + </mat-error>
  77 + </mat-form-field>
  78 + <mat-form-field fxFlex>
  79 + <mat-label>{{ 'device-profile.lwm2m.binding' | translate }}</mat-label>
  80 + <input matInput type="text" formControlName="binding" required>
  81 + <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('binding').hasError('required')">
  82 + {{ 'device-profile.lwm2m.binding' | translate }}
  83 + <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>
  84 + </mat-error>
  85 + </mat-form-field>
  86 + </div>
  87 + <div>
  88 + <mat-checkbox formControlName="notifIfDisabled" color="primary">
  89 + {{ 'device-profile.lwm2m.notif-if-disabled' | translate }}
  90 + </mat-checkbox>
  91 + </div>
64 </div> 92 </div>
65 - <div fxLayout="row" fxLayoutGap="8px">  
66 - <mat-form-field fxFlex>  
67 - <mat-label>{{ 'device-profile.lwm2m.default-min-period' | translate }}</mat-label>  
68 - <input matInput type="number" formControlName="defaultMinPeriod" required>  
69 - <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('defaultMinPeriod').hasError('required')">  
70 - {{ 'device-profile.lwm2m.default-min-period' | translate }}  
71 - <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>  
72 - </mat-error>  
73 - </mat-form-field>  
74 - <mat-form-field fxFlex>  
75 - <mat-label>{{ 'device-profile.lwm2m.binding' | translate }}</mat-label>  
76 - <input matInput type="text" formControlName="binding" required>  
77 - <mat-error *ngIf="lwm2mDeviceProfileTransportConfFormGroup.get('binding').hasError('required')">  
78 - {{ 'device-profile.lwm2m.binding' | translate }}  
79 - <strong>{{ 'device-profile.lwm2m.required' | translate }}</strong>  
80 - </mat-error>  
81 - </mat-form-field> 93 + </mat-expansion-panel>
  94 + </mat-accordion>
  95 + <mat-accordion multi="true" class="mat-body-1">
  96 + <mat-expansion-panel>
  97 + <mat-expansion-panel-header>
  98 + <mat-panel-title>
  99 + <div
  100 + class="tb-panel-title">{{ 'device-profile.lwm2m.bootstrap-server' | translate | uppercase }}</div>
  101 + </mat-panel-title>
  102 + </mat-expansion-panel-header>
  103 + <div class="mat-padding">
  104 + <tb-profile-lwm2m-device-config-server
  105 + [required]="required"
  106 + formControlName="bootstrapServer"
  107 + [bootstrapServerIs]=true>
  108 + </tb-profile-lwm2m-device-config-server>
82 </div> 109 </div>
83 - <div>  
84 - <mat-checkbox formControlName="notifIfDisabled" color="primary">  
85 - {{ 'device-profile.lwm2m.notif-if-disabled' | translate }}  
86 - </mat-checkbox> 110 + </mat-expansion-panel>
  111 + </mat-accordion>
  112 + <mat-accordion multi="true" class="mat-body-1">
  113 + <mat-expansion-panel>
  114 + <mat-expansion-panel-header>
  115 + <mat-panel-title>
  116 + <div class="tb-panel-title">{{ 'device-profile.lwm2m.lwm2m-server' | translate | uppercase }}</div>
  117 + </mat-panel-title>
  118 + </mat-expansion-panel-header>
  119 + <div class="mat-padding">
  120 + <tb-profile-lwm2m-device-config-server
  121 + [required]="required"
  122 + formControlName="lwm2mServer"
  123 + [bootstrapServerIs]=false>
  124 + </tb-profile-lwm2m-device-config-server>
87 </div> 125 </div>
88 - </div>  
89 - </mat-expansion-panel>  
90 - </mat-accordion>  
91 - <mat-accordion multi="true" class="mat-body-1">  
92 - <mat-expansion-panel>  
93 - <mat-expansion-panel-header>  
94 - <mat-panel-title>  
95 - <div class="tb-panel-title">{{ 'device-profile.lwm2m.bootstrap-server' | translate | uppercase }}</div>  
96 - </mat-panel-title>  
97 - </mat-expansion-panel-header>  
98 - <div class="mat-padding">  
99 - <tb-profile-lwm2m-device-config-server  
100 - [required]="required"  
101 - formControlName = "bootstrapServer"  
102 - [bootstrapServerIs]=true>  
103 - </tb-profile-lwm2m-device-config-server>  
104 - </div>  
105 - </mat-expansion-panel>  
106 - </mat-accordion>  
107 - <mat-accordion multi="true" class="mat-body-1">  
108 - <mat-expansion-panel>  
109 - <mat-expansion-panel-header>  
110 - <mat-panel-title>  
111 - <div class="tb-panel-title">{{ 'device-profile.lwm2m.lwm2m-server' | translate | uppercase }}</div>  
112 - </mat-panel-title>  
113 - </mat-expansion-panel-header>  
114 - <div class="mat-padding">  
115 - <tb-profile-lwm2m-device-config-server  
116 - [required]="required"  
117 - formControlName="lwm2mServer"  
118 - [bootstrapServerIs]=false>  
119 - </tb-profile-lwm2m-device-config-server>  
120 - </div>  
121 - </mat-expansion-panel>  
122 - </mat-accordion>  
123 - </div> 126 + </mat-expansion-panel>
  127 + </mat-accordion>
  128 + </div>
  129 + </ng-template>
124 </mat-tab> 130 </mat-tab>
125 <mat-tab label="{{ 'device-profile.lwm2m.config-json-tab' | translate }}"> 131 <mat-tab label="{{ 'device-profile.lwm2m.config-json-tab' | translate }}">
126 - <div class="mat-padding">  
127 - <tb-json-object-edit  
128 - [required]="required"  
129 - [sort] = "sortFunction"  
130 - label="{{ 'device-profile.transport-type-lwm2m' | translate }}"  
131 - formControlName="configurationJson">  
132 - </tb-json-object-edit>  
133 - </div> 132 + <ng-template matTabContent>
  133 + <div class="mat-padding">
  134 + <tb-json-object-edit
  135 + [required]="required"
  136 + [sort]="sortFunction"
  137 + label="{{ 'device-profile.transport-type-lwm2m' | translate }}"
  138 + formControlName="configurationJson">
  139 + </tb-json-object-edit>
  140 + </div>
  141 + </ng-template>
134 </mat-tab> 142 </mat-tab>
135 </mat-tab-group> 143 </mat-tab-group>
136 </div> 144 </div>
@@ -34,10 +34,10 @@ import { @@ -34,10 +34,10 @@ import {
34 OBSERVE_ATTR, 34 OBSERVE_ATTR,
35 TELEMETRY, 35 TELEMETRY,
36 ObjectLwM2M, getDefaultProfileConfig, KEY_NAME, Instance, ProfileConfigModels, ResourceLwM2M 36 ObjectLwM2M, getDefaultProfileConfig, KEY_NAME, Instance, ProfileConfigModels, ResourceLwM2M
37 -} from "./profile-config.models";  
38 -import { DeviceProfileService } from "@core/http/device-profile.service";  
39 -import { deepClone, isUndefined } from "@core/utils";  
40 -import { WINDOW } from "@core/services/window.service"; 37 +} from './profile-config.models';
  38 +import { DeviceProfileService } from '@core/http/device-profile.service';
  39 +import { deepClone, isUndefined } from '@core/utils';
  40 +import { WINDOW } from '@core/services/window.service';
41 import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point'; 41 import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
42 import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined'; 42 import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined';
43 43
@@ -65,7 +65,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -65,7 +65,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
65 bootstrapServers: string; 65 bootstrapServers: string;
66 bootstrapServer: string; 66 bootstrapServer: string;
67 lwm2mServer: string; 67 lwm2mServer: string;
68 - sortFunction = this.sortObjectKeyPathJson; 68 + sortFunction: {};
69 69
70 get required(): boolean { 70 get required(): boolean {
71 return this.requiredValue; 71 return this.requiredValue;
@@ -76,7 +76,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -76,7 +76,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
76 this.requiredValue = coerceBooleanProperty(value); 76 this.requiredValue = coerceBooleanProperty(value);
77 } 77 }
78 78
79 - private propagateChange = (v: any) => { }; 79 + private propagateChange = (v: any) => { };
80 80
81 constructor(private store: Store<AppState>, 81 constructor(private store: Store<AppState>,
82 private fb: FormBuilder, 82 private fb: FormBuilder,
@@ -109,6 +109,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -109,6 +109,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
109 } 109 }
110 110
111 ngOnInit() { 111 ngOnInit() {
  112 + this.sortFunction = this.sortObjectKeyPathJson;
112 } 113 }
113 114
114 setDisabledState(isDisabled: boolean): void { 115 setDisabledState(isDisabled: boolean): void {
@@ -130,22 +131,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -130,22 +131,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
130 this.initWriteValue(); 131 this.initWriteValue();
131 } 132 }
132 133
133 - private initWriteValue(): void { 134 + private initWriteValue = (): void => {
134 const modelValue = {objectIds: null, objectsList: []}; 135 const modelValue = {objectIds: null, objectsList: []};
135 modelValue.objectIds = this.getObjectsFromJsonAllConfig(); 136 modelValue.objectIds = this.getObjectsFromJsonAllConfig();
136 if (modelValue.objectIds !== null) { 137 if (modelValue.objectIds !== null) {
137 this.deviceProfileService.getLwm2mObjects(modelValue.objectIds).subscribe( 138 this.deviceProfileService.getLwm2mObjects(modelValue.objectIds).subscribe(
138 - (objectsList) => {  
139 - modelValue.objectsList = objectsList;  
140 - this.updateWriteValue(modelValue);  
141 - } 139 + (objectsList) => {
  140 + modelValue.objectsList = objectsList;
  141 + this.updateWriteValue(modelValue);
  142 + }
142 ); 143 );
143 } else { 144 } else {
144 this.updateWriteValue(modelValue); 145 this.updateWriteValue(modelValue);
145 } 146 }
146 } 147 }
147 148
148 - private updateWriteValue(value: any): void { 149 + private updateWriteValue = (value: any): void => {
149 const objectsList = deepClone(value.objectsList); 150 const objectsList = deepClone(value.objectsList);
150 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({ 151 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({
151 objectIds: value, 152 objectIds: value,
@@ -161,7 +162,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -161,7 +162,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
161 {emitEvent: false}); 162 {emitEvent: false});
162 } 163 }
163 164
164 - private updateModel() { 165 + private updateModel = (): void => {
165 let configuration: DeviceProfileTransportConfiguration = null; 166 let configuration: DeviceProfileTransportConfiguration = null;
166 if (this.lwm2mDeviceProfileTransportConfFormGroup.valid) { 167 if (this.lwm2mDeviceProfileTransportConfFormGroup.valid) {
167 this.upDateValueToJson(); 168 this.upDateValueToJson();
@@ -171,25 +172,25 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -171,25 +172,25 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
171 this.propagateChange(configuration); 172 this.propagateChange(configuration);
172 } 173 }
173 174
174 - private updateObserveAttrTelemetryObjectFormGroup(objectsList: ObjectLwM2M[]) { 175 + private updateObserveAttrTelemetryObjectFormGroup = (objectsList: ObjectLwM2M[]): void => {
175 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({ 176 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({
176 - observeAttrTelemetry: {clientLwM2M: this.getObserveAttrTelemetryObjects(objectsList)}  
177 - },  
178 - {emitEvent: false}); 177 + observeAttrTelemetry: {clientLwM2M: this.getObserveAttrTelemetryObjects(objectsList)}
  178 + },
  179 + {emitEvent: false});
179 this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').markAsPristine({ 180 this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').markAsPristine({
180 onlySelf: true 181 onlySelf: true
181 }); 182 });
182 } 183 }
183 184
184 - upDateValueToJson(): void {  
185 - this.upDateValueToJsonTab_0();  
186 - this.upDateValueToJsonTab_1(); 185 + private upDateValueToJson = (): void => {
  186 + this.upDateValueToJsonTab0();
  187 + this.upDateValueToJsonTab1();
187 } 188 }
188 189
189 - upDateValueToJsonTab_0(): void { 190 + private upDateValueToJsonTab0 = (): void => {
190 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').pristine) { 191 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').pristine) {
191 this.upDateObserveAttrTelemetryFromGroupToJson( 192 this.upDateObserveAttrTelemetryFromGroupToJson(
192 - this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M 193 + this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M
193 ); 194 );
194 this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').markAsPristine({ 195 this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').markAsPristine({
195 onlySelf: true 196 onlySelf: true
@@ -198,7 +199,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -198,7 +199,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
198 } 199 }
199 } 200 }
200 201
201 - upDateValueToJsonTab_1(): void { 202 + private upDateValueToJsonTab1 = (): void => {
202 this.upDateValueServersToJson(); 203 this.upDateValueServersToJson();
203 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('bootstrapServer').pristine) { 204 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('bootstrapServer').pristine) {
204 this.configurationValue.bootstrap.bootstrapServer = this.lwm2mDeviceProfileTransportConfFormGroup.get('bootstrapServer').value; 205 this.configurationValue.bootstrap.bootstrapServer = this.lwm2mDeviceProfileTransportConfFormGroup.get('bootstrapServer').value;
@@ -216,7 +217,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -216,7 +217,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
216 } 217 }
217 } 218 }
218 219
219 - upDateValueServersToJson(): void { 220 + private upDateValueServersToJson = (): void => {
220 const bootstrapServers = this.configurationValue.bootstrap.servers; 221 const bootstrapServers = this.configurationValue.bootstrap.servers;
221 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('shortId').pristine) { 222 if (!this.lwm2mDeviceProfileTransportConfFormGroup.get('shortId').pristine) {
222 bootstrapServers.shortId = this.lwm2mDeviceProfileTransportConfFormGroup.get('shortId').value; 223 bootstrapServers.shortId = this.lwm2mDeviceProfileTransportConfFormGroup.get('shortId').value;
@@ -255,7 +256,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -255,7 +256,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
255 } 256 }
256 } 257 }
257 258
258 - getObserveAttrTelemetryObjects(listObject: ObjectLwM2M[]): ObjectLwM2M [] { 259 + private getObserveAttrTelemetryObjects = (listObject: ObjectLwM2M[]): ObjectLwM2M [] => {
259 const clientObserveAttr = deepClone(listObject); 260 const clientObserveAttr = deepClone(listObject);
260 if (this.configurationValue[this.observeAttr]) { 261 if (this.configurationValue[this.observeAttr]) {
261 const observeArray = this.configurationValue[this.observeAttr][this.observe] as Array<string>; 262 const observeArray = this.configurationValue[this.observeAttr][this.observe] as Array<string>;
@@ -284,12 +285,13 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -284,12 +285,13 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
284 return clientObserveAttr; 285 return clientObserveAttr;
285 } 286 }
286 287
287 - includesInstancesNo(attributeArray: Array<string>, telemetryArray: Array<string>): boolean { 288 + private includesInstancesNo = (attributeArray: Array<string>, telemetryArray: Array<string>): boolean => {
288 const isIdIndex = (element) => !element.includes('/0/'); 289 const isIdIndex = (element) => !element.includes('/0/');
289 return attributeArray.findIndex(isIdIndex) >= 0 || telemetryArray.findIndex(isIdIndex) >= 0; 290 return attributeArray.findIndex(isIdIndex) >= 0 || telemetryArray.findIndex(isIdIndex) >= 0;
290 } 291 }
291 292
292 - addInstances(attributeArray: Array<string>, telemetryArray: Array<string>, clientObserveAttr: ObjectLwM2M[]): void { 293 + private addInstances = (attributeArray: Array<string>, telemetryArray: Array<string>,
  294 + clientObserveAttr: ObjectLwM2M[]): void => {
293 const attr = [] as Array<string>; 295 const attr = [] as Array<string>;
294 [...attributeArray].filter(x => (!x.includes('/0/'))).forEach(x => { 296 [...attributeArray].filter(x => (!x.includes('/0/'))).forEach(x => {
295 attr.push(this.convertPathToInstance(x)); 297 attr.push(this.convertPathToInstance(x));
@@ -310,42 +312,43 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -310,42 +312,43 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
310 }); 312 });
311 } 313 }
312 314
313 - convertPathToInstance(path: string): string { 315 + private convertPathToInstance = (path: string): string => {
314 const newX = Array.from(path.substring(1).split('/'), Number); 316 const newX = Array.from(path.substring(1).split('/'), Number);
315 return [newX[0], newX[1]].join('/'); 317 return [newX[0], newX[1]].join('/');
316 } 318 }
317 319
318 - updateObserveAttrTelemetryObjects(isParameter: Array<string>, clientObserveAttr: ObjectLwM2M[], nameParameter: string): void { 320 + private updateObserveAttrTelemetryObjects = (isParameter: Array<string>, clientObserveAttr: ObjectLwM2M[],
  321 + nameParameter: string): void => {
319 isParameter.forEach(attr => { 322 isParameter.forEach(attr => {
320 const idKeys = Array.from(attr.substring(1).split('/'), Number); 323 const idKeys = Array.from(attr.substring(1).split('/'), Number);
321 clientObserveAttr 324 clientObserveAttr
322 - .forEach(e => {  
323 - if (e.id === idKeys[0]) {  
324 - const instance = e.instances.find(itrInstance => itrInstance.id === idKeys[1]);  
325 - if (isNotNullOrUndefined(instance)) {  
326 - instance.resources.find(resource => resource.id === idKeys[2])[nameParameter] = true;  
327 - } 325 + .forEach(e => {
  326 + if (e.id === idKeys[0]) {
  327 + const instance = e.instances.find(itrInstance => itrInstance.id === idKeys[1]);
  328 + if (isNotNullOrUndefined(instance)) {
  329 + instance.resources.find(resource => resource.id === idKeys[2])[nameParameter] = true;
328 } 330 }
329 - }); 331 + }
  332 + });
330 }); 333 });
331 } 334 }
332 335
333 - updateKeyNameObjects(nameJson: JsonObject, clientObserveAttr: ObjectLwM2M[]): void { 336 + private updateKeyNameObjects = (nameJson: JsonObject, clientObserveAttr: ObjectLwM2M[]): void => {
334 const keyName = JSON.parse(JSON.stringify(nameJson)); 337 const keyName = JSON.parse(JSON.stringify(nameJson));
335 Object.keys(keyName).forEach(key => { 338 Object.keys(keyName).forEach(key => {
336 const idKeys = Array.from(key.substring(1).split('/'), Number); 339 const idKeys = Array.from(key.substring(1).split('/'), Number);
337 clientObserveAttr 340 clientObserveAttr
338 - .forEach(e => {  
339 - if (e.id === idKeys[0]) {  
340 - e.instances  
341 - .find(instance => instance.id === idKeys[1]).resources  
342 - .find(resource => resource.id === idKeys[2]).keyName = keyName[key];  
343 - }  
344 - }); 341 + .forEach(e => {
  342 + if (e.id === idKeys[0]) {
  343 + e.instances
  344 + .find(instance => instance.id === idKeys[1]).resources
  345 + .find(resource => resource.id === idKeys[2]).keyName = keyName[key];
  346 + }
  347 + });
345 }); 348 });
346 } 349 }
347 350
348 - upDateObserveAttrTelemetryFromGroupToJson(val: ObjectLwM2M[]): void { 351 + private upDateObserveAttrTelemetryFromGroupToJson = (val: ObjectLwM2M[]): void => {
349 const observeArray: Array<string> = []; 352 const observeArray: Array<string> = [];
350 const attributeArray: Array<string> = []; 353 const attributeArray: Array<string> = [];
351 const telemetryArray: Array<string> = []; 354 const telemetryArray: Array<string> = [];
@@ -405,19 +408,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -405,19 +408,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
405 this.updateKeyName(); 408 this.updateKeyName();
406 } 409 }
407 410
408 - sortObjectKeyPathJson(key, value) { 411 + sortObjectKeyPathJson = (key: string, value: object): object => {
409 if (key === 'keyName') { 412 if (key === 'keyName') {
410 return Object.keys(value).sort((a, b) => { 413 return Object.keys(value).sort((a, b) => {
411 const aLC = Array.from(a.substring(1).split('/'), Number); 414 const aLC = Array.from(a.substring(1).split('/'), Number);
412 const bLC = Array.from(b.substring(1).split('/'), Number); 415 const bLC = Array.from(b.substring(1).split('/'), Number);
413 return aLC[0] === bLC[0] ? aLC[1] - bLC[1] : aLC[0] - bLC[0]; 416 return aLC[0] === bLC[0] ? aLC[1] - bLC[1] : aLC[0] - bLC[0];
414 - }).reduce((r, k) => r[k] = value[k], {}); 417 + }).reduce((obj, keySort) => {
  418 + obj[keySort] = value[keySort];
  419 + return obj;
  420 + }, {});
415 } else { 421 } else {
416 return value; 422 return value;
417 } 423 }
418 } 424 }
419 425
420 - updateKeyName(): void { 426 + private updateKeyName = (): void => {
421 const paths = new Set<string>(); 427 const paths = new Set<string>();
422 if (this.configurationValue[this.observeAttr][this.attribute]) { 428 if (this.configurationValue[this.observeAttr][this.attribute]) {
423 this.configurationValue[this.observeAttr][this.attribute].forEach(path => { 429 this.configurationValue[this.observeAttr][this.attribute].forEach(path => {
@@ -431,20 +437,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -431,20 +437,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
431 } 437 }
432 const keyNameNew = {}; 438 const keyNameNew = {};
433 paths.forEach(path => { 439 paths.forEach(path => {
434 - const pathParameter = this.findIndexsForIds(path); 440 + const pathParameter = this.findIndexesForIds(path);
435 if (pathParameter.length === 3) { 441 if (pathParameter.length === 3) {
436 keyNameNew[path] = this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value 442 keyNameNew[path] = this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value
437 - .clientLwM2M[pathParameter[0]].instances[pathParameter[1]].resources[pathParameter[2]][this.keyName]; 443 + .clientLwM2M[pathParameter[0]].instances[pathParameter[1]].resources[pathParameter[2]][this.keyName];
438 } 444 }
439 }); 445 });
440 this.configurationValue[this.observeAttr][this.keyName] = this.sortObjectKeyPathJson('keyName', keyNameNew); 446 this.configurationValue[this.observeAttr][this.keyName] = this.sortObjectKeyPathJson('keyName', keyNameNew);
441 } 447 }
442 448
443 - findIndexsForIds(path: string): number[] { 449 + private findIndexesForIds = (path: string): number[] => {
444 const pathParameter = Array.from(path.substring(1).split('/'), Number); 450 const pathParameter = Array.from(path.substring(1).split('/'), Number);
445 const pathParameterIndexes: number[] = []; 451 const pathParameterIndexes: number[] = [];
446 const objectsOld = deepClone( 452 const objectsOld = deepClone(
447 - this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M) as ObjectLwM2M[]; 453 + this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M) as ObjectLwM2M[];
448 let isIdIndex = (element) => element.id === pathParameter[0]; 454 let isIdIndex = (element) => element.id === pathParameter[0];
449 const objIndex = objectsOld.findIndex(isIdIndex); 455 const objIndex = objectsOld.findIndex(isIdIndex);
450 if (objIndex >= 0) { 456 if (objIndex >= 0) {
@@ -463,7 +469,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -463,7 +469,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
463 return pathParameterIndexes; 469 return pathParameterIndexes;
464 } 470 }
465 471
466 - getObjectsFromJsonAllConfig(): number [] { 472 + private getObjectsFromJsonAllConfig = (): number [] => {
467 const objectsIds = new Set<number>(); 473 const objectsIds = new Set<number>();
468 if (this.configurationValue[this.observeAttr]) { 474 if (this.configurationValue[this.observeAttr]) {
469 if (this.configurationValue[this.observeAttr][this.observe]) { 475 if (this.configurationValue[this.observeAttr][this.observe]) {
@@ -485,7 +491,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -485,7 +491,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
485 return (objectsIds.size > 0) ? Array.from(objectsIds) : null; 491 return (objectsIds.size > 0) ? Array.from(objectsIds) : null;
486 } 492 }
487 493
488 - upDateJsonAllConfig(): void { 494 + private upDateJsonAllConfig = (): void => {
489 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({ 495 this.lwm2mDeviceProfileTransportConfFormGroup.patchValue({
490 configurationJson: this.configurationValue 496 configurationJson: this.configurationValue
491 }, {emitEvent: false}); 497 }, {emitEvent: false});
@@ -494,11 +500,11 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -494,11 +500,11 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
494 }); 500 });
495 } 501 }
496 502
497 - addObjectsList(value: ObjectLwM2M[]): void { 503 + addObjectsList = (value: ObjectLwM2M[]): void => {
498 this.updateObserveAttrTelemetryObjectFormGroup(deepClone(value)); 504 this.updateObserveAttrTelemetryObjectFormGroup(deepClone(value));
499 } 505 }
500 506
501 - removeObjectsList(value: ObjectLwM2M): void { 507 + removeObjectsList = (value: ObjectLwM2M): void => {
502 const objectsOld = deepClone(this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M); 508 const objectsOld = deepClone(this.lwm2mDeviceProfileTransportConfFormGroup.get('observeAttrTelemetry').value.clientLwM2M);
503 const isIdIndex = (element) => element.id === value.id; 509 const isIdIndex = (element) => element.id === value.id;
504 const index = objectsOld.findIndex(isIdIndex); 510 const index = objectsOld.findIndex(isIdIndex);
@@ -514,7 +520,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -514,7 +520,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
514 this.upDateJsonAllConfig(); 520 this.upDateJsonAllConfig();
515 } 521 }
516 522
517 - removeObserveAttrTelemetryFromJson(observeAttrTel: string, id: number): void { 523 + private removeObserveAttrTelemetryFromJson = (observeAttrTel: string, id: number): void => {
518 const isIdIndex = (element) => Array.from(element.substring(1).split('/'), Number)[0] === id; 524 const isIdIndex = (element) => Array.from(element.substring(1).split('/'), Number)[0] === id;
519 let index = this.configurationValue[this.observeAttr][observeAttrTel].findIndex(isIdIndex); 525 let index = this.configurationValue[this.observeAttr][observeAttrTel].findIndex(isIdIndex);
520 while (index >= 0) { 526 while (index >= 0) {
@@ -523,12 +529,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -523,12 +529,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
523 } 529 }
524 } 530 }
525 531
526 - removeKeyNameFromJson(id: number): void {  
527 - const keyNmaeJson = this.configurationValue[this.observeAttr][this.keyName];  
528 - Object.keys(keyNmaeJson).forEach(key => { 532 + private removeKeyNameFromJson = (id: number): void => {
  533 + const keyNameJson = this.configurationValue[this.observeAttr][this.keyName];
  534 + Object.keys(keyNameJson).forEach(key => {
529 const idKey = Array.from(key.substring(1).split('/'), Number)[0]; 535 const idKey = Array.from(key.substring(1).split('/'), Number)[0];
530 if (idKey === id) { 536 if (idKey === id) {
531 - delete keyNmaeJson[key]; 537 + delete keyNameJson[key];
532 } 538 }
533 }); 539 });
534 } 540 }
@@ -538,10 +544,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro @@ -538,10 +544,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
538 if (!isPath) { 544 if (!isPath) {
539 isPath = this.findPathInJson(path, this.telemetry); 545 isPath = this.findPathInJson(path, this.telemetry);
540 } 546 }
541 - return (isPath) ? true : false; 547 + return !!isPath;
542 } 548 }
543 549
544 - findPathInJson(path: string, side: string): string { 550 + private findPathInJson = (path: string, side: string): string => {
545 if (this.configurationValue[this.observeAttr]) { 551 if (this.configurationValue[this.observeAttr]) {
546 if (this.configurationValue[this.observeAttr][side]) { 552 if (this.configurationValue[this.observeAttr][side]) {
547 return this.configurationValue[this.observeAttr][side].find( 553 return this.configurationValue[this.observeAttr][side].find(
@@ -21,44 +21,45 @@ import { @@ -21,44 +21,45 @@ import {
21 OnInit, 21 OnInit,
22 ViewChild, 22 ViewChild,
23 ElementRef, 23 ElementRef,
24 -} from "@angular/core"; 24 +} from '@angular/core';
25 import { 25 import {
26 ControlValueAccessor, 26 ControlValueAccessor,
27 FormBuilder, 27 FormBuilder,
28 FormGroup, 28 FormGroup,
29 NG_VALUE_ACCESSOR, Validators 29 NG_VALUE_ACCESSOR, Validators
30 -} from "@angular/forms";  
31 -import { coerceBooleanProperty } from "@angular/cdk/coercion";  
32 -import { Store } from "@ngrx/store";  
33 -import { AppState } from "@core/core.state"; 30 +} from '@angular/forms';
  31 +import { coerceBooleanProperty } from '@angular/cdk/coercion';
  32 +import { Store } from '@ngrx/store';
  33 +import { AppState } from '@core/core.state';
34 import { MatChipList } from '@angular/material/chips'; 34 import { MatChipList } from '@angular/material/chips';
35 import { 35 import {
36 INSTANCES_ID_VALUE_MAX, 36 INSTANCES_ID_VALUE_MAX,
37 INSTANCES_ID_VALUE_MIN 37 INSTANCES_ID_VALUE_MIN
38 -} from "./profile-config.models";  
39 -import { TranslateService } from "@ngx-translate/core";  
40 -import { DeviceProfileService } from "@core/http/device-profile.service"; 38 +} from './profile-config.models';
  39 +import { TranslateService } from '@ngx-translate/core';
  40 +import { DeviceProfileService } from '@core/http/device-profile.service';
41 41
42 @Component({ 42 @Component({
43 selector: 'tb-profile-lwm2m-object-add-instances-list', 43 selector: 'tb-profile-lwm2m-object-add-instances-list',
44 templateUrl: './lwm2m-object-add-instances-list.component.html', 44 templateUrl: './lwm2m-object-add-instances-list.component.html',
45 styleUrls: ['./lwm2m-object-add-instances-list.component.scss'], 45 styleUrls: ['./lwm2m-object-add-instances-list.component.scss'],
46 providers: [{ 46 providers: [{
47 - provide: NG_VALUE_ACCESSOR,  
48 - useExisting: forwardRef(() => Lwm2mObjectAddInstancesListComponent),  
49 - multi: true  
50 - }] 47 + provide: NG_VALUE_ACCESSOR,
  48 + useExisting: forwardRef(() => Lwm2mObjectAddInstancesListComponent),
  49 + multi: true
  50 + }]
51 }) 51 })
52 export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccessor, OnInit, Validators { 52 export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccessor, OnInit, Validators {
53 53
54 - lwm2mObjectListFormGroup: FormGroup;  
55 private requiredValue: boolean; 54 private requiredValue: boolean;
56 - private instancesIdsList: Set<number> | null;  
57 - filteredObjectsList: Array<number>;  
58 private disabled = false as boolean; 55 private disabled = false as boolean;
59 private dirty = false as boolean; 56 private dirty = false as boolean;
60 - instanceIdValueMin = INSTANCES_ID_VALUE_MIN as number  
61 - instanceIdValueMax = INSTANCES_ID_VALUE_MAX as number 57 +
  58 + lwm2mObjectListFormGroup: FormGroup;
  59 + instancesIdsList: Set<number> | null;
  60 + filteredObjectsList: Array<number>;
  61 + instanceIdValueMin = INSTANCES_ID_VALUE_MIN as number;
  62 + instanceIdValueMax = INSTANCES_ID_VALUE_MAX as number;
62 63
63 get required(): boolean { 64 get required(): boolean {
64 return this.requiredValue; 65 return this.requiredValue;
@@ -76,8 +77,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso @@ -76,8 +77,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso
76 @ViewChild('instanceIdInput') instanceIdInput: ElementRef<HTMLInputElement>; 77 @ViewChild('instanceIdInput') instanceIdInput: ElementRef<HTMLInputElement>;
77 @ViewChild('chipList', {static: true}) chipList: MatChipList; 78 @ViewChild('chipList', {static: true}) chipList: MatChipList;
78 79
79 - private propagateChange = (v: any) => {  
80 - }; 80 + private propagateChange = (v: any) => { };
81 81
82 constructor(private store: Store<AppState>, 82 constructor(private store: Store<AppState>,
83 public translate: TranslateService, 83 public translate: TranslateService,
@@ -89,7 +89,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso @@ -89,7 +89,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso
89 }); 89 });
90 } 90 }
91 91
92 - updateValidators() { 92 + private updateValidators = (): void => {
93 this.lwm2mObjectListFormGroup.get('instanceIdInput').setValidators([ 93 this.lwm2mObjectListFormGroup.get('instanceIdInput').setValidators([
94 Validators.min(this.instanceIdValueMin), 94 Validators.min(this.instanceIdValueMin),
95 Validators.max(this.instanceIdValueMax)]); 95 Validators.max(this.instanceIdValueMax)]);
@@ -128,41 +128,41 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso @@ -128,41 +128,41 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso
128 this.dirty = false; 128 this.dirty = false;
129 } 129 }
130 130
131 - add(value: number): void { 131 + add = (value: number): void => {
132 if (!isNaN(value) && this.lwm2mObjectListFormGroup.get('instanceIdInput').valid) { 132 if (!isNaN(value) && this.lwm2mObjectListFormGroup.get('instanceIdInput').valid) {
133 this.instancesIdsList.add(value); 133 this.instancesIdsList.add(value);
134 this.lwm2mObjectListFormGroup.get('instancesIdsList').setValue(this.instancesIdsList); 134 this.lwm2mObjectListFormGroup.get('instancesIdsList').setValue(this.instancesIdsList);
135 this.propagateChange(this.instancesIdsList); 135 this.propagateChange(this.instancesIdsList);
136 - this.dirty = true 136 + this.dirty = true;
137 } 137 }
138 this.clear(); 138 this.clear();
139 } 139 }
140 140
141 - remove(object: number) { 141 + remove = (object: number): void => {
142 this.instancesIdsList.delete(object); 142 this.instancesIdsList.delete(object);
143 this.lwm2mObjectListFormGroup.get('instancesIdsList').setValue(this.instancesIdsList); 143 this.lwm2mObjectListFormGroup.get('instancesIdsList').setValue(this.instancesIdsList);
144 this.propagateChange(this.instancesIdsList); 144 this.propagateChange(this.instancesIdsList);
145 - this.dirty = true 145 + this.dirty = true;
146 this.clear(); 146 this.clear();
147 } 147 }
  148 + //
  149 + // displayFn(object?: number): number | undefined {
  150 + // return object ? object : undefined;
  151 + // }
148 152
149 - displayFn(object?: number): number | undefined {  
150 - return object ? object : undefined;  
151 - }  
152 -  
153 - clear() { 153 + private clear = (): void => {
154 this.lwm2mObjectListFormGroup.get('instanceIdInput').patchValue(null, {emitEvent: true}); 154 this.lwm2mObjectListFormGroup.get('instanceIdInput').patchValue(null, {emitEvent: true});
155 - this.instanceIdInput.nativeElement.value = ""; 155 + this.instanceIdInput.nativeElement.value = '';
156 setTimeout(() => { 156 setTimeout(() => {
157 this.instanceIdInput.nativeElement.blur(); 157 this.instanceIdInput.nativeElement.blur();
158 this.instanceIdInput.nativeElement.focus(); 158 this.instanceIdInput.nativeElement.focus();
159 }, 0); 159 }, 0);
160 } 160 }
161 161
162 - onkeydown(e: KeyboardEvent) {  
163 - if (e.keyCode == 189 || e.keyCode == 187 || e.keyCode == 109 || e.keyCode == 107) { 162 + onkeydown = (e: KeyboardEvent): boolean => {
  163 + if (e.keyCode === 189 || e.keyCode === 187 || e.keyCode === 109 || e.keyCode === 107) {
164 return false; 164 return false;
165 - } else if (e.keyCode == 8) { 165 + } else if (e.keyCode === 8) {
166 if (this.lwm2mObjectListFormGroup.get('instanceIdInput').value == null) { 166 if (this.lwm2mObjectListFormGroup.get('instanceIdInput').value == null) {
167 this.clear(); 167 this.clear();
168 } 168 }
@@ -170,7 +170,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso @@ -170,7 +170,7 @@ export class Lwm2mObjectAddInstancesListComponent implements ControlValueAccesso
170 } 170 }
171 } 171 }
172 172
173 - onFocus() { 173 + onFocus = (): void => {
174 if (this.dirty) { 174 if (this.dirty) {
175 this.lwm2mObjectListFormGroup.get('instanceIdInput').updateValueAndValidity({onlySelf: true, emitEvent: true}); 175 this.lwm2mObjectListFormGroup.get('instanceIdInput').updateValueAndValidity({onlySelf: true, emitEvent: true});
176 this.dirty = false; 176 this.dirty = false;
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 <button mat-button color="primary" 42 <button mat-button color="primary"
43 type="button" 43 type="button"
44 [disabled]="(isLoading$ | async)" 44 [disabled]="(isLoading$ | async)"
45 - (click)="cancel()" cdkFocusInitial> 45 + (click)="cancel()">
46 {{ 'action.cancel' | translate }} 46 {{ 'action.cancel' | translate }}
47 </button> 47 </button>
48 <button mat-button mat-raised-button color="primary" 48 <button mat-button mat-raised-button color="primary"
@@ -36,8 +36,6 @@ export interface Lwm2mObjectAddInstancesData { @@ -36,8 +36,6 @@ export interface Lwm2mObjectAddInstancesData {
36 export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjectAddInstancesComponent, object> implements OnInit { 36 export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjectAddInstancesComponent, object> implements OnInit {
37 37
38 jsonFormGroup: FormGroup; 38 jsonFormGroup: FormGroup;
39 - // title: string;  
40 -  
41 submitted = false; 39 submitted = false;
42 40
43 constructor(protected store: Store<AppState>, 41 constructor(protected store: Store<AppState>,
@@ -52,7 +50,7 @@ export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjec @@ -52,7 +50,7 @@ export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjec
52 ngOnInit(): void { 50 ngOnInit(): void {
53 this.jsonFormGroup = this.fb.group({ 51 this.jsonFormGroup = this.fb.group({
54 instancesIds: this.data.instancesIds 52 instancesIds: this.data.instancesIds
55 - }) 53 + });
56 } 54 }
57 55
58 cancel(): void { 56 cancel(): void {
@@ -60,7 +58,7 @@ export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjec @@ -60,7 +58,7 @@ export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjec
60 } 58 }
61 59
62 add(): void { 60 add(): void {
63 - this.data.instancesIds = this.jsonFormGroup.get('instancesIds').value 61 + this.data.instancesIds = this.jsonFormGroup.get('instancesIds').value;
64 this.dialogRef.close(this.data); 62 this.dialogRef.close(this.data);
65 } 63 }
66 } 64 }
@@ -23,25 +23,25 @@ import { @@ -23,25 +23,25 @@ import {
23 ElementRef, 23 ElementRef,
24 Output, 24 Output,
25 EventEmitter 25 EventEmitter
26 -} from "@angular/core"; 26 +} from '@angular/core';
27 import { 27 import {
28 ControlValueAccessor, 28 ControlValueAccessor,
29 FormBuilder, 29 FormBuilder,
30 FormGroup, 30 FormGroup,
31 NG_VALUE_ACCESSOR, Validators 31 NG_VALUE_ACCESSOR, Validators
32 -} from "@angular/forms";  
33 -import {coerceBooleanProperty} from "@angular/cdk/coercion";  
34 -import {Store} from "@ngrx/store";  
35 -import {AppState} from "@core/core.state"; 32 +} from '@angular/forms';
  33 +import {coerceBooleanProperty} from '@angular/cdk/coercion';
  34 +import {Store} from '@ngrx/store';
  35 +import {AppState} from '@core/core.state';
36 import {MatChipList} from '@angular/material/chips'; 36 import {MatChipList} from '@angular/material/chips';
37 -import {MatAutocomplete} from "@angular/material/autocomplete";  
38 -import {Observable} from "rxjs"; 37 +import {MatAutocomplete} from '@angular/material/autocomplete';
  38 +import {Observable} from 'rxjs';
39 import {filter, map, mergeMap, share, tap} from 'rxjs/operators'; 39 import {filter, map, mergeMap, share, tap} from 'rxjs/operators';
40 -import {ObjectLwM2M} from "./profile-config.models";  
41 -import {TranslateService} from "@ngx-translate/core";  
42 -import {DeviceProfileService} from "@core/http/device-profile.service";  
43 -import {PageLink} from "@shared/models/page/page-link";  
44 -import {Direction} from "@shared/models/page/sort-order"; 40 +import {ObjectLwM2M} from './profile-config.models';
  41 +import {TranslateService} from '@ngx-translate/core';
  42 +import {DeviceProfileService} from '@core/http/device-profile.service';
  43 +import {PageLink} from '@shared/models/page/page-link';
  44 +import {Direction} from '@shared/models/page/sort-order';
45 45
46 @Component({ 46 @Component({
47 selector: 'tb-profile-lwm2m-object-list', 47 selector: 'tb-profile-lwm2m-object-list',
@@ -56,14 +56,15 @@ import {Direction} from "@shared/models/page/sort-order"; @@ -56,14 +56,15 @@ import {Direction} from "@shared/models/page/sort-order";
56 }) 56 })
57 export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, Validators { 57 export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, Validators {
58 58
59 - lwm2mObjectListFormGroup: FormGroup;  
60 private requiredValue: boolean; 59 private requiredValue: boolean;
  60 + private dirty = false as boolean;
  61 +
  62 + lwm2mObjectListFormGroup: FormGroup;
61 modelValue: Array<number> | null; 63 modelValue: Array<number> | null;
62 objectsList: Array<ObjectLwM2M> = []; 64 objectsList: Array<ObjectLwM2M> = [];
63 filteredObjectsList: Observable<Array<ObjectLwM2M>>; 65 filteredObjectsList: Observable<Array<ObjectLwM2M>>;
64 - private disabled = false as boolean; 66 + disabled = false as boolean;
65 searchText = '' as string; 67 searchText = '' as string;
66 - private dirty = false as boolean;  
67 68
68 get required(): boolean { 69 get required(): boolean {
69 return this.requiredValue; 70 return this.requiredValue;
@@ -88,8 +89,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -88,8 +89,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
88 @ViewChild('objectAutocomplete') matAutocomplete: MatAutocomplete; 89 @ViewChild('objectAutocomplete') matAutocomplete: MatAutocomplete;
89 @ViewChild('chipList', {static: true}) chipList: MatChipList; 90 @ViewChild('chipList', {static: true}) chipList: MatChipList;
90 91
91 - private propagateChange = (v: any) => {  
92 - }; 92 + private propagateChange = (v: any) => { };
93 93
94 constructor(private store: Store<AppState>, 94 constructor(private store: Store<AppState>,
95 public translate: TranslateService, 95 public translate: TranslateService,
@@ -101,7 +101,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -101,7 +101,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
101 }); 101 });
102 } 102 }
103 103
104 - updateValidators() { 104 + private updateValidators = (): void => {
105 this.lwm2mObjectListFormGroup.get('objectLwm2m').setValidators(this.required ? [Validators.required] : []); 105 this.lwm2mObjectListFormGroup.get('objectLwm2m').setValidators(this.required ? [Validators.required] : []);
106 this.lwm2mObjectListFormGroup.get('objectLwm2m').updateValueAndValidity(); 106 this.lwm2mObjectListFormGroup.get('objectLwm2m').updateValueAndValidity();
107 } 107 }
@@ -130,7 +130,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -130,7 +130,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
130 ); 130 );
131 } 131 }
132 132
133 - ngAfterViewInit(): void { 133 + ngAfterViewInit = (): void => {
134 } 134 }
135 135
136 setDisabledState(isDisabled: boolean): void { 136 setDisabledState(isDisabled: boolean): void {
@@ -144,9 +144,10 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -144,9 +144,10 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
144 144
145 writeValue(value: any): void { 145 writeValue(value: any): void {
146 this.searchText = ''; 146 this.searchText = '';
147 - if (value.hasOwnProperty("objectIds") && value["objectIds"] != null && value["objectIds"].length > 0) {  
148 - this.modelValue = [...value["objectIds"]];  
149 - this.objectsList = value["objectsList"]; 147 + const objectIds = 'objectIds';
  148 + if (value.hasOwnProperty(objectIds) && value[objectIds] != null && value[objectIds].length > 0) {
  149 + this.modelValue = [...value[objectIds]];
  150 + this.objectsList = value.objectsList;
150 this.lwm2mObjectListFormGroup.get('objectsList').setValue(this.objectsList); 151 this.lwm2mObjectListFormGroup.get('objectsList').setValue(this.objectsList);
151 } else { 152 } else {
152 this.objectsList = []; 153 this.objectsList = [];
@@ -156,19 +157,19 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -156,19 +157,19 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
156 this.dirty = true; 157 this.dirty = true;
157 } 158 }
158 159
159 - reset() {  
160 - this.objectsList = [];  
161 - this.lwm2mObjectListFormGroup.get('objectsList').setValue(this.objectsList);  
162 - this.modelValue = null;  
163 - if (this.objectInput) {  
164 - this.objectInput.nativeElement.value = '';  
165 - }  
166 - this.lwm2mObjectListFormGroup.get('objectLwm2m').patchValue('', {emitEvent: false});  
167 - this.propagateChange(this.modelValue);  
168 - this.dirty = true;  
169 - } 160 + // reset() {
  161 + // this.objectsList = [];
  162 + // this.lwm2mObjectListFormGroup.get('objectsList').setValue(this.objectsList);
  163 + // this.modelValue = null;
  164 + // if (this.objectInput) {
  165 + // this.objectInput.nativeElement.value = '';
  166 + // }
  167 + // this.lwm2mObjectListFormGroup.get('objectLwm2m').patchValue('', {emitEvent: false});
  168 + // this.propagateChange(this.modelValue);
  169 + // this.dirty = true;
  170 + // }
170 171
171 - add(object: ObjectLwM2M): void { 172 + private add = (object: ObjectLwM2M): void => {
172 if (!this.modelValue || this.modelValue.indexOf(object.id) === -1) { 173 if (!this.modelValue || this.modelValue.indexOf(object.id) === -1) {
173 if (!this.modelValue) { 174 if (!this.modelValue) {
174 this.modelValue = []; 175 this.modelValue = [];
@@ -182,7 +183,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -182,7 +183,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
182 this.clear(); 183 this.clear();
183 } 184 }
184 185
185 - remove(object: ObjectLwM2M) { 186 + remove = (object: ObjectLwM2M): void => {
186 let index = this.objectsList.indexOf(object); 187 let index = this.objectsList.indexOf(object);
187 if (index >= 0) { 188 if (index >= 0) {
188 this.objectsList.splice(index, 1); 189 this.objectsList.splice(index, 1);
@@ -198,11 +199,11 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -198,11 +199,11 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
198 } 199 }
199 } 200 }
200 201
201 - displayObjectLwm2mFn(object?: ObjectLwM2M): string | undefined { 202 + displayObjectLwm2mFn = (object?: ObjectLwM2M): string | undefined => {
202 return object ? object.name : undefined; 203 return object ? object.name : undefined;
203 } 204 }
204 205
205 - fetchListObjects(searchText?: string): Observable<Array<ObjectLwM2M>> { 206 + private fetchListObjects = (searchText?: string): Observable<Array<ObjectLwM2M>> => {
206 this.searchText = searchText; 207 this.searchText = searchText;
207 const pageLink = new PageLink(10, 0, searchText, { 208 const pageLink = new PageLink(10, 0, searchText, {
208 property: 'name', 209 property: 'name',
@@ -210,20 +211,19 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V @@ -210,20 +211,19 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V
210 }); 211 });
211 return this.deviceProfileService.getLwm2mObjectsPage(pageLink, {ignoreLoading: true}).pipe( 212 return this.deviceProfileService.getLwm2mObjectsPage(pageLink, {ignoreLoading: true}).pipe(
212 map(pageData => { 213 map(pageData => {
213 - let data = pageData.data;  
214 - return data; 214 + return pageData.data;
215 }) 215 })
216 ); 216 );
217 } 217 }
218 218
219 - onFocus() { 219 + onFocus = (): void => {
220 if (this.dirty) { 220 if (this.dirty) {
221 this.lwm2mObjectListFormGroup.get('objectLwm2m').updateValueAndValidity({onlySelf: true, emitEvent: true}); 221 this.lwm2mObjectListFormGroup.get('objectLwm2m').updateValueAndValidity({onlySelf: true, emitEvent: true});
222 this.dirty = false; 222 this.dirty = false;
223 } 223 }
224 } 224 }
225 225
226 - clear(value: string = '') { 226 + private clear = (value: string = ''): void => {
227 this.objectInput.nativeElement.value = value; 227 this.objectInput.nativeElement.value = value;
228 this.lwm2mObjectListFormGroup.get('objectLwm2m').patchValue(value, {emitEvent: true}); 228 this.lwm2mObjectListFormGroup.get('objectLwm2m').patchValue(value, {emitEvent: true});
229 setTimeout(() => { 229 setTimeout(() => {
@@ -14,13 +14,13 @@ @@ -14,13 +14,13 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import { Component, forwardRef, Input, OnInit } from "@angular/core"; 17 +import { Component, forwardRef, Input, OnInit } from '@angular/core';
18 import { 18 import {
19 ControlValueAccessor, 19 ControlValueAccessor,
20 FormArray, FormBuilder, 20 FormArray, FormBuilder,
21 FormGroup, 21 FormGroup,
22 NG_VALUE_ACCESSOR, Validators 22 NG_VALUE_ACCESSOR, Validators
23 -} from "@angular/forms"; 23 +} from '@angular/forms';
24 import { 24 import {
25 CAMEL_CASE_REGEXP, 25 CAMEL_CASE_REGEXP,
26 ResourceLwM2M 26 ResourceLwM2M
@@ -45,10 +45,10 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion'; @@ -45,10 +45,10 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion';
45 45
46 export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueAccessor, OnInit, Validators { 46 export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueAccessor, OnInit, Validators {
47 47
48 - resourceFormGroup : FormGroup; 48 + private requiredValue: boolean;
49 49
  50 + resourceFormGroup: FormGroup;
50 disabled = false as boolean; 51 disabled = false as boolean;
51 - private requiredValue: boolean;  
52 52
53 get required(): boolean { 53 get required(): boolean {
54 return this.requiredValue; 54 return this.requiredValue;
@@ -63,7 +63,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA @@ -63,7 +63,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
63 } 63 }
64 constructor(private store: Store<AppState>, 64 constructor(private store: Store<AppState>,
65 private fb: FormBuilder) { 65 private fb: FormBuilder) {
66 - this.resourceFormGroup = this.fb.group({'resources': this.fb.array([])}); 66 + this.resourceFormGroup = this.fb.group({resources: this.fb.array([])});
67 this.resourceFormGroup.valueChanges.subscribe(value => { 67 this.resourceFormGroup.valueChanges.subscribe(value => {
68 if (!this.disabled) { 68 if (!this.disabled) {
69 this.propagateChangeState(value.resources); 69 this.propagateChangeState(value.resources);
@@ -85,7 +85,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA @@ -85,7 +85,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
85 return this.resourceFormGroup.get('resources') as FormArray; 85 return this.resourceFormGroup.get('resources') as FormArray;
86 } 86 }
87 87
88 - resourceLwm2mFormArray(instance: FormGroup): FormArray { 88 + resourceLwm2mFormArray = (instance: FormGroup): FormArray => {
89 return instance.get('resources') as FormArray; 89 return instance.get('resources') as FormArray;
90 } 90 }
91 91
@@ -98,28 +98,28 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA @@ -98,28 +98,28 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
98 } 98 }
99 } 99 }
100 100
101 - getDisabledState(): boolean { 101 + getDisabledState = (): boolean => {
102 return this.disabled; 102 return this.disabled;
103 } 103 }
104 104
105 - updateValueKeyName (event: any, z: number): void { 105 + updateValueKeyName = (event: any, z: number): void => {
106 this.resourceFormArray.at(z).patchValue( {keyName: this.keysToCamel(deepClone(event.target.value))} ); 106 this.resourceFormArray.at(z).patchValue( {keyName: this.keysToCamel(deepClone(event.target.value))} );
107 } 107 }
108 108
109 - keysToCamel(o: any): string {  
110 - let val = o.split(" ");  
111 - let playStore = [];  
112 - val.forEach(function (item, k){ 109 + private keysToCamel = (o: any): string => {
  110 + const val = o.split(' ');
  111 + const playStore = [];
  112 + val.forEach((item, k) => {
113 item = item.replace(CAMEL_CASE_REGEXP, ''); 113 item = item.replace(CAMEL_CASE_REGEXP, '');
114 - item = (k===0)? item.charAt(0).toLowerCase() + item.substr(1) : item.charAt(0).toUpperCase() + item.substr(1) 114 + item = (k === 0) ? item.charAt(0).toLowerCase() + item.substr(1) : item.charAt(0).toUpperCase() + item.substr(1);
115 playStore.push(item); 115 playStore.push(item);
116 }); 116 });
117 return playStore.join(''); 117 return playStore.join('');
118 } 118 }
119 119
120 - createResourceLwM2M(resourcesLwM2MJson: ResourceLwM2M []): void {  
121 - if(resourcesLwM2MJson.length === this.resourceFormArray.length) {  
122 - this.resourceFormArray.patchValue(resourcesLwM2MJson, {emitEvent: false}) 120 + private createResourceLwM2M = (resourcesLwM2MJson: ResourceLwM2M []): void => {
  121 + if (resourcesLwM2MJson.length === this.resourceFormArray.length) {
  122 + this.resourceFormArray.patchValue(resourcesLwM2MJson, {emitEvent: false});
123 } else { 123 } else {
124 this.resourceFormArray.clear(); 124 this.resourceFormArray.clear();
125 resourcesLwM2MJson.forEach(resourceLwM2M => { 125 resourcesLwM2MJson.forEach(resourceLwM2M => {
@@ -131,18 +131,17 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA @@ -131,18 +131,17 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
131 telemetry: resourceLwM2M.telemetry, 131 telemetry: resourceLwM2M.telemetry,
132 keyName: [resourceLwM2M.keyName, Validators.required] 132 keyName: [resourceLwM2M.keyName, Validators.required]
133 })); 133 }));
134 - }) 134 + });
135 } 135 }
136 } 136 }
137 137
138 - private propagateChange = (v: any) => {  
139 - }; 138 + private propagateChange = (v: any) => { };
140 139
141 registerOnChange(fn: any): void { 140 registerOnChange(fn: any): void {
142 this.propagateChange = fn; 141 this.propagateChange = fn;
143 } 142 }
144 143
145 - private propagateChangeState(value: any): void { 144 + private propagateChangeState = (value: any): void => {
146 if (value && this.resourceFormGroup.valid) { 145 if (value && this.resourceFormGroup.valid) {
147 this.propagateChange(value); 146 this.propagateChange(value);
148 } else { 147 } else {
@@ -150,7 +149,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA @@ -150,7 +149,7 @@ export class Lwm2mObserveAttrTelemetryResourceComponent implements ControlValueA
150 } 149 }
151 } 150 }
152 151
153 - trackByParams(index: number): number { 152 + trackByParams = (index: number): number => {
154 return index; 153 return index;
155 } 154 }
156 } 155 }
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 /// 15 ///
16 16
17 17
18 -import { Component, forwardRef, Input, OnInit, Output } from "@angular/core"; 18 +import { Component, forwardRef, Input, OnInit } from '@angular/core';
19 import { 19 import {
20 AbstractControl, 20 AbstractControl,
21 ControlValueAccessor, 21 ControlValueAccessor,
@@ -24,10 +24,10 @@ import { @@ -24,10 +24,10 @@ import {
24 FormGroup, 24 FormGroup,
25 NG_VALUE_ACCESSOR, 25 NG_VALUE_ACCESSOR,
26 Validators 26 Validators
27 -} from "@angular/forms";  
28 -import { Store } from "@ngrx/store";  
29 -import { AppState } from "@core/core.state";  
30 -import { coerceBooleanProperty } from "@angular/cdk/coercion"; 27 +} from '@angular/forms';
  28 +import { Store } from '@ngrx/store';
  29 +import { AppState } from '@core/core.state';
  30 +import { coerceBooleanProperty } from '@angular/cdk/coercion';
31 import { 31 import {
32 ATTR, 32 ATTR,
33 Instance, 33 Instance,
@@ -35,7 +35,7 @@ import { @@ -35,7 +35,7 @@ import {
35 OBSERVE, 35 OBSERVE,
36 ResourceLwM2M, 36 ResourceLwM2M,
37 TELEMETRY 37 TELEMETRY
38 -} from "./profile-config.models"; 38 +} from './profile-config.models';
39 import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined'; 39 import { isNotNullOrUndefined } from 'codelyzer/util/isNotNullOrUndefined';
40 import { deepClone, isUndefined } from '@core/utils'; 40 import { deepClone, isUndefined } from '@core/utils';
41 import { MatDialog } from '@angular/material/dialog'; 41 import { MatDialog } from '@angular/material/dialog';
@@ -60,12 +60,13 @@ import { @@ -60,12 +60,13 @@ import {
60 60
61 export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, OnInit, Validators { 61 export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, OnInit, Validators {
62 62
  63 + private requiredValue: boolean;
  64 +
63 valuePrev = null as any; 65 valuePrev = null as any;
64 observeAttrTelemetryFormGroup: FormGroup; 66 observeAttrTelemetryFormGroup: FormGroup;
65 observe = OBSERVE as string; 67 observe = OBSERVE as string;
66 attribute = ATTR as string; 68 attribute = ATTR as string;
67 telemetry = TELEMETRY as string; 69 telemetry = TELEMETRY as string;
68 - private requiredValue: boolean;  
69 70
70 get required(): boolean { 71 get required(): boolean {
71 return this.requiredValue; 72 return this.requiredValue;
@@ -74,6 +75,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -74,6 +75,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
74 @Input() 75 @Input()
75 disabled: boolean; 76 disabled: boolean;
76 77
  78 + // tslint:disable-next-line:adjacent-overload-signatures
77 @Input() 79 @Input()
78 set required(value: boolean) { 80 set required(value: boolean) {
79 const newVal = coerceBooleanProperty(value); 81 const newVal = coerceBooleanProperty(value);
@@ -86,7 +88,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -86,7 +88,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
86 constructor(private store: Store<AppState>, 88 constructor(private store: Store<AppState>,
87 private fb: FormBuilder, 89 private fb: FormBuilder,
88 private dialog: MatDialog, 90 private dialog: MatDialog,
89 - private translate: TranslateService) { 91 + public translate: TranslateService) {
90 this.observeAttrTelemetryFormGroup = this.fb.group({ 92 this.observeAttrTelemetryFormGroup = this.fb.group({
91 clientLwM2M: this.fb.array([]) 93 clientLwM2M: this.fb.array([])
92 }); 94 });
@@ -100,19 +102,18 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -100,19 +102,18 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
100 ngOnInit(): void { 102 ngOnInit(): void {
101 } 103 }
102 104
103 - private propagateChange = (v: any) => {  
104 - }; 105 + private propagateChange = (v: any) => { };
105 106
106 107
107 registerOnChange(fn: any): void { 108 registerOnChange(fn: any): void {
108 this.propagateChange = fn; 109 this.propagateChange = fn;
109 } 110 }
110 111
111 - private propagateChangeState(value: any): void { 112 + private propagateChangeState = (value: any): void => {
112 if (value) { 113 if (value) {
113 if (this.valuePrev === null) { 114 if (this.valuePrev === null) {
114 - this.valuePrev = "init";  
115 - } else if (this.valuePrev === "init") { 115 + this.valuePrev = 'init';
  116 + } else if (this.valuePrev === 'init') {
116 this.valuePrev = value; 117 this.valuePrev = value;
117 } else if (JSON.stringify(value) !== JSON.stringify(this.valuePrev)) { 118 } else if (JSON.stringify(value) !== JSON.stringify(this.valuePrev)) {
118 this.valuePrev = value; 119 this.valuePrev = value;
@@ -138,7 +139,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -138,7 +139,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
138 } 139 }
139 } 140 }
140 141
141 - getDisabledState(): boolean { 142 + getDisabledState = (): boolean => {
142 return this.disabled; 143 return this.disabled;
143 } 144 }
144 145
@@ -146,13 +147,13 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -146,13 +147,13 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
146 this.buildClientObjectsLwM2M(value.clientLwM2M); 147 this.buildClientObjectsLwM2M(value.clientLwM2M);
147 } 148 }
148 149
149 - private buildClientObjectsLwM2M(objectsLwM2M: ObjectLwM2M []): void { 150 + private buildClientObjectsLwM2M = (objectsLwM2M: ObjectLwM2M []): void => {
150 this.observeAttrTelemetryFormGroup.setControl('clientLwM2M', 151 this.observeAttrTelemetryFormGroup.setControl('clientLwM2M',
151 this.createObjectsLwM2M(objectsLwM2M) 152 this.createObjectsLwM2M(objectsLwM2M)
152 ); 153 );
153 } 154 }
154 155
155 - createObjectsLwM2M(objectsLwM2MJson: ObjectLwM2M []): FormArray { 156 + private createObjectsLwM2M = (objectsLwM2MJson: ObjectLwM2M []): FormArray => {
156 return this.fb.array(objectsLwM2MJson.map((objectLwM2M) => { 157 return this.fb.array(objectsLwM2MJson.map((objectLwM2M) => {
157 return this.fb.group({ 158 return this.fb.group({
158 id: objectLwM2M.id, 159 id: objectLwM2M.id,
@@ -160,62 +161,62 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -160,62 +161,62 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
160 multiple: objectLwM2M.multiple, 161 multiple: objectLwM2M.multiple,
161 mandatory: objectLwM2M.mandatory, 162 mandatory: objectLwM2M.mandatory,
162 instances: this.createInstanceLwM2M(objectLwM2M.instances) 163 instances: this.createInstanceLwM2M(objectLwM2M.instances)
163 - })  
164 - })) 164 + });
  165 + }));
165 } 166 }
166 167
167 - createInstanceLwM2M(instanceLwM2MJson: Instance []): FormArray {  
168 - return this.fb.array(instanceLwM2MJson.map((instanceLwM2M, index) => { 168 + private createInstanceLwM2M = (instanceLwM2MJson: Instance []): FormArray => {
  169 + return this.fb.array(instanceLwM2MJson.map((instanceLwM2M) => {
169 return this.fb.group({ 170 return this.fb.group({
170 id: instanceLwM2M.id, 171 id: instanceLwM2M.id,
171 [this.observe]: {value: false, disabled: this.disabled}, 172 [this.observe]: {value: false, disabled: this.disabled},
172 [this.attribute]: {value: false, disabled: this.disabled}, 173 [this.attribute]: {value: false, disabled: this.disabled},
173 [this.telemetry]: {value: false, disabled: this.disabled}, 174 [this.telemetry]: {value: false, disabled: this.disabled},
174 resources: {value: instanceLwM2M.resources, disabled: this.disabled} 175 resources: {value: instanceLwM2M.resources, disabled: this.disabled}
175 - })  
176 - })) 176 + });
  177 + }));
177 } 178 }
178 179
179 - clientLwM2MFormArray(formGroup: FormGroup): FormArray { 180 + clientLwM2MFormArray = (formGroup: FormGroup): FormArray => {
180 return formGroup.get('clientLwM2M') as FormArray; 181 return formGroup.get('clientLwM2M') as FormArray;
181 } 182 }
182 183
183 - instancesLwm2mFormArray(objectLwM2M: AbstractControl): FormArray { 184 + instancesLwm2mFormArray = (objectLwM2M: AbstractControl): FormArray => {
184 return objectLwM2M.get('instances') as FormArray; 185 return objectLwM2M.get('instances') as FormArray;
185 } 186 }
186 187
187 - changeInstanceResourcesCheckBox(value: boolean, instance: AbstractControl, type: string): void {  
188 - let resources = instance.get('resources').value as ResourceLwM2M [] 188 + changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => {
  189 + const resources = instance.get('resources').value as ResourceLwM2M [];
189 resources.forEach(resource => resource[type] = value); 190 resources.forEach(resource => resource[type] = value);
190 instance.get('resources').patchValue(resources); 191 instance.get('resources').patchValue(resources);
191 this.propagateChange(this.observeAttrTelemetryFormGroup.value); 192 this.propagateChange(this.observeAttrTelemetryFormGroup.value);
192 } 193 }
193 194
194 - updateValidators() { 195 + private updateValidators = (): void => {
195 this.observeAttrTelemetryFormGroup.get('clientLwM2M').setValidators(this.required ? [Validators.required] : []); 196 this.observeAttrTelemetryFormGroup.get('clientLwM2M').setValidators(this.required ? [Validators.required] : []);
196 this.observeAttrTelemetryFormGroup.get('clientLwM2M').updateValueAndValidity(); 197 this.observeAttrTelemetryFormGroup.get('clientLwM2M').updateValueAndValidity();
197 } 198 }
198 199
199 - trackByParams(index: number): number { 200 + trackByParams = (index: number): number => {
200 return index; 201 return index;
201 } 202 }
202 203
203 - getIndeterminate(instance: AbstractControl, type: string) { 204 + getIndeterminate = (instance: AbstractControl, type: string): boolean => {
204 const resources = instance.get('resources').value as ResourceLwM2M []; 205 const resources = instance.get('resources').value as ResourceLwM2M [];
205 if (isNotNullOrUndefined(resources)) { 206 if (isNotNullOrUndefined(resources)) {
206 const isType = (element) => element[type] === true; 207 const isType = (element) => element[type] === true;
207 - let checkedResource = resources.filter(isType);  
208 - if (checkedResource.length === 0) return false; 208 + const checkedResource = resources.filter(isType);
  209 + if (checkedResource.length === 0) { return false; }
209 else if (checkedResource.length === resources.length) { 210 else if (checkedResource.length === resources.length) {
210 instance.patchValue({[type]: true}); 211 instance.patchValue({[type]: true});
211 return false; 212 return false;
212 - } else return true; 213 + } else { return true; }
213 } 214 }
214 return false; 215 return false;
215 } 216 }
216 217
217 218
218 - getChecked(instance: AbstractControl, type: string) { 219 + getChecked = (instance: AbstractControl, type: string): boolean => {
219 const resources = instance.get('resources').value as ResourceLwM2M []; 220 const resources = instance.get('resources').value as ResourceLwM2M [];
220 if (isNotNullOrUndefined(resources)) { 221 if (isNotNullOrUndefined(resources)) {
221 return resources.some(resource => resource[type]); 222 return resources.some(resource => resource[type]);
@@ -223,7 +224,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -223,7 +224,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
223 return false; 224 return false;
224 } 225 }
225 226
226 - getExpended(objectLwM2M: AbstractControl) { 227 + getExpended = (objectLwM2M: AbstractControl): boolean => {
227 return this.instancesLwm2mFormArray(objectLwM2M).length === 1; 228 return this.instancesLwm2mFormArray(objectLwM2M).length === 1;
228 } 229 }
229 230
@@ -233,22 +234,24 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -233,22 +234,24 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
233 * 2) Field in object: <Mandatory> == Mandatory/Optional 234 * 2) Field in object: <Mandatory> == Mandatory/Optional
234 * If this field is “Multiple” then the number of Object Instance can be from 0 to many (Object Instance ID MAX_ID=65535). 235 * If this field is “Multiple” then the number of Object Instance can be from 0 to many (Object Instance ID MAX_ID=65535).
235 * If this field is “Single” then the number of Object Instance can be from 0 to 1. (max count == 1) 236 * If this field is “Single” then the number of Object Instance can be from 0 to 1. (max count == 1)
236 - * If the Object field “Mandatory” is “Mandatory” and the Object field “Instances” is “Single” then, the number of Object Instance MUST be 1.  
237 - * 1. <MultipleInstances> == Multiple (true), <Mandatory> == Optional (false) => Object Instance ID MIN_ID=0 MAX_ID=65535 (может ни одного не быть)  
238 - * 2. <MultipleInstances> == Multiple (true), <Mandatory> == Mandatory (true) => Object Instance ID MIN_ID=0 MAX_ID=65535 (min один обязательный)  
239 - * 3. <MultipleInstances> == Single (false), <Mandatory> == Optional (false) => Object Instance ID cnt_max = 1 cnt_min = 0 (может ни одного не быть)  
240 - * 4. <MultipleInstances> == Single (false), <Mandatory> == Mandatory (true) => Object Instance ID cnt_max = cnt_min = 1 (всегда есть один)  
241 - * @param $event  
242 - * @param objectId  
243 - * @param objectName 237 + * If the Object field “Mandatory” is “Mandatory” and the Object field “Instances” is “Single” then -
  238 + * the number of Object Instance MUST be 1.
  239 + * 1. <MultipleInstances> == Multiple (true), <Mandatory> == Optional (false) -
  240 + * Object Instance ID MIN_ID=0 MAX_ID=65535 (может ни одного не быть)
  241 + * 2. <MultipleInstances> == Multiple (true), <Mandatory> == Mandatory (true) -
  242 + * Object Instance ID MIN_ID=0 MAX_ID=65535 (min один обязательный)
  243 + * 3. <MultipleInstances> == Single (false), <Mandatory> == Optional (false) -
  244 + * Object Instance ID cnt_max = 1 cnt_min = 0 (может ни одного не быть)
  245 + * 4. <MultipleInstances> == Single (false), <Mandatory> == Mandatory (true) -
  246 + * Object Instance ID cnt_max = cnt_min = 1 (всегда есть один)
244 */ 247 */
245 248
246 - addInstances($event: Event, object: ObjectLwM2M): void { 249 + addInstances = ($event: Event, object: ObjectLwM2M): void => {
247 if ($event) { 250 if ($event) {
248 $event.stopPropagation(); 251 $event.stopPropagation();
249 $event.preventDefault(); 252 $event.preventDefault();
250 } 253 }
251 - let instancesIds = new Set<number>(); 254 + const instancesIds = new Set<number>();
252 object.instances.forEach(inst => { 255 object.instances.forEach(inst => {
253 instancesIds.add(inst.id); 256 instancesIds.add(inst.id);
254 }); 257 });
@@ -269,21 +272,22 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -269,21 +272,22 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
269 ); 272 );
270 } 273 }
271 274
272 - updateInstancesIds(data: Lwm2mObjectAddInstancesData) {  
273 - let valueNew = new Set<number>();  
274 - let valueOld = new Set<number>(); 275 + private updateInstancesIds = (data: Lwm2mObjectAddInstancesData): void => {
  276 + const valueNew = new Set<number>();
  277 + const valueOld = new Set<number>();
275 data.instancesIds.forEach(value => { 278 data.instancesIds.forEach(value => {
276 valueNew.add(value); 279 valueNew.add(value);
277 - })  
278 - let oldInstances = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).find(e => e.id == data.objectId).instances; 280 + });
  281 + const oldInstances = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).
  282 + find(e => e.id === data.objectId).instances;
279 oldInstances.forEach(inst => { 283 oldInstances.forEach(inst => {
280 valueOld.add(inst.id); 284 valueOld.add(inst.id);
281 }); 285 });
282 - if (JSON.stringify(Array.from(valueOld)) != JSON.stringify(Array.from(valueNew))) {  
283 - let idsDel = this.diffBetweenSet(valueNew, this.deepCloneSet(valueOld));  
284 - let idsAdd = this.diffBetweenSet(valueOld, this.deepCloneSet(valueNew)); 286 + if (JSON.stringify(Array.from(valueOld)) !== JSON.stringify(Array.from(valueNew))) {
  287 + const idsDel = this.diffBetweenSet(valueNew, this.deepCloneSet(valueOld));
  288 + const idsAdd = this.diffBetweenSet(valueOld, this.deepCloneSet(valueNew));
285 if (idsAdd.size) { 289 if (idsAdd.size) {
286 - this.addInstancesNew(data.objectId, idsAdd) 290 + this.addInstancesNew(data.objectId, idsAdd);
287 } 291 }
288 if (idsDel.size) { 292 if (idsDel.size) {
289 this.delInstances(data.objectId, idsDel); 293 this.delInstances(data.objectId, idsDel);
@@ -291,22 +295,25 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -291,22 +295,25 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
291 } 295 }
292 } 296 }
293 297
294 - delInstances(objectId: number, idsDel: Set<number>): void {  
295 - let isIdIndex = (element) => element.id == objectId;  
296 - let objectIndex = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).findIndex(isIdIndex); 298 + private delInstances = (objectId: number, idsDel: Set<number>): void => {
  299 + let isIdIndex = (element) => element.id === objectId;
  300 + const objectIndex = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).findIndex(isIdIndex);
297 idsDel.forEach(x => { 301 idsDel.forEach(x => {
298 - isIdIndex = (element) => element.value.id == x;  
299 - let instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls[objectIndex].get("instances") as FormArray);  
300 - let instanceIndex = instancesFormArray.controls.findIndex(isIdIndex); 302 + isIdIndex = (element) => element.value.id === x;
  303 + const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray)
  304 + .controls[objectIndex].get('instances') as FormArray);
  305 + const instanceIndex = instancesFormArray.controls.findIndex(isIdIndex);
301 instancesFormArray.removeAt(instanceIndex); 306 instancesFormArray.removeAt(instanceIndex);
302 - }) 307 + });
303 } 308 }
304 309
305 - addInstancesNew(objectId: number, idsAdd: Set<number>): void {  
306 - let instancesValue = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M []).find(e => e.id == objectId).instances;  
307 - let instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls.find(e => e.value.id == objectId).get("instances") as FormArray) as FormArray; 310 + private addInstancesNew = (objectId: number, idsAdd: Set<number>): void => {
  311 + const instancesValue = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M [])
  312 + .find(e => e.id === objectId).instances;
  313 + const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls
  314 + .find(e => e.value.id === objectId).get('instances') as FormArray) as FormArray;
308 idsAdd.forEach(x => { 315 idsAdd.forEach(x => {
309 - let instanceNew = deepClone(instancesValue[0]) as Instance; 316 + const instanceNew = deepClone(instancesValue[0]) as Instance;
310 instanceNew.id = x; 317 instanceNew.id = x;
311 instanceNew.resources.forEach(r => { 318 instanceNew.resources.forEach(r => {
312 r.attribute = false; 319 r.attribute = false;
@@ -321,26 +328,26 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor, @@ -321,26 +328,26 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor,
321 resources: {value: instanceNew.resources, disabled: this.disabled} 328 resources: {value: instanceNew.resources, disabled: this.disabled}
322 })); 329 }));
323 }); 330 });
324 - (instancesFormArray.controls as FormGroup[]).sort((a,b) => a.value.id - b.value.id); 331 + (instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id);
325 } 332 }
326 333
327 - deepCloneSet(oldSet: Set<any>): Set<any> {  
328 - let newSet = new Set<number>(); 334 + private deepCloneSet = (oldSet: Set<any>): Set<any> => {
  335 + const newSet = new Set<number>();
329 oldSet.forEach(p => { 336 oldSet.forEach(p => {
330 newSet.add(p); 337 newSet.add(p);
331 - }) 338 + });
332 return newSet; 339 return newSet;
333 } 340 }
334 341
335 - diffBetweenSet(firstSet: Set<any>, secondSet: Set<any>): Set<any> { 342 + private diffBetweenSet = (firstSet: Set<any>, secondSet: Set<any>): Set<any> => {
336 firstSet.forEach(p => { 343 firstSet.forEach(p => {
337 secondSet.delete(p); 344 secondSet.delete(p);
338 - })  
339 - return secondSet 345 + });
  346 + return secondSet;
340 } 347 }
341 348
342 - setInstancesIds(instances: Instance []): Set<number> {  
343 - let instancesIds = new Set<number>(); 349 + private setInstancesIds = (instances: Instance []): Set<number> => {
  350 + const instancesIds = new Set<number>();
344 if (instances && instances.length) { 351 if (instances && instances.length) {
345 instances.forEach(inst => { 352 instances.forEach(inst => {
346 instancesIds.add(inst.id); 353 instancesIds.add(inst.id);
@@ -14,8 +14,6 @@ @@ -14,8 +14,6 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import { AbstractControl, ValidationErrors } from '@angular/forms';  
18 -  
19 export const OBSERVE_ATTR = 'observeAttr'; 17 export const OBSERVE_ATTR = 'observeAttr';
20 export const OBSERVE = 'observe'; 18 export const OBSERVE = 'observe';
21 export const ATTR = 'attribute'; 19 export const ATTR = 'attribute';
@@ -23,33 +21,29 @@ export const TELEMETRY = 'telemetry'; @@ -23,33 +21,29 @@ export const TELEMETRY = 'telemetry';
23 export const KEY_NAME = 'keyName'; 21 export const KEY_NAME = 'keyName';
24 export const DEFAULT_ID_SERVER = 123; 22 export const DEFAULT_ID_SERVER = 123;
25 export const DEFAULT_ID_BOOTSTRAP = 111; 23 export const DEFAULT_ID_BOOTSTRAP = 111;
26 -export const DEFAULT_HOST_NAME = "localhost"; 24 +export const DEFAULT_HOST_NAME = 'localhost';
27 export const DEFAULT_PORT_SERVER_NO_SEC = 5685; 25 export const DEFAULT_PORT_SERVER_NO_SEC = 5685;
28 export const DEFAULT_PORT_BOOTSTRAP_NO_SEC = 5691; 26 export const DEFAULT_PORT_BOOTSTRAP_NO_SEC = 5691;
29 export const DEFAULT_CLIENT_HOLD_OFF_TIME = 1; 27 export const DEFAULT_CLIENT_HOLD_OFF_TIME = 1;
30 export const DEFAULT_LIFE_TIME = 300; 28 export const DEFAULT_LIFE_TIME = 300;
31 -export const DEFAULT_DEFAULT_MIN_PERIOD = 1; 29 +export const DEFAULT_MIN_PERIOD = 1;
32 export const DEFAULT_NOTIF_IF_DESIBLED = true; 30 export const DEFAULT_NOTIF_IF_DESIBLED = true;
33 -export const DEFAULT_BINDING = "U"; 31 +export const DEFAULT_BINDING = 'U';
34 export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0; 32 export const DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT = 0;
35 -export const LEN_MAX_PUBLIC_KEY_PSK = 182;  
36 -export const LEN_MAX_PUBLIC_KEY_RPK_X509 = 3000;  
37 -export const KEY_IDENT_REGEXP_PSK = /^[0-9a-fA-F]{64,64}$/;  
38 -export const KEY_PRIVATE_REGEXP = /^[0-9a-fA-F]{134,134}$/;  
39 -export const KEY_PUBLIC_REGEXP_PSK = /^[0-9a-fA-F]{182,182}$/;  
40 -export const KEY_PUBLIC_REGEXP_X509 = /^[0-9a-fA-F]{0,3000}$/; 33 +export const LEN_MAX_PUBLIC_KEY_RPK = 182;
  34 +export const LEN_MAX_PUBLIC_KEY_X509 = 3000;
  35 +export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
41 export const CAMEL_CASE_REGEXP = /[-_&@.,*+!?^${}()|[\]\\]/g; 36 export const CAMEL_CASE_REGEXP = /[-_&@.,*+!?^${}()|[\]\\]/g;
42 export const INSTANCES_ID_VALUE_MIN = 0; 37 export const INSTANCES_ID_VALUE_MIN = 0;
43 export const INSTANCES_ID_VALUE_MAX = 65535; 38 export const INSTANCES_ID_VALUE_MAX = 65535;
44 39
45 -//ok  
46 export enum SECURITY_CONFIG_MODE { 40 export enum SECURITY_CONFIG_MODE {
47 PSK = 'PSK', 41 PSK = 'PSK',
48 RPK = 'RPK', 42 RPK = 'RPK',
49 X509 = 'X509', 43 X509 = 'X509',
50 NO_SEC = 'NO_SEC' 44 NO_SEC = 'NO_SEC'
51 } 45 }
52 -//ok 46 +
53 export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>( 47 export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>(
54 [ 48 [
55 [SECURITY_CONFIG_MODE.PSK, 'Pre-Shared Key'], 49 [SECURITY_CONFIG_MODE.PSK, 'Pre-Shared Key'],
@@ -58,59 +52,54 @@ export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>( @@ -58,59 +52,54 @@ export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>(
58 [SECURITY_CONFIG_MODE.NO_SEC, 'No Security'], 52 [SECURITY_CONFIG_MODE.NO_SEC, 'No Security'],
59 ] 53 ]
60 ); 54 );
61 -//ok 55 +
62 export interface BootstrapServersSecurityConfig { 56 export interface BootstrapServersSecurityConfig {
63 - shortId: number,  
64 - lifetime: number,  
65 - defaultMinPeriod: number,  
66 - notifIfDisabled: boolean,  
67 - binding: string 57 + shortId: number;
  58 + lifetime: number;
  59 + defaultMinPeriod: number;
  60 + notifIfDisabled: boolean;
  61 + binding: string;
68 } 62 }
69 63
70 -//ok  
71 export interface ServerSecurityConfig { 64 export interface ServerSecurityConfig {
72 - host?: string,  
73 - port?: number,  
74 - bootstrapServerIs?: boolean,  
75 - securityMode: string,  
76 - clientPublicKeyOrId?: string,  
77 - clientSecretKey?: string, 65 + host?: string;
  66 + port?: number;
  67 + bootstrapServerIs?: boolean;
  68 + securityMode: string;
  69 + clientPublicKeyOrId?: string;
  70 + clientSecretKey?: string;
78 serverPublicKey?: string; 71 serverPublicKey?: string;
79 - clientHoldOffTime?: number,  
80 - serverId?: number,  
81 - bootstrapServerAccountTimeout: number 72 + clientHoldOffTime?: number;
  73 + serverId?: number;
  74 + bootstrapServerAccountTimeout: number;
82 } 75 }
83 76
84 -//ok  
85 interface BootstrapSecurityConfig { 77 interface BootstrapSecurityConfig {
86 - servers: BootstrapServersSecurityConfig,  
87 - bootstrapServer: ServerSecurityConfig,  
88 - lwm2mServer: ServerSecurityConfig 78 + servers: BootstrapServersSecurityConfig;
  79 + bootstrapServer: ServerSecurityConfig;
  80 + lwm2mServer: ServerSecurityConfig;
89 } 81 }
90 82
91 -//ok  
92 export interface ProfileConfigModels { 83 export interface ProfileConfigModels {
93 - bootstrap: BootstrapSecurityConfig, 84 + bootstrap: BootstrapSecurityConfig;
94 observeAttr: { 85 observeAttr: {
95 observe: string [], 86 observe: string [],
96 attribute: string [], 87 attribute: string [],
97 telemetry: string [], 88 telemetry: string [],
98 keyName: [] 89 keyName: []
99 - } 90 + };
100 } 91 }
101 92
102 -//ok  
103 export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig { 93 export function getDefaultBootstrapServersSecurityConfig(): BootstrapServersSecurityConfig {
104 return { 94 return {
105 shortId: DEFAULT_ID_SERVER, 95 shortId: DEFAULT_ID_SERVER,
106 lifetime: DEFAULT_LIFE_TIME, 96 lifetime: DEFAULT_LIFE_TIME,
107 - defaultMinPeriod: DEFAULT_DEFAULT_MIN_PERIOD, 97 + defaultMinPeriod: DEFAULT_MIN_PERIOD,
108 notifIfDisabled: DEFAULT_NOTIF_IF_DESIBLED, 98 notifIfDisabled: DEFAULT_NOTIF_IF_DESIBLED,
109 binding: DEFAULT_BINDING 99 binding: DEFAULT_BINDING
110 - } 100 + };
111 } 101 }
112 102
113 -//ok  
114 export function getDefaultBootstrapServerSecurityConfig(hostname: any): ServerSecurityConfig { 103 export function getDefaultBootstrapServerSecurityConfig(hostname: any): ServerSecurityConfig {
115 return { 104 return {
116 host: hostname, 105 host: hostname,
@@ -121,9 +110,9 @@ export function getDefaultBootstrapServerSecurityConfig(hostname: any): ServerSe @@ -121,9 +110,9 @@ export function getDefaultBootstrapServerSecurityConfig(hostname: any): ServerSe
121 clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME, 110 clientHoldOffTime: DEFAULT_CLIENT_HOLD_OFF_TIME,
122 serverId: DEFAULT_ID_BOOTSTRAP, 111 serverId: DEFAULT_ID_BOOTSTRAP,
123 bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT 112 bootstrapServerAccountTimeout: DEFAULT_BOOTSTRAP_SERVER_ACCOUNT_TIME_OUT
124 - } 113 + };
125 } 114 }
126 -//ok 115 +
127 export function getDefaultLwM2MServerSecurityConfig(hostname): ServerSecurityConfig { 116 export function getDefaultLwM2MServerSecurityConfig(hostname): ServerSecurityConfig {
128 const DefaultLwM2MServerSecurityConfig = getDefaultBootstrapServerSecurityConfig(hostname); 117 const DefaultLwM2MServerSecurityConfig = getDefaultBootstrapServerSecurityConfig(hostname);
129 DefaultLwM2MServerSecurityConfig.bootstrapServerIs = false; 118 DefaultLwM2MServerSecurityConfig.bootstrapServerIs = false;
@@ -132,19 +121,17 @@ export function getDefaultLwM2MServerSecurityConfig(hostname): ServerSecurityCon @@ -132,19 +121,17 @@ export function getDefaultLwM2MServerSecurityConfig(hostname): ServerSecurityCon
132 return DefaultLwM2MServerSecurityConfig; 121 return DefaultLwM2MServerSecurityConfig;
133 } 122 }
134 123
135 -//ok  
136 function getDefaultProfileBootstrapSecurityConfig(hostname: any): BootstrapSecurityConfig { 124 function getDefaultProfileBootstrapSecurityConfig(hostname: any): BootstrapSecurityConfig {
137 return { 125 return {
138 servers: getDefaultBootstrapServersSecurityConfig(), 126 servers: getDefaultBootstrapServersSecurityConfig(),
139 bootstrapServer: getDefaultBootstrapServerSecurityConfig(hostname), 127 bootstrapServer: getDefaultBootstrapServerSecurityConfig(hostname),
140 lwm2mServer: getDefaultLwM2MServerSecurityConfig(hostname) 128 lwm2mServer: getDefaultLwM2MServerSecurityConfig(hostname)
141 - } 129 + };
142 } 130 }
143 131
144 -//ok  
145 export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels { 132 export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels {
146 return { 133 return {
147 - bootstrap: getDefaultProfileBootstrapSecurityConfig((hostname)? hostname : DEFAULT_HOST_NAME), 134 + bootstrap: getDefaultProfileBootstrapSecurityConfig((hostname) ? hostname : DEFAULT_HOST_NAME),
148 observeAttr: { 135 observeAttr: {
149 observe: [], 136 observe: [],
150 attribute: [], 137 attribute: [],
@@ -154,19 +141,18 @@ export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels { @@ -154,19 +141,18 @@ export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels {
154 }; 141 };
155 } 142 }
156 143
157 -//ok  
158 export interface ResourceLwM2M { 144 export interface ResourceLwM2M {
159 - id: number,  
160 - name: string,  
161 - observe: boolean,  
162 - attribute: boolean,  
163 - telemetry: boolean,  
164 - keyName: string 145 + id: number;
  146 + name: string;
  147 + observe: boolean;
  148 + attribute: boolean;
  149 + telemetry: boolean;
  150 + keyName: string;
165 } 151 }
166 -//ok 152 +
167 export interface Instance { 153 export interface Instance {
168 - id: number,  
169 - resources: ResourceLwM2M[] 154 + id: number;
  155 + resources: ResourceLwM2M[];
170 } 156 }
171 157
172 /** 158 /**
@@ -176,10 +162,10 @@ export interface Instance { @@ -176,10 +162,10 @@ export interface Instance {
176 * mandatory == false => Optional 162 * mandatory == false => Optional
177 */ 163 */
178 export interface ObjectLwM2M { 164 export interface ObjectLwM2M {
179 - id: number,  
180 - name: string,  
181 - multiple?: boolean,  
182 - mandatory?: boolean,  
183 - instances?: Instance [] 165 + id: number;
  166 + name: string;
  167 + multiple?: boolean;
  168 + mandatory?: boolean;
  169 + instances?: Instance [];
184 } 170 }
185 171
@@ -25,8 +25,7 @@ import { HomeDialogsModule } from '../../dialogs/home-dialogs.module'; @@ -25,8 +25,7 @@ import { HomeDialogsModule } from '../../dialogs/home-dialogs.module';
25 import { HomeComponentsModule } from '@modules/home/components/home-components.module'; 25 import { HomeComponentsModule } from '@modules/home/components/home-components.module';
26 import { DeviceTabsComponent } from '@home/pages/device/device-tabs.component'; 26 import { DeviceTabsComponent } from '@home/pages/device/device-tabs.component';
27 import { SecurityConfigComponent } from '@home/pages/device/lwm2m/security-config.component'; 27 import { SecurityConfigComponent } from '@home/pages/device/lwm2m/security-config.component';
28 -// TODO: @nickAS21 move to device profile  
29 -import {SecurityConfigServerComponent} from "@home/pages/device/lwm2m/security-config-server.component"; 28 +import { SecurityConfigServerComponent } from '@home/pages/device/lwm2m/security-config-server.component';
30 import { DefaultDeviceConfigurationComponent } from './data/default-device-configuration.component'; 29 import { DefaultDeviceConfigurationComponent } from './data/default-device-configuration.component';
31 import { DeviceConfigurationComponent } from './data/device-configuration.component'; 30 import { DeviceConfigurationComponent } from './data/device-configuration.component';
32 import { DeviceDataComponent } from './data/device-data.component'; 31 import { DeviceDataComponent } from './data/device-data.component';
@@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
24 <mat-select formControlName="securityMode" 24 <mat-select formControlName="securityMode"
25 (ngModelChange)="securityModeChanged($event)"> 25 (ngModelChange)="securityModeChanged($event)">
26 <mat-option *ngFor="let securityMode of securityConfigLwM2MTypes" 26 <mat-option *ngFor="let securityMode of securityConfigLwM2MTypes"
27 - [value]="securityMode" > 27 + [value]="securityMode">
28 {{ credentialTypeLwM2MNamesMap.get(securityConfigLwM2MType[securityMode]) }} 28 {{ credentialTypeLwM2MNamesMap.get(securityConfigLwM2MType[securityMode]) }}
29 </mat-option> 29 </mat-option>
30 </mat-select> 30 </mat-select>
@@ -35,43 +35,64 @@ @@ -35,43 +35,64 @@
35 <div [fxShow]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC"> 35 <div [fxShow]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC">
36 <mat-form-field class="mat-block"> 36 <mat-form-field class="mat-block">
37 <mat-label>{{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }}</mat-label> 37 <mat-label>{{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }}</mat-label>
38 - <textarea matInput type="text" rows="3" cols="1" formControlName="clientPublicKeyOrId" #clientPublicKeyOrId maxlength={{lenMaxClientPublicKeyOrId}}  
39 - [required]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC"></textarea> 38 + <textarea matInput
  39 + #clientPublicKeyOrId
  40 + maxlength={{lenMaxClientPublicKeyOrId}}
  41 + cdkTextareaAutosize
  42 + cdkAutosizeMinRows="1"
  43 + style="overflow:hidden"
  44 + cols="1"
  45 + formControlName="clientPublicKeyOrId"
  46 + [required]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC">
  47 + </textarea>
40 <mat-hint align="end">{{clientPublicKeyOrId.value?.length || 0}}/{{lenMaxClientPublicKeyOrId}}</mat-hint> 48 <mat-hint align="end">{{clientPublicKeyOrId.value?.length || 0}}/{{lenMaxClientPublicKeyOrId}}</mat-hint>
41 <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('required')"> 49 <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('required')">
42 {{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }} 50 {{ 'device.lwm2m-security-config.client-publicKey-or-id' | translate }}
43 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong> 51 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>
44 </mat-error> 52 </mat-error>
45 - <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('pattern') &&  
46 - serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK"> 53 + <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('pattern')">
47 {{ 'device.lwm2m-security-config.client-key' | translate }} 54 {{ 'device.lwm2m-security-config.client-key' | translate }}
48 - <strong>{{ 'device.lwm2m-security-config.pattern_hex_dec_182' | translate }}</strong> 55 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  56 + count: 0
  57 + }) | async }}</strong>
49 </mat-error> 58 </mat-error>
50 - <mat-error *ngIf="serverFormGroup.get('clientPublicKeyOrId').hasError('pattern') &&  
51 - serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509"> 59 + <mat-error *ngIf="(serverFormGroup.get('clientPublicKeyOrId').hasError('maxlength') ||
  60 + serverFormGroup.get('clientPublicKeyOrId').hasError('minlength'))">
52 {{ 'device.lwm2m-security-config.client-key' | translate }} 61 {{ 'device.lwm2m-security-config.client-key' | translate }}
53 - <strong>{{ 'device.lwm2m-security-config.pattern_hex_dec' | translate }}</strong> 62 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  63 + count: lenMaxClientPublicKeyOrId
  64 + }) | async }}</strong>
54 </mat-error> 65 </mat-error>
55 </mat-form-field> 66 </mat-form-field>
56 <mat-form-field class="mat-block"> 67 <mat-form-field class="mat-block">
57 <mat-label>{{ 'device.lwm2m-security-config.client-secret-key' | translate }}</mat-label> 68 <mat-label>{{ 'device.lwm2m-security-config.client-secret-key' | translate }}</mat-label>
58 - <textarea matInput type="text" rows="2" cols="1" formControlName="clientSecretKey" #clientSecretKey maxlength={{lenMaxClientSecretKey}}  
59 - [required]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC"></textarea> 69 + <textarea matInput
  70 + #clientSecretKey
  71 + maxlength={{lenMaxClientSecretKey}}
  72 + cdkTextareaAutosize
  73 + cdkAutosizeMinRows="1"
  74 + style="overflow:hidden"
  75 + cols="1"
  76 + formControlName="clientSecretKey"
  77 + [required]="serverFormGroup.get('securityMode').value !== securityConfigLwM2MType.NO_SEC">
  78 + </textarea>
60 <mat-hint align="end">{{clientSecretKey.value?.length || 0}}/{{lenMaxClientSecretKey}}</mat-hint> 79 <mat-hint align="end">{{clientSecretKey.value?.length || 0}}/{{lenMaxClientSecretKey}}</mat-hint>
61 <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('required')"> 80 <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('required')">
62 {{ 'device.lwm2m-security-config.client-secret-key' | translate }} 81 {{ 'device.lwm2m-security-config.client-secret-key' | translate }}
63 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong> 82 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>
64 </mat-error> 83 </mat-error>
65 - <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('pattern') &&  
66 - (serverFormGroup.get('securityMode').value === securityConfigLwM2MType.RPK ||  
67 - serverFormGroup.get('securityMode').value === securityConfigLwM2MType.X509)"> 84 + <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('pattern')">
68 {{ 'device.lwm2m-security-config.client-key' | translate }} 85 {{ 'device.lwm2m-security-config.client-key' | translate }}
69 - <strong>{{ 'device.lwm2m-security-config.pattern_hex_dec_134' | translate }}</strong> 86 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  87 + count: 0
  88 + }) | async }}</strong>
70 </mat-error> 89 </mat-error>
71 - <mat-error *ngIf="serverFormGroup.get('clientSecretKey').hasError('pattern') &&  
72 - (serverFormGroup.get('securityMode').value === securityConfigLwM2MType.PSK)"> 90 + <mat-error *ngIf="(serverFormGroup.get('clientSecretKey').hasError('maxlength') ||
  91 + serverFormGroup.get('clientSecretKey').hasError('minlength'))">
73 {{ 'device.lwm2m-security-config.client-key' | translate }} 92 {{ 'device.lwm2m-security-config.client-key' | translate }}
74 - <strong>{{ 'device-profile.lwm2m.pattern_hex_dec_64' | translate }}</strong> 93 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  94 + count: lenMaxClientSecretKey
  95 + }) | async }}</strong>
75 </mat-error> 96 </mat-error>
76 </mat-form-field> 97 </mat-form-field>
77 </div> 98 </div>
@@ -14,26 +14,25 @@ @@ -14,26 +14,25 @@
14 /// limitations under the License. 14 /// limitations under the License.
15 /// 15 ///
16 16
17 -import {Component, forwardRef, Inject, Input, OnInit, ViewChild} from "@angular/core"; 17 +import { Component, forwardRef, Inject, Input, OnInit } from '@angular/core';
18 18
19 import { 19 import {
20 ControlValueAccessor, 20 ControlValueAccessor,
21 FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators 21 FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators
22 -} from "@angular/forms"; 22 +} from '@angular/forms';
23 import { 23 import {
24 SECURITY_CONFIG_MODE, 24 SECURITY_CONFIG_MODE,
25 SECURITY_CONFIG_MODE_NAMES, 25 SECURITY_CONFIG_MODE_NAMES,
26 - KEY_IDENT_REGEXP_PSK, 26 + KEY_REGEXP_HEX_DEC,
27 ServerSecurityConfig, 27 ServerSecurityConfig,
28 DeviceCredentialsDialogLwm2mData, 28 DeviceCredentialsDialogLwm2mData,
29 LEN_MAX_PSK, 29 LEN_MAX_PSK,
30 - LEN_MAX_PRIVATE_KEY, LEN_MAX_PUBLIC_KEY_RPK, KEY_PRIVATE_REGEXP, LEN_MAX_PUBLIC_KEY_X509, KEY_PUBLIC_REGEXP_X509  
31 -} from "@home/pages/device/lwm2m/security-config.models";  
32 -import {Store} from "@ngrx/store";  
33 -import {AppState} from "@core/core.state";  
34 -import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog";  
35 -import {PageComponent} from "@shared/components/page.component";  
36 -import {MatPaginator} from "@angular/material/paginator"; 30 + LEN_MAX_PRIVATE_KEY, LEN_MAX_PUBLIC_KEY_RPK, LEN_MAX_PUBLIC_KEY_X509
  31 +} from '@home/pages/device/lwm2m/security-config.models';
  32 +import { Store } from '@ngrx/store';
  33 +import { AppState } from '@core/core.state';
  34 +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
  35 +import { PageComponent } from '@shared/components/page.component';
37 import { TranslateService } from '@ngx-translate/core'; 36 import { TranslateService } from '@ngx-translate/core';
38 37
39 @Component({ 38 @Component({
@@ -54,13 +53,13 @@ export class SecurityConfigServerComponent extends PageComponent implements OnIn @@ -54,13 +53,13 @@ export class SecurityConfigServerComponent extends PageComponent implements OnIn
54 securityConfigLwM2MType = SECURITY_CONFIG_MODE; 53 securityConfigLwM2MType = SECURITY_CONFIG_MODE;
55 securityConfigLwM2MTypes = Object.keys(SECURITY_CONFIG_MODE); 54 securityConfigLwM2MTypes = Object.keys(SECURITY_CONFIG_MODE);
56 credentialTypeLwM2MNamesMap = SECURITY_CONFIG_MODE_NAMES; 55 credentialTypeLwM2MNamesMap = SECURITY_CONFIG_MODE_NAMES;
57 - lenMaxClientPublicKeyOrId = LEN_MAX_PSK; 56 + lenMinClientPublicKeyOrId = 0;
  57 + lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK;
  58 + lenMinClientSecretKey = LEN_MAX_PRIVATE_KEY;
58 lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY; 59 lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY;
59 60
60 @Input() serverFormGroup: FormGroup; 61 @Input() serverFormGroup: FormGroup;
61 62
62 - @ViewChild(MatPaginator) paginator: MatPaginator;  
63 -  
64 constructor(protected store: Store<AppState>, 63 constructor(protected store: Store<AppState>,
65 @Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogLwm2mData, 64 @Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogLwm2mData,
66 public dialogRef: MatDialogRef<SecurityConfigServerComponent, object>, 65 public dialogRef: MatDialogRef<SecurityConfigServerComponent, object>,
@@ -73,40 +72,59 @@ export class SecurityConfigServerComponent extends PageComponent implements OnIn @@ -73,40 +72,59 @@ export class SecurityConfigServerComponent extends PageComponent implements OnIn
73 this.registerDisableOnLoadFormControl(this.serverFormGroup.get('securityMode')); 72 this.registerDisableOnLoadFormControl(this.serverFormGroup.get('securityMode'));
74 } 73 }
75 74
76 - updateValueFields(serverData: ServerSecurityConfig): void { 75 + private updateValueFields(serverData: ServerSecurityConfig): void {
77 this.serverFormGroup.patchValue(serverData, {emitEvent: false}); 76 this.serverFormGroup.patchValue(serverData, {emitEvent: false});
78 const securityMode = this.serverFormGroup.get('securityMode').value as SECURITY_CONFIG_MODE; 77 const securityMode = this.serverFormGroup.get('securityMode').value as SECURITY_CONFIG_MODE;
79 this.updateValidate(securityMode); 78 this.updateValidate(securityMode);
80 } 79 }
81 80
82 - updateValidate(securityMode: SECURITY_CONFIG_MODE): void { 81 + private updateValidate(securityMode: SECURITY_CONFIG_MODE): void {
83 switch (securityMode) { 82 switch (securityMode) {
84 case SECURITY_CONFIG_MODE.NO_SEC: 83 case SECURITY_CONFIG_MODE.NO_SEC:
85 this.serverFormGroup.get('clientPublicKeyOrId').setValidators([]); 84 this.serverFormGroup.get('clientPublicKeyOrId').setValidators([]);
86 this.serverFormGroup.get('clientSecretKey').setValidators([]); 85 this.serverFormGroup.get('clientSecretKey').setValidators([]);
87 break; 86 break;
88 case SECURITY_CONFIG_MODE.PSK: 87 case SECURITY_CONFIG_MODE.PSK:
  88 + this.lenMinClientPublicKeyOrId = 0;
89 this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK; 89 this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK;
  90 + this.lenMinClientSecretKey = LEN_MAX_PSK;
90 this.lenMaxClientSecretKey = LEN_MAX_PSK; 91 this.lenMaxClientSecretKey = LEN_MAX_PSK;
91 - this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required]);  
92 - this.serverFormGroup.get('clientSecretKey').setValidators([Validators.required, Validators.pattern(KEY_IDENT_REGEXP_PSK)]); 92 + this.setValidatorsSecurity(securityMode);
93 break; 93 break;
94 case SECURITY_CONFIG_MODE.RPK: 94 case SECURITY_CONFIG_MODE.RPK:
95 - this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_X509; 95 + this.lenMinClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK;
  96 + this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_RPK;
  97 + this.lenMinClientSecretKey = LEN_MAX_PRIVATE_KEY;
96 this.lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY; 98 this.lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY;
97 - this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required, Validators.pattern(KEY_PUBLIC_REGEXP_X509)]);  
98 - this.serverFormGroup.get('clientSecretKey').setValidators([Validators.required, Validators.pattern(KEY_PRIVATE_REGEXP)]); 99 + this.setValidatorsSecurity(securityMode);
99 break; 100 break;
100 case SECURITY_CONFIG_MODE.X509: 101 case SECURITY_CONFIG_MODE.X509:
  102 + this.lenMinClientPublicKeyOrId = 0;
101 this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_X509; 103 this.lenMaxClientPublicKeyOrId = LEN_MAX_PUBLIC_KEY_X509;
  104 + this.lenMinClientSecretKey = LEN_MAX_PRIVATE_KEY;
102 this.lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY; 105 this.lenMaxClientSecretKey = LEN_MAX_PRIVATE_KEY;
103 - this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required, Validators.pattern(KEY_PUBLIC_REGEXP_X509)]);  
104 - this.serverFormGroup.get('clientSecretKey').setValidators([Validators.required, Validators.pattern(KEY_PRIVATE_REGEXP)]); 106 + this.setValidatorsSecurity(securityMode);
105 break; 107 break;
106 } 108 }
107 this.serverFormGroup.updateValueAndValidity(); 109 this.serverFormGroup.updateValueAndValidity();
108 } 110 }
109 111
  112 + private setValidatorsSecurity = (securityMode: SECURITY_CONFIG_MODE): void => {
  113 + if (securityMode === SECURITY_CONFIG_MODE.PSK) {
  114 + this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required]);
  115 + } else {
  116 + this.serverFormGroup.get('clientPublicKeyOrId').setValidators([Validators.required,
  117 + Validators.pattern(KEY_REGEXP_HEX_DEC),
  118 + Validators.minLength(this.lenMinClientPublicKeyOrId),
  119 + Validators.maxLength(this.lenMaxClientPublicKeyOrId)]);
  120 + }
  121 +
  122 + this.serverFormGroup.get('clientSecretKey').setValidators([Validators.required,
  123 + Validators.pattern(KEY_REGEXP_HEX_DEC),
  124 + Validators.minLength(this.lenMinClientSecretKey),
  125 + Validators.maxLength(this.lenMaxClientSecretKey)]);
  126 + }
  127 +
110 securityModeChanged(securityMode: SECURITY_CONFIG_MODE): void { 128 securityModeChanged(securityMode: SECURITY_CONFIG_MODE): void {
111 this.updateValidate(securityMode); 129 this.updateValidate(securityMode);
112 } 130 }
@@ -35,110 +35,124 @@ @@ -35,110 +35,124 @@
35 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong> 35 <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>
36 </mat-error> 36 </mat-error>
37 </mat-form-field> 37 </mat-form-field>
38 - <mat-tab-group dynamicHeight #tabGroup (selectedTabChange)="tabChanged($event)"> 38 + <mat-tab-group dynamicHeight (selectedTabChange)="tabChanged($event)">
39 <mat-tab label="{{ 'device.lwm2m-security-config.client-tab' | translate }}"> 39 <mat-tab label="{{ 'device.lwm2m-security-config.client-tab' | translate }}">
40 - <div class="mat-padding">  
41 - <mat-form-field class="mat-block">  
42 - <mat-label translate>device.lwm2m-security-config.mode</mat-label>  
43 - <mat-select formControlName="securityConfigClientMode"  
44 - (ngModelChange)="securityConfigClientModeChanged($event)">  
45 - <mat-option *ngFor="let securityConfigClientMode of securityConfigLwM2MTypes"  
46 - [value]="securityConfigClientMode">  
47 - {{ credentialTypeLwM2MNamesMap.get(securityConfigLwM2MType[securityConfigClientMode]) }}  
48 - </mat-option>  
49 - </mat-select>  
50 - </mat-form-field>  
51 - <div [fxShow]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK"> 40 + <ng-template matTabContent>
  41 + <div class="mat-padding">
52 <mat-form-field class="mat-block"> 42 <mat-form-field class="mat-block">
53 - <mat-label>{{ 'device.lwm2m-security-config.identity' | translate }}</mat-label>  
54 - <input matInput type="text" formControlName="identityPSK"  
55 - [required]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">  
56 - <mat-error *ngIf="lwm2mConfigFormGroup.get('identityPSK').hasError('required')">  
57 - {{ 'device.lwm2m-security-config.identity' | translate }}  
58 - <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>  
59 - </mat-error> 43 + <mat-label translate>device.lwm2m-security-config.mode</mat-label>
  44 + <mat-select formControlName="securityConfigClientMode"
  45 + (ngModelChange)="securityConfigClientModeChanged($event)">
  46 + <mat-option *ngFor="let securityConfigClientMode of securityConfigLwM2MTypes"
  47 + [value]="securityConfigClientMode">
  48 + {{ credentialTypeLwM2MNamesMap.get(securityConfigLwM2MType[securityConfigClientMode]) }}
  49 + </mat-option>
  50 + </mat-select>
60 </mat-form-field> 51 </mat-form-field>
61 - </div>  
62 - <div [fxShow]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.RPK || 52 + <div *ngIf="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">
  53 + <mat-form-field class="mat-block">
  54 + <mat-label>{{ 'device.lwm2m-security-config.identity' | translate }}</mat-label>
  55 + <input matInput type="text" formControlName="identityPSK"
  56 + [required]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">
  57 + <mat-error *ngIf="lwm2mConfigFormGroup.get('identityPSK').hasError('required')">
  58 + {{ 'device.lwm2m-security-config.identity' | translate }}
  59 + <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>
  60 + </mat-error>
  61 + </mat-form-field>
  62 + </div>
  63 + <div *ngIf="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.RPK ||
63 lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK"> 64 lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">
64 - <mat-form-field class="mat-block">  
65 - <mat-label>{{ 'device.lwm2m-security-config.client-key' | translate }}</mat-label>  
66 - <textarea matInput #clientKey maxlength={{lenMinMaxClient}} type="text" rows="3" cols="1"  
67 - formControlName="clientKey"  
68 - [required]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.RPK ||  
69 - lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK"></textarea>  
70 - <mat-hint align="end">{{clientKey.value?.length || 0}}/{{lenMaxKeyClient}}</mat-hint>  
71 - <mat-error *ngIf="lwm2mConfigFormGroup.get('clientKey').hasError('required')">  
72 - {{ 'device.lwm2m-security-config.client-key' | translate }}  
73 - <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>  
74 - </mat-error>  
75 - <mat-error *ngIf="lwm2mConfigFormGroup.get('clientKey').hasError('pattern') &&  
76 - lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">  
77 - {{ 'device.lwm2m-security-config.client-key' | translate }}  
78 - <strong>{{ 'device-profile.lwm2m-security-config.pattern_hex_dec_64' | translate }}</strong>  
79 - </mat-error>  
80 - <mat-error *ngIf="lwm2mConfigFormGroup.get('clientKey').hasError('pattern') &&  
81 - lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.RPK">  
82 - {{ 'device.lwm2m-security-config.client-key' | translate }}  
83 - <strong>{{ 'device.lwm2m-security-config.pattern_hex_dec_182' | translate }}</strong>  
84 - </mat-error>  
85 - </mat-form-field>  
86 - </div>  
87 - <div [fxShow]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.X509">  
88 - <mat-checkbox formControlName="clientCertificate" color="primary">  
89 - {{ 'device.lwm2m-security-config.client-certificate' | translate }}  
90 - </mat-checkbox> 65 + <mat-form-field class="mat-block">
  66 + <mat-label>{{ 'device.lwm2m-security-config.client-key' | translate }}</mat-label>
  67 + <textarea matInput
  68 + #clientKey
  69 + maxlength="{{lenMaxKeyClient}}"
  70 + cdkTextareaAutosize
  71 + cdkAutosizeMinRows="1"
  72 + cols="1"
  73 + formControlName="clientKey"
  74 + style="overflow:hidden"
  75 + [required]="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.RPK ||
  76 + lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.PSK">
  77 + </textarea>
  78 + <mat-hint align="end">{{clientKey.value?.length || 0}}/{{lenMaxKeyClient}}</mat-hint>
  79 + <mat-error *ngIf="lwm2mConfigFormGroup.get('clientKey').hasError('required')">
  80 + {{ 'device.lwm2m-security-config.client-key' | translate }}
  81 + <strong>{{ 'device.lwm2m-security-config.required' | translate }}</strong>
  82 + </mat-error>
  83 + <mat-error *ngIf="lwm2mConfigFormGroup.get('clientKey').hasError('pattern')">
  84 + {{ 'device.lwm2m-security-config.client-key' | translate }}
  85 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  86 + count: 0 }) | async }}</strong>
  87 + </mat-error>
  88 + <mat-error *ngIf="(lwm2mConfigFormGroup.get('clientKey').hasError('maxlength') ||
  89 + lwm2mConfigFormGroup.get('clientKey').hasError('minlength'))">
  90 + {{ 'device.lwm2m-security-config.client-key' | translate }}
  91 + <strong>{{ translate.get('device.lwm2m-security-config.pattern_hex_dec', {
  92 + count: lenMaxKeyClient }) | async }}</strong>
  93 + </mat-error>
  94 + </mat-form-field>
  95 + </div>
  96 + <div *ngIf="lwm2mConfigFormGroup.get('securityConfigClientMode').value === securityConfigLwM2MType.X509">
  97 + <mat-checkbox formControlName="clientCertificate" color="primary">
  98 + {{ 'device.lwm2m-security-config.client-certificate' | translate }}
  99 + </mat-checkbox>
  100 + </div>
91 </div> 101 </div>
92 - </div> 102 + </ng-template>
93 </mat-tab> 103 </mat-tab>
94 <mat-tab label="{{ 'device.lwm2m-security-config.bootstrap-tab' | translate }}"> 104 <mat-tab label="{{ 'device.lwm2m-security-config.bootstrap-tab' | translate }}">
95 - <div class="mat-padding">  
96 - <mat-accordion multi="true" class="mat-body-1">  
97 - <mat-expansion-panel>  
98 - <mat-expansion-panel-header>  
99 - <mat-panel-title>  
100 - <div  
101 - class="tb-panel-title">{{ 'device.lwm2m-security-config.bootstrap-server' | translate | uppercase }}</div>  
102 - </mat-panel-title>  
103 - </mat-expansion-panel-header>  
104 - <div class="mat-padding">  
105 - <tb-security-config-server-lwm2m  
106 - [formControlName]="bootstrapServer"  
107 - [serverFormGroup]="bootstrapFormGroup">  
108 - </tb-security-config-server-lwm2m>  
109 - </div>  
110 - </mat-expansion-panel>  
111 - </mat-accordion>  
112 - <mat-accordion multi="true" class="mat-body-1">  
113 - <mat-expansion-panel>  
114 - <mat-expansion-panel-header>  
115 - <mat-panel-title>  
116 - <div  
117 - class="tb-panel-title">{{ 'device.lwm2m-security-config.lwm2m-server' | translate | uppercase }}</div>  
118 - </mat-panel-title>  
119 - </mat-expansion-panel-header>  
120 - <div class="mat-padding">  
121 - <tb-security-config-server-lwm2m  
122 - [formControlName]="lwm2mServer"  
123 - [serverFormGroup]="lwm2mServerFormGroup">  
124 - </tb-security-config-server-lwm2m>  
125 - </div>  
126 - </mat-expansion-panel>  
127 - </mat-accordion>  
128 - </div> 105 + <ng-template matTabContent>
  106 + <div class="mat-padding">
  107 + <mat-accordion multi="true" class="mat-body-1">
  108 + <mat-expansion-panel>
  109 + <mat-expansion-panel-header>
  110 + <mat-panel-title>
  111 + <div
  112 + class="tb-panel-title">{{ 'device.lwm2m-security-config.bootstrap-server' | translate | uppercase }}</div>
  113 + </mat-panel-title>
  114 + </mat-expansion-panel-header>
  115 + <div class="mat-padding">
  116 + <tb-security-config-server-lwm2m
  117 + [formControlName]="bootstrapServer"
  118 + [serverFormGroup]="bootstrapFormGroup">
  119 + </tb-security-config-server-lwm2m>
  120 + </div>
  121 + </mat-expansion-panel>
  122 + </mat-accordion>
  123 + <mat-accordion multi="true" class="mat-body-1">
  124 + <mat-expansion-panel>
  125 + <mat-expansion-panel-header>
  126 + <mat-panel-title>
  127 + <div
  128 + class="tb-panel-title">{{ 'device.lwm2m-security-config.lwm2m-server' | translate | uppercase }}</div>
  129 + </mat-panel-title>
  130 + </mat-expansion-panel-header>
  131 + <div class="mat-padding">
  132 + <tb-security-config-server-lwm2m
  133 + [formControlName]="lwm2mServer"
  134 + [serverFormGroup]="lwm2mServerFormGroup">
  135 + </tb-security-config-server-lwm2m>
  136 + </div>
  137 + </mat-expansion-panel>
  138 + </mat-accordion>
  139 + </div>
  140 + </ng-template>
129 </mat-tab> 141 </mat-tab>
130 <mat-tab label="{{ 'device.lwm2m-security-config.config-json-tab' | translate }}"> 142 <mat-tab label="{{ 'device.lwm2m-security-config.config-json-tab' | translate }}">
131 - <div class="mat-padding">  
132 - <fieldset [disabled]="isLoading$ | async">  
133 - <tb-json-object-edit  
134 - [formControlName]="formControlNameJsonAllConfig"  
135 - label="{{ 'device.lwm2m-value' | translate }}"  
136 - validateContent="true"  
137 - [required]="true"  
138 - [fillHeight]="false">  
139 - </tb-json-object-edit>  
140 - </fieldset>  
141 - </div> 143 + <ng-template matTabContent>
  144 + <div class="mat-padding">
  145 + <fieldset [disabled]="isLoading$ | async">
  146 + <tb-json-object-edit
  147 + [formControlName]="formControlNameJsonAllConfig"
  148 + label="{{ 'device.lwm2m-value' | translate }}"
  149 + validateContent="true"
  150 + [required]="true"
  151 + [fillHeight]="false">
  152 + </tb-json-object-edit>
  153 + </fieldset>
  154 + </div>
  155 + </ng-template>
142 </mat-tab> 156 </mat-tab>
143 </mat-tab-group> 157 </mat-tab-group>
144 </fieldset> 158 </fieldset>
@@ -148,7 +162,7 @@ @@ -148,7 +162,7 @@
148 <button mat-button color="primary" 162 <button mat-button color="primary"
149 type="button" 163 type="button"
150 [disabled]="(isLoading$ | async)" 164 [disabled]="(isLoading$ | async)"
151 - (click)="cancel()" cdkFocusInitial> 165 + (click)="cancel()">
152 {{ 'action.cancel' | translate }} 166 {{ 'action.cancel' | translate }}
153 </button> 167 </button>
154 <button mat-button mat-raised-button color="primary" 168 <button mat-button mat-raised-button color="primary"
@@ -15,14 +15,14 @@ @@ -15,14 +15,14 @@
15 /// 15 ///
16 16
17 17
18 -import {Component, Inject, OnInit} from '@angular/core';  
19 -import {DialogComponent} from '@shared/components/dialog.component';  
20 -import {Store} from '@ngrx/store';  
21 -import {AppState} from '@core/core.state';  
22 -import {Router} from '@angular/router';  
23 -import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';  
24 -import {FormBuilder, FormGroup, Validators} from '@angular/forms';  
25 -import {TranslateService} from '@ngx-translate/core'; 18 +import {Component, Inject, OnInit } from '@angular/core';
  19 +import { DialogComponent } from '@shared/components/dialog.component';
  20 +import { Store } from '@ngrx/store';
  21 +import { AppState } from '@core/core.state';
  22 +import { Router } from '@angular/router';
  23 +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
  24 +import { FormBuilder, FormGroup, Validators } from '@angular/forms';
  25 +import { TranslateService } from '@ngx-translate/core';
26 import { 26 import {
27 SECURITY_CONFIG_MODE_NAMES, 27 SECURITY_CONFIG_MODE_NAMES,
28 SECURITY_CONFIG_MODE, 28 SECURITY_CONFIG_MODE,
@@ -30,22 +30,20 @@ import { @@ -30,22 +30,20 @@ import {
30 ClientSecurityConfigPSK, 30 ClientSecurityConfigPSK,
31 ClientSecurityConfigRPK, 31 ClientSecurityConfigRPK,
32 JSON_ALL_CONFIG, 32 JSON_ALL_CONFIG,
33 - KEY_IDENT_REGEXP_PSK,  
34 - KEY_PUBLIC_REGEXP_PSK, 33 + KEY_REGEXP_HEX_DEC,
35 DeviceCredentialsDialogLwm2mData, 34 DeviceCredentialsDialogLwm2mData,
36 BOOTSTRAP_SERVER, 35 BOOTSTRAP_SERVER,
37 BOOTSTRAP_SERVERS, 36 BOOTSTRAP_SERVERS,
38 LWM2M_SERVER, 37 LWM2M_SERVER,
39 ClientSecurityConfigX509, 38 ClientSecurityConfigX509,
40 - ClientSecurityConfigNO_SEC, 39 + ClientSecurityConfigNoSEC,
41 getDefaultClientSecurityConfigType, 40 getDefaultClientSecurityConfigType,
42 LEN_MAX_PSK, 41 LEN_MAX_PSK,
43 LEN_MAX_PUBLIC_KEY_RPK 42 LEN_MAX_PUBLIC_KEY_RPK
44 -} from "./security-config.models";  
45 -import {WINDOW} from "@core/services/window.service";  
46 -import {MatTabChangeEvent, MatTabGroup} from "@angular/material/tabs";  
47 -import {MatTab} from "@angular/material/tabs/tab";  
48 - 43 +} from './security-config.models';
  44 +import { WINDOW } from '@core/services/window.service';
  45 +import { MatTabChangeEvent } from '@angular/material/tabs';
  46 +import { MatTab } from '@angular/material/tabs/tab';
49 47
50 @Component({ 48 @Component({
51 selector: 'tb-security-config-lwm2m', 49 selector: 'tb-security-config-lwm2m',
@@ -67,8 +65,8 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -67,8 +65,8 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
67 bootstrapServer: string; 65 bootstrapServer: string;
68 lwm2mServer: string; 66 lwm2mServer: string;
69 jsonObserveData: {}; 67 jsonObserveData: {};
70 - lenMaxKeyClient = LEN_MAX_PSK;  
71 - tabPrevious: MatTab 68 + lenMaxKeyClient = LEN_MAX_PSK as number;
  69 + tabPrevious: MatTab;
72 tabIndexPrevious = 0 as number; 70 tabIndexPrevious = 0 as number;
73 71
74 constructor(protected store: Store<AppState>, 72 constructor(protected store: Store<AppState>,
@@ -76,7 +74,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -76,7 +74,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
76 @Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogLwm2mData, 74 @Inject(MAT_DIALOG_DATA) public data: DeviceCredentialsDialogLwm2mData,
77 public dialogRef: MatDialogRef<SecurityConfigComponent, object>, 75 public dialogRef: MatDialogRef<SecurityConfigComponent, object>,
78 public fb: FormBuilder, 76 public fb: FormBuilder,
79 - private translate: TranslateService, 77 + public translate: TranslateService,
80 @Inject(WINDOW) private window: Window) { 78 @Inject(WINDOW) private window: Window) {
81 super(store, router, dialogRef); 79 super(store, router, dialogRef);
82 } 80 }
@@ -85,13 +83,13 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -85,13 +83,13 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
85 this.jsonAllConfig = JSON.parse(JSON.stringify(this.data.jsonAllConfig)) as SecurityConfigModels; 83 this.jsonAllConfig = JSON.parse(JSON.stringify(this.data.jsonAllConfig)) as SecurityConfigModels;
86 this.initConstants(); 84 this.initConstants();
87 this.lwm2mConfigFormGroup = this.initLwm2mConfigFormGroup(); 85 this.lwm2mConfigFormGroup = this.initLwm2mConfigFormGroup();
88 - this.title = this.translate.instant('device.lwm2m-security-info') + ": " + this.data.endPoint 86 + this.title = this.translate.instant('device.lwm2m-security-info') + ': ' + this.data.endPoint;
89 this.lwm2mConfigFormGroup.get('clientCertificate').disable(); 87 this.lwm2mConfigFormGroup.get('clientCertificate').disable();
90 this.initClientSecurityConfig(this.lwm2mConfigFormGroup.get('jsonAllConfig').value); 88 this.initClientSecurityConfig(this.lwm2mConfigFormGroup.get('jsonAllConfig').value);
91 this.registerDisableOnLoadFormControl(this.lwm2mConfigFormGroup.get('securityConfigClientMode')); 89 this.registerDisableOnLoadFormControl(this.lwm2mConfigFormGroup.get('securityConfigClientMode'));
92 } 90 }
93 91
94 - initConstants(): void { 92 + private initConstants = (): void => {
95 this.bootstrapServers = BOOTSTRAP_SERVERS; 93 this.bootstrapServers = BOOTSTRAP_SERVERS;
96 this.bootstrapServer = BOOTSTRAP_SERVER; 94 this.bootstrapServer = BOOTSTRAP_SERVER;
97 this.lwm2mServer = LWM2M_SERVER; 95 this.lwm2mServer = LWM2M_SERVER;
@@ -112,7 +110,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -112,7 +110,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
112 return this.lwm2mConfigFormGroup.get('observeFormGroup') as FormGroup; 110 return this.lwm2mConfigFormGroup.get('observeFormGroup') as FormGroup;
113 } 111 }
114 112
115 - initClientSecurityConfig(jsonAllConfig: SecurityConfigModels): void { 113 + private initClientSecurityConfig = (jsonAllConfig: SecurityConfigModels): void => {
116 switch (jsonAllConfig.client.securityConfigClientMode.toString()) { 114 switch (jsonAllConfig.client.securityConfigClientMode.toString()) {
117 case SECURITY_CONFIG_MODE.NO_SEC.toString(): 115 case SECURITY_CONFIG_MODE.NO_SEC.toString():
118 break; 116 break;
@@ -139,106 +137,110 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -139,106 +137,110 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
139 this.securityConfigClientUpdateValidators(this.lwm2mConfigFormGroup.get('securityConfigClientMode').value); 137 this.securityConfigClientUpdateValidators(this.lwm2mConfigFormGroup.get('securityConfigClientMode').value);
140 } 138 }
141 139
142 - securityConfigClientModeChanged(mode: SECURITY_CONFIG_MODE): void { 140 + securityConfigClientModeChanged = (mode: SECURITY_CONFIG_MODE): void => {
143 switch (mode) { 141 switch (mode) {
144 case SECURITY_CONFIG_MODE.NO_SEC: 142 case SECURITY_CONFIG_MODE.NO_SEC:
145 - let clientSecurityConfigNO_SEC = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigNO_SEC;  
146 - this.jsonAllConfig.client = clientSecurityConfigNO_SEC; 143 + const clientSecurityConfigNoSEC = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigNoSEC;
  144 + this.jsonAllConfig.client = clientSecurityConfigNoSEC;
147 this.lwm2mConfigFormGroup.patchValue({ 145 this.lwm2mConfigFormGroup.patchValue({
148 jsonAllConfig: this.jsonAllConfig, 146 jsonAllConfig: this.jsonAllConfig,
149 clientCertificate: false 147 clientCertificate: false
150 - }, {emitEvent: true}); 148 + }, {emitEvent: false});
151 break; 149 break;
152 case SECURITY_CONFIG_MODE.PSK: 150 case SECURITY_CONFIG_MODE.PSK:
153 - let clientSecurityConfigPSK = getDefaultClientSecurityConfigType(mode, this.lwm2mConfigFormGroup.get('endPoint').value) as ClientSecurityConfigPSK; 151 + const clientSecurityConfigPSK = getDefaultClientSecurityConfigType(mode, this.lwm2mConfigFormGroup.get('endPoint')
  152 + .value) as ClientSecurityConfigPSK;
154 clientSecurityConfigPSK.identity = this.data.endPoint; 153 clientSecurityConfigPSK.identity = this.data.endPoint;
155 clientSecurityConfigPSK.key = this.lwm2mConfigFormGroup.get('clientKey').value; 154 clientSecurityConfigPSK.key = this.lwm2mConfigFormGroup.get('clientKey').value;
156 this.jsonAllConfig.client = clientSecurityConfigPSK; 155 this.jsonAllConfig.client = clientSecurityConfigPSK;
157 this.lwm2mConfigFormGroup.patchValue({ 156 this.lwm2mConfigFormGroup.patchValue({
158 identityPSK: clientSecurityConfigPSK.identity, 157 identityPSK: clientSecurityConfigPSK.identity,
159 clientCertificate: false 158 clientCertificate: false
160 - }, {emitEvent: true}); 159 + }, {emitEvent: false});
161 break; 160 break;
162 case SECURITY_CONFIG_MODE.RPK: 161 case SECURITY_CONFIG_MODE.RPK:
163 - let clientSecurityConfigRPK = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigRPK; 162 + const clientSecurityConfigRPK = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigRPK;
164 clientSecurityConfigRPK.key = this.lwm2mConfigFormGroup.get('clientKey').value; 163 clientSecurityConfigRPK.key = this.lwm2mConfigFormGroup.get('clientKey').value;
165 this.jsonAllConfig.client = clientSecurityConfigRPK; 164 this.jsonAllConfig.client = clientSecurityConfigRPK;
166 this.lwm2mConfigFormGroup.patchValue({ 165 this.lwm2mConfigFormGroup.patchValue({
167 - jsonAllConfig: this.jsonAllConfig,  
168 clientCertificate: false 166 clientCertificate: false
169 - }, {emitEvent: true}) 167 + }, {emitEvent: false});
170 break; 168 break;
171 case SECURITY_CONFIG_MODE.X509: 169 case SECURITY_CONFIG_MODE.X509:
172 - let clientSecurityConfigX509 = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigX509;  
173 - this.jsonAllConfig.client = clientSecurityConfigX509; 170 + this.jsonAllConfig.client = getDefaultClientSecurityConfigType(mode) as ClientSecurityConfigX509;
174 this.lwm2mConfigFormGroup.patchValue({ 171 this.lwm2mConfigFormGroup.patchValue({
175 - jsonAllConfig: this.jsonAllConfig,  
176 clientCertificate: true 172 clientCertificate: true
177 - }, {emitEvent: true}) 173 + }, {emitEvent: false});
178 break; 174 break;
179 } 175 }
180 this.securityConfigClientUpdateValidators(mode); 176 this.securityConfigClientUpdateValidators(mode);
181 } 177 }
182 178
183 - securityConfigClientUpdateValidators(mode: SECURITY_CONFIG_MODE): void { 179 + private securityConfigClientUpdateValidators = (mode: SECURITY_CONFIG_MODE): void => {
184 switch (mode) { 180 switch (mode) {
185 case SECURITY_CONFIG_MODE.NO_SEC: 181 case SECURITY_CONFIG_MODE.NO_SEC:
186 - this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);  
187 - this.lwm2mConfigFormGroup.get('identityPSK').updateValueAndValidity();  
188 - this.lwm2mConfigFormGroup.get('clientKey').setValidators([]);  
189 - this.lwm2mConfigFormGroup.get('clientKey').updateValueAndValidity(); 182 + this.setValidatorsNoSecX509();
190 break; 183 break;
191 case SECURITY_CONFIG_MODE.PSK: 184 case SECURITY_CONFIG_MODE.PSK:
192 this.lenMaxKeyClient = LEN_MAX_PSK; 185 this.lenMaxKeyClient = LEN_MAX_PSK;
193 - this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);  
194 - this.lwm2mConfigFormGroup.get('identityPSK').updateValueAndValidity();  
195 - this.lwm2mConfigFormGroup.get('clientKey').setValidators([Validators.required, Validators.pattern(KEY_IDENT_REGEXP_PSK)]);  
196 - this.lwm2mConfigFormGroup.get('clientKey').updateValueAndValidity(); 186 + this.setValidatorsPskRpk(mode);
197 break; 187 break;
198 case SECURITY_CONFIG_MODE.RPK: 188 case SECURITY_CONFIG_MODE.RPK:
199 this.lenMaxKeyClient = LEN_MAX_PUBLIC_KEY_RPK; 189 this.lenMaxKeyClient = LEN_MAX_PUBLIC_KEY_RPK;
200 - this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);  
201 - this.lwm2mConfigFormGroup.get('identityPSK').updateValueAndValidity();  
202 - this.lwm2mConfigFormGroup.get('clientKey').setValidators([Validators.required, Validators.pattern(KEY_PUBLIC_REGEXP_PSK)]);  
203 - this.lwm2mConfigFormGroup.get('clientKey').updateValueAndValidity(); 190 + this.setValidatorsPskRpk(mode);
204 break; 191 break;
205 case SECURITY_CONFIG_MODE.X509: 192 case SECURITY_CONFIG_MODE.X509:
206 this.lenMaxKeyClient = LEN_MAX_PUBLIC_KEY_RPK; 193 this.lenMaxKeyClient = LEN_MAX_PUBLIC_KEY_RPK;
207 - this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);  
208 - this.lwm2mConfigFormGroup.get('identityPSK').updateValueAndValidity();  
209 - this.lwm2mConfigFormGroup.get('clientKey').setValidators([]);  
210 - this.lwm2mConfigFormGroup.get('clientKey').updateValueAndValidity(); 194 + this.setValidatorsNoSecX509();
211 break; 195 break;
212 } 196 }
  197 + this.lwm2mConfigFormGroup.updateValueAndValidity();
  198 + }
  199 +
  200 + private setValidatorsNoSecX509 = (): void => {
  201 + this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);
  202 + this.lwm2mConfigFormGroup.get('clientKey').setValidators([]);
  203 + }
  204 +
  205 + private setValidatorsPskRpk = (mode: SECURITY_CONFIG_MODE): void => {
  206 + if (mode === SECURITY_CONFIG_MODE.PSK) {
  207 + this.lwm2mConfigFormGroup.get('identityPSK').setValidators([Validators.required]);
  208 + } else {
  209 + this.lwm2mConfigFormGroup.get('identityPSK').setValidators([]);
  210 + }
  211 + this.lwm2mConfigFormGroup.get('clientKey').setValidators([Validators.required,
  212 + Validators.pattern(KEY_REGEXP_HEX_DEC),
  213 + Validators.maxLength(this.lenMaxKeyClient), Validators.minLength(this.lenMaxKeyClient)]);
213 } 214 }
214 215
215 tabChanged = (tabChangeEvent: MatTabChangeEvent): void => { 216 tabChanged = (tabChangeEvent: MatTabChangeEvent): void => {
216 - if (this.tabIndexPrevious !== tabChangeEvent.index) this.upDateValueToJson(); 217 + if (this.tabIndexPrevious !== tabChangeEvent.index) { this.upDateValueToJson(); }
217 this.tabIndexPrevious = tabChangeEvent.index; 218 this.tabIndexPrevious = tabChangeEvent.index;
218 } 219 }
219 220
220 - upDateValueToJson(): void { 221 + private upDateValueToJson(): void {
221 switch (this.tabIndexPrevious) { 222 switch (this.tabIndexPrevious) {
222 case 0: 223 case 0:
223 - this.upDateValueToJsonTab_0(); 224 + this.upDateValueToJsonTab0();
224 break; 225 break;
225 case 1: 226 case 1:
226 - this.upDateValueToJsonTab_1(); 227 + this.upDateValueToJsonTab1();
227 break; 228 break;
228 case 2: 229 case 2:
229 - this.upDateValueToJsonTab_2(); 230 + this.upDateValueToJsonTab2();
230 break; 231 break;
231 } 232 }
232 } 233 }
233 234
234 - upDateValueToJsonTab_0(): void { 235 + private upDateValueToJsonTab0 = (): void => {
235 if (this.lwm2mConfigFormGroup !== null) { 236 if (this.lwm2mConfigFormGroup !== null) {
236 if (!this.lwm2mConfigFormGroup.get('endPoint').pristine && this.lwm2mConfigFormGroup.get('endPoint').valid) { 237 if (!this.lwm2mConfigFormGroup.get('endPoint').pristine && this.lwm2mConfigFormGroup.get('endPoint').valid) {
237 this.data.endPoint = this.lwm2mConfigFormGroup.get('endPoint').value; 238 this.data.endPoint = this.lwm2mConfigFormGroup.get('endPoint').value;
238 // Client mode == PSK 239 // Client mode == PSK
239 if (this.lwm2mConfigFormGroup.get('securityConfigClientMode').value === SECURITY_CONFIG_MODE.PSK) { 240 if (this.lwm2mConfigFormGroup.get('securityConfigClientMode').value === SECURITY_CONFIG_MODE.PSK) {
240 - this.jsonAllConfig.client["endpoint"] = this.data.endPoint;  
241 - this.jsonAllConfig.client["endpoint"].markAsPristine({ 241 + const endPoint = 'endpoint';
  242 + this.jsonAllConfig.client[endPoint] = this.data.endPoint;
  243 + this.jsonAllConfig.client[endPoint].markAsPristine({
242 onlySelf: true 244 onlySelf: true
243 }); 245 });
244 this.upDateJsonAllConfig(); 246 this.upDateJsonAllConfig();
@@ -261,7 +263,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -261,7 +263,7 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
261 } 263 }
262 } 264 }
263 265
264 - upDateValueToJsonTab_1(): void { 266 + private upDateValueToJsonTab1 = (): void => {
265 if (this.lwm2mConfigFormGroup !== null) { 267 if (this.lwm2mConfigFormGroup !== null) {
266 if (this.bootstrapFormGroup !== null && !this.bootstrapFormGroup.pristine && this.bootstrapFormGroup.valid) { 268 if (this.bootstrapFormGroup !== null && !this.bootstrapFormGroup.pristine && this.bootstrapFormGroup.valid) {
267 this.jsonAllConfig.bootstrap.bootstrapServer = this.bootstrapFormGroup.value; 269 this.jsonAllConfig.bootstrap.bootstrapServer = this.bootstrapFormGroup.value;
@@ -281,8 +283,9 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -281,8 +283,9 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
281 } 283 }
282 } 284 }
283 285
284 - upDateValueToJsonTab_2(): void {  
285 - if (!this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).pristine && this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).valid) { 286 + private upDateValueToJsonTab2 = (): void => {
  287 + if (!this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).pristine &&
  288 + this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).valid) {
286 this.jsonAllConfig = this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).value; 289 this.jsonAllConfig = this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).value;
287 this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).markAsPristine({ 290 this.lwm2mConfigFormGroup.get(this.formControlNameJsonAllConfig).markAsPristine({
288 onlySelf: true 291 onlySelf: true
@@ -290,15 +293,17 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -290,15 +293,17 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
290 } 293 }
291 } 294 }
292 295
293 - updateIdentityPSK(): void {  
294 - if (this.lwm2mConfigFormGroup.get('bootstrapServer').value['securityMode'] === SECURITY_CONFIG_MODE.PSK.toString()) { 296 + private updateIdentityPSK = (): void => {
  297 + const securityMode = 'securityMode';
  298 + if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
295 this.lwm2mConfigFormGroup.get('bootstrapFormGroup').patchValue({ 299 this.lwm2mConfigFormGroup.get('bootstrapFormGroup').patchValue({
296 clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value 300 clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value
297 }); 301 });
298 - this.jsonAllConfig.client['identity'] = this.lwm2mConfigFormGroup.get('identityPSK').value; 302 + const identity = 'identity';
  303 + this.jsonAllConfig.client[identity] = this.lwm2mConfigFormGroup.get('identityPSK').value;
299 this.upDateJsonAllConfig(); 304 this.upDateJsonAllConfig();
300 } 305 }
301 - if (this.lwm2mConfigFormGroup.get('lwm2mServer').value['securityMode'] === SECURITY_CONFIG_MODE.PSK.toString()) { 306 + if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
302 this.lwm2mConfigFormGroup.get('lwm2mServerFormGroup').patchValue({ 307 this.lwm2mConfigFormGroup.get('lwm2mServerFormGroup').patchValue({
303 clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value 308 clientPublicKeyOrId: this.lwm2mConfigFormGroup.get('identityPSK').value
304 }); 309 });
@@ -307,32 +312,26 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -307,32 +312,26 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
307 } 312 }
308 } 313 }
309 314
310 - updateClientKey(): void {  
311 - this.jsonAllConfig.client["key"] = this.lwm2mConfigFormGroup.get('clientKey').value;  
312 - if (this.lwm2mConfigFormGroup.get('bootstrapServer').value['securityMode'] === SECURITY_CONFIG_MODE.PSK.toString()) { 315 + private updateClientKey = (): void => {
  316 + const key = 'key';
  317 + const securityMode = 'securityMode';
  318 + this.jsonAllConfig.client[key] = this.lwm2mConfigFormGroup.get('clientKey').value;
  319 + if (this.lwm2mConfigFormGroup.get('bootstrapServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
313 this.lwm2mConfigFormGroup.get('bootstrapServer').patchValue({ 320 this.lwm2mConfigFormGroup.get('bootstrapServer').patchValue({
314 - clientSecretKey: this.jsonAllConfig.client["key"] 321 + clientSecretKey: this.jsonAllConfig.client[key]
315 }, {emitEvent: false}); 322 }, {emitEvent: false});
316 - this.jsonAllConfig.bootstrap.bootstrapServer.clientSecretKey = this.jsonAllConfig.client["key"]; 323 + this.jsonAllConfig.bootstrap.bootstrapServer.clientSecretKey = this.jsonAllConfig.client[key];
317 } 324 }
318 - if (this.lwm2mConfigFormGroup.get('lwm2mServer').value['securityMode'] === SECURITY_CONFIG_MODE.PSK.toString()) { 325 + if (this.lwm2mConfigFormGroup.get('lwm2mServer').value[securityMode] === SECURITY_CONFIG_MODE.PSK.toString()) {
319 this.lwm2mConfigFormGroup.get('lwm2mServer').patchValue({ 326 this.lwm2mConfigFormGroup.get('lwm2mServer').patchValue({
320 - clientSecretKey: this.jsonAllConfig.client["key"] 327 + clientSecretKey: this.jsonAllConfig.client[key]
321 }, {emitEvent: false}); 328 }, {emitEvent: false});
322 - this.jsonAllConfig.bootstrap.lwm2mServer.clientSecretKey = this.jsonAllConfig.client["key"]; 329 + this.jsonAllConfig.bootstrap.lwm2mServer.clientSecretKey = this.jsonAllConfig.client[key];
323 } 330 }
324 this.upDateJsonAllConfig(); 331 this.upDateJsonAllConfig();
325 } 332 }
326 333
327 - upDateJsonAllConfig(): void {  
328 - this.data.jsonAllConfig = JSON.parse(JSON.stringify(this.jsonAllConfig));  
329 - this.lwm2mConfigFormGroup.patchValue({  
330 - jsonAllConfig: JSON.parse(JSON.stringify(this.jsonAllConfig))  
331 - }, {emitEvent: false});  
332 - this.lwm2mConfigFormGroup.markAsDirty();  
333 - }  
334 -  
335 - upDateBootstrapFormGroup(): void { 334 + private upDateJsonAllConfig = (): void => {
336 this.data.jsonAllConfig = JSON.parse(JSON.stringify(this.jsonAllConfig)); 335 this.data.jsonAllConfig = JSON.parse(JSON.stringify(this.jsonAllConfig));
337 this.lwm2mConfigFormGroup.patchValue({ 336 this.lwm2mConfigFormGroup.patchValue({
338 jsonAllConfig: JSON.parse(JSON.stringify(this.jsonAllConfig)) 337 jsonAllConfig: JSON.parse(JSON.stringify(this.jsonAllConfig))
@@ -340,9 +339,10 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -340,9 +339,10 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
340 this.lwm2mConfigFormGroup.markAsDirty(); 339 this.lwm2mConfigFormGroup.markAsDirty();
341 } 340 }
342 341
343 - initLwm2mConfigFormGroup(): FormGroup { 342 + private initLwm2mConfigFormGroup = (): FormGroup => {
344 if (SECURITY_CONFIG_MODE[this.jsonAllConfig.client.securityConfigClientMode.toString()] === SECURITY_CONFIG_MODE.PSK) { 343 if (SECURITY_CONFIG_MODE[this.jsonAllConfig.client.securityConfigClientMode.toString()] === SECURITY_CONFIG_MODE.PSK) {
345 - this.data.endPoint = this.jsonAllConfig.client['endpoint']; 344 + const endpoint = 'endpoint';
  345 + this.data.endPoint = this.jsonAllConfig.client[endpoint];
346 } 346 }
347 return this.fb.group({ 347 return this.fb.group({
348 securityConfigClientMode: [SECURITY_CONFIG_MODE[this.jsonAllConfig.client.securityConfigClientMode.toString()], []], 348 securityConfigClientMode: [SECURITY_CONFIG_MODE[this.jsonAllConfig.client.securityConfigClientMode.toString()], []],
@@ -351,27 +351,28 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo @@ -351,27 +351,28 @@ export class SecurityConfigComponent extends DialogComponent<SecurityConfigCompo
351 clientCertificate: [false, []], 351 clientCertificate: [false, []],
352 bootstrapServer: [this.jsonAllConfig.bootstrap[this.bootstrapServer], []], 352 bootstrapServer: [this.jsonAllConfig.bootstrap[this.bootstrapServer], []],
353 lwm2mServer: [this.jsonAllConfig.bootstrap[this.lwm2mServer], []], 353 lwm2mServer: [this.jsonAllConfig.bootstrap[this.lwm2mServer], []],
354 - bootstrapFormGroup: this.getServerGroup(true),  
355 - lwm2mServerFormGroup: this.getServerGroup(false), 354 + bootstrapFormGroup: this.getServerGroup(),
  355 + lwm2mServerFormGroup: this.getServerGroup(),
356 endPoint: [this.data.endPoint, []], 356 endPoint: [this.data.endPoint, []],
357 jsonAllConfig: [this.jsonAllConfig, []] 357 jsonAllConfig: [this.jsonAllConfig, []]
358 }); 358 });
359 } 359 }
360 360
361 - getServerGroup(bootstrapServerIs: boolean): FormGroup { 361 + private getServerGroup = (): FormGroup => {
362 return this.fb.group({ 362 return this.fb.group({
363 securityMode: [this.fb.control(SECURITY_CONFIG_MODE.NO_SEC), []], 363 securityMode: [this.fb.control(SECURITY_CONFIG_MODE.NO_SEC), []],
364 clientPublicKeyOrId: ['', []], 364 clientPublicKeyOrId: ['', []],
365 clientSecretKey: ['', []] 365 clientSecretKey: ['', []]
366 - }) 366 + });
367 } 367 }
368 368
369 save(): void { 369 save(): void {
370 this.upDateValueToJson(); 370 this.upDateValueToJson();
371 - this.data.endPoint = this.lwm2mConfigFormGroup.get('endPoint').value.split('\"').join(''); 371 + this.data.endPoint = this.lwm2mConfigFormGroup.get('endPoint').value.split('\'').join('');
372 this.data.jsonAllConfig = this.jsonAllConfig; 372 this.data.jsonAllConfig = this.jsonAllConfig;
373 if (this.lwm2mConfigFormGroup.get('securityConfigClientMode').value === SECURITY_CONFIG_MODE.PSK) { 373 if (this.lwm2mConfigFormGroup.get('securityConfigClientMode').value === SECURITY_CONFIG_MODE.PSK) {
374 - this.data.endPoint = this.data.jsonAllConfig.client["identity"]; 374 + const identity = 'identity';
  375 + this.data.endPoint = this.data.jsonAllConfig.client[identity];
375 } 376 }
376 this.dialogRef.close(this.data); 377 this.dialogRef.close(this.data);
377 } 378 }
@@ -25,10 +25,8 @@ export const LEN_MAX_PSK = 64; @@ -25,10 +25,8 @@ export const LEN_MAX_PSK = 64;
25 export const LEN_MAX_PRIVATE_KEY = 134; 25 export const LEN_MAX_PRIVATE_KEY = 134;
26 export const LEN_MAX_PUBLIC_KEY_RPK = 182; 26 export const LEN_MAX_PUBLIC_KEY_RPK = 182;
27 export const LEN_MAX_PUBLIC_KEY_X509 = 3000; 27 export const LEN_MAX_PUBLIC_KEY_X509 = 3000;
28 -export const KEY_IDENT_REGEXP_PSK = /^[0-9a-fA-F]{64,64}$/;  
29 -export const KEY_PRIVATE_REGEXP = /^[0-9a-fA-F]{134,134}$/;  
30 -export const KEY_PUBLIC_REGEXP_PSK = /^[0-9a-fA-F]{182,182}$/;  
31 -export const KEY_PUBLIC_REGEXP_X509 = /^[0-9a-fA-F]{0,3000}$/; 28 +export const KEY_REGEXP_HEX_DEC = /^[-+]?[0-9A-Fa-f]+\.?[0-9A-Fa-f]*?$/;
  29 +
32 30
33 export interface DeviceCredentialsDialogLwm2mData { 31 export interface DeviceCredentialsDialogLwm2mData {
34 jsonAllConfig?: SecurityConfigModels; 32 jsonAllConfig?: SecurityConfigModels;
@@ -55,43 +53,43 @@ export type ClientSecurityConfigType = @@ -55,43 +53,43 @@ export type ClientSecurityConfigType =
55 ClientSecurityConfigPSK 53 ClientSecurityConfigPSK
56 | ClientSecurityConfigRPK 54 | ClientSecurityConfigRPK
57 | ClientSecurityConfigX509 55 | ClientSecurityConfigX509
58 - | ClientSecurityConfigNO_SEC; 56 + | ClientSecurityConfigNoSEC;
59 57
60 export interface ClientSecurityConfigPSK { 58 export interface ClientSecurityConfigPSK {
61 - securityConfigClientMode: string,  
62 - endpoint: string,  
63 - identity: string,  
64 - key: string 59 + securityConfigClientMode: string;
  60 + endpoint: string;
  61 + identity: string;
  62 + key: string;
65 } 63 }
66 64
67 export interface ClientSecurityConfigRPK { 65 export interface ClientSecurityConfigRPK {
68 - securityConfigClientMode: string,  
69 - key: string 66 + securityConfigClientMode: string;
  67 + key: string;
70 } 68 }
71 69
72 export interface ClientSecurityConfigX509 { 70 export interface ClientSecurityConfigX509 {
73 - securityConfigClientMode: string,  
74 - x509: boolean 71 + securityConfigClientMode: string;
  72 + x509: boolean;
75 } 73 }
76 74
77 -export interface ClientSecurityConfigNO_SEC {  
78 - securityConfigClientMode: string 75 +export interface ClientSecurityConfigNoSEC {
  76 + securityConfigClientMode: string;
79 } 77 }
80 78
81 export interface ServerSecurityConfig { 79 export interface ServerSecurityConfig {
82 - securityMode: string,  
83 - clientPublicKeyOrId?: string,  
84 - clientSecretKey?: string 80 + securityMode: string;
  81 + clientPublicKeyOrId?: string;
  82 + clientSecretKey?: string;
85 } 83 }
86 84
87 interface BootstrapSecurityConfig { 85 interface BootstrapSecurityConfig {
88 - bootstrapServer: ServerSecurityConfig,  
89 - lwm2mServer: ServerSecurityConfig 86 + bootstrapServer: ServerSecurityConfig;
  87 + lwm2mServer: ServerSecurityConfig;
90 } 88 }
91 89
92 export interface SecurityConfigModels { 90 export interface SecurityConfigModels {
93 - client: ClientSecurityConfigType,  
94 - bootstrap: BootstrapSecurityConfig 91 + client: ClientSecurityConfigType;
  92 + bootstrap: BootstrapSecurityConfig;
95 } 93 }
96 94
97 export function getDefaultClientSecurityConfigType(securityConfigMode: SECURITY_CONFIG_MODE, endPoint?: string): ClientSecurityConfigType { 95 export function getDefaultClientSecurityConfigType(securityConfigMode: SECURITY_CONFIG_MODE, endPoint?: string): ClientSecurityConfigType {
@@ -103,24 +101,24 @@ export function getDefaultClientSecurityConfigType(securityConfigMode: SECURITY_ @@ -103,24 +101,24 @@ export function getDefaultClientSecurityConfigType(securityConfigMode: SECURITY_
103 endpoint: endPoint, 101 endpoint: endPoint,
104 identity: endPoint, 102 identity: endPoint,
105 key: '' 103 key: ''
106 - } 104 + };
107 break; 105 break;
108 case SECURITY_CONFIG_MODE.RPK: 106 case SECURITY_CONFIG_MODE.RPK:
109 security = { 107 security = {
110 securityConfigClientMode: '', 108 securityConfigClientMode: '',
111 key: '' 109 key: ''
112 - } 110 + };
113 break; 111 break;
114 case SECURITY_CONFIG_MODE.X509: 112 case SECURITY_CONFIG_MODE.X509:
115 security = { 113 security = {
116 securityConfigClientMode: '', 114 securityConfigClientMode: '',
117 x509: true 115 x509: true
118 - } 116 + };
119 break; 117 break;
120 case SECURITY_CONFIG_MODE.NO_SEC: 118 case SECURITY_CONFIG_MODE.NO_SEC:
121 security = { 119 security = {
122 securityConfigClientMode: '' 120 securityConfigClientMode: ''
123 - } 121 + };
124 break; 122 break;
125 } 123 }
126 security.securityConfigClientMode = securityConfigMode.toString(); 124 security.securityConfigClientMode = securityConfigMode.toString();
@@ -132,14 +130,14 @@ export function getDefaultServerSecurityConfig(): ServerSecurityConfig { @@ -132,14 +130,14 @@ export function getDefaultServerSecurityConfig(): ServerSecurityConfig {
132 securityMode: SECURITY_CONFIG_MODE.NO_SEC.toString(), 130 securityMode: SECURITY_CONFIG_MODE.NO_SEC.toString(),
133 clientPublicKeyOrId: '', 131 clientPublicKeyOrId: '',
134 clientSecretKey: '' 132 clientSecretKey: ''
135 - } 133 + };
136 } 134 }
137 135
138 function getDefaultBootstrapSecurityConfig(): BootstrapSecurityConfig { 136 function getDefaultBootstrapSecurityConfig(): BootstrapSecurityConfig {
139 return { 137 return {
140 bootstrapServer: getDefaultServerSecurityConfig(), 138 bootstrapServer: getDefaultServerSecurityConfig(),
141 lwm2mServer: getDefaultServerSecurityConfig() 139 lwm2mServer: getDefaultServerSecurityConfig()
142 - } 140 + };
143 } 141 }
144 142
145 export function getDefaultSecurityConfig(): SecurityConfigModels { 143 export function getDefaultSecurityConfig(): SecurityConfigModels {
@@ -61,6 +61,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va @@ -61,6 +61,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
61 61
62 @Input() editorStyle: { [klass: string]: any }; 62 @Input() editorStyle: { [klass: string]: any };
63 63
  64 + // tslint:disable-next-line:ban-types
64 @Input() sort: Function; 65 @Input() sort: Function;
65 66
66 private requiredValue: boolean; 67 private requiredValue: boolean;
@@ -226,9 +227,10 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va @@ -226,9 +227,10 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va
226 try { 227 try {
227 228
228 if (this.modelValue) { 229 if (this.modelValue) {
229 - this.contentValue = JSON.stringify(this.modelValue, isUndefined(this.sort) ? undefined : 230 + this.contentValue = JSON.stringify(this.modelValue, isUndefined(this.sort) ? null :
  231 + // tslint:disable-next-line:no-shadowed-variable
230 (key, value) => { 232 (key, value) => {
231 - return this.sort(key, value) 233 + return this.sort(key, value);
232 }, 2); 234 }, 2);
233 this.objectValid = true; 235 this.objectValid = true;
234 } else { 236 } else {
@@ -893,9 +893,8 @@ @@ -893,9 +893,8 @@
893 "lwm2m-server": "LwM2M Server", 893 "lwm2m-server": "LwM2M Server",
894 "client-publicKey-or-id": "Client Public Key or Id", 894 "client-publicKey-or-id": "Client Public Key or Id",
895 "client-secret-key": "Client Secret Key", 895 "client-secret-key": "Client Secret Key",
896 - "config-json-tab": "Json Client Security Config",  
897 - "pattern_hex_dec_64": "must be hex decimal format and 64 characters",  
898 - "pattern_hex_dec_182": "must be hex decimal format and 182 characters" 896 + "config-json-tab": "Json Client Security Config",
  897 + "pattern_hex_dec": "{ count, plural, 0 {must be hex decimal format} other {must be # characters} }"
899 }, 898 },
900 "client-id": "Client ID", 899 "client-id": "Client ID",
901 "client-id-pattern": "Contains invalid character.", 900 "client-id-pattern": "Contains invalid character.",
@@ -1121,10 +1120,7 @@ @@ -1121,10 +1120,7 @@
1121 "key-name_label": "Key Name in Camel format", 1120 "key-name_label": "Key Name in Camel format",
1122 "required": " value is required.", 1121 "required": " value is required.",
1123 "mode": "Security config mode", 1122 "mode": "Security config mode",
1124 - "pattern_hex_dec_64": "must be hex decimal format and 64 characters",  
1125 - "pattern_hex_dec_134": "must be hex decimal format and 134 characters",  
1126 - "pattern_hex_dec_182": "must be hex decimal format and 182 characters",  
1127 - "pattern_hex_dec": "must be hex decimal format", 1123 + "pattern_hex_dec": "{ count, plural, 0 {must be hex decimal format} other {must be # characters} }",
1128 "bootstrap-tab": "Bootstrap", 1124 "bootstrap-tab": "Bootstrap",
1129 "servers": "Servers", 1125 "servers": "Servers",
1130 "short-id": "Short ID", 1126 "short-id": "Short ID",