@eohjsc/react-native-smart-city 0.7.3 → 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/Automation-fill.svg +85 -0
- package/assets/images/Map/LocationPin.svg +10 -0
- package/assets/images/Scenario-filled.svg +22 -0
- package/assets/images/schedule-fill.svg +48 -0
- package/package.json +20 -17
- package/src/commons/Action/ItemQuickAction.js +1 -1
- package/src/commons/Action/__test__/ItemQuickAction.test.js +6 -6
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
- package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +5 -5
- 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/ThreeButtonTemplate/__test__/ThreeButtonCircle.test.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonDefault.test.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__/ColorPickerTemplate.test.js +9 -10
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +5 -5
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +8 -8
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +6 -6
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +1 -1
- package/src/commons/ActionGroup/__test__/index.test.js +6 -6
- package/src/commons/ActionGroup/index.js +2 -2
- package/src/commons/ActionTemplate/__test__/index.test.js +4 -4
- 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/ChartAggregationOption/__test__/FourButtonFilterHistory.test.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +8 -9
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +7 -7
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +3 -3
- package/src/commons/DateTimeRangeChange/index.js +1 -1
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +1 -1
- package/src/commons/Device/FlatListItems.js +20 -19
- package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.test.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 +5 -21
- 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/FieldTemplate/PasscodeField/__test__/index.test.js +3 -3
- package/src/commons/FieldTemplate/ScheduleField/__test__/index.test.js +6 -6
- package/src/commons/FlatListDnD/__test__/index.test.js +4 -4
- package/src/commons/FlatListDnD/index.js +12 -9
- package/src/commons/Grid/GridItem.js +10 -2
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +3 -3
- package/src/commons/Header/HeaderCustom.js +2 -2
- package/src/commons/Header/__test__/HeaderCT.test.js +3 -3
- package/src/commons/HeaderAni/index.js +2 -2
- package/src/commons/IconComponent/index.js +3 -3
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +5 -5
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +6 -4
- package/src/commons/MenuActionMore/MenuActionMoreStyles.js +2 -1
- package/src/commons/MenuActionMore/index.js +1 -1
- package/src/commons/NavBar/NavBarStyles.js +1 -1
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/OneTapTemplate/__test__/StatesGridActionTemplate.test.js +1 -1
- package/src/commons/Popover/__test__/index.test.js +3 -3
- package/src/commons/Processing/__test__/Connecting.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/SelectUnit/__test__/SelectUnit.test.js +5 -5
- 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 +6 -7
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +0 -2
- package/src/commons/SubUnit/OneTap/index.js +9 -8
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +8 -8
- package/src/commons/Unit/HeaderUnit/index.js +30 -22
- package/src/commons/Unit/SharedUnit.js +7 -7
- package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +9 -13
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +34 -2
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +88 -8
- package/src/commons/WrapParallaxScrollView/index.js +9 -10
- package/src/configs/API.js +1 -1
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/configs/Constants.js +3 -3
- package/src/configs/Theme.js +1 -1
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +5 -5
- package/src/hooks/IoT/__test__/useHomeAssistantConnection.test.js +12 -12
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +14 -7
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -3
- package/src/hooks/IoT/useRemoteControl.js +24 -13
- package/src/hooks/useMqtt.js +2 -2
- package/src/iot/RemoteControl/Bluetooth.js +19 -22
- package/src/iot/RemoteControl/Internet.js +13 -5
- package/src/iot/RemoteControl/__test__/Internet.test.js +7 -7
- 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/__test__/index.test.js +12 -12
- 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/AddNewGateway/ShareWifiPassword.js +16 -15
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +7 -7
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +8 -8
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +5 -5
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +4 -4
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +6 -6
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +0 -4
- package/src/screens/AddNewGateway/hooks/__Tests__/useWifiManage.test.js +2 -2
- package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +19 -17
- package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +18 -16
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +43 -35
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +38 -22
- package/src/screens/AllGateway/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/components/Detail/__test__/index.test.js +3 -5
- package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +3 -3
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +6 -6
- package/src/screens/AllGateway/hooks/__test__/index.test.js +2 -2
- package/src/screens/AllGateway/test-utils.js +3 -4
- 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 +12 -12
- 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__/SetupScriptDelay.test.js +9 -9
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +39 -10
- package/src/screens/Automate/AddNewAutoSmart/AddTypeSmart.js +10 -10
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +13 -8
- package/src/screens/Automate/Components/InputName.js +10 -7
- package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +8 -8
- package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +6 -6
- package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +7 -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 +18 -8
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +15 -7
- 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/__test__/useStarredScript.test.js +6 -6
- package/src/screens/Automate/ScriptDetail/index.js +51 -40
- package/src/screens/Automate/SetSchedule/__test__/SelectWeekday.test.js +4 -4
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +29 -18
- 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/__test__/index.test.js +6 -6
- package/src/screens/ChangePosition/index.js +2 -1
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +13 -13
- 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 +14 -14
- package/src/screens/Device/__test__/mqttDetail.test.js +9 -9
- package/src/screens/Device/components/BluetoothDevice.js +135 -0
- package/src/screens/Device/components/SensorDisplayItem.js +9 -8
- package/src/screens/Device/detail.js +70 -62
- package/src/screens/Device/hooks/useEvaluateValue.js +1 -1
- package/src/screens/Drawer/Drawer.test.js +2 -2
- 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/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +7 -7
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +8 -8
- package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
- package/src/screens/GuestInfo/components/__test__/AccessScheduleSheet.test.js +3 -3
- 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/__test__/Detail.test.js +9 -9
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +10 -10
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/index.js +3 -3
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +9 -9
- package/src/screens/Notification/__test__/Notification.test.js +9 -9
- package/src/screens/Notification/components/NotificationItem.js +3 -4
- package/src/screens/Notification/index.js +3 -3
- package/src/screens/Notification/styles/NotificationItemStyles.js +0 -1
- package/src/screens/PlayBackCamera/__test__/index.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +1 -1
- package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +8 -8
- 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/Sharing/__test__/UpdateShareDevice.test.js +7 -7
- package/src/screens/SideMenuDetail/__test__/index.test.js +8 -8
- package/src/screens/SmartAccount/Connecting/index.js +5 -5
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +8 -8
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +7 -7
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +2 -2
- package/src/screens/SmartAccount/__test__/Connecting.test.js +6 -6
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +10 -10
- 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 -26
- 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/Template/__test__/EditTemplate.test.js +7 -7
- package/src/screens/Template/__test__/detail.test.js +4 -4
- package/src/screens/Template/__test__/index.test.js +1 -1
- package/src/screens/UVIndexGuide/index.js +2 -4
- package/src/screens/Unit/Detail.js +1 -5
- package/src/screens/Unit/MoreMenu.js +6 -5
- package/src/screens/Unit/SelectAddToFavorites.js +2 -2
- package/src/screens/Unit/SelectAddress.js +16 -12
- package/src/screens/Unit/Station/__test__/index.test.js +1 -1
- package/src/screens/Unit/__test__/MoreMenu.test.js +5 -1
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +9 -9
- package/src/screens/Unit/__test__/SelectAddress.test.js +11 -17
- package/src/screens/Unit/__test__/Summaries.test.js +7 -7
- package/src/screens/Unit/components/AutomateScript/index.js +5 -5
- 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/Unit/components/__test__/AutomateScript.test.js +3 -3
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +8 -8
- package/src/screens/Unit/hook/__test__/useUnitConnectRemoteDevices.test.js +2 -2
- package/src/screens/UnitSummary/components/AirQuality/index.js +6 -11
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +5 -5
- package/src/screens/UnitSummary/index.js +6 -2
- 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/__test__/Utils.test.js +16 -16
- package/src/utils/bluetooth.js +3 -0
- package/assets/images/OneTap.svg +0 -14
- package/assets/images/Schedule.svg +0 -39
- package/assets/images/ValueChange.svg +0 -49
|
@@ -13,12 +13,13 @@ import ParallaxScrollView from '../../libs/react-native-parallax-scroll-view';
|
|
|
13
13
|
const stickyHeaderHeight =
|
|
14
14
|
Device.TopbarHeight + (Device.isIOS ? 0 : StatusBar.currentHeight);
|
|
15
15
|
|
|
16
|
-
const WrapParallaxScrollView = ({ children, unit,
|
|
16
|
+
const WrapParallaxScrollView = ({ children, unit, onRefresh }) => {
|
|
17
|
+
const { name = '', background } = unit;
|
|
17
18
|
const t = useTranslations();
|
|
18
19
|
const renderForeground = useCallback(
|
|
19
20
|
() => (
|
|
20
21
|
<View style={styles.wrap}>
|
|
21
|
-
<HeaderUnit unit={unit}
|
|
22
|
+
<HeaderUnit transparent unit={unit} />
|
|
22
23
|
<Text
|
|
23
24
|
numberOfLines={1}
|
|
24
25
|
semibold
|
|
@@ -26,12 +27,12 @@ const WrapParallaxScrollView = ({ children, unit, unitData, onRefresh }) => {
|
|
|
26
27
|
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_TEXT}
|
|
27
28
|
>
|
|
28
29
|
{t('Welcome {name}', {
|
|
29
|
-
name:
|
|
30
|
+
name: name,
|
|
30
31
|
})}
|
|
31
32
|
</Text>
|
|
32
33
|
</View>
|
|
33
34
|
),
|
|
34
|
-
[unit,
|
|
35
|
+
[unit, t, name]
|
|
35
36
|
);
|
|
36
37
|
const renderBackground = useCallback(
|
|
37
38
|
() => (
|
|
@@ -39,9 +40,7 @@ const WrapParallaxScrollView = ({ children, unit, unitData, onRefresh }) => {
|
|
|
39
40
|
<FImage
|
|
40
41
|
style={styles.image}
|
|
41
42
|
source={
|
|
42
|
-
|
|
43
|
-
? { uri: unit.background }
|
|
44
|
-
: SCConfig.appUnitDefaultBackground
|
|
43
|
+
background ? { uri: background } : SCConfig.appUnitDefaultBackground
|
|
45
44
|
}
|
|
46
45
|
defaultSource={Images.BgUnit}
|
|
47
46
|
resizeMode="cover"
|
|
@@ -52,15 +51,15 @@ const WrapParallaxScrollView = ({ children, unit, unitData, onRefresh }) => {
|
|
|
52
51
|
/>
|
|
53
52
|
</View>
|
|
54
53
|
),
|
|
55
|
-
[
|
|
54
|
+
[background]
|
|
56
55
|
);
|
|
57
56
|
const renderStickyHeader = useCallback(
|
|
58
57
|
() => (
|
|
59
58
|
<View style={styles.stickyHeader}>
|
|
60
|
-
<HeaderUnit unit={unit}
|
|
59
|
+
<HeaderUnit unit={unit} />
|
|
61
60
|
</View>
|
|
62
61
|
),
|
|
63
|
-
[unit
|
|
62
|
+
[unit]
|
|
64
63
|
);
|
|
65
64
|
return (
|
|
66
65
|
<ParallaxScrollView
|
package/src/configs/API.js
CHANGED
|
@@ -54,7 +54,7 @@ const API = {
|
|
|
54
54
|
JSON_CONFIGURATION: '/chip_manager/chips/json_configuration/',
|
|
55
55
|
},
|
|
56
56
|
DEVICE: {
|
|
57
|
-
|
|
57
|
+
DEVICE_DETAIL: (id) => `/property_manager/devices/${id}/`,
|
|
58
58
|
DISPLAY: (id) => `/property_manager/devices/${id}/display/`,
|
|
59
59
|
SIDE_MENU_DETAIL: (id, side_menu_id) =>
|
|
60
60
|
`/property_manager/devices/${id}/display/side_menu/${side_menu_id}/`,
|
|
@@ -239,6 +239,7 @@ export default {
|
|
|
239
239
|
BUTTON_ADD_SCRIPT_ACTION: 'BUTTON_ADD_SCRIPT_ACTION',
|
|
240
240
|
ICON_CLOSE: 'ICON_CLOSE',
|
|
241
241
|
ICON_MORE: 'ICON_MORE',
|
|
242
|
+
ICON_MENU_POPUP: 'ICON_MENU_POPUP',
|
|
242
243
|
ICON_ARROW_RIGHT: 'ICON_ARROW_RIGHT',
|
|
243
244
|
TEXT_AUTOMATE_NAME: 'TEXT_AUTOMATE_NAME',
|
|
244
245
|
AUTOMATE_LIST_SCRIPT_ACTION: 'AUTOMATE_LIST_SCRIPT_ACTION',
|
package/src/configs/Constants.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as AccessibilityLabel } from './AccessibilityLabel';
|
|
2
2
|
import { Platform, Dimensions, StatusBar } from 'react-native';
|
|
3
3
|
import { RFValue } from 'react-native-responsive-fontsize';
|
|
4
|
-
import OneTap from '../../assets/images/
|
|
5
|
-
import ValueChange from '../../assets/images/
|
|
6
|
-
import Schedule from '../../assets/images/
|
|
4
|
+
import OneTap from '../../assets/images/Scenario-filled.svg';
|
|
5
|
+
import ValueChange from '../../assets/images/Automation-fill.svg';
|
|
6
|
+
import Schedule from '../../assets/images/schedule-fill.svg';
|
|
7
7
|
import Event from '../../assets/images/Event.svg';
|
|
8
8
|
|
|
9
9
|
const X_WIDTH = 375;
|
package/src/configs/Theme.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { useNavigation } from '@react-navigation/native';
|
|
2
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { Platform } from 'react-native';
|
|
3
|
-
import { renderHook } from '@testing-library/react-hooks';
|
|
4
|
-
import { useAndroidTranslucentStatusBar } from '../index';
|
|
5
5
|
import { SCProvider } from '../../../context';
|
|
6
6
|
import { mockSCStore } from '../../../context/mockStore';
|
|
7
|
-
import {
|
|
7
|
+
import { useAndroidTranslucentStatusBar } from '../index';
|
|
8
8
|
|
|
9
9
|
const mockedSetAction = jest.fn();
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ describe('test useAndroidTranslucentStatusBar', () => {
|
|
|
28
28
|
wrapper,
|
|
29
29
|
}
|
|
30
30
|
);
|
|
31
|
-
expect(addListener).not.
|
|
31
|
+
expect(addListener).not.toHaveBeenCalled();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
34
|
it('test useAndroidTranslucentStatusBar ios', async () => {
|
|
@@ -39,6 +39,6 @@ describe('test useAndroidTranslucentStatusBar', () => {
|
|
|
39
39
|
wrapper,
|
|
40
40
|
}
|
|
41
41
|
);
|
|
42
|
-
expect(addListener).not.
|
|
42
|
+
expect(addListener).not.toHaveBeenCalled();
|
|
43
43
|
});
|
|
44
44
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { act, renderHook } from '@testing-library/react-hooks';
|
|
3
|
-
import { createConnection, getStates } from 'home-assistant-js-websocket';
|
|
4
2
|
import MockAdapter from 'axios-mock-adapter';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { createConnection, getStates } from 'home-assistant-js-websocket';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { API } from '../../../configs';
|
|
7
6
|
import { SCProvider } from '../../../context';
|
|
8
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
9
7
|
import { Action } from '../../../context/actionType';
|
|
10
|
-
import {
|
|
8
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
|
+
import api from '../../../utils/Apis/axios';
|
|
10
|
+
import { useHomeAssistantConnection } from '../index';
|
|
11
11
|
|
|
12
12
|
const mock = new MockAdapter(api.axiosInstance);
|
|
13
13
|
|
|
@@ -124,7 +124,7 @@ describe('Test useHomeAssistantConnection', () => {
|
|
|
124
124
|
await act(async () => {
|
|
125
125
|
await result.current.connectHomeAssistant(options);
|
|
126
126
|
});
|
|
127
|
-
expect(mockedSetAction).
|
|
127
|
+
expect(mockedSetAction).toHaveBeenCalledWith(
|
|
128
128
|
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
129
129
|
conns
|
|
130
130
|
);
|
|
@@ -145,7 +145,7 @@ describe('Test useHomeAssistantConnection', () => {
|
|
|
145
145
|
await act(async () => {
|
|
146
146
|
await result.current.connectHomeAssistant(options);
|
|
147
147
|
});
|
|
148
|
-
expect(mockedSetAction).
|
|
148
|
+
expect(mockedSetAction).toHaveBeenCalledWith(
|
|
149
149
|
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
150
150
|
conns
|
|
151
151
|
);
|
|
@@ -167,12 +167,12 @@ describe('Test useHomeAssistantConnection', () => {
|
|
|
167
167
|
await act(async () => {
|
|
168
168
|
await result.current.connectHomeAssistant(options);
|
|
169
169
|
});
|
|
170
|
-
expect(mockedSetAction).
|
|
171
|
-
expect(mockedSetAction).
|
|
170
|
+
expect(mockedSetAction).toHaveBeenCalledTimes(2);
|
|
171
|
+
expect(mockedSetAction).toHaveBeenCalledWith(
|
|
172
172
|
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
173
173
|
conns
|
|
174
174
|
);
|
|
175
|
-
expect(mockedSetAction).
|
|
175
|
+
expect(mockedSetAction).toHaveBeenCalledWith(Action.LIST_DEVICE_TYPES, {
|
|
176
176
|
chipId: options[0].chip_id,
|
|
177
177
|
sentEmail: true,
|
|
178
178
|
});
|
|
@@ -190,7 +190,7 @@ describe('Test useHomeAssistantConnection', () => {
|
|
|
190
190
|
await act(async () => {
|
|
191
191
|
await result.current.disconnectHomeAssistant(conns, options);
|
|
192
192
|
});
|
|
193
|
-
expect(mockedSetAction).
|
|
193
|
+
expect(mockedSetAction).toHaveBeenCalledWith(
|
|
194
194
|
Action.SET_HOME_ASSISTANT_CONNECTIONS,
|
|
195
195
|
{}
|
|
196
196
|
);
|
|
@@ -81,7 +81,8 @@ describe('Test useRemoteControl', () => {
|
|
|
81
81
|
sensor,
|
|
82
82
|
action,
|
|
83
83
|
data,
|
|
84
|
-
userId
|
|
84
|
+
userId,
|
|
85
|
+
false
|
|
85
86
|
);
|
|
86
87
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
87
88
|
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
@@ -106,13 +107,15 @@ describe('Test useRemoteControl', () => {
|
|
|
106
107
|
sensor,
|
|
107
108
|
action,
|
|
108
109
|
data,
|
|
109
|
-
userId
|
|
110
|
+
userId,
|
|
111
|
+
false
|
|
110
112
|
);
|
|
111
113
|
expect(sendCommandOverInternet).toBeCalledWith(
|
|
112
114
|
sensor,
|
|
113
115
|
action,
|
|
114
116
|
data,
|
|
115
|
-
'bluetooth'
|
|
117
|
+
'bluetooth',
|
|
118
|
+
false
|
|
116
119
|
);
|
|
117
120
|
expect(sendCommandOverInternet).toBeCalledTimes(1);
|
|
118
121
|
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
@@ -143,7 +146,8 @@ describe('Test useRemoteControl', () => {
|
|
|
143
146
|
sensor,
|
|
144
147
|
action,
|
|
145
148
|
data,
|
|
146
|
-
userId
|
|
149
|
+
userId,
|
|
150
|
+
false
|
|
147
151
|
);
|
|
148
152
|
expect(sendCommandOverInternet).not.toBeCalled();
|
|
149
153
|
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
@@ -181,7 +185,8 @@ describe('Test useRemoteControl', () => {
|
|
|
181
185
|
sensor,
|
|
182
186
|
action,
|
|
183
187
|
data,
|
|
184
|
-
userId
|
|
188
|
+
userId,
|
|
189
|
+
false
|
|
185
190
|
);
|
|
186
191
|
expect(sendCommandOverHomeAssistant).not.toBeCalled();
|
|
187
192
|
});
|
|
@@ -202,7 +207,8 @@ describe('Test useRemoteControl', () => {
|
|
|
202
207
|
sensor,
|
|
203
208
|
action,
|
|
204
209
|
data,
|
|
205
|
-
'internet'
|
|
210
|
+
'internet',
|
|
211
|
+
false
|
|
206
212
|
);
|
|
207
213
|
expect(sendCommandOverInternet).toBeCalledTimes(1);
|
|
208
214
|
expect(sendCommandOverBluetooth).not.toBeCalled();
|
|
@@ -303,7 +309,8 @@ describe('Test useRemoteControl', () => {
|
|
|
303
309
|
sensor,
|
|
304
310
|
action,
|
|
305
311
|
data,
|
|
306
|
-
'bluetooth'
|
|
312
|
+
'bluetooth',
|
|
313
|
+
false
|
|
307
314
|
);
|
|
308
315
|
expect(sendCommandOverBluetooth).toBeCalledTimes(6);
|
|
309
316
|
expect(sendCommandOverInternet).toBeCalledTimes(1);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
1
|
import { renderHook } from '@testing-library/react-hooks';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
3
|
import { SCProvider } from '../../../context';
|
|
4
4
|
import { mockSCStore } from '../../../context/mockStore';
|
|
5
|
+
import { unwatchMultiConfigs, watchMultiConfigs } from '../../../iot/Monitor';
|
|
5
6
|
import { useWatchConfigs } from '../index';
|
|
6
|
-
import { watchMultiConfigs, unwatchMultiConfigs } from '../../../iot/Monitor';
|
|
7
7
|
|
|
8
8
|
const mockedSetAction = jest.fn();
|
|
9
9
|
|
|
@@ -27,6 +27,6 @@ describe('Test useWatchConfigs', () => {
|
|
|
27
27
|
wrapper,
|
|
28
28
|
});
|
|
29
29
|
jest.runOnlyPendingTimers();
|
|
30
|
-
expect(watchMultiConfigs).
|
|
30
|
+
expect(watchMultiConfigs).toHaveBeenCalledWith([1]);
|
|
31
31
|
});
|
|
32
32
|
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import NetInfo from '@react-native-community/netinfo';
|
|
2
|
+
import { t } from 'i18n-js';
|
|
1
3
|
import { useCallback } from 'react';
|
|
2
4
|
import { useSCContextSelector } from '../../context';
|
|
3
|
-
import { sendCommandOverHomeAssistant } from '../../iot/RemoteControl/HomeAssistant';
|
|
4
|
-
import { sendCommandOverInternet } from '../../iot/RemoteControl/Internet';
|
|
5
5
|
import {
|
|
6
|
-
sendCommandOverBluetooth,
|
|
7
|
-
SEND_COMMAND_OVER_BLUETOOTH_FAIL,
|
|
8
6
|
BLUETOOOH_DEVICE_UNSTABLE,
|
|
7
|
+
SEND_COMMAND_OVER_BLUETOOTH_FAIL,
|
|
8
|
+
sendCommandOverBluetooth,
|
|
9
9
|
} from '../../iot/RemoteControl/Bluetooth';
|
|
10
|
+
import { sendCommandOverHomeAssistant } from '../../iot/RemoteControl/HomeAssistant';
|
|
11
|
+
import { sendCommandOverInternet } from '../../iot/RemoteControl/Internet';
|
|
10
12
|
import { ToastBottomHelper } from '../../utils/Utils';
|
|
11
|
-
import { t } from 'i18n-js';
|
|
12
|
-
import NetInfo from '@react-native-community/netinfo';
|
|
13
13
|
|
|
14
14
|
const handleReconnectionDeviceBle = async (device, action, data, userId) => {
|
|
15
15
|
for (let i = 0; i < 5; i++) {
|
|
@@ -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'));
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import t from '../../hooks/Common/useTranslations';
|
|
2
2
|
|
|
3
|
-
import { ToastBottomHelper } from '../../utils/Utils';
|
|
4
|
-
import { axiosPost } from '../../utils/Apis/axios';
|
|
5
3
|
import { API } from '../../configs';
|
|
4
|
+
import { axiosPost } from '../../utils/Apis/axios';
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import Toast from 'react-native-toast-message';
|
|
2
1
|
import MockAdapter from 'axios-mock-adapter';
|
|
3
|
-
import
|
|
4
|
-
import api from '../../../utils/Apis/axios';
|
|
2
|
+
import Toast from 'react-native-toast-message';
|
|
5
3
|
import { API } from '../../../configs';
|
|
4
|
+
import api from '../../../utils/Apis/axios';
|
|
5
|
+
import { sendCommandOverInternet } from '../Internet';
|
|
6
6
|
|
|
7
7
|
const mock = new MockAdapter(api.axiosInstance);
|
|
8
8
|
|
|
@@ -14,24 +14,24 @@ describe('Test IOT Remote Control Internet', () => {
|
|
|
14
14
|
it('Trigger action via request POST', async () => {
|
|
15
15
|
mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
|
|
16
16
|
await sendCommandOverInternet({}, {}, 'internet');
|
|
17
|
-
expect(Toast.show).
|
|
17
|
+
expect(Toast.show).toHaveBeenCalledTimes(2);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
it('Trigger action via request POST with data isInteger', async () => {
|
|
21
21
|
mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
|
|
22
22
|
await sendCommandOverInternet({}, {}, 1);
|
|
23
|
-
expect(Toast.show).
|
|
23
|
+
expect(Toast.show).toHaveBeenCalledTimes(2);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('Trigger action via request POST with data is null', async () => {
|
|
27
27
|
mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(200);
|
|
28
28
|
await sendCommandOverInternet({}, {}, null);
|
|
29
|
-
expect(Toast.show).
|
|
29
|
+
expect(Toast.show).toHaveBeenCalledTimes(2);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('Trigger action fail show error', async () => {
|
|
33
33
|
mock.onPost(API.DEVICE.TRIGGER_ACTION()).reply(400);
|
|
34
34
|
await sendCommandOverInternet({}, {}, 'internet');
|
|
35
|
-
expect(Toast.show).
|
|
35
|
+
expect(Toast.show).toHaveBeenCalled();
|
|
36
36
|
});
|
|
37
37
|
});
|
|
@@ -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
|