@eohjsc/react-native-smart-city 0.7.3-rc9 → 0.7.4
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/assets/images/Map/LocationPin.svg +10 -0
- package/package.json +4 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -2
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +7 -7
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
- package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +5 -5
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +6 -3
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/__test__/index.test.js +2 -2
- package/src/commons/ActionGroup/index.js +2 -2
- package/src/commons/Automate/ItemAutomate.js +9 -41
- package/src/commons/Automate/ItemConditionScriptDetail.js +109 -0
- package/src/commons/Automate/ItemConditionScriptDetailStyles.js +46 -0
- package/src/commons/Automate/__test__/ItemAutomate.test.js +0 -21
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/BottomButtonView/index.js +1 -0
- package/src/commons/ButtonPopup/index.js +3 -2
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
- package/src/commons/Device/FlatListItems.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
- package/src/commons/Device/HorizontalBarChart.js +54 -34
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Device/ItemDevice.js +2 -2
- package/src/commons/Device/SonosSpeaker/index.js +3 -3
- package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +6 -2
- package/src/commons/DisplayChecking/index.js +2 -2
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/FlatListDnD/index.js +12 -9
- package/src/commons/Grid/GridItem.js +10 -2
- package/src/commons/Header/HeaderCustom.js +2 -2
- package/src/commons/HeaderAni/index.js +2 -2
- package/src/commons/IconComponent/index.js +4 -4
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +4 -4
- package/src/commons/SearchLocation/index.js +3 -3
- package/src/commons/SelectActionCard/index.js +2 -2
- package/src/commons/SelectSubUnit/index.js +6 -2
- package/src/commons/Sharing/BtnRemoveMember.js +2 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
- package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -4
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
- package/src/commons/SubUnit/OneTap/index.js +9 -8
- package/src/commons/Unit/HeaderUnit/index.js +3 -3
- package/src/commons/Unit/SharedUnit.js +7 -7
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +4 -15
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +29 -18
- package/src/configs/API.js +1 -1
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Theme.js +1 -1
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
- package/src/hooks/IoT/useRemoteControl.js +18 -7
- package/src/hooks/useMqtt.js +2 -2
- package/src/iot/RemoteControl/Bluetooth.js +19 -22
- package/src/iot/RemoteControl/Internet.js +11 -3
- package/src/navigations/EmergencyContactsStack.js +4 -3
- package/src/navigations/SharedStack.js +2 -0
- package/src/navigations/UnitStack.js +56 -57
- package/src/screens/AQIGuide/index.js +0 -2
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddLocationMaps/index.js +16 -19
- package/src/screens/AddLocationMaps/indexStyle.js +1 -0
- package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
- package/src/screens/AddNewGateway/SelectDeviceType.js +1 -1
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +25 -9
- package/src/screens/Automate/AddNewAction/ChooseAction.js +17 -3
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +7 -6
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +8 -8
- package/src/screens/Automate/AddNewAction/SelectControlDevices.js +30 -20
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +17 -10
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +58 -44
- package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +3 -3
- package/src/screens/Automate/AddNewAction/Styles/SetupSensorStyles.js +20 -4
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +1 -1
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +14 -8
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +13 -7
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +54 -15
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +29 -0
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +2 -0
- package/src/screens/Automate/Components/InputName.js +10 -7
- package/src/screens/Automate/EditActionsList/index.js +19 -17
- package/src/screens/Automate/MultiUnits.js +19 -22
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +12 -2
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +9 -1
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +14 -6
- package/src/screens/Automate/ScriptDetail/Components/RenameScript.js +4 -7
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +42 -17
- package/src/screens/Automate/ScriptDetail/index.js +33 -22
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +21 -10
- package/src/screens/Automate/SetSchedule/components/RowItem.js +5 -5
- package/src/screens/Automate/SetSchedule/index.js +8 -7
- package/src/screens/Automate/Styles/indexStyles.js +1 -1
- package/src/screens/Automate/__test__/MultiUnits.test.js +1 -4
- package/src/screens/Automate/__test__/index.test.js +0 -1
- package/src/screens/Automate/index.js +36 -34
- package/src/screens/ChangePosition/index.js +2 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +4 -4
- package/src/screens/Device/EditDevice/index.js +4 -4
- package/src/screens/Device/__test__/BluetoothDevice.test.js +300 -0
- package/src/screens/Device/__test__/detail.test.js +3 -3
- package/src/screens/Device/components/BluetoothDevice.js +135 -0
- package/src/screens/Device/components/SensorDisplayItem.js +4 -3
- package/src/screens/Device/detail.js +70 -62
- package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
- package/src/screens/Drawer/index.js +3 -3
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +8 -4
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
- package/src/screens/GuestInfo/index.js +2 -2
- package/src/screens/HanetCamera/ManageAccess.js +3 -3
- package/src/screens/HanetCamera/MemberInfo.js +2 -2
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +3 -3
- package/src/screens/Notification/components/NotificationItem.js +3 -3
- package/src/screens/Notification/index.js +3 -3
- package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +1 -1
- package/src/screens/SelectUnit/index.js +4 -4
- package/src/screens/SharedUnit/TabHeader.js +2 -2
- package/src/screens/Sharing/Components/EndDevice.js +3 -3
- package/src/screens/Sharing/UnitMemberList.js +2 -2
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +3 -2
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +2 -2
- package/src/screens/SmartIr/components/SelectBrand.js +2 -2
- package/src/screens/SubUnit/AddSubUnit.js +28 -24
- package/src/screens/SubUnit/AddSubUnitStyles.js +10 -4
- package/src/screens/SubUnit/EditSubUnit.js +12 -11
- package/src/screens/SubUnit/ManageSubUnit.js +3 -3
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +13 -13
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +3 -3
- package/src/screens/Template/EditTemplate.js +6 -4
- package/src/screens/UVIndexGuide/index.js +2 -4
- package/src/screens/Unit/SelectAddToFavorites.js +2 -2
- package/src/screens/Unit/SelectAddress.js +16 -12
- package/src/screens/Unit/components/AutomateScript/index.js +2 -2
- package/src/screens/Unit/components/ButtonWrapper/index.js +3 -3
- package/src/screens/Unit/components/Header/index.js +2 -2
- package/src/screens/Unit/components/SharedUnit/index.js +5 -5
- package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +6 -6
- package/src/screens/UnitSummary/index.js +3 -3
- package/src/utils/Apis/axios.js +5 -5
- package/src/utils/Functions/ShortEmail.js +1 -0
- package/src/utils/I18n/translations/en.js +6 -3
- package/src/utils/I18n/translations/vi.js +8 -4
- package/src/utils/bluetooth.js +3 -0
|
@@ -26,13 +26,13 @@ const handleReconnectionDeviceBle = async (device, action, data, userId) => {
|
|
|
26
26
|
return SEND_COMMAND_OVER_BLUETOOTH_FAIL;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const useRemoteControl = () => {
|
|
29
|
+
const useRemoteControl = (bluetoothDevice) => {
|
|
30
30
|
const homeAssistantConnections = useSCContextSelector(
|
|
31
31
|
(state) => state.iot.homeassistant.connections
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const sendRemoteCommand = useCallback(
|
|
35
|
-
async (device, action, data, userId) => {
|
|
35
|
+
async (device, action, data, userId, silent = false) => {
|
|
36
36
|
// No action, raise not authorized
|
|
37
37
|
let result = false;
|
|
38
38
|
if (!action) {
|
|
@@ -41,9 +41,18 @@ const useRemoteControl = () => {
|
|
|
41
41
|
);
|
|
42
42
|
return result;
|
|
43
43
|
}
|
|
44
|
-
|
|
45
44
|
if (action.command_prefer_over_bluetooth) {
|
|
46
|
-
|
|
45
|
+
// custom control for i/o pin over bluetooth
|
|
46
|
+
if (bluetoothDevice?.isConnected && action.arduino_action) {
|
|
47
|
+
return bluetoothDevice.control(action, data, silent);
|
|
48
|
+
}
|
|
49
|
+
let res = await sendCommandOverBluetooth(
|
|
50
|
+
device,
|
|
51
|
+
action,
|
|
52
|
+
data,
|
|
53
|
+
userId,
|
|
54
|
+
silent
|
|
55
|
+
);
|
|
47
56
|
if (res === BLUETOOOH_DEVICE_UNSTABLE) {
|
|
48
57
|
res = await handleReconnectionDeviceBle(device, action, data, userId);
|
|
49
58
|
}
|
|
@@ -57,7 +66,8 @@ const useRemoteControl = () => {
|
|
|
57
66
|
device,
|
|
58
67
|
action,
|
|
59
68
|
data,
|
|
60
|
-
'bluetooth'
|
|
69
|
+
'bluetooth',
|
|
70
|
+
silent
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
return result;
|
|
@@ -80,7 +90,8 @@ const useRemoteControl = () => {
|
|
|
80
90
|
device,
|
|
81
91
|
action,
|
|
82
92
|
data,
|
|
83
|
-
action.command_prefer_over_bluetooth ? 'bluetooth' : 'internet'
|
|
93
|
+
action.command_prefer_over_bluetooth ? 'bluetooth' : 'internet',
|
|
94
|
+
silent
|
|
84
95
|
);
|
|
85
96
|
}
|
|
86
97
|
|
|
@@ -95,7 +106,7 @@ const useRemoteControl = () => {
|
|
|
95
106
|
|
|
96
107
|
return await sendCommandOverInternet(device, action, data, 'internet');
|
|
97
108
|
},
|
|
98
|
-
[homeAssistantConnections]
|
|
109
|
+
[bluetoothDevice, homeAssistantConnections]
|
|
99
110
|
);
|
|
100
111
|
|
|
101
112
|
return sendRemoteCommand;
|
package/src/hooks/useMqtt.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import mqtt from 'precompiled-mqtt/dist/mqtt.browser';
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import API from '../configs/API';
|
|
5
|
-
import { axiosGet } from '../utils/Apis/axios';
|
|
6
5
|
import { handleMqttMessage } from '../iot/mqtt';
|
|
6
|
+
import { axiosGet } from '../utils/Apis/axios';
|
|
7
7
|
|
|
8
8
|
const useChipJsonConfiguration = (dashboardId) => {
|
|
9
9
|
const [chips, setChips] = useState([]);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
2
2
|
import base64 from 'react-native-base64';
|
|
3
|
-
import {
|
|
3
|
+
import { ScanMode } from 'react-native-ble-plx';
|
|
4
4
|
import CryptoAesCbc from 'react-native-crypto-aes-cbc';
|
|
5
5
|
|
|
6
6
|
import { base64ToHex, ToastBottomHelper } from '../../utils/Utils';
|
|
7
7
|
import { BLE } from '../../configs';
|
|
8
8
|
import t from '../../hooks/Common/useTranslations';
|
|
9
|
+
import { bleManager } from '../../utils/bluetooth';
|
|
9
10
|
|
|
10
11
|
const bluetoothDevices = {};
|
|
11
12
|
const needToScanDevices = [];
|
|
12
|
-
const bleManager = new BleManager();
|
|
13
13
|
|
|
14
14
|
let isScanning = false;
|
|
15
15
|
|
|
@@ -98,7 +98,8 @@ export const sendCommandOverBluetooth = async (
|
|
|
98
98
|
sensor,
|
|
99
99
|
action,
|
|
100
100
|
data,
|
|
101
|
-
userID
|
|
101
|
+
userID,
|
|
102
|
+
silent
|
|
102
103
|
) => {
|
|
103
104
|
const bluetooth = sensor?.remote_control_options?.bluetooth;
|
|
104
105
|
let device = null;
|
|
@@ -115,7 +116,8 @@ export const sendCommandOverBluetooth = async (
|
|
|
115
116
|
user: userID,
|
|
116
117
|
},
|
|
117
118
|
false,
|
|
118
|
-
bluetooth?.is_use_secret_key
|
|
119
|
+
bluetooth?.is_use_secret_key,
|
|
120
|
+
silent
|
|
119
121
|
);
|
|
120
122
|
return result;
|
|
121
123
|
};
|
|
@@ -124,18 +126,6 @@ export const getDeviceByName = (name) => {
|
|
|
124
126
|
return bluetoothDevices[name];
|
|
125
127
|
};
|
|
126
128
|
|
|
127
|
-
export const isDeviceConnected = (deviceName) => {
|
|
128
|
-
return !!bluetoothDevices[deviceName];
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
export const subcribeCharacteristicNotify = async (device, onListener) => {
|
|
132
|
-
return await device.monitorCharacteristicForService(
|
|
133
|
-
BLE.BLE_REMOTE_SERVICE_UUID,
|
|
134
|
-
BLE.BLE_REMOTE_CHARACTERISTIC_UUID_TX,
|
|
135
|
-
onListener
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
129
|
export const readCharacteristic = async (
|
|
140
130
|
device,
|
|
141
131
|
serviceUUID = BLE.BLE_REMOTE_SERVICE_UUID,
|
|
@@ -151,13 +141,16 @@ export const sendDataOverBluetooth = async (
|
|
|
151
141
|
device = null,
|
|
152
142
|
data,
|
|
153
143
|
keepConnect = false,
|
|
154
|
-
isUseSecretKey = false
|
|
144
|
+
isUseSecretKey = false,
|
|
145
|
+
silent
|
|
155
146
|
) => {
|
|
156
147
|
if (!device) {
|
|
157
148
|
return SEND_COMMAND_OVER_BLUETOOTH_FAIL;
|
|
158
149
|
}
|
|
159
150
|
|
|
160
|
-
|
|
151
|
+
if (!silent) {
|
|
152
|
+
ToastBottomHelper.info(t('Sending command via bluetooth'));
|
|
153
|
+
}
|
|
161
154
|
|
|
162
155
|
let connectedDevice = null;
|
|
163
156
|
let fullDataDevice = null;
|
|
@@ -196,9 +189,11 @@ export const sendDataOverBluetooth = async (
|
|
|
196
189
|
hasResponse = true;
|
|
197
190
|
const notify = error ? '' : base64.decode(characteristic.value);
|
|
198
191
|
if (notify === BLE.BLE_RESPONSE_OK) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
if (!silent) {
|
|
193
|
+
ToastBottomHelper.success(
|
|
194
|
+
t('control_device_via_bluetooth_successfully')
|
|
195
|
+
);
|
|
196
|
+
}
|
|
202
197
|
if (!keepConnect) {
|
|
203
198
|
await connectedDevice.cancelConnection();
|
|
204
199
|
}
|
|
@@ -234,7 +229,9 @@ export const sendDataOverBluetooth = async (
|
|
|
234
229
|
base64.encode(JSON.stringify(data))
|
|
235
230
|
);
|
|
236
231
|
}
|
|
237
|
-
|
|
232
|
+
if (!silent) {
|
|
233
|
+
ToastBottomHelper.info(t('command_is_sent_to_device_via_bluetooth'));
|
|
234
|
+
}
|
|
238
235
|
} catch (e) {
|
|
239
236
|
await connectedDevice.cancelConnection();
|
|
240
237
|
ToastBottomHelper.error(t('command_is_fail_to_send_via_bluetooth'));
|
|
@@ -4,7 +4,13 @@ import { API } from '../../configs';
|
|
|
4
4
|
import { axiosPost } from '../../utils/Apis/axios';
|
|
5
5
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
6
6
|
|
|
7
|
-
export const sendCommandOverInternet = async (
|
|
7
|
+
export const sendCommandOverInternet = async (
|
|
8
|
+
sensor,
|
|
9
|
+
action,
|
|
10
|
+
data,
|
|
11
|
+
source,
|
|
12
|
+
silent
|
|
13
|
+
) => {
|
|
8
14
|
if (data !== null) {
|
|
9
15
|
if (Number.isInteger(data)) {
|
|
10
16
|
data = data.toString(16).toUpperCase();
|
|
@@ -13,13 +19,15 @@ export const sendCommandOverInternet = async (sensor, action, data, source) => {
|
|
|
13
19
|
if (typeof data === 'object') {
|
|
14
20
|
data = JSON.stringify(data);
|
|
15
21
|
}
|
|
16
|
-
|
|
22
|
+
if (!silent) {
|
|
23
|
+
ToastBottomHelper.info(t('Sending command via internet'));
|
|
24
|
+
}
|
|
17
25
|
const { success } = await axiosPost(API.DEVICE.TRIGGER_ACTION(sensor.id), {
|
|
18
26
|
key: action.key,
|
|
19
27
|
data,
|
|
20
28
|
source,
|
|
21
29
|
});
|
|
22
|
-
if (success) {
|
|
30
|
+
if (success && !silent) {
|
|
23
31
|
ToastBottomHelper.success(t('Command is sent to device via internet'));
|
|
24
32
|
}
|
|
25
33
|
return success;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
2
2
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
3
3
|
import React, { memo } from 'react';
|
|
4
4
|
import { StyleSheet } from 'react-native';
|
|
@@ -19,7 +19,7 @@ export const EmergencyContactsStack = memo(() => {
|
|
|
19
19
|
...screenOptions,
|
|
20
20
|
headerTitleAlign: 'center',
|
|
21
21
|
headerBackImage: () => (
|
|
22
|
-
<
|
|
22
|
+
<IconOutline
|
|
23
23
|
name="left"
|
|
24
24
|
size={27}
|
|
25
25
|
color={Colors.Black}
|
|
@@ -32,7 +32,8 @@ export const EmergencyContactsStack = memo(() => {
|
|
|
32
32
|
borderBottomWidth: Device.isIOS === 'android' ? 1 : 0,
|
|
33
33
|
borderColor: Colors.Gray4,
|
|
34
34
|
},
|
|
35
|
-
|
|
35
|
+
headerTintColor: Colors.Black,
|
|
36
|
+
headerBackTitleVisible: false,
|
|
36
37
|
}}
|
|
37
38
|
>
|
|
38
39
|
<Stack.Screen
|
|
@@ -1,78 +1,76 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AppState, View } from 'react-native';
|
|
3
|
-
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
4
|
-
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
5
|
-
import { BleManager } from 'react-native-ble-plx';
|
|
1
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
6
2
|
import NetInfo from '@react-native-community/netinfo';
|
|
3
|
+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
|
7
4
|
import { get } from 'lodash';
|
|
5
|
+
import React, { memo, useContext, useEffect } from 'react';
|
|
6
|
+
import { AppState, View } from 'react-native';
|
|
8
7
|
|
|
9
8
|
import Text from '../commons/Text';
|
|
9
|
+
import { API, Colors, Device } from '../configs';
|
|
10
|
+
import { SCContext } from '../context';
|
|
11
|
+
import { Action } from '../context/actionType';
|
|
10
12
|
import { useTranslations } from '../hooks/Common/useTranslations';
|
|
11
13
|
import { unwatchAllConfigs } from '../iot/Monitor';
|
|
12
|
-
import { API, Colors, Device } from '../configs';
|
|
13
|
-
import Route from '../utils/Route';
|
|
14
14
|
import ActivityLogScreen from '../screens/ActivityLog';
|
|
15
|
+
import Route from '../utils/Route';
|
|
15
16
|
import { screenOptions } from './utils';
|
|
16
|
-
import { SCContext } from '../context';
|
|
17
|
-
import { Action } from '../context/actionType';
|
|
18
17
|
|
|
18
|
+
import { useBluetoothConnection } from '../hooks/IoT';
|
|
19
|
+
import { realScanBluetoothDevices } from '../iot/RemoteControl/Bluetooth';
|
|
20
|
+
import AllCamera from '../screens/AllCamera';
|
|
21
|
+
import AllGateway from '../screens/AllGateway';
|
|
19
22
|
import AQIGuide from '../screens/AQIGuide';
|
|
20
|
-
import
|
|
23
|
+
import ChooseAction from '../screens/Automate/AddNewAction/ChooseAction';
|
|
24
|
+
import ChooseConfig from '../screens/Automate/AddNewAction/ChooseConfig';
|
|
25
|
+
import SelectControlDevices from '../screens/Automate/AddNewAction/SelectControlDevices';
|
|
26
|
+
import SelectMonitorDevices from '../screens/Automate/AddNewAction/SelectMonitorDevices';
|
|
27
|
+
import SetupConfigCondition from '../screens/Automate/AddNewAction/SetupConfigCondition';
|
|
28
|
+
import SetupScriptDelay from '../screens/Automate/AddNewAction/SetupScriptDelay';
|
|
29
|
+
import SetupScriptNotify from '../screens/Automate/AddNewAction/SetupScriptNotify';
|
|
30
|
+
import AddAutomationTypeSmart from '../screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart';
|
|
31
|
+
import AddUnknownTypeSmart from '../screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart';
|
|
32
|
+
import EditActionsList from '../screens/Automate/EditActionsList';
|
|
33
|
+
import UpdateActionScript from '../screens/Automate/EditActionsList/UpdateActionScript';
|
|
34
|
+
import AddNewOneTap from '../screens/Automate/OneTap';
|
|
35
|
+
import ScenarioName from '../screens/Automate/Scenario/ScenarioName';
|
|
36
|
+
import ScriptDetail from '../screens/Automate/ScriptDetail';
|
|
37
|
+
import SetSchedule from '../screens/Automate/SetSchedule';
|
|
38
|
+
import ValueChangeName from '../screens/Automate/ValueChange/ValueChangeName';
|
|
21
39
|
import ChangePosition from '../screens/ChangePosition';
|
|
40
|
+
import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
|
|
41
|
+
import DeviceDetail from '../screens/Device/detail';
|
|
42
|
+
import EditDevice from '../screens/Device/EditDevice/index';
|
|
43
|
+
import DeviceInfo from '../screens/DeviceInfo';
|
|
44
|
+
import EmergencySetting from '../screens/EmergencySetting';
|
|
45
|
+
import EnterPassword from '../screens/EnterPassword';
|
|
46
|
+
import GuestInfo from '../screens/GuestInfo';
|
|
47
|
+
import ManageAccessScreen from '../screens/ManageAccess';
|
|
48
|
+
import MoveToAnotherSubUnit from '../screens/MoveToAnotherSubUnit';
|
|
49
|
+
import PlaybackCamera from '../screens/PlayBackCamera';
|
|
50
|
+
import SelectUnit from '../screens/SelectUnit';
|
|
51
|
+
import InfoMemberUnit from '../screens/Sharing/InfoMemberUnit';
|
|
22
52
|
import UnitMemberList from '../screens/Sharing/UnitMemberList';
|
|
53
|
+
import SideMenuDetail from '../screens/SideMenuDetail';
|
|
54
|
+
import EditSubUnit from '../screens/SubUnit/EditSubUnit';
|
|
23
55
|
import ManageSubUnit from '../screens/SubUnit/ManageSubUnit';
|
|
24
|
-
import
|
|
56
|
+
import TDSGuide from '../screens/TDSGuide';
|
|
25
57
|
import ChooseLocation from '../screens/Unit/ChooseLocation';
|
|
58
|
+
import UnitDetail from '../screens/Unit/Detail';
|
|
26
59
|
import ManageUnit from '../screens/Unit/ManageUnit';
|
|
60
|
+
import SelectAddress from '../screens/Unit/SelectAddress';
|
|
61
|
+
import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
|
|
27
62
|
import ListSmartAccount from '../screens/Unit/SmartAccount';
|
|
28
|
-
import UnitDetail from '../screens/Unit/Detail';
|
|
29
63
|
import UnitSummary from '../screens/UnitSummary';
|
|
30
64
|
import UVIndexGuide from '../screens/UVIndexGuide';
|
|
31
|
-
import TDSGuide from '../screens/TDSGuide';
|
|
32
65
|
import WaterQualityGuide from '../screens/WaterQualityGuide';
|
|
33
|
-
import DeviceInfo from '../screens/DeviceInfo';
|
|
34
|
-
import AddNewOneTap from '../screens/Automate/OneTap';
|
|
35
|
-
import AddUnknownTypeSmart from '../screens/Automate/AddNewAutoSmart/AddUnknownTypeSmart';
|
|
36
|
-
import PlaybackCamera from '../screens/PlayBackCamera';
|
|
37
|
-
import AllCamera from '../screens/AllCamera';
|
|
38
|
-
import ManageAccessScreen from '../screens/ManageAccess';
|
|
39
|
-
import MoveToAnotherSubUnit from '../screens/MoveToAnotherSubUnit';
|
|
40
|
-
import GuestInfo from '../screens/GuestInfo';
|
|
41
|
-
import ScriptDetail from '../screens/Automate/ScriptDetail';
|
|
42
|
-
import EditActionsList from '../screens/Automate/EditActionsList';
|
|
43
|
-
import SelectUnit from '../screens/SelectUnit';
|
|
44
|
-
import SetSchedule from '../screens/Automate/SetSchedule';
|
|
45
|
-
import SelectMonitorDevices from '../screens/Automate/AddNewAction/SelectMonitorDevices';
|
|
46
|
-
import EditSubUnit from '../screens/SubUnit/EditSubUnit';
|
|
47
|
-
import SetupConfigCondition from '../screens/Automate/AddNewAction/SetupConfigCondition';
|
|
48
|
-
import EditDevice from '../screens/Device/EditDevice/index';
|
|
49
|
-
import EmergencySetting from '../screens/EmergencySetting';
|
|
50
|
-
import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
|
|
51
|
-
import InfoMemberUnit from '../screens/Sharing/InfoMemberUnit';
|
|
52
|
-
import EnterPassword from '../screens/EnterPassword';
|
|
53
|
-
import AllGateway from '../screens/AllGateway';
|
|
54
|
-
import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
|
|
55
|
-
import { HanetCameraStack } from './HanetCameraStack';
|
|
56
66
|
import { axiosGet, fetchWithCache } from '../utils/Apis/axios';
|
|
57
|
-
import SideMenuDetail from '../screens/SideMenuDetail';
|
|
58
|
-
import { styles } from './UnitStackStyles';
|
|
59
|
-
import { useBluetoothConnection } from '../hooks/IoT';
|
|
60
|
-
import { realScanBluetoothDevices } from '../iot/RemoteControl/Bluetooth';
|
|
61
67
|
import { ToastBottomHelper } from '../utils/Utils';
|
|
62
|
-
import
|
|
63
|
-
import
|
|
64
|
-
import
|
|
65
|
-
import ScenarioName from '../screens/Automate/Scenario/ScenarioName';
|
|
66
|
-
import ValueChangeName from '../screens/Automate/ValueChange/ValueChangeName';
|
|
67
|
-
import AddAutomationTypeSmart from '../screens/Automate/AddNewAutoSmart/AddAutomationTypeSmart';
|
|
68
|
-
import SetupScriptNotify from '../screens/Automate/AddNewAction/SetupScriptNotify';
|
|
69
|
-
import SetupScriptDelay from '../screens/Automate/AddNewAction/SetupScriptDelay';
|
|
70
|
-
import UpdateActionScript from '../screens/Automate/EditActionsList/UpdateActionScript';
|
|
68
|
+
import { HanetCameraStack } from './HanetCameraStack';
|
|
69
|
+
import { styles } from './UnitStackStyles';
|
|
70
|
+
import { bleManager } from '../utils/bluetooth';
|
|
71
71
|
|
|
72
72
|
const Stack = createNativeStackNavigator();
|
|
73
73
|
|
|
74
|
-
const bleManager = new BleManager();
|
|
75
|
-
|
|
76
74
|
export const UnitStack = memo((props) => {
|
|
77
75
|
const t = useTranslations();
|
|
78
76
|
const { setAction } = useContext(SCContext);
|
|
@@ -173,7 +171,7 @@ export const UnitStack = memo((props) => {
|
|
|
173
171
|
...screenOptions,
|
|
174
172
|
headerTitleAlign: 'center',
|
|
175
173
|
headerBackImage: () => (
|
|
176
|
-
<
|
|
174
|
+
<IconOutline
|
|
177
175
|
name="left"
|
|
178
176
|
size={27}
|
|
179
177
|
color={Colors.Black}
|
|
@@ -186,7 +184,8 @@ export const UnitStack = memo((props) => {
|
|
|
186
184
|
borderBottomWidth: Device.isIOS === 'android' ? 1 : 0,
|
|
187
185
|
borderColor: Colors.Gray4,
|
|
188
186
|
},
|
|
189
|
-
|
|
187
|
+
headerTintColor: Colors.Black,
|
|
188
|
+
headerBackTitleVisible: false,
|
|
190
189
|
}}
|
|
191
190
|
>
|
|
192
191
|
<Stack.Screen
|
|
@@ -286,28 +285,28 @@ export const UnitStack = memo((props) => {
|
|
|
286
285
|
name={Route.UVIndexGuide}
|
|
287
286
|
component={UVIndexGuide}
|
|
288
287
|
options={{
|
|
289
|
-
|
|
288
|
+
headerTitle: t('uv_index_guide'),
|
|
290
289
|
}}
|
|
291
290
|
/>
|
|
292
291
|
<Stack.Screen
|
|
293
292
|
name={Route.TDSGuide}
|
|
294
293
|
component={TDSGuide}
|
|
295
294
|
options={{
|
|
296
|
-
|
|
295
|
+
headerTitle: t('tds_information'),
|
|
297
296
|
}}
|
|
298
297
|
/>
|
|
299
298
|
<Stack.Screen
|
|
300
299
|
name={Route.AQIGuide}
|
|
301
300
|
component={AQIGuide}
|
|
302
301
|
options={{
|
|
303
|
-
|
|
302
|
+
headerTitle: t('aqi_guide'),
|
|
304
303
|
}}
|
|
305
304
|
/>
|
|
306
305
|
<Stack.Screen
|
|
307
306
|
name={Route.WaterQualityGuide}
|
|
308
307
|
component={WaterQualityGuide}
|
|
309
308
|
options={{
|
|
310
|
-
|
|
309
|
+
headerTitle: t('water_quality_guide'),
|
|
311
310
|
}}
|
|
312
311
|
/>
|
|
313
312
|
<Stack.Screen
|
|
@@ -4,7 +4,6 @@ import { getBottomSpace } from 'react-native-iphone-x-helper';
|
|
|
4
4
|
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
6
|
import { Colors, Theme } from '../../configs';
|
|
7
|
-
import useTitleHeader from '../../hooks/Common/useTitleHeader';
|
|
8
7
|
import { AccessibilityLabel } from '../../configs/Constants';
|
|
9
8
|
import Text from '../../commons/Text';
|
|
10
9
|
import SvgSmile from '../../../assets/images/Feeling/smile.svg';
|
|
@@ -16,7 +15,6 @@ import { useSCContextSelector } from '../../context';
|
|
|
16
15
|
|
|
17
16
|
const AQIGuide = memo(() => {
|
|
18
17
|
const t = useTranslations();
|
|
19
|
-
useTitleHeader(t('AQI Guide'));
|
|
20
18
|
const language = useSCContextSelector((state) => state.language);
|
|
21
19
|
const data = useMemo(
|
|
22
20
|
() => ({
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
TouchableOpacity,
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
10
|
-
import
|
|
10
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
11
11
|
import { Colors } from '../../configs';
|
|
12
12
|
import { HeaderCustom } from '../../commons/Header';
|
|
13
13
|
import ItemLog from './ItemLog';
|
|
@@ -83,7 +83,7 @@ const ActivityLogScreen = ({ route }) => {
|
|
|
83
83
|
onPress={setShowFilterPopup}
|
|
84
84
|
accessibilityLabel={AccessibilityLabel.FILTER_BUTTON}
|
|
85
85
|
>
|
|
86
|
-
<
|
|
86
|
+
<IconOutline name={'filter'} size={27} color={Colors.Black} />
|
|
87
87
|
</TouchableOpacity>
|
|
88
88
|
),
|
|
89
89
|
[setShowFilterPopup]
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { View, ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
-
import MapView, { Marker, Circle, PROVIDER_GOOGLE } from 'react-native-maps';
|
|
1
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
2
|
import { useNavigation } from '@react-navigation/native';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { ScrollView, TouchableOpacity, View } from 'react-native';
|
|
5
|
+
import MapView, { Circle, Marker, PROVIDER_GOOGLE } from 'react-native-maps';
|
|
7
6
|
import { check, RESULTS } from 'react-native-permissions';
|
|
7
|
+
import MaterialIcons from 'react-native-vector-icons/MaterialIcons';
|
|
8
8
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
9
9
|
|
|
10
|
-
import Text from '../../commons/Text';
|
|
11
10
|
import { FullLoading } from '../../commons';
|
|
11
|
+
import BottomButtonView from '../../commons/BottomButtonView';
|
|
12
12
|
import SearchBarLocation from '../../commons/SearchLocation';
|
|
13
13
|
import RowLocation from '../../commons/SearchLocation/RowLocation';
|
|
14
|
-
import
|
|
14
|
+
import Text from '../../commons/Text';
|
|
15
15
|
import { API, Colors, SCConfig } from '../../configs';
|
|
16
16
|
import {
|
|
17
17
|
AccessibilityLabel,
|
|
18
|
-
MAP_INITIAL_REGION,
|
|
19
18
|
EOH_LOCATION,
|
|
19
|
+
MAP_INITIAL_REGION,
|
|
20
20
|
} from '../../configs/Constants';
|
|
21
|
-
import
|
|
22
|
-
import Routes from '../../utils/Route';
|
|
21
|
+
import { axiosGet } from '../../utils/Apis/axios';
|
|
23
22
|
import {
|
|
24
23
|
GEOLOCATION_ERROR,
|
|
25
24
|
keyPermission,
|
|
26
25
|
OpenSetting,
|
|
27
26
|
} from '../../utils/Permission/common';
|
|
27
|
+
import Routes from '../../utils/Route';
|
|
28
28
|
import { openPromptEnableLocation } from '../../utils/Setting/Location';
|
|
29
|
-
import
|
|
29
|
+
import styles from './indexStyle';
|
|
30
30
|
|
|
31
31
|
navigator.geolocation = require('@react-native-community/geolocation');
|
|
32
32
|
|
|
@@ -180,12 +180,9 @@ const AddLocationMaps = memo(() => {
|
|
|
180
180
|
return (
|
|
181
181
|
<View style={styles.container}>
|
|
182
182
|
<Text color={Colors.Gray9} size={24} semibold style={styles.textHeader}>
|
|
183
|
-
{t('
|
|
183
|
+
{t('location')}
|
|
184
184
|
</Text>
|
|
185
185
|
<View style={styles.content}>
|
|
186
|
-
<Text color={Colors.Gray8} size={12} style={styles.textExplain}>
|
|
187
|
-
{t('text_explain_add_geolocation')}
|
|
188
|
-
</Text>
|
|
189
186
|
<View style={styles.searchLocation}>
|
|
190
187
|
<SearchBarLocation
|
|
191
188
|
input={input?.description || input}
|
|
@@ -225,8 +222,8 @@ const AddLocationMaps = memo(() => {
|
|
|
225
222
|
style={styles.button}
|
|
226
223
|
accessibilityLabel={AccessibilityLabel.BUTTON_CHOOSE_ON_MAP}
|
|
227
224
|
>
|
|
228
|
-
<
|
|
229
|
-
name="
|
|
225
|
+
<IconOutline
|
|
226
|
+
name="environment"
|
|
230
227
|
size={27}
|
|
231
228
|
color={Colors.Primary}
|
|
232
229
|
/>
|
|
@@ -274,8 +271,8 @@ const AddLocationMaps = memo(() => {
|
|
|
274
271
|
}}
|
|
275
272
|
tracksViewChanges={false}
|
|
276
273
|
>
|
|
277
|
-
<
|
|
278
|
-
name="
|
|
274
|
+
<IconOutline
|
|
275
|
+
name="environment"
|
|
279
276
|
size={27}
|
|
280
277
|
color={Colors.Blue10}
|
|
281
278
|
/>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState, useMemo } from 'react';
|
|
2
2
|
import { ScrollView, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
4
|
import { CommonActions, useNavigation } from '@react-navigation/native';
|
|
5
5
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
6
6
|
import { Colors } from '../../configs';
|
|
@@ -357,7 +357,7 @@ const RenameNewDevices = memo(({ route }) => {
|
|
|
357
357
|
/>
|
|
358
358
|
<View style={styles.content}>
|
|
359
359
|
<View style={styles.viewIconSuccess}>
|
|
360
|
-
<
|
|
360
|
+
<IconOutline name="check-circle" size={28} color={Colors.Green6} />
|
|
361
361
|
<Text
|
|
362
362
|
semibold
|
|
363
363
|
color={Colors.Black}
|
|
@@ -192,7 +192,7 @@ const SelectDeviceType = ({ route }) => {
|
|
|
192
192
|
useEffect(() => {
|
|
193
193
|
const fetchCountSummary = async () => {
|
|
194
194
|
const { success, data } = await axiosGet(API.DEV_MODE.GATEWAY.COUNT(), {
|
|
195
|
-
unit: unit?.id,
|
|
195
|
+
params: { unit: unit?.id },
|
|
196
196
|
});
|
|
197
197
|
if (success) {
|
|
198
198
|
setUnitCountSummary(data);
|
|
@@ -45,20 +45,20 @@ describe('Test GatewayInfo', () => {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
mock.reset();
|
|
50
|
+
});
|
|
51
|
+
|
|
48
52
|
it('test render GatewayInfo', async () => {
|
|
49
53
|
useRoute.mockReturnValue({
|
|
50
54
|
params: { chipId: 1 },
|
|
51
55
|
});
|
|
52
56
|
mock.onGet(API.DEV_MODE.GATEWAY.DETAIL(1)).reply(200, {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
modbus_gateway: 1,
|
|
59
|
-
zigbee_gateway: 1,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
57
|
+
id: 1,
|
|
58
|
+
name: 'device 1',
|
|
59
|
+
arduino_gateway: 1,
|
|
60
|
+
modbus_gateway: 1,
|
|
61
|
+
zigbee_gateway: 1,
|
|
62
62
|
});
|
|
63
63
|
await act(async () => {
|
|
64
64
|
tree = await create(wrapComponent());
|
|
@@ -118,4 +118,20 @@ describe('Test GatewayInfo', () => {
|
|
|
118
118
|
});
|
|
119
119
|
expect(global.mockedPop).toHaveBeenCalledWith(2);
|
|
120
120
|
});
|
|
121
|
+
|
|
122
|
+
it('test render GatewayInfo onPress cancel delete gateway', async () => {
|
|
123
|
+
await act(async () => {
|
|
124
|
+
tree = await create(wrapComponent());
|
|
125
|
+
});
|
|
126
|
+
const instance = tree.root;
|
|
127
|
+
const btnDelete = buttonDelete(instance);
|
|
128
|
+
await act(async () => {
|
|
129
|
+
await btnDelete.props.onPress();
|
|
130
|
+
});
|
|
131
|
+
const modal = instance.findByType(ModalPopupCT);
|
|
132
|
+
await act(async () => {
|
|
133
|
+
await modal.props.onPressCancel();
|
|
134
|
+
});
|
|
135
|
+
expect(modal.props.isVisible).toBeFalsy();
|
|
136
|
+
});
|
|
121
137
|
});
|