Commit 573837c4b126e19428a67933dbc6b2d9bbe10240
1 parent
e6d4e91e
Lwm2m: front: refactoring sort json and add instances
Showing
5 changed files
with
48 additions
and
411 deletions
common/transport/lwm2m/src/main/resources/models/LWM2M_Connectivity_Monitoring-v1_0_2.xml
deleted
100644 → 0
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<!-- | |
3 | - | |
4 | -FILE INFORMATION | |
5 | - | |
6 | -OMA Permanent Document | |
7 | - File: OMA-SUP-XML_LWM2M_Connectivity_Monitoring-V1_0_2-20180612-A | |
8 | - Type: xml | |
9 | - Date: 2018-June-12 | |
10 | - | |
11 | -Public Reachable Information | |
12 | - Path: http://www.openmobilealliance.org/tech/profiles | |
13 | - Name: LWM2M_Connectivity_Monitoring-v1_0_2.xml | |
14 | - | |
15 | -NORMATIVE INFORMATION | |
16 | - | |
17 | - Information about this file can be found in the latest revision of | |
18 | - | |
19 | - OMA-TS-LightweightM2M-V1_0_2 | |
20 | - OMA-TS-LightweightM2M_Core-V1_1 | |
21 | - | |
22 | - This is available at http://www.openmobilealliance.org/ | |
23 | - | |
24 | - Send comments to https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues | |
25 | - | |
26 | -LEGAL DISCLAIMER | |
27 | - | |
28 | - Copyright 2018 Open Mobile Alliance All rights reserved. | |
29 | - | |
30 | - Redistribution and use in source and binary forms, with or without | |
31 | - modification, are permitted provided that the following conditions | |
32 | - are met: | |
33 | - | |
34 | - 1. Redistributions of source code must retain the above copyright | |
35 | - notice, this list of conditions and the following disclaimer. | |
36 | - 2. Redistributions in binary form must reproduce the above copyright | |
37 | - notice, this list of conditions and the following disclaimer in the | |
38 | - documentation and/or other materials provided with the distribution. | |
39 | - 3. Neither the name of the copyright holder nor the names of its | |
40 | - contributors may be used to endorse or promote products derived | |
41 | - from this software without specific prior written permission. | |
42 | - | |
43 | - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
44 | - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
45 | - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
46 | - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
47 | - COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
48 | - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
49 | - BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
50 | - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
51 | - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
52 | - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
53 | - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
54 | - POSSIBILITY OF SUCH DAMAGE. | |
55 | - | |
56 | - The above license is used as a license under copyright only. Please | |
57 | - reference the OMA IPR Policy for patent licensing terms: | |
58 | - http://www.openmobilealliance.org/ipr.html | |
59 | ---> | |
60 | -<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://openmobilealliance.org/tech/profiles/LWM2M.xsd"> | |
61 | - <Object ObjectType="MODefinition"> | |
62 | - <Name>Connectivity Monitoring</Name> | |
63 | - <Description1> | |
64 | - This LwM2M Object enables monitoring of parameters related to network connectivity. In this general connectivity Object, the Resources are limited to the most general cases common to most network bearers. It is recommended to read the description, which refers to relevant standard development organizations (e.g. 3GPP, IEEE). The goal of the Connectivity Monitoring Object is to carry information reflecting the more up to date values of the current connection for monitoring purposes. Resources such as Link Quality, Radio Signal Strength, Cell ID are retrieved during connected mode at least for cellular networks. | |
65 | - </Description1> | |
66 | - <ObjectID>4</ObjectID> | |
67 | - <ObjectURN>urn:oma:lwm2m:oma:4</ObjectURN> | |
68 | - <LWM2MVersion>1.0</LWM2MVersion> | |
69 | - <ObjectVersion>1.0</ObjectVersion> | |
70 | - <MultipleInstances>Single</MultipleInstances> | |
71 | - <Mandatory>Optional</Mandatory> | |
72 | - <Resources> | |
73 | - <Item ID="0"> | |
74 | - <Name>Network Bearer</Name> | |
75 | - <Operations>R</Operations> | |
76 | - <MultipleInstances>Single</MultipleInstances> | |
77 | - <Mandatory>Mandatory</Mandatory> | |
78 | - <Type>Integer</Type> | |
79 | - <RangeEnumeration>0-50</RangeEnumeration> | |
80 | - <Units/> | |
81 | - <Description> | |
82 | - Indicates the network bearer used for the current LwM2M communication session from the network bearer list below. The number range is split into three categories: 0 - 20 are Cellular Bearers 21 - 40 are Wireless Bearers 41 - 50 are Wireline Bearers More specifically: 0: GSM cellular network 1: TD-SCDMA cellular network 2: WCDMA cellular network 3: CDMA2000 cellular network 4: WiMAX cellular network 5: LTE-TDD cellular network 6: LTE-FDD cellular network 7: NB-IoT 8 - 20: Reserved for other types of cellular network 21: WLAN network 22: Bluetooth network 23: IEEE 802.15.4 network 24 - 40: Reserved for other types of local wireless network 41: Ethernet 42: DSL 43: PLC 44 - 50: reserved for other types of wireline networks. | |
83 | - </Description> | |
84 | - </Item> | |
85 | - <Item ID="1"> | |
86 | - <Name>Available Network Bearer</Name> | |
87 | - <Operations>R</Operations> | |
88 | - <MultipleInstances>Multiple</MultipleInstances> | |
89 | - <Mandatory>Mandatory</Mandatory> | |
90 | - <Type>Integer</Type> | |
91 | - <RangeEnumeration>0-50</RangeEnumeration> | |
92 | - <Units/> | |
93 | - <Description> | |
94 | - Indicates a list of current available network bearer. Each Resource Instance has a value from the network bearer list. | |
95 | - </Description> | |
96 | - </Item> | |
97 | - <Item ID="2"> | |
98 | - <Name>Radio Signal Strength</Name> | |
99 | - <Operations>R</Operations> | |
100 | - <MultipleInstances>Single</MultipleInstances> | |
101 | - <Mandatory>Mandatory</Mandatory> | |
102 | - <Type>Integer</Type> | |
103 | - <RangeEnumeration/> | |
104 | - <Units>dBm</Units> | |
105 | - <Description> | |
106 | - Indicates the average value of the received signal strength indication used in the current network bearer (as indicated by Resource 0 of this Object). For the following network bearers the signal strength parameters indicated below are represented by this resource: GSM: RSSI UMTS: RSCP LTE: RSRP NB-IoT: NRSRP For more details on Network Measurement Report, refer to the appropriate Cellular or Wireless Network standards, (e.g. for LTE Cellular Network refer to 3GPP TS 36.133 specification). | |
107 | - </Description> | |
108 | - </Item> | |
109 | - <Item ID="3"> | |
110 | - <Name>Link Quality</Name> | |
111 | - <Operations>R</Operations> | |
112 | - <MultipleInstances>Single</MultipleInstances> | |
113 | - <Mandatory>Optional</Mandatory> | |
114 | - <Type>Integer</Type> | |
115 | - <RangeEnumeration/> | |
116 | - <Units/> | |
117 | - <Description> | |
118 | - This contains received link quality e.g. LQI for IEEE 802.15.4 (range 0...255), RxQual Downlink for GSM (range 0...7, refer to [3GPP 44.018] for more details on Network Measurement Report encoding), RSRQ for LTE, (refer to [3GPP 36.214]), NRSRQ for NB-IoT (refer to [3GPP 36.214]). | |
119 | - </Description> | |
120 | - </Item> | |
121 | - <Item ID="4"> | |
122 | - <Name>IP Addresses</Name> | |
123 | - <Operations>R</Operations> | |
124 | - <MultipleInstances>Multiple</MultipleInstances> | |
125 | - <Mandatory>Mandatory</Mandatory> | |
126 | - <Type>String</Type> | |
127 | - <RangeEnumeration/> | |
128 | - <Units/> | |
129 | - <Description> | |
130 | - The IP addresses assigned to the connectivity interface. (e.g. IPv4, IPv6, etc.) | |
131 | - </Description> | |
132 | - </Item> | |
133 | - <Item ID="5"> | |
134 | - <Name>Router IP Addresses</Name> | |
135 | - <Operations>R</Operations> | |
136 | - <MultipleInstances>Multiple</MultipleInstances> | |
137 | - <Mandatory>Optional</Mandatory> | |
138 | - <Type>String</Type> | |
139 | - <RangeEnumeration/> | |
140 | - <Units/> | |
141 | - <Description> | |
142 | - The IP address of the next-hop IP router, on each of the interfaces specified in resource 4 (IP Addresses). Note: This IP Address doesn’t indicate the Server IP address. | |
143 | - </Description> | |
144 | - </Item> | |
145 | - <Item ID="6"> | |
146 | - <Name>Link Utilization</Name> | |
147 | - <Operations>R</Operations> | |
148 | - <MultipleInstances>Single</MultipleInstances> | |
149 | - <Mandatory>Optional</Mandatory> | |
150 | - <Type>Integer</Type> | |
151 | - <RangeEnumeration>0-100</RangeEnumeration> | |
152 | - <Units>%</Units> | |
153 | - <Description> | |
154 | - The percentage indicating the average utilization of the link to the next-hop IP router. | |
155 | - </Description> | |
156 | - </Item> | |
157 | - <Item ID="7"> | |
158 | - <Name>APN</Name> | |
159 | - <Operations>R</Operations> | |
160 | - <MultipleInstances>Multiple</MultipleInstances> | |
161 | - <Mandatory>Optional</Mandatory> | |
162 | - <Type>String</Type> | |
163 | - <RangeEnumeration/> | |
164 | - <Units/> | |
165 | - <Description> | |
166 | - Access Point Name in case Network Bearer Resource is a Cellular Network. | |
167 | - </Description> | |
168 | - </Item> | |
169 | - <Item ID="8"> | |
170 | - <Name>Cell ID</Name> | |
171 | - <Operations>R</Operations> | |
172 | - <MultipleInstances>Single</MultipleInstances> | |
173 | - <Mandatory>Optional</Mandatory> | |
174 | - <Type>Integer</Type> | |
175 | - <RangeEnumeration/> | |
176 | - <Units/> | |
177 | - <Description> | |
178 | - Serving Cell ID in case Network Bearer Resource is a Cellular Network. As specified in TS [3GPP 23.003] and in [3GPP. 24.008]. Range (0...65535) in GSM/EDGE UTRAN Cell ID has a length of 28 bits. Cell Identity in WCDMA/TD-SCDMA. Range: (0...268435455). LTE Cell ID has a length of 28 bits. Parameter definitions in [3GPP 25.331]. | |
179 | - </Description> | |
180 | - </Item> | |
181 | - <Item ID="9"> | |
182 | - <Name>SMNC</Name> | |
183 | - <Operations>R</Operations> | |
184 | - <MultipleInstances>Single</MultipleInstances> | |
185 | - <Mandatory>Optional</Mandatory> | |
186 | - <Type>Integer</Type> | |
187 | - <RangeEnumeration>0-999</RangeEnumeration> | |
188 | - <Units>%</Units> | |
189 | - <Description> | |
190 | - Serving Mobile Network Code. This is applicable when the Network Bearer Resource value is referring to a cellular network. As specified in TS [3GPP 23.003]. | |
191 | - </Description> | |
192 | - </Item> | |
193 | - <Item ID="10"> | |
194 | - <Name>SMCC</Name> | |
195 | - <Operations>R</Operations> | |
196 | - <MultipleInstances>Single</MultipleInstances> | |
197 | - <Mandatory>Optional</Mandatory> | |
198 | - <Type>Integer</Type> | |
199 | - <RangeEnumeration>0-999</RangeEnumeration> | |
200 | - <Units/> | |
201 | - <Description> | |
202 | - Serving Mobile Country Code. This is applicable when the Network Bearer Resource value is referring to a cellular network. As specified in TS [3GPP 23.003]. | |
203 | - </Description> | |
204 | - </Item> | |
205 | - </Resources> | |
206 | - <Description2/> | |
207 | - </Object> | |
208 | -</LWM2M> |
1 | -<?xml version="1.0" encoding="UTF-8"?> | |
2 | -<!-- | |
3 | - | |
4 | - Copyright © 2016-2020 The Thingsboard Authors | |
5 | - | |
6 | - Licensed under the Apache License, Version 2.0 (the "License"); | |
7 | - you may not use this file except in compliance with the License. | |
8 | - You may obtain a copy of the License at | |
9 | - | |
10 | - http://www.apache.org/licenses/LICENSE-2.0 | |
11 | - | |
12 | - Unless required by applicable law or agreed to in writing, software | |
13 | - distributed under the License is distributed on an "AS IS" BASIS, | |
14 | - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | - See the License for the specific language governing permissions and | |
16 | - limitations under the License. | |
17 | - | |
18 | ---> | |
19 | -<LWM2M xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://openmobilealliance.org/tech/profiles/LWM2M.xsd"> | |
20 | - <Object ObjectType="MODefinition"> | |
21 | - <Name>Connectivity Monitoring</Name> | |
22 | - <Description1> | |
23 | - This LwM2M Object enables monitoring of parameters related to network connectivity. In this general connectivity Object, the Resources are limited to the most general cases common to most network bearers. It is recommended to read the description, which refers to relevant standard development organizations (e.g. 3GPP, IEEE). The goal of the Connectivity Monitoring Object is to carry information reflecting the more up to date values of the current connection for monitoring purposes. Resources such as Link Quality, Radio Signal Strength, Cell ID are retrieved during connected mode at least for cellular networks. | |
24 | - </Description1> | |
25 | - <ObjectID>4</ObjectID> | |
26 | - <ObjectURN>urn:oma:lwm2m:oma:4</ObjectURN> | |
27 | - <LWM2MVersion>1.0</LWM2MVersion> | |
28 | - <ObjectVersion>1.0</ObjectVersion> | |
29 | - <MultipleInstances>Single</MultipleInstances> | |
30 | - <Mandatory>Optional</Mandatory> | |
31 | - <Resources> | |
32 | - <Item ID="0"> | |
33 | - <Name>Network Bearer</Name> | |
34 | - <Operations>R</Operations> | |
35 | - <MultipleInstances>Single</MultipleInstances> | |
36 | - <Mandatory>Mandatory</Mandatory> | |
37 | - <Type>Integer</Type> | |
38 | - <RangeEnumeration>0-50</RangeEnumeration> | |
39 | - <Units/> | |
40 | - <Description> | |
41 | - Indicates the network bearer used for the current LwM2M communication session from the network bearer list below. The number range is split into three categories: 0 - 20 are Cellular Bearers 21 - 40 are Wireless Bearers 41 - 50 are Wireline Bearers More specifically: 0: GSM cellular network 1: TD-SCDMA cellular network 2: WCDMA cellular network 3: CDMA2000 cellular network 4: WiMAX cellular network 5: LTE-TDD cellular network 6: LTE-FDD cellular network 7: NB-IoT 8 - 20: Reserved for other types of cellular network 21: WLAN network 22: Bluetooth network 23: IEEE 802.15.4 network 24 - 40: Reserved for other types of local wireless network 41: Ethernet 42: DSL 43: PLC 44 - 50: reserved for other types of wireline networks. | |
42 | - </Description> | |
43 | - </Item> | |
44 | - <Item ID="1"> | |
45 | - <Name>Available Network Bearer</Name> | |
46 | - <Operations>R</Operations> | |
47 | - <MultipleInstances>Multiple</MultipleInstances> | |
48 | - <Mandatory>Mandatory</Mandatory> | |
49 | - <Type>Integer</Type> | |
50 | - <RangeEnumeration>0-50</RangeEnumeration> | |
51 | - <Units/> | |
52 | - <Description> | |
53 | - Indicates a list of current available network bearer. Each Resource Instance has a value from the network bearer list. | |
54 | - </Description> | |
55 | - </Item> | |
56 | - <Item ID="2"> | |
57 | - <Name>Radio Signal Strength</Name> | |
58 | - <Operations>R</Operations> | |
59 | - <MultipleInstances>Single</MultipleInstances> | |
60 | - <Mandatory>Mandatory</Mandatory> | |
61 | - <Type>Integer</Type> | |
62 | - <RangeEnumeration/> | |
63 | - <Units>dBm</Units> | |
64 | - <Description> | |
65 | - Indicates the average value of the received signal strength indication used in the current network bearer (as indicated by Resource 0 of this Object). For the following network bearers the signal strength parameters indicated below are represented by this resource: GSM: RSSI UMTS: RSCP LTE: RSRP NB-IoT: NRSRP For more details on Network Measurement Report, refer to the appropriate Cellular or Wireless Network standards, (e.g. for LTE Cellular Network refer to 3GPP TS 36.133 specification). | |
66 | - </Description> | |
67 | - </Item> | |
68 | - <Item ID="3"> | |
69 | - <Name>Link Quality</Name> | |
70 | - <Operations>R</Operations> | |
71 | - <MultipleInstances>Single</MultipleInstances> | |
72 | - <Mandatory>Optional</Mandatory> | |
73 | - <Type>Integer</Type> | |
74 | - <RangeEnumeration/> | |
75 | - <Units/> | |
76 | - <Description> | |
77 | - This contains received link quality e.g. LQI for IEEE 802.15.4 (range 0...255), RxQual Downlink for GSM (range 0...7, refer to [3GPP 44.018] for more details on Network Measurement Report encoding), RSRQ for LTE, (refer to [3GPP 36.214]), NRSRQ for NB-IoT (refer to [3GPP 36.214]). | |
78 | - </Description> | |
79 | - </Item> | |
80 | - <Item ID="4"> | |
81 | - <Name>IP Addresses</Name> | |
82 | - <Operations>R</Operations> | |
83 | - <MultipleInstances>Multiple</MultipleInstances> | |
84 | - <Mandatory>Mandatory</Mandatory> | |
85 | - <Type>String</Type> | |
86 | - <RangeEnumeration/> | |
87 | - <Units/> | |
88 | - <Description> | |
89 | - The IP addresses assigned to the connectivity interface. (e.g. IPv4, IPv6, etc.) | |
90 | - </Description> | |
91 | - </Item> | |
92 | - <Item ID="5"> | |
93 | - <Name>Router IP Addresses</Name> | |
94 | - <Operations>R</Operations> | |
95 | - <MultipleInstances>Multiple</MultipleInstances> | |
96 | - <Mandatory>Optional</Mandatory> | |
97 | - <Type>String</Type> | |
98 | - <RangeEnumeration/> | |
99 | - <Units/> | |
100 | - <Description> | |
101 | - The IP address of the next-hop IP router, on each of the interfaces specified in resource 4 (IP Addresses). Note: This IP Address doesn’t indicate the Server IP address. | |
102 | - </Description> | |
103 | - </Item> | |
104 | - <Item ID="6"> | |
105 | - <Name>Link Utilization</Name> | |
106 | - <Operations>R</Operations> | |
107 | - <MultipleInstances>Single</MultipleInstances> | |
108 | - <Mandatory>Optional</Mandatory> | |
109 | - <Type>Integer</Type> | |
110 | - <RangeEnumeration>0-100</RangeEnumeration> | |
111 | - <Units>%</Units> | |
112 | - <Description> | |
113 | - The percentage indicating the average utilization of the link to the next-hop IP router. | |
114 | - </Description> | |
115 | - </Item> | |
116 | - <Item ID="7"> | |
117 | - <Name>APN</Name> | |
118 | - <Operations>R</Operations> | |
119 | - <MultipleInstances>Multiple</MultipleInstances> | |
120 | - <Mandatory>Optional</Mandatory> | |
121 | - <Type>String</Type> | |
122 | - <RangeEnumeration/> | |
123 | - <Units/> | |
124 | - <Description> | |
125 | - Access Point Name in case Network Bearer Resource is a Cellular Network. | |
126 | - </Description> | |
127 | - </Item> | |
128 | - <Item ID="8"> | |
129 | - <Name>Cell ID</Name> | |
130 | - <Operations>R</Operations> | |
131 | - <MultipleInstances>Single</MultipleInstances> | |
132 | - <Mandatory>Optional</Mandatory> | |
133 | - <Type>Integer</Type> | |
134 | - <RangeEnumeration/> | |
135 | - <Units/> | |
136 | - <Description> | |
137 | - Serving Cell ID in case Network Bearer Resource is a Cellular Network. As specified in TS [3GPP 23.003] and in [3GPP. 24.008]. Range (0...65535) in GSM/EDGE UTRAN Cell ID has a length of 28 bits. Cell Identity in WCDMA/TD-SCDMA. Range: (0...268435455). LTE Cell ID has a length of 28 bits. Parameter definitions in [3GPP 25.331]. | |
138 | - </Description> | |
139 | - </Item> | |
140 | - <Item ID="9"> | |
141 | - <Name>SMNC</Name> | |
142 | - <Operations>R</Operations> | |
143 | - <MultipleInstances>Single</MultipleInstances> | |
144 | - <Mandatory>Optional</Mandatory> | |
145 | - <Type>Integer</Type> | |
146 | - <RangeEnumeration>0-999</RangeEnumeration> | |
147 | - <Units>%</Units> | |
148 | - <Description> | |
149 | - Serving Mobile Network Code. This is applicable when the Network Bearer Resource value is referring to a cellular network. As specified in TS [3GPP 23.003]. | |
150 | - </Description> | |
151 | - </Item> | |
152 | - <Item ID="10"> | |
153 | - <Name>SMCC</Name> | |
154 | - <Operations>R</Operations> | |
155 | - <MultipleInstances>Single</MultipleInstances> | |
156 | - <Mandatory>Optional</Mandatory> | |
157 | - <Type>Integer</Type> | |
158 | - <RangeEnumeration>0-999</RangeEnumeration> | |
159 | - <Units/> | |
160 | - <Description> | |
161 | - Serving Mobile Country Code. This is applicable when the Network Bearer Resource value is referring to a cellular network. As specified in TS [3GPP 23.003]. | |
162 | - </Description> | |
163 | - </Item> | |
164 | - </Resources> | |
165 | - <Description2/> | |
166 | - </Object> | |
167 | -</LWM2M> |
... | ... | @@ -73,7 +73,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
73 | 73 | this.requiredValue = coerceBooleanProperty(value); |
74 | 74 | } |
75 | 75 | |
76 | - private propagateChange = (v: any) => { }; | |
76 | + private propagateChange = (v: any) => { | |
77 | + }; | |
77 | 78 | |
78 | 79 | constructor(private store: Store<AppState>, |
79 | 80 | private fb: FormBuilder, |
... | ... | @@ -403,19 +404,26 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
403 | 404 | |
404 | 405 | sortObjectKeyPathJson = (key: string, value: object): object => { |
405 | 406 | if (key === 'keyName') { |
406 | - return Object.keys(value).sort((a, b) => { | |
407 | - const aLC = Array.from(a.substring(1).split('/'), Number); | |
408 | - const bLC = Array.from(b.substring(1).split('/'), Number); | |
409 | - return aLC[0] === bLC[0] ? aLC[1] - bLC[1] : aLC[0] - bLC[0]; | |
410 | - }).reduce((obj, keySort) => { | |
407 | + return Object.keys(value).sort(this.sortPath).reduce((obj, keySort) => { | |
411 | 408 | obj[keySort] = value[keySort]; |
412 | 409 | return obj; |
413 | 410 | }, {}); |
411 | + } else if (key === 'observe' || key === 'attribute' || key === 'telemetry') { | |
412 | + return Object.values(value).sort(this.sortPath).reduce((arr, arrValue) => { | |
413 | + arr.push(arrValue); | |
414 | + return arr; | |
415 | + }, []); | |
414 | 416 | } else { |
415 | 417 | return value; |
416 | 418 | } |
417 | 419 | } |
418 | 420 | |
421 | + private sortPath = (a, b): number => { | |
422 | + const aLC = Array.from(a.substring(1).split('/'), Number); | |
423 | + const bLC = Array.from(b.substring(1).split('/'), Number); | |
424 | + return aLC[0] === bLC[0] ? aLC[1] - bLC[1] : aLC[0] - bLC[0]; | |
425 | + } | |
426 | + | |
419 | 427 | private updateKeyName = (): void => { |
420 | 428 | const paths = new Set<string>(); |
421 | 429 | if (this.configurationValue[this.observeAttr][this.attribute]) { | ... | ... |
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | class="tb-autocomplete" |
42 | 42 | [displayWith]="displayObjectLwm2mFn"> |
43 | 43 | <mat-option *ngFor="let objectLwm2m of filteredObjectsList | async" [value]="objectLwm2m"> |
44 | - <span [innerHTML]="objectLwm2m.name | highlight:searchText"></span> | |
44 | + <span [innerHTML]="objectLwm2m.id + ': ' + objectLwm2m.name | highlight:searchText"></span> | |
45 | 45 | </mat-option> |
46 | 46 | <mat-option *ngIf="!(filteredObjectsList | async)?.length" [value]="null"> |
47 | 47 | <span> | ... | ... |
... | ... | @@ -89,7 +89,6 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor |
89 | 89 | |
90 | 90 | private propagateChange = (v: any) => { }; |
91 | 91 | |
92 | - | |
93 | 92 | registerOnChange(fn: any): void { |
94 | 93 | this.propagateChange = fn; |
95 | 94 | } |
... | ... | @@ -164,7 +163,7 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor |
164 | 163 | } |
165 | 164 | |
166 | 165 | changeInstanceResourcesCheckBox = (value: boolean, instance: AbstractControl, type: string): void => { |
167 | - const resources = instance.get('resources').value as ResourceLwM2M[]; | |
166 | + const resources = deepClone(instance.get('resources').value as ResourceLwM2M[]); | |
168 | 167 | resources.forEach(resource => resource[type] = value); |
169 | 168 | instance.get('resources').patchValue(resources); |
170 | 169 | this.propagateChange(this.observeAttrTelemetryFormGroup.value); |
... | ... | @@ -238,49 +237,54 @@ export class Lwm2mObserveAttrTelemetryComponent implements ControlValueAccessor |
238 | 237 | } |
239 | 238 | |
240 | 239 | private updateInstancesIds = (data: Lwm2mObjectAddInstancesData): void => { |
241 | - const instances = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M[]) | |
242 | - .find(objectLwM2M => objectLwM2M.id === data.objectId).instances; | |
243 | - const valueOld = this.instancesToSetId(instances); | |
244 | - | |
240 | + const objectLwM2MFormGroup = (this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls | |
241 | + .find(e => e.value.id === data.objectId) as FormGroup; | |
242 | + const instancesArray = objectLwM2MFormGroup.value.instances as Instance []; | |
243 | + const instancesFormArray = objectLwM2MFormGroup.get('instances') as FormArray; | |
244 | + const instance0 = deepClone(instancesFormArray.at(0).value as Instance); | |
245 | + instance0.resources.forEach(r => { | |
246 | + r.attribute = false; | |
247 | + r.telemetry = false; | |
248 | + r.observe = false; | |
249 | + }); | |
250 | + const valueOld = this.instancesToSetId(instancesArray); | |
245 | 251 | if (!isEqual(valueOld, data.instancesIds)) { |
246 | 252 | const idsDel = this.diffBetweenSet(valueOld, data.instancesIds); |
247 | 253 | const idsAdd = this.diffBetweenSet(data.instancesIds, valueOld); |
248 | 254 | if (idsAdd.size) { |
249 | - this.addInstancesNew(data.objectId, idsAdd, instances.find(instance => instance.id === 0)); | |
255 | + this.addInstancesNew(idsAdd, objectLwM2MFormGroup, instancesFormArray, instance0); | |
250 | 256 | } |
251 | 257 | if (idsDel.size) { |
252 | - this.deleteInstances(data.objectId, idsDel); | |
258 | + this.deleteInstances(idsDel, objectLwM2MFormGroup, instancesFormArray, instance0); | |
253 | 259 | } |
254 | 260 | } |
255 | 261 | } |
256 | 262 | |
257 | - private deleteInstances = (objectId: number, idsDel: Set<number>): void => { | |
258 | - const objectIndex = (this.observeAttrTelemetryFormGroup.get('clientLwM2M').value as ObjectLwM2M[]) | |
259 | - .findIndex(element => element.id === objectId); | |
263 | + private addInstancesNew = (idsAdd: Set<number>, objectLwM2MFormGroup: FormGroup, instancesFormArray: FormArray, | |
264 | + instanceNew: Instance): void => { | |
265 | + idsAdd.forEach(x => { | |
266 | + this.pushInstance(instancesFormArray, x, instanceNew); | |
267 | + }); | |
268 | + (instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id); | |
269 | + } | |
270 | + | |
271 | + private deleteInstances = (idsDel: Set<number>, objectLwM2MFormGroup: FormGroup, instancesFormArray: FormArray, | |
272 | + instance0: Instance): void => { | |
260 | 273 | idsDel.forEach(x => { |
261 | - const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray) | |
262 | - .at(objectIndex).get('instances') as FormArray); | |
263 | 274 | const instanceIndex = instancesFormArray.value.findIndex(element => element.id === x); |
264 | 275 | instancesFormArray.removeAt(instanceIndex); |
265 | 276 | }); |
277 | + if (instancesFormArray.length === 0) { | |
278 | + this.pushInstance(instancesFormArray, 0, instance0); | |
279 | + } | |
280 | + (instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id); | |
266 | 281 | } |
267 | 282 | |
268 | - private addInstancesNew = (objectId: number, idsAdd: Set<number>, instance: Instance): void => { | |
269 | - const instancesFormArray = ((this.observeAttrTelemetryFormGroup.get('clientLwM2M') as FormArray).controls | |
270 | - .find(e => e.value.id === objectId).get('instances') as FormArray) as FormArray; | |
271 | - idsAdd.forEach(x => { | |
272 | - const instanceNew = deepClone(instance); | |
273 | - instanceNew.resources.forEach(r => { | |
274 | - r.attribute = false; | |
275 | - r.telemetry = false; | |
276 | - r.observe = false; | |
277 | - }); | |
278 | - instancesFormArray.push(this.fb.group({ | |
279 | - id: x, | |
280 | - resources: {value: instanceNew.resources, disabled: this.disabled} | |
281 | - })); | |
282 | - }); | |
283 | - (instancesFormArray.controls as FormGroup[]).sort((a, b) => a.value.id - b.value.id); | |
283 | + private pushInstance = (instancesFormArray: FormArray, x: number, instanceNew: Instance): void => { | |
284 | + instancesFormArray.push(this.fb.group({ | |
285 | + id: x, | |
286 | + resources: {value: instanceNew.resources, disabled: this.disabled} | |
287 | + })); | |
284 | 288 | } |
285 | 289 | |
286 | 290 | private diffBetweenSet<T>(firstSet: Set<T>, secondSet: Set<T>): Set<T> { | ... | ... |