@eohjsc/react-native-smart-city 0.3.85 → 0.3.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/Images/Common/logo.png +0 -0
- package/src/Images/Common/logo@2x.png +0 -0
- package/src/Images/Common/logo@3x.png +0 -0
- package/src/Images/Common/unit_default_background.png +0 -0
- package/src/Images/Common/unit_default_background@2x.png +0 -0
- package/src/Images/Common/unit_default_background@3x.png +0 -0
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/index.js +1 -1
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -13
- package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +0 -1
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +4 -4
- package/src/commons/ActionGroup/__test__/index.test.js +1 -1
- package/src/commons/Automate/__test__/ItemAutomate.test.js +25 -3
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +37 -0
- package/src/commons/Dashboard/MyUnit/index.js +28 -6
- package/src/commons/Device/ProgressBar/__test__/ProgressBar.test.js +1 -1
- package/src/commons/Device/ProgressBar/index.js +4 -2
- package/src/commons/Device/ProgressBar/styles.js +1 -0
- package/src/commons/Device/SonosSpeaker/__test__/SonosSpeaker.test.js +1 -1
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Device/WindSpeed/Anemometer/index.js +96 -14
- package/src/commons/Device/WindSpeed/__test__/Anemometer.test.js +89 -2
- package/src/commons/ModalPopupCT/index.js +21 -2
- package/src/commons/ModalPopupCT/styles.js +7 -0
- package/src/commons/WrapParallaxScrollView/index.js +5 -4
- package/src/configs/API.js +3 -2
- package/src/configs/AccessibilityLabel.js +3 -0
- package/src/configs/Constants.js +1 -0
- package/src/configs/Images.js +1 -0
- package/src/context/actionType.ts +3 -0
- package/src/context/mockStore.ts +1 -0
- package/src/context/reducer.ts +19 -0
- package/src/screens/AddNewAction/__test__/LoadingSelectAction.test.js +16 -0
- package/src/screens/AllCamera/__test__/index.test.js +1 -1
- package/src/screens/AllCamera/index.js +2 -2
- package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +179 -111
- package/src/screens/AllGateway/DetailConfigActionInternal/index.js +48 -50
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +4 -0
- package/src/screens/AllGateway/DeviceInternalDetail/index.js +14 -1
- package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +25 -0
- package/src/screens/AllGateway/GatewayConnectionMethods/index.js +59 -35
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +14 -4
- package/src/screens/AllGateway/GatewayInfo/index.js +21 -2
- package/src/screens/AllGateway/components/Detail/__test__/index.test.js +28 -1
- package/src/screens/AllGateway/components/Detail/index.js +8 -2
- package/src/screens/AllGateway/components/Information/index.js +4 -1
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -1
- package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
- package/src/screens/AllGateway/components/TabPaneCT/styles.js +1 -1
- package/src/screens/ConfirmUnitDeletion/index.js +6 -2
- package/src/screens/Unit/ManageUnit.js +7 -3
- package/src/utils/I18n/translations/en.json +3 -0
- package/src/utils/I18n/translations/vi.json +3 -0
- package/src/utils/Utils.js +6 -0
|
@@ -33,154 +33,222 @@ jest.mock('@react-navigation/native', () => {
|
|
|
33
33
|
};
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
const initData = async (params) => {
|
|
37
37
|
let tree;
|
|
38
|
+
useRoute.mockReturnValue({
|
|
39
|
+
params: {
|
|
40
|
+
isConfigRead: false,
|
|
41
|
+
isConfigWrite: true,
|
|
42
|
+
isAction: false,
|
|
43
|
+
itemActionConfig: {
|
|
44
|
+
id: 1,
|
|
45
|
+
config: { name: 'config1' },
|
|
46
|
+
value_type: 'boolean',
|
|
47
|
+
pin_number: 0,
|
|
48
|
+
pin_mode: 1,
|
|
49
|
+
},
|
|
50
|
+
board: 'stm323',
|
|
51
|
+
...params,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
await act(async () => {
|
|
55
|
+
tree = await create(wrapComponent());
|
|
56
|
+
});
|
|
57
|
+
return tree.root;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
describe('Test DetailConfigActionInternal', () => {
|
|
38
61
|
it('test render DetailConfigActionInternal isConfigRead', async () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
pin_mode: 1,
|
|
50
|
-
},
|
|
51
|
-
board: 'stm32',
|
|
62
|
+
const instance = await initData({
|
|
63
|
+
isConfigRead: true,
|
|
64
|
+
isConfigWrite: false,
|
|
65
|
+
isAction: false,
|
|
66
|
+
itemActionConfig: {
|
|
67
|
+
id: 1,
|
|
68
|
+
config: { name: 'config1' },
|
|
69
|
+
value_type: 'boolean',
|
|
70
|
+
pin_number: '0',
|
|
71
|
+
pin_mode: 1,
|
|
52
72
|
},
|
|
73
|
+
board: 'stm32',
|
|
53
74
|
});
|
|
54
|
-
await act(async () => {
|
|
55
|
-
tree = await create(wrapComponent());
|
|
56
|
-
});
|
|
57
|
-
const instance = tree.root;
|
|
58
75
|
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
59
76
|
expect(detailConfigAction).toHaveLength(1);
|
|
60
77
|
});
|
|
78
|
+
|
|
61
79
|
it('test render DetailConfigActionInternal isConfigWrite', async () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
pin_mode: 1,
|
|
73
|
-
},
|
|
74
|
-
board: 'stm32',
|
|
80
|
+
const instance = await initData({
|
|
81
|
+
isConfigRead: false,
|
|
82
|
+
isConfigWrite: true,
|
|
83
|
+
isAction: false,
|
|
84
|
+
itemActionConfig: {
|
|
85
|
+
id: 1,
|
|
86
|
+
config: { name: 'config1' },
|
|
87
|
+
value_type: 'boolean',
|
|
88
|
+
pin_number: 0,
|
|
89
|
+
pin_mode: 1,
|
|
75
90
|
},
|
|
91
|
+
board: 'stm32',
|
|
76
92
|
});
|
|
77
|
-
await act(async () => {
|
|
78
|
-
tree = await create(wrapComponent());
|
|
79
|
-
});
|
|
80
|
-
const instance = tree.root;
|
|
81
93
|
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
82
94
|
expect(detailConfigAction).toHaveLength(1);
|
|
83
95
|
});
|
|
96
|
+
|
|
84
97
|
it('test render DetailConfigActionInternal isAction', async () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
default_value: 0,
|
|
96
|
-
},
|
|
97
|
-
board: 'stm32',
|
|
98
|
+
const instance = await initData({
|
|
99
|
+
isConfigRead: false,
|
|
100
|
+
isConfigWrite: false,
|
|
101
|
+
isAction: true,
|
|
102
|
+
isChildAction: false,
|
|
103
|
+
itemActionConfig: {
|
|
104
|
+
id: 1,
|
|
105
|
+
action: { name: 'config1' },
|
|
106
|
+
pin: 'boolean',
|
|
107
|
+
default_value: 0,
|
|
98
108
|
},
|
|
109
|
+
board: 'stm32',
|
|
99
110
|
});
|
|
100
|
-
await act(async () => {
|
|
101
|
-
tree = await create(wrapComponent());
|
|
102
|
-
});
|
|
103
|
-
const instance = tree.root;
|
|
104
111
|
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
105
112
|
expect(detailConfigAction).toHaveLength(1);
|
|
106
113
|
});
|
|
114
|
+
|
|
107
115
|
it('test render DetailConfigActionInternal isAction isInternal wrong board', async () => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
default_value: 0,
|
|
120
|
-
},
|
|
121
|
-
board: 'stm322132',
|
|
122
|
-
writeConfigPins: [],
|
|
116
|
+
const instance = await initData({
|
|
117
|
+
isConfigRead: false,
|
|
118
|
+
isConfigWrite: false,
|
|
119
|
+
isAction: true,
|
|
120
|
+
isChildAction: false,
|
|
121
|
+
isInternal: true,
|
|
122
|
+
itemActionConfig: {
|
|
123
|
+
id: 1,
|
|
124
|
+
action: { name: 'config1' },
|
|
125
|
+
pin: 'boolean',
|
|
126
|
+
default_value: 0,
|
|
123
127
|
},
|
|
128
|
+
board: 'stm322132',
|
|
129
|
+
writeConfigPins: [],
|
|
124
130
|
});
|
|
125
|
-
await act(async () => {
|
|
126
|
-
tree = await create(wrapComponent());
|
|
127
|
-
});
|
|
128
|
-
const instance = tree.root;
|
|
129
131
|
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
130
132
|
expect(detailConfigAction[0].props?.listData[1]?.title).toEqual(
|
|
131
133
|
'pin_number'
|
|
132
134
|
);
|
|
133
135
|
expect(detailConfigAction[0].props?.listData[1]?.data).toEqual([]);
|
|
134
136
|
});
|
|
137
|
+
|
|
135
138
|
it('test render DetailConfigActionInternal isAction isInternal', async () => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
const instance = await initData({
|
|
140
|
+
isConfigRead: false,
|
|
141
|
+
isConfigWrite: false,
|
|
142
|
+
isAction: true,
|
|
143
|
+
isChildAction: false,
|
|
144
|
+
isInternal: true,
|
|
145
|
+
itemActionConfig: {
|
|
146
|
+
id: 1,
|
|
147
|
+
action: { name: 'config1' },
|
|
148
|
+
pin: 'boolean',
|
|
149
|
+
default_value: 0,
|
|
150
|
+
},
|
|
151
|
+
board: 'stm32',
|
|
152
|
+
writeConfigPins: [
|
|
153
|
+
{
|
|
154
|
+
config: {
|
|
155
|
+
is_read: false,
|
|
156
|
+
is_write: true,
|
|
157
|
+
name: 'config1',
|
|
158
|
+
},
|
|
144
159
|
id: 1,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
160
|
+
pin_mode: 'output',
|
|
161
|
+
pin_number: 0,
|
|
162
|
+
value_type: 'boolean',
|
|
148
163
|
},
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
is_write: true,
|
|
155
|
-
name: 'config1',
|
|
156
|
-
},
|
|
157
|
-
id: 1,
|
|
158
|
-
pin_mode: 'output',
|
|
159
|
-
pin_number: 0,
|
|
160
|
-
value_type: 'boolean',
|
|
164
|
+
{
|
|
165
|
+
config: {
|
|
166
|
+
is_read: true,
|
|
167
|
+
is_write: true,
|
|
168
|
+
name: 'config2',
|
|
161
169
|
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
id: 2,
|
|
169
|
-
pin_mode: 'output',
|
|
170
|
-
pin_number: 0,
|
|
171
|
-
value_type: 'integer',
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
await act(async () => {
|
|
177
|
-
tree = await create(wrapComponent());
|
|
170
|
+
id: 2,
|
|
171
|
+
pin_mode: 'output',
|
|
172
|
+
pin_number: 0,
|
|
173
|
+
value_type: 'integer',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
178
176
|
});
|
|
179
|
-
const instance = tree.root;
|
|
180
177
|
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
181
178
|
expect(detailConfigAction[0].props?.listData[1]?.title).toEqual(
|
|
182
179
|
'pin_number'
|
|
183
180
|
);
|
|
184
181
|
expect(detailConfigAction[0].props?.listData[1]?.data).toEqual('0');
|
|
185
182
|
});
|
|
183
|
+
it('format pin should return an empty array if board is not found in INTERNAL_DEVICE', async () => {
|
|
184
|
+
const instance = await initData({
|
|
185
|
+
isConfigRead: true,
|
|
186
|
+
isConfigWrite: false,
|
|
187
|
+
isAction: false,
|
|
188
|
+
itemActionConfig: {
|
|
189
|
+
id: 1,
|
|
190
|
+
config: { name: 'config1' },
|
|
191
|
+
value_type: 'boolean',
|
|
192
|
+
pin_number: '0',
|
|
193
|
+
pin_mode: 1,
|
|
194
|
+
},
|
|
195
|
+
board: 'stm323',
|
|
196
|
+
});
|
|
197
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
198
|
+
expect(detailConfigAction[0].props?.listData[2]?.data).toEqual('0');
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('format pin should return VIRTUAL_PIN if value_type is VIRTUAL_TYPE', async () => {
|
|
202
|
+
const instance = await initData({
|
|
203
|
+
isConfigRead: true,
|
|
204
|
+
isConfigWrite: false,
|
|
205
|
+
isAction: false,
|
|
206
|
+
itemActionConfig: {
|
|
207
|
+
id: 1,
|
|
208
|
+
config: { name: 'config1' },
|
|
209
|
+
value_type: 'virtual',
|
|
210
|
+
pin_number: '0',
|
|
211
|
+
pin_mode: 1,
|
|
212
|
+
},
|
|
213
|
+
board: 'stm32',
|
|
214
|
+
});
|
|
215
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
216
|
+
expect(detailConfigAction[0].props?.listData[2]?.data).toEqual('V0');
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('should return PIN_MAPPING if config is write and read', async () => {
|
|
220
|
+
const instance = await initData({
|
|
221
|
+
isConfigRead: true,
|
|
222
|
+
isConfigWrite: false,
|
|
223
|
+
isAction: false,
|
|
224
|
+
itemActionConfig: {
|
|
225
|
+
id: 1,
|
|
226
|
+
config: { name: 'config1', is_read: true, is_write: true },
|
|
227
|
+
value_type: 'integer',
|
|
228
|
+
pin_number: '0',
|
|
229
|
+
pin_mode: 1,
|
|
230
|
+
},
|
|
231
|
+
board: 'stm32',
|
|
232
|
+
});
|
|
233
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
234
|
+
expect(detailConfigAction[0].props?.listData[2]?.data).toEqual('PA0');
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('format pin should return PIN_MAPPING with the given readOrWrite type', async () => {
|
|
238
|
+
const instance = await initData({
|
|
239
|
+
isConfigRead: true,
|
|
240
|
+
isConfigWrite: false,
|
|
241
|
+
isAction: false,
|
|
242
|
+
itemActionConfig: {
|
|
243
|
+
id: 1,
|
|
244
|
+
config: { name: 'config1', is_read: true, is_write: false },
|
|
245
|
+
value_type: 'integer',
|
|
246
|
+
pin_number: '0',
|
|
247
|
+
pin_mode: 1,
|
|
248
|
+
},
|
|
249
|
+
board: 'stm32',
|
|
250
|
+
});
|
|
251
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
252
|
+
expect(detailConfigAction[0].props?.listData[2]?.data).toEqual('PA0');
|
|
253
|
+
});
|
|
186
254
|
});
|
|
@@ -4,8 +4,12 @@ import { useRoute } from '@react-navigation/native';
|
|
|
4
4
|
|
|
5
5
|
import styles from './styles';
|
|
6
6
|
import DetailConfigAction from '../components/DetailConfigAction';
|
|
7
|
-
import { PIN_MAPPING,
|
|
8
|
-
import {
|
|
7
|
+
import { PIN_MAPPING, PIN_MODE_LIST } from '../../../utils/Utils';
|
|
8
|
+
import {
|
|
9
|
+
INTERNAL_DEVICE,
|
|
10
|
+
VIRTUAL_PIN,
|
|
11
|
+
VIRTUAL_TYPE,
|
|
12
|
+
} from '../../../configs/IOPinConstants';
|
|
9
13
|
|
|
10
14
|
const DetailConfigActionInternal = () => {
|
|
11
15
|
const { params = {} } = useRoute();
|
|
@@ -16,6 +20,7 @@ const DetailConfigActionInternal = () => {
|
|
|
16
20
|
isConfigWrite,
|
|
17
21
|
isAction,
|
|
18
22
|
isInternal,
|
|
23
|
+
isVirtualPin,
|
|
19
24
|
writeConfigPins,
|
|
20
25
|
virtualConfigPins,
|
|
21
26
|
board,
|
|
@@ -46,7 +51,17 @@ const DetailConfigActionInternal = () => {
|
|
|
46
51
|
}, [board, virtualConfigPins, writeConfigPins, itemActionConfig]);
|
|
47
52
|
|
|
48
53
|
const listPINs = useCallback(() => {
|
|
49
|
-
|
|
54
|
+
if (!Object.values(INTERNAL_DEVICE)?.includes(board)) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
if (itemActionConfig?.value_type === VIRTUAL_TYPE) {
|
|
58
|
+
return VIRTUAL_PIN;
|
|
59
|
+
}
|
|
60
|
+
const configType =
|
|
61
|
+
itemActionConfig?.config?.is_write && itemActionConfig?.config?.is_read
|
|
62
|
+
? 'write'
|
|
63
|
+
: readOrWrite;
|
|
64
|
+
return PIN_MAPPING[board][configType][itemActionConfig?.value_type];
|
|
50
65
|
}, [board, itemActionConfig, readOrWrite]);
|
|
51
66
|
|
|
52
67
|
const formatPIN = useCallback(() => {
|
|
@@ -57,12 +72,7 @@ const DetailConfigActionInternal = () => {
|
|
|
57
72
|
return pin?.value;
|
|
58
73
|
}, [itemActionConfig, listPINs]);
|
|
59
74
|
|
|
60
|
-
const listPINModes = useCallback(() => {
|
|
61
|
-
return PIN_MODE_MAPPING[readOrWrite][itemActionConfig?.value_type];
|
|
62
|
-
}, [itemActionConfig, readOrWrite]);
|
|
63
|
-
|
|
64
75
|
const formatPinMode = useCallback(() => {
|
|
65
|
-
const listPinModes = listPINModes();
|
|
66
76
|
let pinMode = '';
|
|
67
77
|
if (
|
|
68
78
|
isConfigRead &&
|
|
@@ -75,38 +85,34 @@ const DetailConfigActionInternal = () => {
|
|
|
75
85
|
pinMode = itemActionConfig?.pin_mode;
|
|
76
86
|
}
|
|
77
87
|
|
|
78
|
-
const pin_mode =
|
|
88
|
+
const pin_mode = PIN_MODE_LIST.find((el) => el?.key === pinMode);
|
|
79
89
|
return pin_mode?.value;
|
|
80
|
-
}, [isConfigRead, itemActionConfig
|
|
90
|
+
}, [isConfigRead, itemActionConfig]);
|
|
81
91
|
|
|
82
92
|
const listData = useMemo(() => {
|
|
93
|
+
let configName, valueType, configType;
|
|
94
|
+
configName = itemActionConfig?.config?.name || '--';
|
|
95
|
+
valueType = itemActionConfig?.value_type;
|
|
96
|
+
|
|
83
97
|
if (isConfigRead || isConfigWrite) {
|
|
98
|
+
if (valueType === 'boolean') {
|
|
99
|
+
configType = 'Digital';
|
|
100
|
+
} else if (valueType === 'integer') {
|
|
101
|
+
configType = 'Analog';
|
|
102
|
+
} else {
|
|
103
|
+
configType = '--';
|
|
104
|
+
}
|
|
84
105
|
return [
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
? 'Digital'
|
|
96
|
-
: itemActionConfig?.value_type === 'integer'
|
|
97
|
-
? 'Analog'
|
|
98
|
-
: '--',
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: 3,
|
|
102
|
-
title: 'pin',
|
|
103
|
-
data: formatPIN() || '0',
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
id: 4,
|
|
107
|
-
title: 'pin_mode',
|
|
108
|
-
data: formatPinMode() || '--',
|
|
109
|
-
},
|
|
106
|
+
{ id: 1, title: 'config_name', data: configName },
|
|
107
|
+
{ id: 2, title: 'config_type', data: configType },
|
|
108
|
+
{ id: 3, title: 'pin', data: formatPIN() || '0' },
|
|
109
|
+
{ id: 4, title: 'pin_mode', data: formatPinMode() || '--' },
|
|
110
|
+
];
|
|
111
|
+
}
|
|
112
|
+
if (isVirtualPin) {
|
|
113
|
+
return [
|
|
114
|
+
{ id: 1, title: 'config_name', data: configName },
|
|
115
|
+
{ id: 2, title: 'pin', data: formatPIN() || '0' },
|
|
110
116
|
];
|
|
111
117
|
}
|
|
112
118
|
if (isAction) {
|
|
@@ -137,6 +143,7 @@ const DetailConfigActionInternal = () => {
|
|
|
137
143
|
isConfigRead,
|
|
138
144
|
isConfigWrite,
|
|
139
145
|
isInternal,
|
|
146
|
+
isVirtualPin,
|
|
140
147
|
itemActionConfig?.action?.name,
|
|
141
148
|
itemActionConfig?.config?.name,
|
|
142
149
|
itemActionConfig?.pin,
|
|
@@ -144,21 +151,12 @@ const DetailConfigActionInternal = () => {
|
|
|
144
151
|
itemActionConfig?.value_type,
|
|
145
152
|
]);
|
|
146
153
|
|
|
147
|
-
const title =
|
|
148
|
-
()
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
isConfigRead,
|
|
154
|
-
isConfigWrite,
|
|
155
|
-
itemActionConfig?.config?.name,
|
|
156
|
-
itemActionConfig?.action?.name,
|
|
157
|
-
isAction,
|
|
158
|
-
]
|
|
159
|
-
);
|
|
160
|
-
|
|
161
|
-
const subTitle = useMemo(() => device?.sensor?.name || '--', [device]);
|
|
154
|
+
const title =
|
|
155
|
+
((isConfigRead || isConfigWrite || isVirtualPin) &&
|
|
156
|
+
itemActionConfig?.config?.name) ||
|
|
157
|
+
(isAction && itemActionConfig?.action?.name) ||
|
|
158
|
+
'';
|
|
159
|
+
const subTitle = device?.sensor?.name || '--';
|
|
162
160
|
|
|
163
161
|
return (
|
|
164
162
|
<View style={styles.wrap}>
|
|
@@ -288,6 +288,7 @@ describe('Test DeviceInternalDetail', () => {
|
|
|
288
288
|
isConfigWrite: true,
|
|
289
289
|
itemActionConfig: 1,
|
|
290
290
|
isInternal: true,
|
|
291
|
+
isVirtualPin: false,
|
|
291
292
|
board: undefined,
|
|
292
293
|
virtualConfigPins: [],
|
|
293
294
|
writeConfigPins: [
|
|
@@ -339,6 +340,7 @@ describe('Test DeviceInternalDetail', () => {
|
|
|
339
340
|
itemActionConfig: 1,
|
|
340
341
|
board: undefined,
|
|
341
342
|
isInternal: true,
|
|
343
|
+
isVirtualPin: false,
|
|
342
344
|
writeConfigPins: [],
|
|
343
345
|
virtualConfigPins: [],
|
|
344
346
|
});
|
|
@@ -360,7 +362,9 @@ describe('Test DeviceInternalDetail', () => {
|
|
|
360
362
|
itemActionConfig: 1,
|
|
361
363
|
board: undefined,
|
|
362
364
|
isInternal: true,
|
|
365
|
+
isVirtualPin: false,
|
|
363
366
|
writeConfigPins: undefined,
|
|
367
|
+
virtualConfigPins: undefined,
|
|
364
368
|
});
|
|
365
369
|
});
|
|
366
370
|
|
|
@@ -49,11 +49,17 @@ const DeviceInternalDetail = () => {
|
|
|
49
49
|
title: PERMISSION_TYPE.ACTION,
|
|
50
50
|
data: detailDeviceInternal?.actions,
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
id: 4,
|
|
54
|
+
title: PERMISSION_TYPE.VIRTUAL_PIN,
|
|
55
|
+
data: detailDeviceInternal?.config_virtual,
|
|
56
|
+
},
|
|
52
57
|
],
|
|
53
58
|
[
|
|
54
59
|
detailDeviceInternal?.actions,
|
|
55
60
|
detailDeviceInternal?.config_read,
|
|
56
61
|
detailDeviceInternal?.config_write,
|
|
62
|
+
detailDeviceInternal?.config_virtual,
|
|
57
63
|
]
|
|
58
64
|
);
|
|
59
65
|
|
|
@@ -114,8 +120,12 @@ const DeviceInternalDetail = () => {
|
|
|
114
120
|
return listTabs[selectedIndex]?.title === PERMISSION_TYPE.ACTION;
|
|
115
121
|
}, [listTabs, selectedIndex]);
|
|
116
122
|
|
|
123
|
+
const isVirtualPin = useMemo(() => {
|
|
124
|
+
return listTabs[selectedIndex]?.title === PERMISSION_TYPE.VIRTUAL_PIN;
|
|
125
|
+
}, [listTabs, selectedIndex]);
|
|
126
|
+
|
|
117
127
|
const loadData = useCallback(async () => {
|
|
118
|
-
if (isConfigRead || isConfigWrite) {
|
|
128
|
+
if (isConfigRead || isConfigWrite || isVirtualPin) {
|
|
119
129
|
fetchConfigActionInterval(gatewayId, device?.id);
|
|
120
130
|
}
|
|
121
131
|
if (isAction) {
|
|
@@ -128,6 +138,7 @@ const DeviceInternalDetail = () => {
|
|
|
128
138
|
isAction,
|
|
129
139
|
isConfigRead,
|
|
130
140
|
isConfigWrite,
|
|
141
|
+
isVirtualPin,
|
|
131
142
|
]);
|
|
132
143
|
|
|
133
144
|
useEffect(() => {
|
|
@@ -144,6 +155,7 @@ const DeviceInternalDetail = () => {
|
|
|
144
155
|
isConfigRead,
|
|
145
156
|
isConfigWrite,
|
|
146
157
|
isAction,
|
|
158
|
+
isVirtualPin,
|
|
147
159
|
isInternal,
|
|
148
160
|
board,
|
|
149
161
|
writeConfigPins: detailDeviceInternal?.config_write,
|
|
@@ -159,6 +171,7 @@ const DeviceInternalDetail = () => {
|
|
|
159
171
|
isConfigRead,
|
|
160
172
|
isConfigWrite,
|
|
161
173
|
isInternal,
|
|
174
|
+
isVirtualPin,
|
|
162
175
|
navigate,
|
|
163
176
|
]
|
|
164
177
|
);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FlatList } from 'react-native';
|
|
3
3
|
import { create, act } from 'react-test-renderer';
|
|
4
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
4
5
|
|
|
5
6
|
import { SCProvider } from '../../../../context';
|
|
6
7
|
import { mockSCStore } from '../../../../context/mockStore';
|
|
@@ -8,6 +9,28 @@ import GatewayConnectionMethods from '..';
|
|
|
8
9
|
import { HeaderCustom } from '../../../../commons';
|
|
9
10
|
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
10
11
|
import { getTranslate } from '../../../../utils/I18n';
|
|
12
|
+
import api from '../../../../utils/Apis/axios';
|
|
13
|
+
import { API } from '../../../../configs';
|
|
14
|
+
|
|
15
|
+
const mock = new MockAdapter(api.axiosInstance);
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useNavigation: () => ({
|
|
20
|
+
navigate: jest.fn(),
|
|
21
|
+
pop: jest.fn(),
|
|
22
|
+
}),
|
|
23
|
+
useRoute: jest.fn().mockReturnValue({
|
|
24
|
+
params: {
|
|
25
|
+
methodsConnection: [
|
|
26
|
+
{ zigbee_gateway: 1 },
|
|
27
|
+
{ modbus_gateway: 1 },
|
|
28
|
+
{ arduino_gateway: 1 },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
});
|
|
11
34
|
|
|
12
35
|
const wrapComponent = () => (
|
|
13
36
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -19,6 +42,7 @@ describe('Test GatewayConnectionMethods', () => {
|
|
|
19
42
|
let tree;
|
|
20
43
|
|
|
21
44
|
it('test render GatewayConnectionMethods', async () => {
|
|
45
|
+
mock.onGet(API.DEV_MODE.MODBUS.DETAIL(1)).reply(200, { baud_speed: 9600 });
|
|
22
46
|
await act(async () => {
|
|
23
47
|
tree = await create(wrapComponent());
|
|
24
48
|
});
|
|
@@ -37,5 +61,6 @@ describe('Test GatewayConnectionMethods', () => {
|
|
|
37
61
|
})
|
|
38
62
|
);
|
|
39
63
|
expect(flatList).toHaveLength(1);
|
|
64
|
+
expect(mock.history.get).toHaveLength(1);
|
|
40
65
|
});
|
|
41
66
|
});
|