@eohjsc/react-native-smart-city 0.2.99 → 0.3.2
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/README.md +1 -1
- package/package.json +6 -4
- package/react-native-smart-city.podspec +1 -0
- package/src/commons/Action/ItemQuickAction.js +11 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +11 -6
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +10 -5
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +31 -20
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/__test__/index.test.js +4 -0
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/ItemPasscode.js +1 -1
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/ItemPasscode.test.js +24 -0
- package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +14 -0
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +3 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +8 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +2 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +0 -1
- package/src/commons/ActionGroup/__test__/CurtainButtonTemplate.test.js +53 -4
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +45 -48
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +77 -0
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +58 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +49 -1
- package/src/commons/ActionGroup/__test__/index.test.js +137 -2
- package/src/commons/Automate/ItemAutomate.js +1 -3
- package/src/commons/Calendar/__test__/Calendar.test.js +33 -0
- package/src/commons/Connecting/__test__/Connecting.test.js +19 -2
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItem.js +7 -3
- package/src/commons/ConnectingProcess/DeviceItem/DeviceItemStyles.js +8 -11
- package/src/commons/ConnectingProcess/__test__/Connecting.test.js +136 -3
- package/src/commons/ConnectingProcess/__test__/DeviceItem.test.js +3 -2
- package/src/commons/ConnectingProcess/index.js +72 -25
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +16 -13
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +1 -1
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +0 -5
- package/src/commons/Device/ConnectedViewHeader.js +1 -1
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +58 -0
- package/src/commons/Device/HistoryChart.js +3 -3
- package/src/commons/Device/ItemDevice.js +15 -11
- package/src/commons/Device/LinearChart.js +15 -0
- package/src/commons/Device/SonosSpeaker/index.js +1 -1
- package/src/commons/Explore/__test__/CityItem.test.js +33 -54
- package/src/commons/FieldTemplate/ChooseUserField/__test__/index.test.js +19 -14
- package/src/commons/FieldTemplate/PasscodeField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +0 -3
- package/src/commons/FieldTemplate/ScheduleField/index.js +2 -2
- package/src/commons/Header/HeaderCustom.js +2 -1
- package/src/commons/HorizontalPicker/index.js +2 -2
- package/src/commons/MediaPlayerDetail/Styles/MediaPlayerDetailStyles.js +0 -6
- package/src/commons/MediaPlayerDetail/index.js +24 -55
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +0 -1
- package/src/commons/SubUnit/Favorites/index.js +2 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +8 -35
- package/src/commons/SubUnit/OneTap/index.js +1 -2
- package/src/commons/SubUnit/ShortDetail.js +25 -9
- package/src/commons/SubUnit/__test__/Item.test.js +0 -1
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -1
- package/src/commons/Unit/SharedUnit.js +1 -0
- package/src/commons/Unit/__test__/SharedUnit.test.js +38 -183
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +2 -13
- package/src/commons/UnitSummary/ConfigHistoryChart.js +22 -13
- package/src/commons/WheelDateTimePicker/index.js +2 -2
- package/src/configs/API.js +85 -144
- package/src/configs/Constants.js +24 -0
- package/src/configs/SCConfig.js +2 -0
- package/src/context/actionType.ts +8 -0
- package/src/context/mockStore.ts +10 -0
- package/src/context/reducer.ts +38 -2
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGGHomeDeviceConnected.js +16 -0
- package/src/hooks/Common/useGetIdUser.js +1 -5
- package/src/hooks/Common/useSensorsStatus.js +4 -4
- package/src/hooks/IoT/__test__/useGGHomeConnection.test.js +198 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +198 -0
- package/src/hooks/IoT/index.js +4 -0
- package/src/hooks/IoT/useGGHomeConnection.js +91 -0
- package/src/hooks/IoT/useRemoteControl.js +79 -0
- package/src/hooks/index.js +4 -0
- package/src/hooks/useReceiveNotifications.js +9 -5
- package/src/iot/Monitor.js +3 -2
- package/src/iot/RemoteControl/Bluetooth.js +1 -1
- package/src/iot/RemoteControl/GoogleHome.js +75 -49
- package/src/iot/RemoteControl/Internet.js +1 -1
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +95 -48
- package/src/iot/RemoteControl/__test__/Internet.test.js +18 -7
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +36 -177
- package/src/iot/RemoteControl/index.js +52 -52
- package/src/screens/ActivityLog/__test__/index.test.js +38 -23
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +51 -90
- package/src/screens/ActivityLog/hooks/index.js +1 -1
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +13 -24
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +9 -33
- package/src/screens/AddLocationMaps/index.js +5 -4
- package/src/screens/AddNewAction/SelectAction.js +8 -8
- package/src/screens/AddNewAction/SetupSensor.js +7 -7
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +10 -91
- package/src/screens/AddNewAction/__test__/SelectSensorDevices.test.js +40 -26
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -3
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +34 -33
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +0 -4
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +21 -21
- package/src/screens/AddNewDevice/hooks/ConnectDevices.js +1 -1
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +23 -17
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +3 -3
- package/src/screens/AddNewGateway/SetupGatewayWifi.js +1 -0
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +4 -6
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +5 -29
- package/src/screens/AddNewGateway/__test__/SelectGateway.test.js +0 -4
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +0 -4
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -23
- package/src/screens/AllCamera/index.js +4 -4
- package/src/screens/Automate/MultiUnits.js +8 -8
- package/src/screens/Automate/__test__/MultiUnits.test.js +6 -9
- package/src/screens/Automate/__test__/index.test.js +7 -12
- package/src/screens/Automate/index.js +3 -3
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +36 -8
- package/src/screens/ConfirmUnitDeletion/index.js +7 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +71 -22
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +32 -85
- package/src/screens/Device/components/DetailHistoryChart.js +1 -1
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +1 -0
- package/src/screens/Device/components/SensorDisplayItem.js +5 -2
- package/src/screens/Device/detail.js +53 -22
- package/src/screens/Device/hooks/useDisconnectedDevice.js +4 -4
- package/src/screens/Device/hooks/useFavoriteDevice.js +5 -9
- package/src/screens/DeviceInfo/__test__/index.test.js +0 -2
- package/src/screens/EditActionsList/index.js +1 -1
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +1 -1
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +7 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +18 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +30 -31
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +41 -25
- package/src/screens/GuestInfo/__test__/index.test.js +13 -40
- package/src/screens/HanetCamera/Detail.js +1 -1
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +8 -12
- package/src/screens/HanetCamera/__test__/Detail.test.js +27 -42
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +8 -5
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -32
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +3 -2
- package/src/screens/HanetCamera/hooks/__test__/useHanetCheckinData.test.js +43 -35
- package/src/screens/HanetCamera/hooks/__test__/useHanetPlaceMembers.test.js +10 -21
- package/src/screens/HanetCamera/hooks/useHanetCheckinData.js +11 -11
- package/src/screens/HanetCamera/hooks/useHanetPlaceMembers.js +11 -11
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +33 -22
- package/src/screens/ManageAccess/hooks/__test__/useManageAccess.test.js +44 -45
- package/src/screens/ManageAccess/hooks/index.js +7 -4
- package/src/screens/ManageAccess/index.js +1 -1
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +35 -12
- package/src/screens/MoveToAnotherSubUnit/index.js +5 -5
- package/src/screens/Notification/__test__/Notification.test.js +14 -25
- package/src/screens/Notification/__test__/NotificationItem.test.js +8 -7
- package/src/screens/Notification/components/NotificationItem.js +17 -20
- package/src/screens/Notification/index.js +9 -2
- package/src/screens/PlayBackCamera/Timer.js +2 -2
- package/src/screens/PlayBackCamera/__test__/index.test.js +87 -2
- package/src/screens/PlayBackCamera/index.js +22 -6
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +7 -20
- package/src/screens/ScanChipQR/hooks/index.js +15 -16
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +8 -24
- package/src/screens/ScriptDetail/__test__/index.test.js +17 -86
- package/src/screens/ScriptDetail/index.js +16 -11
- package/src/screens/SelectUnit/__test__/index.test.js +11 -54
- package/src/screens/SelectUnit/index.js +4 -2
- package/src/screens/SetSchedule/index.js +9 -9
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +0 -2
- package/src/screens/Sharing/Components/SensorItem.js +10 -12
- package/src/screens/Sharing/InfoMemberUnit.js +1 -1
- package/src/screens/Sharing/SelectPermission.js +121 -76
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +47 -29
- package/src/screens/Sharing/__test__/MemberList.test.js +13 -127
- package/src/screens/Sharing/__test__/MemberList2.test.js +80 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +28 -38
- package/src/screens/Sharing/__test__/SelectUser.test.js +17 -38
- package/src/screens/SideMenuDetail/__test__/index.test.js +12 -23
- package/src/screens/SideMenuDetail/index.js +2 -3
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -2
- package/src/screens/SubUnit/Detail.js +1 -2
- package/src/screens/SubUnit/ManageSubUnit.js +12 -7
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +21 -67
- package/src/screens/SubUnit/__test__/Detail.test.js +31 -8
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +21 -89
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +27 -1
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +48 -45
- package/src/screens/SubUnit/hooks/useManageSubUnit.js +7 -7
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +14 -90
- package/src/screens/Unit/ChooseLocation.js +7 -14
- package/src/screens/Unit/Detail.js +30 -75
- package/src/screens/Unit/ManageUnit.js +1 -0
- package/src/screens/Unit/SelectAddress.js +34 -21
- package/src/screens/Unit/SmartAccount.js +4 -4
- package/src/screens/Unit/Summaries.js +17 -1
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +24 -29
- package/src/screens/Unit/__test__/ChooseLocation.test.js +27 -14
- package/src/screens/Unit/__test__/Detail.test.js +99 -200
- package/src/screens/Unit/__test__/ManageUnit.test.js +18 -42
- package/src/screens/Unit/__test__/SelectAddress.test.js +84 -51
- package/src/screens/Unit/__test__/SmartAccount.test.js +17 -9
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -1
- package/src/screens/Unit/__test__/Summaries.test.js +100 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/MyAllUnit.test.js +36 -0
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +54 -0
- package/src/screens/Unit/components/SharedUnit/index.js +1 -0
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +31 -34
- package/src/screens/Unit/hook/useUnitConnectRemoteDevices.js +50 -0
- package/src/screens/Unit/styles.js +4 -0
- package/src/screens/UnitSummary/__test__/index.test.js +70 -41
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +31 -2
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/__test__/index.test.js +7 -4
- package/src/screens/UnitSummary/components/PowerConsumeHistoryChart/index.js +2 -13
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -1
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +14 -16
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +11 -2
- package/src/screens/UnitSummary/components/RunningDevices/index.js +7 -10
- package/src/screens/UnitSummary/components/Temperature/index.js +4 -4
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +10 -2
- package/src/screens/UnitSummary/index.js +15 -1
- package/src/utils/Apis/axios.js +46 -31
- package/src/utils/Converter/time.js +0 -18
- package/src/utils/I18n/translations/en.json +4 -1
- package/src/utils/I18n/translations/vi.json +5 -1
- package/src/utils/Permission/common.js +67 -0
- package/src/utils/Utils.js +11 -7
package/README.md
CHANGED
|
@@ -159,7 +159,7 @@ export const MyFunctionalComponent = () => {
|
|
|
159
159
|
- sendRemoteCommand user needs to `have permission to control the device`, you pass in the `sensor and action` to it and it will run after calling render.
|
|
160
160
|
- `sensor` is a device in your Unit and action is the `action` key of the device..
|
|
161
161
|
- You can take out the sensor and action from your Unit when calling the `API.UNIT.UNIT_DETAIL(unitId)` it will return all devices in 1 unit.
|
|
162
|
-
- Or get sensor from `API.
|
|
162
|
+
- Or get sensor from `API.DEVICE.DISPLAY(sensor.id)` returns all actions of 1 device.
|
|
163
163
|
- Refer YourProjectPath /node_modules/@eohjsc/react-native-smart-city/src/screens/Unit/Detail.js
|
|
164
164
|
|
|
165
165
|
## Sync file to EoH source
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.02",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"ios": "react-native run-ios",
|
|
19
19
|
"start": "react-native start",
|
|
20
20
|
"test": "yarn run lint && yarn run jest",
|
|
21
|
-
"lint": "eslint . --ext js --ext ts --ext tsx",
|
|
21
|
+
"lint": "eslint . --ext js --ext ts --ext tsx --max-warnings 5",
|
|
22
22
|
"lint-fix": "eslint . --fix",
|
|
23
23
|
"type-check": "npx tsc",
|
|
24
24
|
"pod": "cd ios && pod install",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"@types/react": "^17.0.0",
|
|
75
75
|
"@types/react-native": "^0.63.43",
|
|
76
76
|
"@types/react-test-renderer": "^17.0.0",
|
|
77
|
+
"axios-mock-adapter": "^1.21.1",
|
|
77
78
|
"babel-jest": "^26.6.3",
|
|
78
79
|
"detox": "^18.3.1",
|
|
79
80
|
"eslint": "7.14.0",
|
|
@@ -99,7 +100,7 @@
|
|
|
99
100
|
"@ant-design/icons-react-native": "^2.2.1",
|
|
100
101
|
"@ant-design/react-native": "^4.0.5",
|
|
101
102
|
"@babel/helper-environment-visitor": "^7.16.7",
|
|
102
|
-
"@eohjsc/highcharts": "^1.0.
|
|
103
|
+
"@eohjsc/highcharts": "^1.0.9",
|
|
103
104
|
"@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
104
105
|
"@formatjs/intl-getcanonicallocales": "^1.4.5",
|
|
105
106
|
"@formatjs/intl-numberformat": "^5.6.2",
|
|
@@ -124,6 +125,7 @@
|
|
|
124
125
|
"@react-navigation/stack": "^5.7.0",
|
|
125
126
|
"@sentry/react-native": "^1.7.1",
|
|
126
127
|
"@testing-library/react-hooks": "^6.0.0",
|
|
128
|
+
"apisauce": "^2.1.5",
|
|
127
129
|
"axios": "^0.19.2",
|
|
128
130
|
"dotenv": "^8.2.0",
|
|
129
131
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -174,7 +176,7 @@
|
|
|
174
176
|
"react-native-pager-view": "^5.4.1",
|
|
175
177
|
"react-native-parallax-scroll-view": "^0.21.3",
|
|
176
178
|
"react-native-parsed-text": "^0.0.22",
|
|
177
|
-
"react-native-permissions": "
|
|
179
|
+
"react-native-permissions": "3.0.3",
|
|
178
180
|
"react-native-popover-view": "^4.0.3",
|
|
179
181
|
"react-native-progress": "^5.0.0",
|
|
180
182
|
"react-native-reanimated": "1.10.1",
|
|
@@ -3,7 +3,7 @@ import { TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
import { TESTID } from '../../configs/Constants';
|
|
4
4
|
import { useSCContextSelector } from '../../context';
|
|
5
5
|
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
6
|
-
import {
|
|
6
|
+
import { useRemoteControl } from '../../hooks/IoT';
|
|
7
7
|
import { useConfigGlobalState } from '../../iot/states';
|
|
8
8
|
import IconComponent from '../IconComponent';
|
|
9
9
|
|
|
@@ -13,6 +13,8 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
|
|
|
13
13
|
// eslint-disable-next-line no-unused-vars
|
|
14
14
|
const [configValues, _] = useConfigGlobalState('configValues');
|
|
15
15
|
|
|
16
|
+
const sendRemoteCommand = useRemoteControl();
|
|
17
|
+
|
|
16
18
|
const revertActionUpdate = useCallback(
|
|
17
19
|
(value, on_action, on_status, off_action, off_status) => {
|
|
18
20
|
setIsSendingCommand(false);
|
|
@@ -81,7 +83,14 @@ const ItemQuickAction = memo(({ sensor, wrapperStyle, setStatus, unit }) => {
|
|
|
81
83
|
statusCallback(action.id === sensor.quick_action.on_action.id);
|
|
82
84
|
}, sensor.quick_action.interval);
|
|
83
85
|
}
|
|
84
|
-
}, [
|
|
86
|
+
}, [
|
|
87
|
+
sensor,
|
|
88
|
+
action,
|
|
89
|
+
userId,
|
|
90
|
+
revertActionUpdate,
|
|
91
|
+
statusCallback,
|
|
92
|
+
sendRemoteCommand,
|
|
93
|
+
]);
|
|
85
94
|
|
|
86
95
|
if (!action) {
|
|
87
96
|
return <View />;
|
|
@@ -5,7 +5,6 @@ import ItemQuickAction from '../ItemQuickAction';
|
|
|
5
5
|
import { Colors } from '../../../configs';
|
|
6
6
|
import { TESTID } from '../../../configs/Constants';
|
|
7
7
|
import { factory } from 'factory-girl';
|
|
8
|
-
import { sendRemoteCommand } from '../../../iot/RemoteControl';
|
|
9
8
|
|
|
10
9
|
class Sensor {}
|
|
11
10
|
|
|
@@ -21,7 +20,13 @@ jest.mock('react', () => {
|
|
|
21
20
|
|
|
22
21
|
useState.mockImplementation((init) => [init, mockSetState]);
|
|
23
22
|
|
|
24
|
-
jest.
|
|
23
|
+
const mockSendRemoteControl = jest.fn();
|
|
24
|
+
jest.mock('../../../hooks/IoT', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('../../../hooks/IoT'),
|
|
27
|
+
useRemoteControl: () => mockSendRemoteControl,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
25
30
|
|
|
26
31
|
jest.mock('../../../iot/states', () => ({
|
|
27
32
|
useConfigGlobalState: () => [{}, null],
|
|
@@ -83,9 +88,9 @@ describe('Test ItemQuickAction', () => {
|
|
|
83
88
|
};
|
|
84
89
|
|
|
85
90
|
test('render with no action', async () => {
|
|
86
|
-
const
|
|
91
|
+
const newSensor = await factory.build('Sensor');
|
|
87
92
|
act(() => {
|
|
88
|
-
tree = create(<ItemQuickAction sensor={
|
|
93
|
+
tree = create(<ItemQuickAction sensor={newSensor} />);
|
|
89
94
|
});
|
|
90
95
|
const instance = tree.root;
|
|
91
96
|
const buttonOnActionPress = instance.findAll(
|
|
@@ -121,7 +126,7 @@ describe('Test ItemQuickAction', () => {
|
|
|
121
126
|
act(() => {
|
|
122
127
|
buttonOnActionPress.props.onPress();
|
|
123
128
|
});
|
|
124
|
-
expect(
|
|
129
|
+
expect(mockSendRemoteControl).toBeCalled();
|
|
125
130
|
expect(mockSetState).toBeCalledTimes(1);
|
|
126
131
|
|
|
127
132
|
jest.runAllTimers();
|
|
@@ -154,7 +159,7 @@ describe('Test ItemQuickAction', () => {
|
|
|
154
159
|
act(() => {
|
|
155
160
|
buttonOnActionPress.props.onPress();
|
|
156
161
|
});
|
|
157
|
-
expect(
|
|
162
|
+
expect(mockSendRemoteControl).toBeCalled();
|
|
158
163
|
expect(mockSetState).toBeCalledTimes(1);
|
|
159
164
|
|
|
160
165
|
jest.runAllTimers();
|
|
@@ -17,6 +17,11 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
17
17
|
close_action_data,
|
|
18
18
|
action_off_data,
|
|
19
19
|
action_on_data,
|
|
20
|
+
is_display_lock,
|
|
21
|
+
text1,
|
|
22
|
+
text2,
|
|
23
|
+
text3,
|
|
24
|
+
text_door_lock,
|
|
20
25
|
} = configuration || {};
|
|
21
26
|
const [lock, setLock] = useState(false);
|
|
22
27
|
|
|
@@ -52,21 +57,21 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
52
57
|
{
|
|
53
58
|
style: styles.buttonActionCurtain,
|
|
54
59
|
icon: Images.buttonLeftCurtain,
|
|
55
|
-
text:
|
|
60
|
+
text: text1,
|
|
56
61
|
onPress: onButtonOpenPress,
|
|
57
62
|
testID: TESTID.BUTTON_TEMPLATE_1,
|
|
58
63
|
},
|
|
59
64
|
{
|
|
60
65
|
style: styles.buttonActionCurtainCenter,
|
|
61
66
|
icon: Images.buttonPauseCurtain,
|
|
62
|
-
text:
|
|
67
|
+
text: text2,
|
|
63
68
|
onPress: onButtonStopPress,
|
|
64
69
|
testID: TESTID.BUTTON_TEMPLATE_2,
|
|
65
70
|
},
|
|
66
71
|
{
|
|
67
72
|
style: styles.buttonActionCurtain,
|
|
68
73
|
icon: Images.buttonRightCurtain,
|
|
69
|
-
text:
|
|
74
|
+
text: text3,
|
|
70
75
|
onPress: onButtonClosePress,
|
|
71
76
|
testID: TESTID.BUTTON_TEMPLATE_3,
|
|
72
77
|
},
|
|
@@ -96,7 +101,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
96
101
|
style={styles.textLockDoor}
|
|
97
102
|
testID={TESTID.TEXT_DOOR_LOOK_ON_OFF}
|
|
98
103
|
>
|
|
99
|
-
{
|
|
104
|
+
{text_door_lock}{' '}
|
|
100
105
|
</Text>
|
|
101
106
|
</View>
|
|
102
107
|
<Switch
|
|
@@ -115,7 +120,7 @@ const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
115
120
|
<RenderThreeButtonActions />
|
|
116
121
|
</View>
|
|
117
122
|
<View style={styles.lockSwitch}>
|
|
118
|
-
{
|
|
123
|
+
{is_display_lock &&
|
|
119
124
|
itemLock(
|
|
120
125
|
lock ? 'lock' : 'unlock',
|
|
121
126
|
lock ? Colors.Primary : Colors.Gray6
|
|
@@ -7,6 +7,7 @@ import Text from '../Text';
|
|
|
7
7
|
import { useConfigGlobalState } from '../../iot/states';
|
|
8
8
|
import styles from './NumberUpDownActionTemplateStyle';
|
|
9
9
|
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
10
|
+
import { TESTID } from '../../configs/Constants';
|
|
10
11
|
|
|
11
12
|
const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
12
13
|
const { configuration, title } = actionGroup;
|
|
@@ -15,39 +16,39 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
15
16
|
max_value,
|
|
16
17
|
min_value,
|
|
17
18
|
text_format,
|
|
18
|
-
keep_track_config,
|
|
19
19
|
config,
|
|
20
|
+
allow_config_store_value,
|
|
20
21
|
} = configuration;
|
|
21
22
|
|
|
22
23
|
// eslint-disable-next-line no-unused-vars
|
|
23
24
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
24
|
-
const [value, setValue] = useState(
|
|
25
|
+
const [value, setValue] = useState();
|
|
26
|
+
const valueDefault = 28;
|
|
25
27
|
|
|
26
28
|
useEffect(() => {
|
|
27
|
-
if (!keep_track_config) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
29
|
if (!config) {
|
|
30
|
+
setValue(valueDefault);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const configValue = configValues[config];
|
|
35
35
|
if (configValue !== null && configValue !== undefined) {
|
|
36
36
|
setValue(configValue);
|
|
37
|
+
} else {
|
|
38
|
+
setValue(valueDefault);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
+
}, []);
|
|
39
42
|
|
|
40
43
|
const doActionAndWatchConfig = useCallback(
|
|
41
44
|
async (actionData, actionValue, actionName) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
if (!sensor?.is_managed_by_backend) {
|
|
48
|
-
return;
|
|
45
|
+
const data = { temperature: actionValue };
|
|
46
|
+
if (allow_config_store_value && config) {
|
|
47
|
+
data.config_id = config;
|
|
48
|
+
data.value = actionValue;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
await doAction(actionData, JSON.stringify(data), actionName);
|
|
51
|
+
if (!sensor?.is_managed_by_backend) {
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
if (!config) {
|
|
@@ -59,11 +60,11 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
59
60
|
watchMultiConfigs([config]);
|
|
60
61
|
},
|
|
61
62
|
[
|
|
62
|
-
config,
|
|
63
63
|
doAction,
|
|
64
|
-
|
|
65
|
-
sensor.is_managed_by_backend,
|
|
64
|
+
sensor?.is_managed_by_backend,
|
|
66
65
|
sensor.device_type,
|
|
66
|
+
allow_config_store_value,
|
|
67
|
+
config,
|
|
67
68
|
]
|
|
68
69
|
);
|
|
69
70
|
|
|
@@ -103,13 +104,23 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
103
104
|
)}
|
|
104
105
|
|
|
105
106
|
<View style={styles.controlPannel}>
|
|
106
|
-
<TouchableOpacity
|
|
107
|
+
<TouchableOpacity
|
|
108
|
+
style={styles.downButton}
|
|
109
|
+
onPress={doActionDown}
|
|
110
|
+
testID={TESTID.NUMBER_ACTION_DOWN}
|
|
111
|
+
>
|
|
107
112
|
<IconOutline name="down" size={32} color={Colors.Primary} />
|
|
108
113
|
</TouchableOpacity>
|
|
109
114
|
|
|
110
|
-
<Text type="H2">
|
|
115
|
+
<Text testID={'abcd'} type="H2">
|
|
116
|
+
{text_format.replace('{number}', value)}
|
|
117
|
+
</Text>
|
|
111
118
|
|
|
112
|
-
<TouchableOpacity
|
|
119
|
+
<TouchableOpacity
|
|
120
|
+
style={styles.upButton}
|
|
121
|
+
onPress={doActionUp}
|
|
122
|
+
testID={TESTID.NUMBER_ACTION_UP}
|
|
123
|
+
>
|
|
113
124
|
<IconOutline name="up" size={32} color={Colors.Primary} />
|
|
114
125
|
</TouchableOpacity>
|
|
115
126
|
</View>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
|
+
import { Switch } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import AutoLock from '../index';
|
|
5
6
|
import { mockSCStore } from '../../../../../context/mockStore';
|
|
@@ -38,6 +39,9 @@ describe('Test AutoLock', () => {
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
const instance = tree.root;
|
|
42
|
+
const switchs = instance.findByType(Switch);
|
|
43
|
+
await switchs.props.onValueChange();
|
|
44
|
+
|
|
41
45
|
const { buttonEnable, buttonInstant, buttonRelockTiming } =
|
|
42
46
|
getElement(instance);
|
|
43
47
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { SCProvider } from '../../../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../../../context/mockStore';
|
|
6
|
+
import ItemPasscode from '../ItemPasscode';
|
|
7
|
+
|
|
8
|
+
const wrapComponent = (route = {}) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<ItemPasscode route={route} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
describe('Test ItemPasscode', () => {
|
|
15
|
+
let tree;
|
|
16
|
+
test('test render without params', async () => {
|
|
17
|
+
await act(async () => {
|
|
18
|
+
tree = await create(wrapComponent());
|
|
19
|
+
});
|
|
20
|
+
const instance = tree.root;
|
|
21
|
+
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
22
|
+
expect(TouchableOpacities).toHaveLength(2);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -40,6 +40,7 @@ describe('Test SetupGeneratePasscode', () => {
|
|
|
40
40
|
const changeDuration = instance.findAll(
|
|
41
41
|
(item) => item.props.testID === TESTID.GENERATE_PASSCODE_SET_DURATION
|
|
42
42
|
);
|
|
43
|
+
|
|
43
44
|
return {
|
|
44
45
|
changeName,
|
|
45
46
|
changeTime,
|
|
@@ -58,5 +59,18 @@ describe('Test SetupGeneratePasscode', () => {
|
|
|
58
59
|
expect(changeName[0]).toBeDefined();
|
|
59
60
|
expect(changeTime[0]).toBeDefined();
|
|
60
61
|
expect(changeDuration[0]).toBeDefined();
|
|
62
|
+
|
|
63
|
+
await changeDuration[0].props.onPressSetMinute();
|
|
64
|
+
await changeDuration[0].props.onPressSelectCircle();
|
|
65
|
+
await changeTime[0].props.onPressSetTime();
|
|
66
|
+
|
|
67
|
+
const wheelDateTimePicker = instance.findAll(
|
|
68
|
+
(item) =>
|
|
69
|
+
item.props.testID ===
|
|
70
|
+
`${TESTID.WHEEL_DATE_TIME_PICKER_BUTTON}${TESTID.VIEW_BUTTON_BOTTOM_RIGHT_BUTTON}`
|
|
71
|
+
);
|
|
72
|
+
await wheelDateTimePicker[5].props.onClick();
|
|
73
|
+
await wheelDateTimePicker[11].props.onClick();
|
|
74
|
+
await wheelDateTimePicker[17].props.onClick();
|
|
61
75
|
});
|
|
62
76
|
});
|
|
@@ -92,7 +92,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
92
92
|
return t('not_available');
|
|
93
93
|
}
|
|
94
94
|
return selectedOption.text;
|
|
95
|
-
}, [configuration
|
|
95
|
+
}, [configuration?.config, selectedOption?.text, t]);
|
|
96
96
|
|
|
97
97
|
const iconSvg = useMemo(() => {
|
|
98
98
|
switch (icon) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
|
-
import { View, ScrollView
|
|
2
|
+
import { View, ScrollView } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import styles from './SmartTiviActionTemplateStyles';
|
|
5
5
|
import Text from '../../Text';
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
Youtube,
|
|
23
23
|
Netflix,
|
|
24
24
|
} from './component/Icon';
|
|
25
|
+
import { notImplemented } from '../../../utils/Utils';
|
|
25
26
|
|
|
26
27
|
const SmartTiviActionTemplate = memo(
|
|
27
28
|
({ actionGroup, doAction, scrollEnabled = true }) => {
|
|
@@ -68,7 +69,7 @@ const SmartTiviActionTemplate = memo(
|
|
|
68
69
|
case SMART_TIVI_BUTTON.HOME_BUTTON:
|
|
69
70
|
case SMART_TIVI_BUTTON.BACK_BUTTON:
|
|
70
71
|
case SMART_TIVI_BUTTON.CHANNEL_BUTTON:
|
|
71
|
-
return
|
|
72
|
+
return notImplemented(t);
|
|
72
73
|
default:
|
|
73
74
|
return <></>;
|
|
74
75
|
}
|
|
@@ -105,15 +105,19 @@ const GridItem = ({ item, index, length, doAction, sensor, title }) => {
|
|
|
105
105
|
);
|
|
106
106
|
};
|
|
107
107
|
|
|
108
|
-
const StatesGridActionTemplate = ({
|
|
109
|
-
|
|
108
|
+
const StatesGridActionTemplate = ({
|
|
109
|
+
actionGroup = {},
|
|
110
|
+
doAction,
|
|
111
|
+
sensor = {},
|
|
112
|
+
}) => {
|
|
113
|
+
const { configuration = {}, title } = actionGroup;
|
|
110
114
|
|
|
111
115
|
// eslint-disable-next-line no-unused-vars
|
|
112
116
|
const [configValues, setConfigValues] = useConfigGlobalState('configValues');
|
|
113
117
|
|
|
114
118
|
const options = useMemo(() => {
|
|
115
|
-
return configuration
|
|
116
|
-
if (configValues[option
|
|
119
|
+
return (configuration?.options || []).map((option) => {
|
|
120
|
+
if (configValues[option?.config] === option?.is_on_value) {
|
|
117
121
|
return {
|
|
118
122
|
...option,
|
|
119
123
|
active: true,
|
|
@@ -14,9 +14,9 @@ import { Colors } from '../../configs';
|
|
|
14
14
|
import { useConfigGlobalState } from '../../iot/states';
|
|
15
15
|
import BottomScrollPicker from '../BottomScrollPicker';
|
|
16
16
|
|
|
17
|
-
const TimerActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
17
|
+
const TimerActionTemplate = ({ actionGroup = {}, doAction, sensor = {} }) => {
|
|
18
18
|
const t = useTranslations();
|
|
19
|
-
const { configuration, title } = actionGroup;
|
|
19
|
+
const { configuration = {}, title } = actionGroup;
|
|
20
20
|
const [showTime, setShowTime] = useState(false);
|
|
21
21
|
const [showHour, setShowHour] = useState(false);
|
|
22
22
|
|
|
@@ -14,7 +14,6 @@ const TwoButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
14
14
|
const { button1, button2 } = configuration;
|
|
15
15
|
const [isOn, setIsOn] = useState(true);
|
|
16
16
|
const [isStart, setIsStart] = useState(true);
|
|
17
|
-
// eslint-disable-next-line no-unused-vars
|
|
18
17
|
const [configValues] = useConfigGlobalState('configValues');
|
|
19
18
|
const isLight = false;
|
|
20
19
|
|
|
@@ -1,20 +1,37 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
+
import { TouchableOpacity, Switch } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import CurtainButtonTemplate from '../CurtainButtonTemplate';
|
|
6
6
|
import { SCProvider } from '../../../context';
|
|
7
7
|
import { mockSCStore } from '../../../context/mockStore';
|
|
8
8
|
|
|
9
|
-
const
|
|
9
|
+
const mockDoAction = jest.fn();
|
|
10
|
+
const mockActionOffData = jest.fn();
|
|
11
|
+
const mockActionOnData = jest.fn();
|
|
12
|
+
const mockCloseActionData = jest.fn();
|
|
13
|
+
|
|
14
|
+
const wrapComponent = (actionGroup = {}, sensor = {}) => (
|
|
10
15
|
<SCProvider initState={mockSCStore({})}>
|
|
11
|
-
<CurtainButtonTemplate
|
|
16
|
+
<CurtainButtonTemplate
|
|
17
|
+
actionGroup={actionGroup}
|
|
18
|
+
doAction={mockDoAction}
|
|
19
|
+
sensor={sensor}
|
|
20
|
+
/>
|
|
12
21
|
</SCProvider>
|
|
13
22
|
);
|
|
14
23
|
|
|
15
24
|
describe('Test CurtainButtonTemplate', () => {
|
|
25
|
+
const sensor = {
|
|
26
|
+
name: 'test',
|
|
27
|
+
};
|
|
16
28
|
const actionGroup = {
|
|
17
29
|
configuration: {
|
|
30
|
+
text_open: 'open',
|
|
31
|
+
is_display_lock: true,
|
|
32
|
+
action_off_data: mockActionOffData,
|
|
33
|
+
action_on_data: mockActionOnData,
|
|
34
|
+
close_action_data: mockCloseActionData,
|
|
18
35
|
action1: '2b949045-8e03-4c07-a855-7794ade2e69c',
|
|
19
36
|
action1_data: {
|
|
20
37
|
color: '#00979D',
|
|
@@ -61,12 +78,44 @@ describe('Test CurtainButtonTemplate', () => {
|
|
|
61
78
|
|
|
62
79
|
let wrapper;
|
|
63
80
|
|
|
81
|
+
test('render without params', async () => {
|
|
82
|
+
await act(() => {
|
|
83
|
+
wrapper = renderer.create(wrapComponent());
|
|
84
|
+
});
|
|
85
|
+
const instance = wrapper.root;
|
|
86
|
+
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
87
|
+
expect(touchableOpacities.length).toEqual(3);
|
|
88
|
+
});
|
|
89
|
+
|
|
64
90
|
test('render CurtainButtonTemplate', async () => {
|
|
65
91
|
await act(() => {
|
|
66
|
-
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
92
|
+
wrapper = renderer.create(wrapComponent(actionGroup, sensor));
|
|
67
93
|
});
|
|
68
94
|
const instance = wrapper.root;
|
|
69
95
|
const touchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
70
96
|
expect(touchableOpacities.length).toEqual(3);
|
|
97
|
+
await touchableOpacities[0].props.onPress();
|
|
98
|
+
await touchableOpacities[1].props.onPress();
|
|
99
|
+
await touchableOpacities[2].props.onPress();
|
|
100
|
+
expect(mockDoAction).toBeCalledWith(
|
|
101
|
+
mockCloseActionData,
|
|
102
|
+
null,
|
|
103
|
+
sensor?.name + ' undefined'
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
const Switchs = instance.findAllByType(Switch);
|
|
107
|
+
expect(Switchs).toHaveLength(1);
|
|
108
|
+
await Switchs[0].props.onValueChange();
|
|
109
|
+
expect(mockDoAction).toBeCalledWith(
|
|
110
|
+
mockActionOnData,
|
|
111
|
+
null,
|
|
112
|
+
`${sensor.name} lock`
|
|
113
|
+
);
|
|
114
|
+
await Switchs[0].props.onValueChange();
|
|
115
|
+
expect(mockDoAction).toBeCalledWith(
|
|
116
|
+
mockActionOffData,
|
|
117
|
+
null,
|
|
118
|
+
`${sensor.name} unlock`
|
|
119
|
+
);
|
|
71
120
|
});
|
|
72
121
|
});
|