Commit 793e43e9a81f642606f5fabdbe806f3b5f579237

Authored by nickAS21
Committed by Andrew Shvayka
1 parent f6eb3b13

Lwm2m: front: add key to profile - refactoring-light start

... ... @@ -20,7 +20,16 @@
20 20 <mat-tab label="{{ 'device-profile.lwm2m.model-tab' | translate }}">
21 21 <ng-template matTabContent>
22 22 <section [formGroup]="lwm2mDeviceProfileFormGroup">
23   - <div class="mat-padding">
  23 + <div class="mat-padding" style="padding-bottom: 0px">
  24 + <mat-checkbox formControlName="clientUpdateValueAfterConnect" color="primary"
  25 + matTooltip="{{ translate.get('device-profile.lwm2m.client-update-value-after-connect-tip',
  26 + { count: +lwm2mDeviceProfileFormGroup.get('clientUpdateValueAfterConnect').value,
  27 + value: lwm2mDeviceProfileFormGroup.get('clientUpdateValueAfterConnect').value }) | async }}"
  28 + matTooltipPosition="above">
  29 + {{ 'device-profile.lwm2m.client-update-value-after-connect' | translate }}
  30 + </mat-checkbox>
  31 + </div>
  32 + <div class="mat-padding" style="padding-top: 0">
24 33 <tb-profile-lwm2m-object-list
25 34 (addList)="addObjectsList($event)"
26 35 (removeList)="removeObjectsList($event)"
... ...
... ... @@ -32,6 +32,7 @@ import { deepClone, isDefinedAndNotNull, isUndefined } from '@core/utils';
32 32 import { WINDOW } from '@core/services/window.service';
33 33 import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
34 34 import { Direction } from '@shared/models/page/sort-order';
  35 +import { TranslateService } from '@ngx-translate/core';
35 36
36 37 @Component({
37 38 selector: 'tb-profile-lwm2m-device-transport-configuration',
... ... @@ -68,10 +69,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
68 69 }
69 70
70 71 constructor(private store: Store<AppState>,
  72 + public translate: TranslateService,
71 73 private fb: FormBuilder,
72 74 private deviceProfileService: DeviceProfileService,
73 75 @Inject(WINDOW) private window: Window) {
74 76 this.lwm2mDeviceProfileFormGroup = this.fb.group({
  77 + clientUpdateValueAfterConnect: [false, []],
75 78 objectIds: [null, Validators.required],
76 79 observeAttrTelemetry: [null, Validators.required],
77 80 shortId: [null, Validators.required],
... ... @@ -141,6 +144,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
141 144
142 145 private updateWriteValue = (value: ModelValue): void => {
143 146 this.lwm2mDeviceProfileFormGroup.patchValue({
  147 + clientUpdateValueAfterConnect: this.configurationValue.clientLwM2mSettings.clientUpdateValueAfterConnect,
144 148 objectIds: value,
145 149 observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value['objectsList']),
146 150 shortId: this.configurationValue.bootstrap.servers.shortId,
... ... @@ -172,6 +176,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
172 176
173 177 private updateDeviceProfileValue(config): void {
174 178 if (this.lwm2mDeviceProfileFormGroup.valid) {
  179 + this.configurationValue.clientLwM2mSettings.clientUpdateValueAfterConnect =
  180 + config.clientUpdateValueAfterConnect;
175 181 this.updateObserveAttrTelemetryFromGroupToJson(config.observeAttrTelemetry.clientLwM2M);
176 182 this.configurationValue.bootstrap.bootstrapServer = config.bootstrapServer;
177 183 this.configurationValue.bootstrap.lwm2mServer = config.lwm2mServer;
... ...
... ... @@ -14,16 +14,15 @@
14 14 /// limitations under the License.
15 15 ///
16 16
17   -import { JsonObject } from '@angular/compiler-cli/ngcc/src/packages/entry_point';
18   -
19 17 export const INSTANCES = 'instances';
20 18 export const RESOURCES = 'resources';
  19 +export const CLIENT_LWM2M = 'clientLwM2M';
  20 +export const CLIENT_LWM2M_SETTINGS = 'clientLwM2mSettings';
21 21 export const OBSERVE_ATTR_TELEMETRY = 'observeAttrTelemetry';
22 22 export const OBSERVE = 'observe';
23 23 export const ATTRIBUTE = 'attribute';
24 24 export const TELEMETRY = 'telemetry';
25 25 export const KEY_NAME = 'keyName';
26   -export const CLIENT_LWM2M = 'clientLwM2M';
27 26 export const DEFAULT_ID_SERVER = 123;
28 27 export const DEFAULT_ID_BOOTSTRAP = 111;
29 28 export const DEFAULT_HOST_NAME = 'localhost';
... ... @@ -91,10 +90,15 @@ interface BootstrapSecurityConfig {
91 90 }
92 91
93 92 export interface ProfileConfigModels {
94   - bootstrap: BootstrapSecurityConfig;
  93 + clientLwM2mSettings: ClientLwM2mSettings;
95 94 observeAttr: ObservableAttributes;
  95 + bootstrap: BootstrapSecurityConfig;
  96 +
96 97 }
97 98
  99 +export interface ClientLwM2mSettings {
  100 + clientUpdateValueAfterConnect: false;
  101 +}
98 102 export interface ObservableAttributes {
99 103 observe: string[];
100 104 attribute: string[];
... ... @@ -143,13 +147,16 @@ function getDefaultProfileBootstrapSecurityConfig(hostname: any): BootstrapSecur
143 147
144 148 export function getDefaultProfileConfig(hostname?: any): ProfileConfigModels {
145 149 return {
146   - bootstrap: getDefaultProfileBootstrapSecurityConfig((hostname) ? hostname : DEFAULT_HOST_NAME),
  150 + clientLwM2mSettings: {
  151 + clientUpdateValueAfterConnect: false
  152 + },
147 153 observeAttr: {
148 154 observe: [],
149 155 attribute: [],
150 156 telemetry: [],
151 157 keyName: {}
152   - }
  158 + },
  159 + bootstrap: getDefaultProfileBootstrapSecurityConfig((hostname) ? hostname : DEFAULT_HOST_NAME)
153 160 };
154 161 }
155 162
... ...
... ... @@ -1103,6 +1103,8 @@
1103 1103 "schedule-time-to": "To",
1104 1104 "schedule-days-of-week-required": "At least one day of week should be selected.",
1105 1105 "lwm2m": {
  1106 + "client-update-value-after-connect": "Query client resource values after connecting ",
  1107 + "client-update-value-after-connect-tip": "{ count, plural, 1 {After connecting the Client, we get All resource values for all objects} other {Once connected to the client, requests are sent to the observer from the profile configuration.} }",
1106 1108 "object-list": "Object list",
1107 1109 "object-list-empty": "No objects selected.",
1108 1110 "no-objects-matching": "No objects matching '{{object}}' were found.",
... ...