Showing
8 changed files
with
33 additions
and
33 deletions
@@ -139,7 +139,7 @@ export class Lwm2mDeviceConfigServerComponent implements ControlValueAccessor { | @@ -139,7 +139,7 @@ export class Lwm2mDeviceConfigServerComponent implements ControlValueAccessor { | ||
139 | Validators.maxLength(this.lenMaxServerPublicKey)]); | 139 | Validators.maxLength(this.lenMaxServerPublicKey)]); |
140 | } | 140 | } |
141 | 141 | ||
142 | - writeValue(value: any): void { | 142 | + writeValue(value: ServerSecurityConfig): void { |
143 | if (value) { | 143 | if (value) { |
144 | this.updateValueFields(value); | 144 | this.updateValueFields(value); |
145 | } | 145 | } |
@@ -21,12 +21,11 @@ import { Store } from '@ngrx/store'; | @@ -21,12 +21,11 @@ import { Store } from '@ngrx/store'; | ||
21 | import { AppState } from '@app/core/core.state'; | 21 | import { AppState } from '@app/core/core.state'; |
22 | import { coerceBooleanProperty } from '@angular/cdk/coercion'; | 22 | import { coerceBooleanProperty } from '@angular/cdk/coercion'; |
23 | import { | 23 | import { |
24 | - ID, INSTANCES, RESOURCES, OBSERVE_ATTR_TELEMETRY, OBSERVE, ATTRIBUTE, TELEMETRY, KEY_NAME, | 24 | + INSTANCES, RESOURCES, OBSERVE_ATTR_TELEMETRY, OBSERVE, ATTRIBUTE, TELEMETRY, KEY_NAME, |
25 | getDefaultProfileConfig, | 25 | getDefaultProfileConfig, |
26 | - Instance, | ||
27 | ObjectLwM2M, | 26 | ObjectLwM2M, |
28 | ProfileConfigModels, | 27 | ProfileConfigModels, |
29 | - ResourceLwM2M | 28 | + ModelValue |
30 | } from './profile-config.models'; | 29 | } from './profile-config.models'; |
31 | import { DeviceProfileService } from '@core/http/device-profile.service'; | 30 | import { DeviceProfileService } from '@core/http/device-profile.service'; |
32 | import { deepClone, isDefinedAndNotNull, isUndefined } from '@core/utils'; | 31 | import { deepClone, isDefinedAndNotNull, isUndefined } from '@core/utils'; |
@@ -113,7 +112,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | @@ -113,7 +112,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | ||
113 | } | 112 | } |
114 | } | 113 | } |
115 | 114 | ||
116 | - writeValue(value: any | null): void { | 115 | + writeValue(value: ProfileConfigModels | null): void { |
117 | this.configurationValue = (Object.keys(value).length === 0) ? getDefaultProfileConfig() : value; | 116 | this.configurationValue = (Object.keys(value).length === 0) ? getDefaultProfileConfig() : value; |
118 | this.lwm2mDeviceConfigFormGroup.patchValue({ | 117 | this.lwm2mDeviceConfigFormGroup.patchValue({ |
119 | configurationJson: this.configurationValue | 118 | configurationJson: this.configurationValue |
@@ -122,7 +121,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | @@ -122,7 +121,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | ||
122 | } | 121 | } |
123 | 122 | ||
124 | private initWriteValue = (): void => { | 123 | private initWriteValue = (): void => { |
125 | - const modelValue = {objectIds: null, objectsList: []}; | 124 | + const modelValue = {objectIds: null, objectsList: []} as ModelValue; |
126 | modelValue.objectIds = this.getObjectsFromJsonAllConfig(); | 125 | modelValue.objectIds = this.getObjectsFromJsonAllConfig(); |
127 | if (modelValue.objectIds !== null) { | 126 | if (modelValue.objectIds !== null) { |
128 | const sortOrder = { | 127 | const sortOrder = { |
@@ -140,11 +139,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | @@ -140,11 +139,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro | ||
140 | } | 139 | } |
141 | } | 140 | } |
142 | 141 | ||
143 | - private updateWriteValue = (value: any): void => { | ||
144 | - const objectsList = value.objectsList; | 142 | + private updateWriteValue = (value: ModelValue): void => { |
145 | this.lwm2mDeviceProfileFormGroup.patchValue({ | 143 | this.lwm2mDeviceProfileFormGroup.patchValue({ |
146 | objectIds: value, | 144 | objectIds: value, |
147 | - observeAttrTelemetry: this.getObserveAttrTelemetryObjects(objectsList), | 145 | + observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value['objectsList']), |
148 | shortId: this.configurationValue.bootstrap.servers.shortId, | 146 | shortId: this.configurationValue.bootstrap.servers.shortId, |
149 | lifetime: this.configurationValue.bootstrap.servers.lifetime, | 147 | lifetime: this.configurationValue.bootstrap.servers.lifetime, |
150 | defaultMinPeriod: this.configurationValue.bootstrap.servers.defaultMinPeriod, | 148 | defaultMinPeriod: this.configurationValue.bootstrap.servers.defaultMinPeriod, |
@@ -25,7 +25,6 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; | @@ -25,7 +25,6 @@ import { DeviceProfileService } from '@core/http/device-profile.service'; | ||
25 | @Component({ | 25 | @Component({ |
26 | selector: 'tb-profile-lwm2m-object-add-instances-list', | 26 | selector: 'tb-profile-lwm2m-object-add-instances-list', |
27 | templateUrl: './lwm2m-object-add-instances-list.component.html', | 27 | templateUrl: './lwm2m-object-add-instances-list.component.html', |
28 | - styleUrls: [], | ||
29 | providers: [{ | 28 | providers: [{ |
30 | provide: NG_VALUE_ACCESSOR, | 29 | provide: NG_VALUE_ACCESSOR, |
31 | useExisting: forwardRef(() => Lwm2mObjectAddInstancesListComponent), | 30 | useExisting: forwardRef(() => Lwm2mObjectAddInstancesListComponent), |
@@ -30,8 +30,7 @@ export interface Lwm2mObjectAddInstancesData { | @@ -30,8 +30,7 @@ export interface Lwm2mObjectAddInstancesData { | ||
30 | 30 | ||
31 | @Component({ | 31 | @Component({ |
32 | selector: 'tb-lwm2m-object-add-instances', | 32 | selector: 'tb-lwm2m-object-add-instances', |
33 | - templateUrl: './lwm2m-object-add-instances.component.html', | ||
34 | - styleUrls: [] | 33 | + templateUrl: './lwm2m-object-add-instances.component.html' |
35 | }) | 34 | }) |
36 | export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjectAddInstancesComponent, object> implements OnInit { | 35 | export class Lwm2mObjectAddInstancesComponent extends DialogComponent<Lwm2mObjectAddInstancesComponent, object> implements OnInit { |
37 | 36 |
@@ -21,7 +21,7 @@ import { Store } from '@ngrx/store'; | @@ -21,7 +21,7 @@ import { Store } from '@ngrx/store'; | ||
21 | import { AppState } from '@core/core.state'; | 21 | import { AppState } from '@core/core.state'; |
22 | import { Observable } from 'rxjs'; | 22 | import { Observable } from 'rxjs'; |
23 | import { filter, map, mergeMap, publishReplay, refCount, tap } from 'rxjs/operators'; | 23 | import { filter, map, mergeMap, publishReplay, refCount, tap } from 'rxjs/operators'; |
24 | -import { ObjectLwM2M } from './profile-config.models'; | 24 | +import { ModelValue, ObjectLwM2M } from './profile-config.models'; |
25 | import { TranslateService } from '@ngx-translate/core'; | 25 | import { TranslateService } from '@ngx-translate/core'; |
26 | import { DeviceProfileService } from '@core/http/device-profile.service'; | 26 | import { DeviceProfileService } from '@core/http/device-profile.service'; |
27 | import { Direction } from '@shared/models/page/sort-order'; | 27 | import { Direction } from '@shared/models/page/sort-order'; |
@@ -120,7 +120,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V | @@ -120,7 +120,7 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V | ||
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | - writeValue(value: any): void { | 123 | + writeValue(value: ModelValue): void { |
124 | this.searchText = ''; | 124 | this.searchText = ''; |
125 | if (isDefinedAndNotNull(value)) { | 125 | if (isDefinedAndNotNull(value)) { |
126 | if (Array.isArray(value.objectIds)) { | 126 | if (Array.isArray(value.objectIds)) { |
@@ -193,7 +193,6 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V | @@ -193,7 +193,6 @@ export class Lwm2mObjectListComponent implements ControlValueAccessor, OnInit, V | ||
193 | return this.lw2mModels; | 193 | return this.lw2mModels; |
194 | } | 194 | } |
195 | 195 | ||
196 | - | ||
197 | onFocus = (): void => { | 196 | onFocus = (): void => { |
198 | if (!this.dirty) { | 197 | if (!this.dirty) { |
199 | this.lwm2mListFormGroup.get('objectLwm2m').updateValueAndValidity({onlySelf: true, emitEvent: true}); | 198 | this.lwm2mListFormGroup.get('objectLwm2m').updateValueAndValidity({onlySelf: true, emitEvent: true}); |
@@ -25,7 +25,6 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion'; | @@ -25,7 +25,6 @@ import { coerceBooleanProperty } from '@angular/cdk/coercion'; | ||
25 | @Component({ | 25 | @Component({ |
26 | selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource', | 26 | selector: 'tb-profile-lwm2m-observe-attr-telemetry-resource', |
27 | templateUrl: './lwm2m-observe-attr-telemetry-resource.component.html', | 27 | templateUrl: './lwm2m-observe-attr-telemetry-resource.component.html', |
28 | - styleUrls: [], | ||
29 | providers: [ | 28 | providers: [ |
30 | { | 29 | { |
31 | provide: NG_VALUE_ACCESSOR, | 30 | provide: NG_VALUE_ACCESSOR, |
@@ -28,7 +28,7 @@ import { | @@ -28,7 +28,7 @@ import { | ||
28 | import { Store } from '@ngrx/store'; | 28 | import { Store } from '@ngrx/store'; |
29 | import { AppState } from '@core/core.state'; | 29 | import { AppState } from '@core/core.state'; |
30 | import { coerceBooleanProperty } from '@angular/cdk/coercion'; | 30 | import { coerceBooleanProperty } from '@angular/cdk/coercion'; |
31 | -import { Instance, ObjectLwM2M, ResourceLwM2M } from './profile-config.models'; | 31 | +import { CLIENT_LWM2M, Instance, INSTANCES, ObjectLwM2M, ResourceLwM2M, RESOURCES } from './profile-config.models'; |
32 | import { deepClone, isDefinedAndNotNull, isEqual, isUndefined } from '@core/utils'; | 32 | import { deepClone, isDefinedAndNotNull, isEqual, isUndefined } from '@core/utils'; |
33 | import { MatDialog } from '@angular/material/dialog'; | 33 | import { MatDialog } from '@angular/material/dialog'; |
34 | import { TranslateService } from '@ngx-translate/core'; | 34 | import { TranslateService } from '@ngx-translate/core'; |
@@ -78,7 +78,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -78,7 +78,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
78 | private dialog: MatDialog, | 78 | private dialog: MatDialog, |
79 | public translate: TranslateService) { | 79 | public translate: TranslateService) { |
80 | this.observeAttrTelemetryFormGroup = this.fb.group({ | 80 | this.observeAttrTelemetryFormGroup = this.fb.group({ |
81 | - clientLwM2M: this.fb.array([]) | 81 | + [CLIENT_LWM2M]: this.fb.array([]) |
82 | }); | 82 | }); |
83 | this.observeAttrTelemetryFormGroup.valueChanges.subscribe(value => { | 83 | this.observeAttrTelemetryFormGroup.valueChanges.subscribe(value => { |
84 | if (isUndefined(this.disabled) || !this.disabled) { | 84 | if (isUndefined(this.disabled) || !this.disabled) { |
@@ -87,7 +87,8 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -87,7 +87,8 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
87 | }); | 87 | }); |
88 | } | 88 | } |
89 | 89 | ||
90 | - private propagateChange = (v: any) => { }; | 90 | + private propagateChange = (v: any) => { |
91 | + }; | ||
91 | 92 | ||
92 | registerOnChange(fn: any): void { | 93 | registerOnChange(fn: any): void { |
93 | this.propagateChange = fn; | 94 | this.propagateChange = fn; |
@@ -123,14 +124,14 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -123,14 +124,14 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
123 | } | 124 | } |
124 | } | 125 | } |
125 | 126 | ||
126 | - writeValue(value: any): void { | 127 | + writeValue(value: {}): void { |
127 | if (isDefinedAndNotNull(value)) { | 128 | if (isDefinedAndNotNull(value)) { |
128 | - this.buildClientObjectsLwM2M(value.clientLwM2M); | 129 | + this.buildClientObjectsLwM2M(value[CLIENT_LWM2M]); |
129 | } | 130 | } |
130 | } | 131 | } |
131 | 132 | ||
132 | private buildClientObjectsLwM2M = (objectsLwM2M: ObjectLwM2M []): void => { | 133 | private buildClientObjectsLwM2M = (objectsLwM2M: ObjectLwM2M []): void => { |
133 | - this.observeAttrTelemetryFormGroup.setControl('clientLwM2M', | 134 | + this.observeAttrTelemetryFormGroup.setControl(CLIENT_LWM2M, |
134 | this.createObjectsLwM2M(objectsLwM2M) | 135 | this.createObjectsLwM2M(objectsLwM2M) |
135 | ); | 136 | ); |
136 | } | 137 | } |
@@ -157,23 +158,23 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -157,23 +158,23 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
157 | } | 158 | } |
158 | 159 | ||
159 | get clientLwM2MFormArray(): FormArray { | 160 | get clientLwM2MFormArray(): FormArray { |
160 | - return this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray; | 161 | + return this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M) as FormArray; |
161 | } | 162 | } |
162 | 163 | ||
163 | instancesLwm2mFormArray = (objectLwM2M: AbstractControl): FormArray => { | 164 | instancesLwm2mFormArray = (objectLwM2M: AbstractControl): FormArray => { |
164 | - return objectLwM2M.get('instances') as FormArray; | 165 | + return objectLwM2M.get(INSTANCES) as FormArray; |
165 | } | 166 | } |
166 | 167 | ||
167 | changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => { | 168 | changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => { |
168 | - const resources = deepClone(instance.get('resources').value as ResourceLwM2M[]); | 169 | + const resources = deepClone(instance.get(RESOURCES).value as ResourceLwM2M[]); |
169 | resources.forEach(resource => resource[type] = value); | 170 | resources.forEach(resource => resource[type] = value); |
170 | - instance.get('resources').patchValue(resources); | 171 | + instance.get(RESOURCES).patchValue(resources); |
171 | this.propagateChange(this.observeAttrTelemetryFormGroup.value); | 172 | this.propagateChange(this.observeAttrTelemetryFormGroup.value); |
172 | } | 173 | } |
173 | 174 | ||
174 | private updateValidators = (): void => { | 175 | private updateValidators = (): void => { |
175 | - this.observeAttrTelemetryFormGroup.get('clientLwM2M').setValidators(this.required ? Validators.required : []); | ||
176 | - this.observeAttrTelemetryFormGroup.get('clientLwM2M').updateValueAndValidity(); | 176 | + this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M).setValidators(this.required ? Validators.required : []); |
177 | + this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M).updateValueAndValidity(); | ||
177 | } | 178 | } |
178 | 179 | ||
179 | trackByParams = (index: number, element: any): number => { | 180 | trackByParams = (index: number, element: any): number => { |
@@ -181,7 +182,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -181,7 +182,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
181 | } | 182 | } |
182 | 183 | ||
183 | getIndeterminate = (instance: AbstractControl, type: string): boolean => { | 184 | getIndeterminate = (instance: AbstractControl, type: string): boolean => { |
184 | - const resources = instance.get('resources').value as ResourceLwM2M[]; | 185 | + const resources = instance.get(RESOURCES).value as ResourceLwM2M[]; |
185 | if (isDefinedAndNotNull(resources)) { | 186 | if (isDefinedAndNotNull(resources)) { |
186 | const checkedResource = resources.filter(resource => resource[type]); | 187 | const checkedResource = resources.filter(resource => resource[type]); |
187 | return checkedResource.length !== 0 && checkedResource.length !== resources.length; | 188 | return checkedResource.length !== 0 && checkedResource.length !== resources.length; |
@@ -190,7 +191,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -190,7 +191,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
190 | } | 191 | } |
191 | 192 | ||
192 | getChecked = (instance: AbstractControl, type: string): boolean => { | 193 | getChecked = (instance: AbstractControl, type: string): boolean => { |
193 | - const resources = instance.get('resources').value as ResourceLwM2M[]; | 194 | + const resources = instance.get(RESOURCES).value as ResourceLwM2M[]; |
194 | return isDefinedAndNotNull(resources) && resources.every(resource => resource[type]); | 195 | return isDefinedAndNotNull(resources) && resources.every(resource => resource[type]); |
195 | } | 196 | } |
196 | 197 | ||
@@ -239,10 +240,10 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | @@ -239,10 +240,10 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor | ||
239 | } | 240 | } |
240 | 241 | ||
241 | private updateInstancesIds = (data: Lwm2mObjectAddInstancesData): void => { | 242 | private updateInstancesIds = (data: Lwm2mObjectAddInstancesData): void => { |
242 | - const objectLwM2MFormGroup = (this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls | 243 | + const objectLwM2MFormGroup = (this.observeAttrTelemetryFormGroup.get(CLIENT_LWM2M) as FormArray).controls |
243 | .find(e => e.value.id === data.objectId) as FormGroup; | 244 | .find(e => e.value.id === data.objectId) as FormGroup; |
244 | const instancesArray = objectLwM2MFormGroup.value.instances as Instance []; | 245 | const instancesArray = objectLwM2MFormGroup.value.instances as Instance []; |
245 | - const instancesFormArray = objectLwM2MFormGroup.get('instances') as FormArray; | 246 | + const instancesFormArray = objectLwM2MFormGroup.get(INSTANCES) as FormArray; |
246 | const instance0 = deepClone(instancesFormArray.at(0).value as Instance); | 247 | const instance0 = deepClone(instancesFormArray.at(0).value as Instance); |
247 | instance0.resources.forEach(r => { | 248 | instance0.resources.forEach(r => { |
248 | r.attribute = false; | 249 | r.attribute = false; |
@@ -16,7 +16,6 @@ | @@ -16,7 +16,6 @@ | ||
16 | 16 | ||
17 | import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point'; | 17 | import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point'; |
18 | 18 | ||
19 | -export const ID = 'id'; | ||
20 | export const INSTANCES = 'instances'; | 19 | export const INSTANCES = 'instances'; |
21 | export const RESOURCES = 'resources'; | 20 | export const RESOURCES = 'resources'; |
22 | export const OBSERVE_ATTR_TELEMETRY = 'observeAttrTelemetry'; | 21 | export const OBSERVE_ATTR_TELEMETRY = 'observeAttrTelemetry'; |
@@ -24,6 +23,7 @@ export const OBSERVE = 'observe'; | @@ -24,6 +23,7 @@ export const OBSERVE = 'observe'; | ||
24 | export const ATTRIBUTE = 'attribute'; | 23 | export const ATTRIBUTE = 'attribute'; |
25 | export const TELEMETRY = 'telemetry'; | 24 | export const TELEMETRY = 'telemetry'; |
26 | export const KEY_NAME = 'keyName'; | 25 | export const KEY_NAME = 'keyName'; |
26 | +export const CLIENT_LWM2M = 'clientLwM2M'; | ||
27 | export const DEFAULT_ID_SERVER = 123; | 27 | export const DEFAULT_ID_SERVER = 123; |
28 | export const DEFAULT_ID_BOOTSTRAP = 111; | 28 | export const DEFAULT_ID_BOOTSTRAP = 111; |
29 | export const DEFAULT_HOST_NAME = 'localhost'; | 29 | export const DEFAULT_HOST_NAME = 'localhost'; |
@@ -58,6 +58,11 @@ export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>( | @@ -58,6 +58,11 @@ export const SECURITY_CONFIG_MODE_NAMES = new Map<SECURITY_CONFIG_MODE, string>( | ||
58 | ] | 58 | ] |
59 | ); | 59 | ); |
60 | 60 | ||
61 | +export interface ModelValue { | ||
62 | + objectIds: number[] | null, | ||
63 | + objectsList: ObjectLwM2M[] | ||
64 | +} | ||
65 | + | ||
61 | export interface BootstrapServersSecurityConfig { | 66 | export interface BootstrapServersSecurityConfig { |
62 | shortId: number; | 67 | shortId: number; |
63 | lifetime: number; | 68 | lifetime: number; |