@eohjsc/react-native-smart-city 0.3.48 → 0.3.50
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 +4 -4
- package/src/Images/DevMode/file_copy.svg +3 -0
- package/src/Images/DevMode/inforCode.png +0 -0
- package/src/Images/DevMode/inforCode@2x.png +0 -0
- package/src/Images/DevMode/inforCode@3x.png +0 -0
- package/src/commons/Action/__test__/ItemQuickAction.test.js +0 -7
- package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -8
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -2
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +1 -8
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +99 -1
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +28 -11
- package/src/commons/ActionTemplate/__test__/CurtainAction.test.js +64 -0
- package/src/commons/ActionTemplate/__test__/OnOffSmartLockAction.test.js +54 -0
- package/src/commons/ActionTemplate/__test__/index.test.js +0 -7
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +3 -3
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +1 -1
- package/src/commons/Dashboard/MyUnit/index.js +30 -4
- package/src/commons/DevMode/Styles/ItemStyles.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +0 -1
- package/src/commons/Device/PMSensor/PMSensorIndicatior.js +4 -1
- package/src/commons/FourButtonFilterHistory/__test__/FourButtonFilterHistory.test.js +0 -7
- package/src/commons/Header/HeaderCustom.js +13 -6
- package/src/commons/MediaPlayer/__test__/index.test.js +0 -7
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +0 -1
- package/src/commons/MenuActionMore/index.js +4 -1
- package/src/commons/NavBar/index.js +1 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +0 -7
- package/src/commons/OneTapTemplate/__test__/OptionsDropdownActionTemplate.test.js +0 -7
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +0 -7
- package/src/commons/Processing/styles.js +0 -2
- package/src/commons/RowItem/index.js +6 -1
- package/src/commons/SelectUnit/index.js +4 -1
- package/src/commons/Sharing/WrapHeaderScrollable.js +5 -4
- package/src/commons/StatusBox/styles.js +8 -3
- package/src/commons/SubUnit/__test__/Favorites.test.js +0 -7
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +0 -7
- package/src/commons/Tabbar/__test__/index.test.js +0 -7
- package/src/commons/Unit/__test__/HeaderUnit.test.js +0 -5
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +9 -9
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +41 -39
- package/src/configs/API.js +28 -0
- package/src/configs/AccessibilityLabel.js +13 -0
- package/src/configs/Colors.js +4 -0
- package/src/configs/Constants.js +8 -0
- package/src/configs/Images.js +1 -0
- package/src/configs/SCConfig.js +3 -0
- package/src/context/actionType.ts +8 -1
- package/src/context/mockStore.ts +8 -2
- package/src/context/reducer.ts +27 -4
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +46 -0
- package/src/hooks/IoT/useBluetoothConnection.js +78 -4
- package/src/hooks/IoT/useBluetoothDeviceConnected.js +1 -1
- package/src/iot/RemoteControl/Bluetooth.js +0 -16
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +0 -25
- package/src/navigations/AddDeviceStack.js +0 -5
- package/src/navigations/Main.js +39 -0
- package/src/navigations/UnitStack.js +23 -9
- package/src/screens/AQIGuide/index.js +2 -2
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +0 -7
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +0 -7
- package/src/screens/ActivityLog/__test__/index.test.js +0 -7
- package/src/screens/ActivityLog/styles/itemLogStyles.js +1 -0
- package/src/screens/AddLocationMaps/__test__/index.test.js +0 -7
- package/src/screens/AddNewAction/SelectAction.js +22 -18
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +35 -16
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +0 -7
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +1 -5
- package/src/screens/AddNewGateway/ConnectingDevice.js +25 -3
- package/src/screens/AddNewGateway/ConnectingWifiGuide.js +1 -1
- package/src/screens/AddNewGateway/ConnectingWifiGuideStyles.js +10 -0
- package/src/screens/AddNewGateway/ConnectingZigbeeDevice.js +5 -6
- package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -1
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +2 -5
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +29 -6
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +0 -7
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +0 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +0 -7
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +0 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +0 -7
- package/src/screens/Device/__test__/detail.test.js +1 -1
- package/src/screens/Device/detail.js +12 -6
- package/src/screens/Device/hooks/useDisconnectedDevice.js +26 -7
- package/src/screens/EmergencyContacts/__test__/hooks.test.js +79 -0
- package/src/screens/Gateway/DetailConfigActionModbus/__test__/index.test.js +138 -0
- package/src/screens/Gateway/DetailConfigActionModbus/index.js +180 -0
- package/src/screens/Gateway/DetailConfigActionModbus/styles.js +9 -0
- package/src/screens/Gateway/DetailConfigActionZigbee/__test__/index.test.js +73 -0
- package/src/screens/Gateway/DetailConfigActionZigbee/index.js +62 -0
- package/src/screens/Gateway/DetailConfigActionZigbee/styles.js +9 -0
- package/src/screens/Gateway/DeviceGatewayInfo/__test__/index.test.js +73 -0
- package/src/screens/Gateway/DeviceGatewayInfo/index.js +96 -0
- package/src/screens/Gateway/DeviceGatewayInfo/styles.js +9 -0
- package/src/screens/Gateway/DeviceModbusDetail/__test__/index.test.js +393 -0
- package/src/screens/Gateway/DeviceModbusDetail/index.js +176 -0
- package/src/screens/Gateway/DeviceModbusDetail/styles.js +12 -0
- package/src/screens/Gateway/DeviceZigbeeDetail/__test__/index.test.js +265 -0
- package/src/screens/Gateway/DeviceZigbeeDetail/index.js +148 -0
- package/src/screens/Gateway/DeviceZigbeeDetail/styles.js +12 -0
- package/src/screens/Gateway/GatewayConnectionMethods/__test__/index.test.js +37 -0
- package/src/screens/Gateway/GatewayConnectionMethods/index.js +73 -0
- package/src/screens/Gateway/GatewayConnectionMethods/styles.js +45 -0
- package/src/screens/Gateway/GatewayDetail/__test__/index.test.js +298 -0
- package/src/screens/Gateway/GatewayDetail/index.js +148 -0
- package/src/screens/Gateway/GatewayDetail/styles.js +12 -0
- package/src/screens/Gateway/GatewayInfo/__test__/index.test.js +137 -0
- package/src/screens/Gateway/GatewayInfo/index.js +115 -0
- package/src/screens/Gateway/GatewayInfo/styles.js +9 -0
- package/src/screens/Gateway/__test__/index.test.js +58 -0
- package/src/screens/Gateway/components/Detail/__test__/index.test.js +46 -0
- package/src/screens/Gateway/components/Detail/index.js +62 -0
- package/src/screens/Gateway/components/Detail/styles.js +27 -0
- package/src/screens/Gateway/components/DetailActionModbus/__test__/index.test.js +49 -0
- package/src/screens/Gateway/components/DetailActionModbus/index.js +52 -0
- package/src/screens/Gateway/components/DetailActionModbus/styles.js +32 -0
- package/src/screens/Gateway/components/DetailConfigAction/__test__/index.test.js +59 -0
- package/src/screens/Gateway/components/DetailConfigAction/index.js +69 -0
- package/src/screens/Gateway/components/DetailConfigAction/styles.js +21 -0
- package/src/screens/Gateway/components/GatewayItem/__test__/index.test.js +1 -1
- package/src/screens/Gateway/components/GatewayItem/styles.js +4 -33
- package/src/screens/Gateway/components/Information/__test__/index.test.js +70 -0
- package/src/screens/Gateway/components/Information/index.js +116 -0
- package/src/screens/Gateway/components/Information/styles.js +59 -0
- package/src/screens/Gateway/components/RowItem/__test__/index.test.js +67 -0
- package/src/screens/Gateway/components/RowItem/index.js +65 -0
- package/src/screens/Gateway/components/RowItem/styles.js +25 -0
- package/src/screens/Gateway/components/TabPaneCT/__test__/index.test.js +98 -0
- package/src/screens/Gateway/components/TabPaneCT/index.js +134 -0
- package/src/screens/Gateway/components/TabPaneCT/styles.js +58 -0
- package/src/screens/Gateway/hooks/__test__/index.test.js +93 -0
- package/src/screens/Gateway/hooks/useGateway.js +110 -16
- package/src/screens/Gateway/index.js +19 -3
- package/src/screens/Gateway/styles.js +6 -8
- package/src/screens/Gateway/utils/index.js +16 -0
- package/src/screens/GuestInfo/__test__/index.test.js +0 -7
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +0 -7
- package/src/screens/HanetCamera/__test__/Detail.test.js +0 -7
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +0 -7
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +0 -7
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +0 -6
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +0 -7
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +0 -7
- package/src/screens/Notification/__test__/Notification.test.js +0 -7
- package/src/screens/Notification/__test__/NotificationItem.test.js +1 -0
- package/src/screens/Notification/components/NotificationItem.js +16 -1
- package/src/screens/Notification/index.js +1 -0
- package/src/screens/Notification/styles/indexStyles.js +3 -0
- package/src/screens/PlayBackCamera/__test__/index.test.js +0 -1
- package/src/screens/ScriptDetail/__test__/index.test.js +0 -7
- package/src/screens/SelectUnit/__test__/index.test.js +0 -1
- package/src/screens/SetSchedule/__test__/index.test.js +0 -7
- package/src/screens/Sharing/Components/__test__/DeviceItem.test.js +0 -7
- package/src/screens/Sharing/Components/__test__/ItemChangeRole.test.js +0 -7
- package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +0 -7
- package/src/screens/Sharing/SelectPermission.js +2 -2
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +0 -6
- package/src/screens/Sharing/hooks/__test__/index.test.js +80 -0
- package/src/screens/SmartAccount/ListDevice/__test__/DeviceItem.test.js +0 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +26 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +29 -11
- package/src/screens/SmartIr/__test__/ButtonsBottom.test.js +0 -6
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +1 -6
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +1 -6
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -6
- package/src/screens/SubUnit/AddSubUnit.js +1 -0
- package/src/screens/SubUnit/ManageSubUnit.js +4 -1
- package/src/screens/SubUnit/hooks/__test__/useEmergencyContacts.test.js +34 -0
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +0 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +1 -8
- package/src/screens/Template/__test__/GatewayList.test.js +1 -1
- package/src/screens/Template/__test__/Information.test.js +1 -1
- package/src/screens/Unit/Detail.js +24 -18
- package/src/screens/Unit/__test__/AddMenu.test.js +0 -7
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +1 -1
- package/src/screens/Unit/__test__/ChooseLocation.test.js +0 -7
- package/src/screens/Unit/__test__/Detail.test.js +63 -26
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +0 -7
- package/src/screens/Unit/__test__/SelectAddress.test.js +0 -7
- package/src/screens/Unit/__test__/SmartAccount.test.js +0 -7
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -7
- package/src/screens/Unit/__test__/Summaries.test.js +0 -7
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +4 -3
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/utils/Apis/axios.js +52 -36
- package/src/utils/I18n/translations/en.json +32 -0
- package/src/utils/I18n/translations/vi.json +33 -1
- package/src/utils/Route/index.js +8 -0
- package/src/utils/Storage.js +0 -4
- package/src/utils/Utils.js +1 -1
- package/src/utils/__test__/Utils.test.js +27 -3
- package/src/screens/AddNewDevice/ConnectingDevices.js +0 -62
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +0 -110
|
@@ -23,13 +23,6 @@ jest.mock('@react-navigation/native', () => {
|
|
|
23
23
|
};
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
jest.mock('react', () => {
|
|
27
|
-
return {
|
|
28
|
-
...jest.requireActual('react'),
|
|
29
|
-
memo: (x) => x,
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
26
|
const wrapComponent = (route) => (
|
|
34
27
|
<SCProvider initState={mockSCStore({})}>
|
|
35
28
|
<SelectAction route={route} />
|
|
@@ -101,7 +94,8 @@ describe('Test SelectAction', () => {
|
|
|
101
94
|
const config1 = 1,
|
|
102
95
|
config2 = 2,
|
|
103
96
|
config3 = 3,
|
|
104
|
-
config4 = 4
|
|
97
|
+
config4 = 4,
|
|
98
|
+
config5 = 5;
|
|
105
99
|
const response = {
|
|
106
100
|
status: 200,
|
|
107
101
|
success: true,
|
|
@@ -152,13 +146,25 @@ describe('Test SelectAction', () => {
|
|
|
152
146
|
text_format: '{number} \u00b0C',
|
|
153
147
|
},
|
|
154
148
|
},
|
|
149
|
+
{
|
|
150
|
+
title: '',
|
|
151
|
+
template: 'NumberUpDownActionTemplate',
|
|
152
|
+
configuration: {
|
|
153
|
+
config: config4,
|
|
154
|
+
allow_config_store_value: true,
|
|
155
|
+
action: '11111111-6c1a-452d-a1d1-87a314c20528',
|
|
156
|
+
min_value: 12,
|
|
157
|
+
max_value: 20,
|
|
158
|
+
text_format: '{number} \u00b0C',
|
|
159
|
+
},
|
|
160
|
+
},
|
|
155
161
|
{
|
|
156
162
|
title: '',
|
|
157
163
|
template: 'StatesGridActionTemplate',
|
|
158
164
|
configuration: {
|
|
159
165
|
options: [
|
|
160
166
|
{
|
|
161
|
-
config:
|
|
167
|
+
config: config5,
|
|
162
168
|
is_on_value: 1,
|
|
163
169
|
action: '800ff454-4e2a-4a38-bad6-1bded728193e',
|
|
164
170
|
allow_config_store_value: true,
|
|
@@ -179,7 +185,7 @@ describe('Test SelectAction', () => {
|
|
|
179
185
|
const renderActionItem = instance.find(
|
|
180
186
|
(el) => el.props.accessibilityLabel === AccessibilityLabel.ACTION_ITEM
|
|
181
187
|
);
|
|
182
|
-
expect(renderActionItem.props.data.length).toBe(
|
|
188
|
+
expect(renderActionItem.props.data.length).toBe(5);
|
|
183
189
|
|
|
184
190
|
const simpleActionOn = instance.find(
|
|
185
191
|
(el) =>
|
|
@@ -209,22 +215,27 @@ describe('Test SelectAction', () => {
|
|
|
209
215
|
await touchOpacity.props.onPress();
|
|
210
216
|
});
|
|
211
217
|
|
|
212
|
-
const buttonNumberUp = instance.
|
|
218
|
+
const buttonNumberUp = instance.findAll(
|
|
213
219
|
(item) =>
|
|
214
220
|
item.props.accessibilityLabel ===
|
|
215
221
|
AccessibilityLabel.NUMBER_UP_DOWN_ACTION_UP &&
|
|
216
222
|
item.type === TouchableOpacity
|
|
217
223
|
);
|
|
218
|
-
|
|
224
|
+
expect(buttonNumberUp).toHaveLength(2);
|
|
225
|
+
|
|
226
|
+
const buttonSaveNumberAction = instance.findAll(
|
|
219
227
|
(item) =>
|
|
220
228
|
item.props.accessibilityLabel ===
|
|
221
229
|
AccessibilityLabel.NUMBER_UP_DOWN_ACTION_DONE &&
|
|
222
230
|
item.type === TouchableOpacity
|
|
223
231
|
);
|
|
232
|
+
expect(buttonSaveNumberAction).toHaveLength(2);
|
|
224
233
|
|
|
225
234
|
await act(async () => {
|
|
226
|
-
await buttonNumberUp.props.onPress();
|
|
227
|
-
await
|
|
235
|
+
await buttonNumberUp[0].props.onPress();
|
|
236
|
+
await buttonNumberUp[1].props.onPress();
|
|
237
|
+
await buttonSaveNumberAction[0].props.onPress();
|
|
238
|
+
await buttonSaveNumberAction[1].props.onPress();
|
|
228
239
|
});
|
|
229
240
|
|
|
230
241
|
const chooseMode = instance.find(
|
|
@@ -234,7 +245,7 @@ describe('Test SelectAction', () => {
|
|
|
234
245
|
item.type === TouchableOpacity
|
|
235
246
|
);
|
|
236
247
|
await act(async () => {
|
|
237
|
-
await chooseMode.props.onPress(response.data[
|
|
248
|
+
await chooseMode.props.onPress(response.data[4].configuration.options[0]);
|
|
238
249
|
});
|
|
239
250
|
|
|
240
251
|
mock.onPost(API.AUTOMATE.ADD_SCRIPT_ACTION(1)).reply(200);
|
|
@@ -275,9 +286,17 @@ describe('Test SelectAction', () => {
|
|
|
275
286
|
config_value: 29,
|
|
276
287
|
},
|
|
277
288
|
},
|
|
289
|
+
{
|
|
290
|
+
action: '11111111-6c1a-452d-a1d1-87a314c20528',
|
|
291
|
+
data: {
|
|
292
|
+
temperature: 28,
|
|
293
|
+
config_id: config4,
|
|
294
|
+
config_value: 28,
|
|
295
|
+
},
|
|
296
|
+
},
|
|
278
297
|
{
|
|
279
298
|
action: '800ff454-4e2a-4a38-bad6-1bded728193e',
|
|
280
|
-
data: { config_id:
|
|
299
|
+
data: { config_id: config5, config_value: 1 },
|
|
281
300
|
},
|
|
282
301
|
],
|
|
283
302
|
unit: 1,
|
|
@@ -32,13 +32,6 @@ jest.mock('@react-navigation/native', () => {
|
|
|
32
32
|
};
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
jest.mock('react', () => {
|
|
36
|
-
return {
|
|
37
|
-
...jest.requireActual('react'),
|
|
38
|
-
memo: (x) => x,
|
|
39
|
-
};
|
|
40
|
-
});
|
|
41
|
-
|
|
42
35
|
const wrapComponent = (route) => (
|
|
43
36
|
<SCProvider initState={mockSCStore({})}>
|
|
44
37
|
<SelectSensorDevices route={route} />
|
|
@@ -22,10 +22,6 @@ const wrapComponent = (route) => (
|
|
|
22
22
|
|
|
23
23
|
const mock = new MockAdapter(api.axiosInstance);
|
|
24
24
|
|
|
25
|
-
jest.mock('react', () => {
|
|
26
|
-
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
27
|
-
});
|
|
28
|
-
|
|
29
25
|
const mockedNavigate = jest.fn();
|
|
30
26
|
const mockedGoBack = jest.fn();
|
|
31
27
|
|
|
@@ -101,7 +97,7 @@ describe('Test AddNewDevice', () => {
|
|
|
101
97
|
});
|
|
102
98
|
|
|
103
99
|
it('fetchDetails fail', async () => {
|
|
104
|
-
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(
|
|
100
|
+
mock.onGet(API.UNIT.UNIT_DETAIL(1)).reply(500);
|
|
105
101
|
await act(async () => {
|
|
106
102
|
tree = await create(wrapComponent(route));
|
|
107
103
|
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { useNavigation } from '@react-navigation/native';
|
|
2
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useNavigation } from '@react-navigation/native';
|
|
3
|
+
import { Alert } from 'react-native';
|
|
4
|
+
|
|
3
5
|
import Processing from '../../commons/Processing';
|
|
4
6
|
import Routes from '../../utils/Route';
|
|
7
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
5
8
|
|
|
9
|
+
let timeout;
|
|
6
10
|
const ConnectingDevice = ({
|
|
7
11
|
title,
|
|
8
12
|
fail,
|
|
@@ -13,13 +17,13 @@ const ConnectingDevice = ({
|
|
|
13
17
|
chipId,
|
|
14
18
|
sensorId,
|
|
15
19
|
addDeviceType,
|
|
16
|
-
goBack,
|
|
17
20
|
showPopupTurnOnGuide,
|
|
18
21
|
setHidePopupTurnOnGuide,
|
|
19
22
|
setIsRecallChipScan,
|
|
20
23
|
isChangeAddressSuccess,
|
|
21
24
|
}) => {
|
|
22
|
-
const
|
|
25
|
+
const t = useTranslations();
|
|
26
|
+
const { navigate, goBack } = useNavigation();
|
|
23
27
|
|
|
24
28
|
const [renameParams, setRenameParams] = useState({
|
|
25
29
|
unitId,
|
|
@@ -31,11 +35,29 @@ const ConnectingDevice = ({
|
|
|
31
35
|
|
|
32
36
|
const complete = useCallback(
|
|
33
37
|
(deviceInfo) => {
|
|
38
|
+
timeout && clearTimeout(timeout);
|
|
34
39
|
navigate(Routes.RenameNewDevices, renameParams);
|
|
35
40
|
},
|
|
36
41
|
[navigate, renameParams]
|
|
37
42
|
);
|
|
38
43
|
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
timeout = setTimeout(() => {
|
|
46
|
+
Alert.alert(t('continue_to_wait'), t('it_has_been_5_minutes'), [
|
|
47
|
+
{
|
|
48
|
+
text: t('back'),
|
|
49
|
+
onPress: goBack,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
text: t('continue'),
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
}, 300 * 1000); // when test, it takes more than 3 min
|
|
56
|
+
return () => {
|
|
57
|
+
clearTimeout(timeout);
|
|
58
|
+
};
|
|
59
|
+
}, [fail, goBack, t]);
|
|
60
|
+
|
|
39
61
|
const onMessage = useCallback(
|
|
40
62
|
(data) => {
|
|
41
63
|
setRenameParams((oldParams) => {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
1
2
|
import { Dimensions, StyleSheet } from 'react-native';
|
|
3
|
+
import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
2
4
|
import { Colors } from '../../configs';
|
|
3
5
|
|
|
4
6
|
const customWidth = (Dimensions.get('window').width - 32 - 15) / 2; // set gap between flex item is 15px
|
|
@@ -55,4 +57,12 @@ export default StyleSheet.create({
|
|
|
55
57
|
textAlign: 'center',
|
|
56
58
|
lineHeight: 24,
|
|
57
59
|
},
|
|
60
|
+
bottomButtonView: {
|
|
61
|
+
marginBottom:
|
|
62
|
+
getBottomSpace() +
|
|
63
|
+
Platform.select({
|
|
64
|
+
android: 10,
|
|
65
|
+
ios: -10,
|
|
66
|
+
}),
|
|
67
|
+
},
|
|
58
68
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useNavigation } from '@react-navigation/native';
|
|
2
|
-
import React, { useCallback
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
3
|
import { Alert } from 'react-native';
|
|
4
|
+
|
|
4
5
|
import API from '../../configs/API';
|
|
5
6
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
7
|
import { axiosPost } from '../../utils/Apis/axios';
|
|
@@ -10,14 +11,13 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
10
11
|
const t = useTranslations();
|
|
11
12
|
const { goBack } = useNavigation();
|
|
12
13
|
const { unitId, subUnit, chipId } = route?.params || {};
|
|
13
|
-
const [sensorId, setSensorId] = useState(null);
|
|
14
14
|
|
|
15
15
|
const fail = useCallback(
|
|
16
16
|
(message) => {
|
|
17
17
|
Alert.alert(t('fail_add_zigbee_device'), message, [
|
|
18
18
|
{
|
|
19
19
|
text: t('ok'),
|
|
20
|
-
onPress:
|
|
20
|
+
onPress: goBack,
|
|
21
21
|
},
|
|
22
22
|
]);
|
|
23
23
|
},
|
|
@@ -39,9 +39,8 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
39
39
|
fail(JSON.stringify(problem || data));
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
setSensorId(data.id);
|
|
43
42
|
},
|
|
44
|
-
[chipId, fail, subUnit, unitId]
|
|
43
|
+
[chipId, fail, subUnit?.id, unitId]
|
|
45
44
|
);
|
|
46
45
|
|
|
47
46
|
return (
|
|
@@ -53,7 +52,7 @@ const ConnectingZigbeeDevice = ({ route }) => {
|
|
|
53
52
|
unitId={unitId}
|
|
54
53
|
subUnit={subUnit}
|
|
55
54
|
chipId={chipId}
|
|
56
|
-
sensorId={
|
|
55
|
+
sensorId={null}
|
|
57
56
|
/>
|
|
58
57
|
);
|
|
59
58
|
};
|
|
@@ -105,6 +105,7 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
105
105
|
}
|
|
106
106
|
if (ssid !== currentSsid) {
|
|
107
107
|
clearInterval(checkWifiInterval);
|
|
108
|
+
setIsShowPopupPassword(false);
|
|
108
109
|
navigation.navigate(Routes.ConnectingWifiDevice, {
|
|
109
110
|
unitId,
|
|
110
111
|
subUnit,
|
|
@@ -149,7 +150,7 @@ const ShareWifiPassword = ({ route }) => {
|
|
|
149
150
|
|
|
150
151
|
socket.on('message', (msg, rinfo) => {
|
|
151
152
|
if (handleSocketOnMsg(currentSsid, msg)) {
|
|
152
|
-
socket
|
|
153
|
+
socket?.close();
|
|
153
154
|
socket = null;
|
|
154
155
|
}
|
|
155
156
|
});
|
|
@@ -20,10 +20,6 @@ const wrapComponent = (route) => (
|
|
|
20
20
|
|
|
21
21
|
const mock = new MockAdapter(api.axiosInstance);
|
|
22
22
|
|
|
23
|
-
jest.mock('react', () => {
|
|
24
|
-
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
25
|
-
});
|
|
26
|
-
|
|
27
23
|
const mockedNavigate = jest.fn();
|
|
28
24
|
const mockedGoBack = jest.fn();
|
|
29
25
|
|
|
@@ -15,10 +15,6 @@ const wrapComponent = (route) => (
|
|
|
15
15
|
|
|
16
16
|
const mock = new MockAdapter(api.axiosInstance);
|
|
17
17
|
|
|
18
|
-
jest.mock('react', () => {
|
|
19
|
-
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
20
|
-
});
|
|
21
|
-
|
|
22
18
|
const mockedNavigate = jest.fn();
|
|
23
19
|
const mockedGoBack = jest.fn();
|
|
24
20
|
|
|
@@ -18,10 +18,6 @@ const wrapComponent = (route) => (
|
|
|
18
18
|
|
|
19
19
|
const mock = new MockAdapter(api.axiosInstance);
|
|
20
20
|
|
|
21
|
-
jest.mock('react', () => {
|
|
22
|
-
return { ...jest.requireActual('react'), memo: (x) => x };
|
|
23
|
-
});
|
|
24
|
-
|
|
25
21
|
const mockedNavigate = jest.fn();
|
|
26
22
|
const mockedGoBack = jest.fn();
|
|
27
23
|
|
|
@@ -64,7 +60,8 @@ describe('Test connecting wifi device', () => {
|
|
|
64
60
|
});
|
|
65
61
|
const instance = tree.root;
|
|
66
62
|
expect(instance.findAllByType(Processing)).toHaveLength(1);
|
|
67
|
-
jest.
|
|
63
|
+
jest.runOnlyPendingTimers();
|
|
64
|
+
|
|
68
65
|
expect(mock.history.post).toHaveLength(0);
|
|
69
66
|
const connectingDevice = instance.findByType(ConnectingDevice);
|
|
70
67
|
await act(async () => {
|
|
@@ -8,6 +8,7 @@ import { SCProvider } from '../../../context';
|
|
|
8
8
|
import { mockSCStore } from '../../../context/mockStore';
|
|
9
9
|
import api from '../../../utils/Apis/axios';
|
|
10
10
|
import Processing from '../../../commons/Processing';
|
|
11
|
+
import { Alert } from 'react-native';
|
|
11
12
|
|
|
12
13
|
const wrapComponent = (route) => (
|
|
13
14
|
<SCProvider initState={mockSCStore({})}>
|
|
@@ -17,13 +18,21 @@ const wrapComponent = (route) => (
|
|
|
17
18
|
|
|
18
19
|
const mock = new MockAdapter(api.axiosInstance);
|
|
19
20
|
|
|
20
|
-
jest.mock('react', () => {
|
|
21
|
-
|
|
21
|
+
jest.mock('react-native', () => {
|
|
22
|
+
const RN = jest.requireActual('react-native');
|
|
23
|
+
return Object.setPrototypeOf(
|
|
24
|
+
{
|
|
25
|
+
Alert: {
|
|
26
|
+
...RN.Alert,
|
|
27
|
+
alert: jest.fn(),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
RN
|
|
31
|
+
);
|
|
22
32
|
});
|
|
23
33
|
|
|
24
34
|
const mockedNavigate = jest.fn();
|
|
25
35
|
const mockedGoBack = jest.fn();
|
|
26
|
-
|
|
27
36
|
jest.mock('@react-navigation/native', () => {
|
|
28
37
|
return {
|
|
29
38
|
...jest.requireActual('@react-navigation/native'),
|
|
@@ -66,10 +75,21 @@ describe('Test connecting modbus device', () => {
|
|
|
66
75
|
expect(mock.history.post).toHaveLength(1);
|
|
67
76
|
});
|
|
68
77
|
|
|
69
|
-
it('
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
it('timeout', async () => {
|
|
79
|
+
jest.useFakeTimers();
|
|
80
|
+
|
|
81
|
+
await act(async () => {
|
|
82
|
+
tree = await create(wrapComponent(route));
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
await act(async () => {
|
|
86
|
+
jest.runOnlyPendingTimers();
|
|
72
87
|
});
|
|
88
|
+
expect(Alert.alert).toBeCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('receive sensor-id from channel then rename sensor-id', async () => {
|
|
92
|
+
mock.onPost().reply(200, {});
|
|
73
93
|
await act(async () => {
|
|
74
94
|
tree = await create(wrapComponent(route));
|
|
75
95
|
});
|
|
@@ -80,6 +100,9 @@ describe('Test connecting modbus device', () => {
|
|
|
80
100
|
channel = channels[key];
|
|
81
101
|
}
|
|
82
102
|
}
|
|
103
|
+
await act(async () => {
|
|
104
|
+
await channel.trigger('progress', { data: { sensorId: 1 } });
|
|
105
|
+
});
|
|
83
106
|
await act(async () => {
|
|
84
107
|
await channel.trigger('progress', { success: 1 });
|
|
85
108
|
});
|
|
@@ -18,13 +18,6 @@ const wrapComponent = (route) => (
|
|
|
18
18
|
|
|
19
19
|
const mock = new MockAdapter(api.axiosInstance);
|
|
20
20
|
|
|
21
|
-
jest.mock('react', () => {
|
|
22
|
-
return {
|
|
23
|
-
...jest.requireActual('react'),
|
|
24
|
-
memo: (x) => x,
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
|
|
28
21
|
const mockedNavigate = jest.fn();
|
|
29
22
|
const mockedGoBack = jest.fn();
|
|
30
23
|
|
|
@@ -23,13 +23,6 @@ const wrapComponent = (route) => (
|
|
|
23
23
|
|
|
24
24
|
const mock = new MockAdapter(api.axiosInstance);
|
|
25
25
|
|
|
26
|
-
jest.mock('react', () => {
|
|
27
|
-
return {
|
|
28
|
-
...jest.requireActual('react'),
|
|
29
|
-
memo: (x) => x,
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
|
|
33
26
|
const mockPop = jest.fn();
|
|
34
27
|
const mockSetSensorDetail = jest.fn();
|
|
35
28
|
jest.mock('@react-navigation/native', () => {
|
|
@@ -735,7 +735,7 @@ describe('test DeviceDetail', () => {
|
|
|
735
735
|
});
|
|
736
736
|
|
|
737
737
|
it('Open popup ble when server down', async () => {
|
|
738
|
-
store.
|
|
738
|
+
store.bluetooth.isEnabled = false;
|
|
739
739
|
data_sensor_display.items[1].configuration.configuration.action1_data.command_prefer_over_bluetooth = true;
|
|
740
740
|
const responseDisplay = {
|
|
741
741
|
status: 200,
|
|
@@ -101,7 +101,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
101
101
|
(state) => state.app.isNetworkConnected
|
|
102
102
|
);
|
|
103
103
|
const isBluetoothEnabled = useSCContextSelector((state) => {
|
|
104
|
-
return state.
|
|
104
|
+
return state.bluetooth.isEnabled;
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
const { isConnected: isEoHBackendConnected } =
|
|
@@ -165,9 +165,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
165
165
|
}, [currentUserId, unit]);
|
|
166
166
|
|
|
167
167
|
const fetchUnitDetail = useCallback(async () => {
|
|
168
|
-
const { success, data } = await axiosGet(API.UNIT.UNIT_DETAIL(unitId)
|
|
169
|
-
headers: { 'Cache-Control': 'no-cache' },
|
|
170
|
-
});
|
|
168
|
+
const { success, data } = await axiosGet(API.UNIT.UNIT_DETAIL(unitId));
|
|
171
169
|
if (success) {
|
|
172
170
|
setUnit(data);
|
|
173
171
|
}
|
|
@@ -181,7 +179,15 @@ const DeviceDetail = ({ route }) => {
|
|
|
181
179
|
|
|
182
180
|
const { connectHomeAssistant } = useHomeAssistantConnection();
|
|
183
181
|
|
|
184
|
-
const {
|
|
182
|
+
const {
|
|
183
|
+
permissionsGranted: bluetoothPermGranted,
|
|
184
|
+
requestPerm: requestBluetoothPerm,
|
|
185
|
+
bluetoothScanDevices,
|
|
186
|
+
} = useBluetoothConnection();
|
|
187
|
+
|
|
188
|
+
useEffect(() => {
|
|
189
|
+
isDeviceHasBle && isBluetoothEnabled && requestBluetoothPerm();
|
|
190
|
+
}, [isDeviceHasBle, isBluetoothEnabled, requestBluetoothPerm]);
|
|
185
191
|
|
|
186
192
|
useEffect(() => {
|
|
187
193
|
if (
|
|
@@ -202,7 +208,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
202
208
|
bluetoothScanDevices([bluetooth.address]);
|
|
203
209
|
}
|
|
204
210
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
-
}, [isBluetoothEnabled, controlOptions, unit]);
|
|
211
|
+
}, [isBluetoothEnabled, bluetoothPermGranted, controlOptions, unit]);
|
|
206
212
|
|
|
207
213
|
const fetchSensorDetail = useCallback(async () => {
|
|
208
214
|
const { success, data, resp_status } = await axiosGet(
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useNavigation } from '@react-navigation/native';
|
|
2
|
-
import { useCallback, useEffect } from 'react';
|
|
3
|
-
import {
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { Linking, Platform } from 'react-native';
|
|
4
|
+
import AlertAsync from 'react-native-alert-async';
|
|
4
5
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
5
6
|
import { useSCContextSelector } from '../../../context';
|
|
6
|
-
import { enableBluetoothForAndroid } from '../../../iot/RemoteControl/Bluetooth';
|
|
7
7
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
8
|
+
import { enableBluetoothForAndroid } from '../../../iot/RemoteControl/Bluetooth';
|
|
9
|
+
import { useBluetoothConnection } from '../../../hooks/IoT';
|
|
8
10
|
|
|
9
11
|
export const useDisconnectedDevice = (
|
|
10
12
|
sensorName,
|
|
@@ -12,10 +14,27 @@ export const useDisconnectedDevice = (
|
|
|
12
14
|
serverDown
|
|
13
15
|
) => {
|
|
14
16
|
const t = useTranslations();
|
|
17
|
+
const { goBack } = useNavigation();
|
|
18
|
+
const [allowEnableBluetooth, setAllowEnableBluetooth] = useState(false);
|
|
19
|
+
|
|
15
20
|
const openBluetoothIOS = () => {
|
|
16
21
|
Linking.openURL('App-Prefs:Bluetooth');
|
|
17
22
|
};
|
|
18
|
-
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
permissionsGranted: bluetoothPermGranted,
|
|
26
|
+
requestPerm: requestBluetoothPerm,
|
|
27
|
+
} = useBluetoothConnection();
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
allowEnableBluetooth && bluetoothPermGranted && enableBluetoothForAndroid();
|
|
31
|
+
}, [allowEnableBluetooth, bluetoothPermGranted]);
|
|
32
|
+
|
|
33
|
+
const enableBluetooth = async () => {
|
|
34
|
+
setAllowEnableBluetooth(true);
|
|
35
|
+
!bluetoothPermGranted && (await requestBluetoothPerm());
|
|
36
|
+
};
|
|
37
|
+
|
|
19
38
|
const actions =
|
|
20
39
|
Platform.OS === 'ios'
|
|
21
40
|
? [
|
|
@@ -35,12 +54,12 @@ export const useDisconnectedDevice = (
|
|
|
35
54
|
},
|
|
36
55
|
{
|
|
37
56
|
text: 'Open',
|
|
38
|
-
onPress: () =>
|
|
57
|
+
onPress: () => enableBluetooth(),
|
|
39
58
|
},
|
|
40
59
|
];
|
|
41
60
|
|
|
42
61
|
const isBluetoothEnabled = useSCContextSelector(
|
|
43
|
-
(state) => state.
|
|
62
|
+
(state) => state.bluetooth.isEnabled
|
|
44
63
|
);
|
|
45
64
|
const isNetworkConnected = useSCContextSelector(
|
|
46
65
|
(state) => state.app.isNetworkConnected
|
|
@@ -61,7 +80,7 @@ export const useDisconnectedDevice = (
|
|
|
61
80
|
})
|
|
62
81
|
);
|
|
63
82
|
} else if (isBluetoothEnabled === false) {
|
|
64
|
-
|
|
83
|
+
AlertAsync(
|
|
65
84
|
'',
|
|
66
85
|
t(
|
|
67
86
|
'your_connection_to_the_server_was_disconnected_please_open_the_bluetooth_to_continue'
|