@eohjsc/react-native-smart-city 0.5.9 → 0.6.0-rc1
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/android/build.gradle +8 -10
- package/package.json +52 -69
- 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/__test__/index.test.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/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -15
- package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
- 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 +3 -3
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +4 -4
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -4
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +2 -9
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +4 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +2 -9
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -18
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +2 -2
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +1 -8
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -7
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +4 -15
- package/src/commons/ActionGroup/__test__/TerminalBoxTemplate.test.js +0 -7
- package/src/commons/ActionGroup/__test__/TextBoxTemplate.test.js +1 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +1 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +1 -8
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +2 -9
- package/src/commons/ActionGroup/__test__/index.test.js +14 -21
- package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
- package/src/commons/ActionTemplate/__test__/utils.js +21 -0
- package/src/commons/ActionTemplate/index.js +1 -2
- package/src/commons/BackDefault/index.js +2 -2
- package/src/commons/ButtonPopup/index.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +1 -12
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +27 -20
- package/src/commons/Dashboard/MyUnit/index.js +0 -1
- package/src/commons/DateTimeRangeChange/DateTimeButton.js +2 -2
- package/src/commons/Device/ConnectedViewHeader.js +2 -2
- package/src/commons/Device/DisconnectedView.js +2 -2
- package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +2 -2
- package/src/commons/Device/FlatListItems.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
- package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -11
- package/src/commons/Device/HorizontalBarChart.js +1 -1
- package/src/commons/Device/ItemAddNew/index.js +2 -2
- package/src/commons/Device/ItemDevice.js +2 -2
- package/src/commons/Device/PowerConsumptionChart.js +154 -0
- 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 +2 -6
- package/src/commons/DisplayChecking/index.js +2 -2
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/EmergencyButton/AlertSent.js +2 -2
- package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
- package/src/commons/Form/CurrencyInput.js +1 -15
- package/src/commons/Header/HeaderCustom.js +3 -3
- package/src/commons/HeaderAni/index.js +2 -2
- package/src/commons/IconComponent/index.js +3 -3
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +1 -1
- package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -0
- package/src/commons/NavBar/index.js +2 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
- package/src/commons/PreventAccess/__test__/PreventAccess.test.js +1 -13
- package/src/commons/Processing/__test__/Connecting.test.js +3 -14
- package/src/commons/SearchLocation/index.js +2 -2
- package/src/commons/SelectActionCard/index.js +2 -2
- package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -18
- package/src/commons/SelectSubUnit/index.js +2 -2
- package/src/commons/SelectUnit/__test__/SelectUnit.test.js +1 -13
- package/src/commons/Sharing/BtnRemoveMember.js +2 -2
- package/src/commons/Sharing/StationDevicePermissions.js +2 -2
- package/src/commons/Sharing/WrapHeaderScrollable.js +1 -1
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -1
- 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/Item/index.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -2
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +11 -8
- package/src/commons/SubUnit/__test__/Favorites.test.js +1 -13
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +5 -16
- package/src/commons/Tabbar/__test__/index.test.js +0 -11
- package/src/commons/Unit/HeaderUnit/index.js +4 -4
- package/src/commons/Unit/SharedUnit.js +5 -5
- package/src/commons/Unit/__test__/HeaderUnit.test.js +3 -15
- package/src/commons/Unit/__test__/SharedUnit.test.js +94 -105
- package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +11 -30
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +6 -61
- package/src/commons/Widgets/IFrame/IFrame.js +54 -0
- package/src/commons/Widgets/IFrame/IFrameStyles.js +35 -0
- package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +74 -0
- package/src/commons/Widgets/IFrame/index.js +0 -0
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +163 -0
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfigStyles.js +9 -0
- package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +284 -0
- package/src/commons/Widgets/IFrameWithConfig/index.js +0 -0
- package/src/commons/Widgets/Widget.js +0 -0
- package/src/commons/Widgets/index.js +0 -0
- package/src/configs/Constants.js +5 -0
- package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +4 -15
- package/src/hooks/Common/useDevicesStatus.js +23 -23
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +0 -7
- package/src/iot/RemoteControl/HomeAssistant.js +1 -1
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +234 -232
- package/src/navigations/AutomateStack.js +2 -2
- package/src/navigations/EmergencyContactsStack.js +2 -2
- package/src/navigations/SharedStack.js +2 -2
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/ActivityLog/hooks/index.js +7 -4
- package/src/screens/ActivityLog/index.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +4 -21
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +7 -19
- package/src/screens/AddLocationMaps/__test__/index.test.js +3 -13
- package/src/screens/AddLocationMaps/index.js +4 -4
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +3 -20
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +11 -18
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +4 -21
- package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +0 -17
- package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +4 -19
- package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +3 -15
- package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +31 -51
- package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +9 -22
- package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +12 -19
- package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +6 -16
- package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +4 -15
- package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +3 -3
- package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +18 -10
- package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +1 -1
- package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +12 -9
- package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +12 -9
- package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +7 -21
- package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -10
- package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +0 -20
- package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +7 -24
- package/src/screens/AllGateway/DeviceGatewayInfo/__test__/index.test.js +0 -17
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +84 -100
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +64 -82
- package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -55
- package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +9 -18
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +10 -37
- package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +7 -32
- package/src/screens/AllGateway/__test__/index.test.js +1 -14
- package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +0 -12
- package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -13
- package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
- package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -8
- package/src/screens/AllGateway/test-utils.js +1 -1
- package/src/screens/Automate/AddNewAction/NewActionWrapper.js +2 -2
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +27 -28
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +3 -3
- package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +8 -5
- package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +2 -2
- package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +1 -18
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +17 -15
- package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +4 -4
- package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +38 -55
- package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +0 -18
- package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +1 -19
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +14 -11
- package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +3 -3
- package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +2 -2
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +2 -2
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +33 -25
- package/src/screens/Automate/ScriptDetail/index.js +5 -6
- package/src/screens/Automate/SetSchedule/__test__/index.test.js +4 -4
- package/src/screens/Automate/SetSchedule/components/RowItem.js +3 -3
- package/src/screens/Automate/__test__/MultiUnits.test.js +5 -5
- package/src/screens/Automate/__test__/index.test.js +6 -6
- package/src/screens/Automate/index.js +2 -2
- package/src/screens/ChangePosition/__test__/index.test.js +1 -14
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +0 -12
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +1 -11
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +11 -11
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +3 -15
- package/src/screens/Device/components/SensorDisplayItem.js +23 -5
- package/src/screens/Device/components/__test__/VisualChart.test.js +2 -9
- package/src/screens/Device/detail.js +11 -10
- package/src/screens/Drawer/Drawer.test.js +3 -11
- package/src/screens/Drawer/index.js +3 -4
- package/src/screens/EmergencyContacts/EmergencyContactsList.js +4 -8
- package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +4 -17
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +3 -14
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +0 -10
- package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
- package/src/screens/EnterPassword/__test__/EnterPassword.test.js +4 -17
- package/src/screens/GuestInfo/__test__/index.test.js +0 -11
- package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
- package/src/screens/GuestInfo/index.js +2 -2
- package/src/screens/HanetCamera/Detail.js +2 -2
- package/src/screens/HanetCamera/ManageAccess.js +3 -4
- package/src/screens/HanetCamera/MemberInfo.js +4 -4
- package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +2 -16
- package/src/screens/HanetCamera/__test__/Detail.test.js +1 -12
- package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -16
- package/src/screens/HanetCamera/__test__/MemberInfo.test.js +5 -18
- package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +3 -19
- package/src/screens/ManageAccess/index.js +3 -3
- package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +5 -5
- package/src/screens/Notification/__test__/NotificationItem.test.js +9 -19
- package/src/screens/Notification/index.js +3 -3
- package/src/screens/PlayBackCamera/Styles/index.js +2 -4
- package/src/screens/PlayBackCamera/Timer.js +65 -47
- package/src/screens/PlayBackCamera/__test__/index.test.js +32 -33
- package/src/screens/PlayBackCamera/index.js +115 -112
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +0 -11
- package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
- package/src/screens/SelectUnit/__test__/index.test.js +1 -21
- package/src/screens/SelectUnit/index.js +2 -2
- 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__/InfoMemberUnit.test.js +9 -4
- package/src/screens/Sharing/__test__/SelectShareDevice.test.js +2 -15
- package/src/screens/Sharing/__test__/SelectUser.test.js +2 -22
- package/src/screens/Sharing/__test__/UnitMemberList.test.js +2 -2
- package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +4 -17
- package/src/screens/Sharing/hooks/__test__/index.test.js +2 -13
- package/src/screens/SmartAccount/Connecting/index.js +0 -2
- package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +3 -18
- package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +11 -21
- package/src/screens/SmartAccount/SuccessfullyConnected/index.js +3 -4
- package/src/screens/SmartAccount/__test__/Connecting.test.js +30 -36
- package/src/screens/SmartAccount/__test__/SmartAccount.test.js +12 -21
- package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +7 -17
- package/src/screens/SmartIr/__test__/SelectBrand.test.js +1 -11
- package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -12
- package/src/screens/SmartIr/__test__/SmartIr.test.js +3 -11
- package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -3
- package/src/screens/SmartIr/components/SelectBrand.js +2 -2
- package/src/screens/SubUnit/AddSubUnit.js +1 -0
- package/src/screens/SubUnit/EditSubUnit.js +3 -2
- package/src/screens/SubUnit/ManageSubUnit.js +4 -5
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +9 -31
- package/src/screens/SubUnit/__test__/Detail.test.js +4 -28
- package/src/screens/SubUnit/__test__/EditSubUnit.test.js +12 -30
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +2 -2
- package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +0 -12
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +7 -20
- package/src/screens/Template/__test__/EditTemplate.test.js +2 -13
- package/src/screens/Template/__test__/GatewayList.test.js +0 -9
- package/src/screens/Template/__test__/detail.test.js +4 -4
- package/src/screens/Template/__test__/index.test.js +1 -12
- package/src/screens/Template/detail.js +2 -2
- package/src/screens/Unit/SelectAddToFavorites.js +2 -2
- package/src/screens/Unit/SelectAddress.js +4 -4
- package/src/screens/Unit/SmartAccountItem.js +2 -2
- package/src/screens/Unit/Summaries.js +3 -2
- package/src/screens/Unit/__test__/AddMenu.test.js +5 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +0 -12
- package/src/screens/Unit/__test__/ChooseLocation.test.js +1 -4
- package/src/screens/Unit/__test__/Detail.test.js +5 -5
- package/src/screens/Unit/__test__/ManageUnit.test.js +2 -17
- package/src/screens/Unit/__test__/MoreMenu.test.js +1 -11
- package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +3 -14
- package/src/screens/Unit/__test__/SelectAddress.test.js +4 -17
- package/src/screens/Unit/__test__/SmartAccount.test.js +14 -11
- package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -11
- package/src/screens/Unit/__test__/Summaries.test.js +2 -14
- package/src/screens/Unit/components/AutomateScript/index.js +2 -2
- package/src/screens/Unit/components/ButtonWrapper/index.js +3 -4
- package/src/screens/Unit/components/Header/index.js +3 -3
- package/src/screens/Unit/components/SharedUnit/index.js +5 -5
- package/src/screens/Unit/components/__test__/Header.test.js +1 -14
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +1 -11
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +1 -11
- package/src/screens/UnitSummary/__test__/index.test.js +51 -17
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +0 -12
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +10 -23
- package/src/screens/UnitSummary/components/AirQuality/__test__/index.test.js +1 -7
- package/src/screens/UnitSummary/components/AirQuality/index.js +3 -3
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +38 -14
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +21 -30
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +1 -16
- package/src/screens/UnitSummary/components/Temperature/index.js +5 -1
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +0 -8
- package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -2
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +14 -18
- package/src/screens/UnitSummary/index.js +4 -8
- package/src/utils/Converter/__test__/timer.test.js +8 -0
- package/src/utils/Functions/preloadImages.js +13 -14
- package/src/utils/Storage.js +1 -1
- package/src/commons/Device/HistoryChart.js +0 -225
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +0 -48
- package/src/commons/Device/WindSpeed/LinearChart/index.js +0 -155
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
- package/src/screens/Device/__test__/DetailHistoryChart.test.js +0 -69
- package/src/screens/Device/components/DetailHistoryChart.js +0 -118
- package/src/screens/UnitSummary/components/Temperature/ChartAverage/index.js +0 -62
- package/src/screens/UnitSummary/components/Temperature/__test__/ChartAverage.test.js +0 -17
- package/src/utils/dateHelper/getTickValues.js +0 -22
|
@@ -12,17 +12,6 @@ const wrapComponent = (props) => (
|
|
|
12
12
|
</SCProvider>
|
|
13
13
|
);
|
|
14
14
|
|
|
15
|
-
const mockNavigate = jest.fn();
|
|
16
|
-
jest.mock('@react-navigation/native', () => {
|
|
17
|
-
return {
|
|
18
|
-
...jest.requireActual('@react-navigation/native'),
|
|
19
|
-
useRoute: jest.fn(),
|
|
20
|
-
useNavigation: () => ({
|
|
21
|
-
navigate: mockNavigate,
|
|
22
|
-
}),
|
|
23
|
-
};
|
|
24
|
-
});
|
|
25
|
-
|
|
26
15
|
describe('Test HanetCameraDetail', () => {
|
|
27
16
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
28
17
|
let tree, props;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useRef } from 'react';
|
|
2
2
|
import { View, TouchableOpacity, StyleSheet, StatusBar } from 'react-native';
|
|
3
|
-
import
|
|
3
|
+
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
4
4
|
import { useNavigation } from '@react-navigation/native';
|
|
5
5
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
6
6
|
|
|
@@ -47,7 +47,7 @@ const HeaderUnit = memo(
|
|
|
47
47
|
onPress={onPressBack}
|
|
48
48
|
>
|
|
49
49
|
<View style={styles.btnLeft}>
|
|
50
|
-
<
|
|
50
|
+
<AntDesign
|
|
51
51
|
name={'left'}
|
|
52
52
|
size={27}
|
|
53
53
|
color={transparent ? Colors.White : Colors.Black}
|
|
@@ -70,7 +70,7 @@ const HeaderUnit = memo(
|
|
|
70
70
|
onPress={onPressAdd}
|
|
71
71
|
>
|
|
72
72
|
<View style={styles.btnAdd}>
|
|
73
|
-
<
|
|
73
|
+
<AntDesign
|
|
74
74
|
name={'plus'}
|
|
75
75
|
size={27}
|
|
76
76
|
color={transparent ? Colors.White : Colors.Black}
|
|
@@ -84,7 +84,7 @@ const HeaderUnit = memo(
|
|
|
84
84
|
accessibilityLabel={idButtonMore}
|
|
85
85
|
>
|
|
86
86
|
<View style={styles.btnMore}>
|
|
87
|
-
<
|
|
87
|
+
<AntDesign
|
|
88
88
|
name={'more'}
|
|
89
89
|
size={27}
|
|
90
90
|
color={transparent ? Colors.White : Colors.Black}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { Fragment, useCallback } from 'react';
|
|
2
2
|
import { View, Image, TouchableOpacity } from 'react-native';
|
|
3
3
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
4
|
-
import
|
|
4
|
+
import AntDesign from 'react-native-vector-icons/AntDesign';
|
|
5
5
|
|
|
6
6
|
import { API, Colors, Images } from '../../configs';
|
|
7
7
|
import Text from '../../commons/Text';
|
|
@@ -91,7 +91,7 @@ const SharedUnit = ({
|
|
|
91
91
|
{isOptions && (
|
|
92
92
|
<Fragment>
|
|
93
93
|
{item.is_pin ? (
|
|
94
|
-
<
|
|
94
|
+
<AntDesign
|
|
95
95
|
name="pushpin"
|
|
96
96
|
size={20}
|
|
97
97
|
color={Colors.Blue10}
|
|
@@ -99,7 +99,7 @@ const SharedUnit = ({
|
|
|
99
99
|
accessibilityLabel={`${AccessibilityLabel.ICON_REMOVE_PIN_SHARED_UNIT}-${item.id}`}
|
|
100
100
|
/>
|
|
101
101
|
) : (
|
|
102
|
-
<
|
|
102
|
+
<AntDesign
|
|
103
103
|
name="pushpin"
|
|
104
104
|
size={20}
|
|
105
105
|
onPress={addPinSharedUnit}
|
|
@@ -107,7 +107,7 @@ const SharedUnit = ({
|
|
|
107
107
|
/>
|
|
108
108
|
)}
|
|
109
109
|
{item.is_star ? (
|
|
110
|
-
<
|
|
110
|
+
<AntDesign
|
|
111
111
|
name="star"
|
|
112
112
|
size={20}
|
|
113
113
|
color={Colors.Yellow6}
|
|
@@ -115,7 +115,7 @@ const SharedUnit = ({
|
|
|
115
115
|
accessibilityLabel={`${AccessibilityLabel.ICON_REMOVE_STAR_SHARED_UNIT}-${item.id}`}
|
|
116
116
|
/>
|
|
117
117
|
) : (
|
|
118
|
-
<
|
|
118
|
+
<AntDesign
|
|
119
119
|
name="star"
|
|
120
120
|
size={20}
|
|
121
121
|
onPress={addStarSharedUnit}
|
|
@@ -2,23 +2,11 @@ import React from 'react';
|
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
4
4
|
import HeaderUnit from '../HeaderUnit/index';
|
|
5
|
-
|
|
6
|
-
const mockedGoBack = jest.fn();
|
|
7
|
-
|
|
8
|
-
jest.mock('@react-navigation/native', () => {
|
|
9
|
-
return {
|
|
10
|
-
...jest.requireActual('@react-navigation/native'),
|
|
11
|
-
useNavigation: () => ({
|
|
12
|
-
goBack: mockedGoBack,
|
|
13
|
-
}),
|
|
14
|
-
};
|
|
15
|
-
});
|
|
5
|
+
import { useNavigation } from '@react-navigation/native';
|
|
16
6
|
|
|
17
7
|
describe('Test HeaderUnit', () => {
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
mockedGoBack.mockClear();
|
|
20
|
-
});
|
|
21
8
|
let tree;
|
|
9
|
+
const { goBack } = useNavigation();
|
|
22
10
|
const mockedFunc = jest.fn();
|
|
23
11
|
const mockedOnBack = jest.fn();
|
|
24
12
|
it('HeaderUnit onPress', async () => {
|
|
@@ -65,7 +53,7 @@ describe('Test HeaderUnit', () => {
|
|
|
65
53
|
await act(async () => {
|
|
66
54
|
item.props.onPress();
|
|
67
55
|
});
|
|
68
|
-
expect(
|
|
56
|
+
expect(goBack).toHaveBeenCalled();
|
|
69
57
|
});
|
|
70
58
|
|
|
71
59
|
it('HeaderUnit onPressAdd onPressMore', async () => {
|
|
@@ -14,26 +14,18 @@ import api from '../../../utils/Apis/axios';
|
|
|
14
14
|
|
|
15
15
|
const mock = new MockAdapter(api.axiosInstance);
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<SharedUnit
|
|
30
|
-
item={item}
|
|
31
|
-
navigation={navigation}
|
|
32
|
-
isOptions={isOptions}
|
|
33
|
-
renewItem={mockedRenewItem}
|
|
34
|
-
/>
|
|
35
|
-
</SCProvider>
|
|
36
|
-
);
|
|
17
|
+
const wrapComponent = (item, navigation, isOptions, mockedRenewItem) => {
|
|
18
|
+
return (
|
|
19
|
+
<SCProvider initState={mockSCStore({})}>
|
|
20
|
+
<SharedUnit
|
|
21
|
+
item={item}
|
|
22
|
+
navigation={navigation}
|
|
23
|
+
isOptions={isOptions}
|
|
24
|
+
renewItem={mockedRenewItem}
|
|
25
|
+
/>
|
|
26
|
+
</SCProvider>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
37
29
|
|
|
38
30
|
describe('Test SharedUnit', () => {
|
|
39
31
|
let tree, item, unit;
|
|
@@ -67,9 +59,6 @@ describe('Test SharedUnit', () => {
|
|
|
67
59
|
);
|
|
68
60
|
});
|
|
69
61
|
|
|
70
|
-
await act(async () => {
|
|
71
|
-
tree = await create(wrapComponent(item, navigation));
|
|
72
|
-
});
|
|
73
62
|
const instance = tree.root;
|
|
74
63
|
const touchSharedUnit = instance.find(
|
|
75
64
|
(el) =>
|
|
@@ -111,7 +100,7 @@ describe('Test SharedUnit', () => {
|
|
|
111
100
|
iconAddStarSharedUnit.props.onPress();
|
|
112
101
|
});
|
|
113
102
|
expect(iconRemovePinSharedUnit).toHaveLength(0);
|
|
114
|
-
expect(
|
|
103
|
+
expect(global.mockedNavigate).toHaveBeenCalledWith(Routes.UnitStack, {
|
|
115
104
|
screen: Routes.UnitDetail,
|
|
116
105
|
params: {
|
|
117
106
|
unitId: 3,
|
|
@@ -120,85 +109,85 @@ describe('Test SharedUnit', () => {
|
|
|
120
109
|
});
|
|
121
110
|
});
|
|
122
111
|
|
|
123
|
-
it('test create SharedUnit unit without unit owner', async () => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('test create SharedUnit unit isOption false', async () => {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('test create SharedUnit unit is pin, is star', async () => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
});
|
|
112
|
+
// it('test create SharedUnit unit without unit owner', async () => {
|
|
113
|
+
// const navigation = useNavigation();
|
|
114
|
+
// delete unit.owner_name;
|
|
115
|
+
//
|
|
116
|
+
// await act(async () => {
|
|
117
|
+
// tree = await create(wrapComponent(item, navigation));
|
|
118
|
+
// });
|
|
119
|
+
// const instance = tree.root;
|
|
120
|
+
// const ownerName = instance.findAll(
|
|
121
|
+
// (el) =>
|
|
122
|
+
// el.props.accessibilityLabel === AccessibilityLabel.SHARED_UNIT_OWN_BY
|
|
123
|
+
// );
|
|
124
|
+
//
|
|
125
|
+
// expect(ownerName).toHaveLength(0);
|
|
126
|
+
// });
|
|
127
|
+
//
|
|
128
|
+
// it('test create SharedUnit unit isOption false', async () => {
|
|
129
|
+
// const navigation = useNavigation();
|
|
130
|
+
//
|
|
131
|
+
// await act(async () => {
|
|
132
|
+
// tree = await create(wrapComponent(item, navigation, false));
|
|
133
|
+
// });
|
|
134
|
+
// const instance = tree.root;
|
|
135
|
+
//
|
|
136
|
+
// const iconAddPinSharedUnit = instance.findAll(
|
|
137
|
+
// (el) =>
|
|
138
|
+
// el.props.accessibilityLabel ===
|
|
139
|
+
// AccessibilityLabel.ICON_ADD_PIN_SHARED_UNIT + '-69'
|
|
140
|
+
// );
|
|
141
|
+
// const iconStarUnit = instance.findAll(
|
|
142
|
+
// (el) =>
|
|
143
|
+
// el.props.accessibilityLabel ===
|
|
144
|
+
// AccessibilityLabel.ICON_ADD_STAR_SHARED_UNIT + '-69'
|
|
145
|
+
// );
|
|
146
|
+
//
|
|
147
|
+
// expect(iconAddPinSharedUnit).toHaveLength(0);
|
|
148
|
+
// expect(iconStarUnit).toHaveLength(0);
|
|
149
|
+
// });
|
|
150
|
+
//
|
|
151
|
+
// it('test create SharedUnit unit is pin, is star', async () => {
|
|
152
|
+
// const navigation = useNavigation();
|
|
153
|
+
// item.is_pin = true;
|
|
154
|
+
// item.is_star = true;
|
|
155
|
+
//
|
|
156
|
+
// await act(async () => {
|
|
157
|
+
// tree = await create(wrapComponent(item, navigation));
|
|
158
|
+
// });
|
|
159
|
+
// const instance = tree.root;
|
|
160
|
+
// const iconRemovePinSharedUnit = instance.find(
|
|
161
|
+
// (el) =>
|
|
162
|
+
// el.props.accessibilityLabel ===
|
|
163
|
+
// AccessibilityLabel.ICON_REMOVE_PIN_SHARED_UNIT + '-69'
|
|
164
|
+
// );
|
|
165
|
+
// mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(200);
|
|
166
|
+
// await act(async () => {
|
|
167
|
+
// iconRemovePinSharedUnit.props.onPress();
|
|
168
|
+
// });
|
|
169
|
+
// mock.onPost(API.UNIT.UNPIN_UNIT(3)).reply(400);
|
|
170
|
+
// await act(async () => {
|
|
171
|
+
// iconRemovePinSharedUnit.props.onPress();
|
|
172
|
+
// });
|
|
173
|
+
// const iconRemoveStarSharedUnit = instance.find(
|
|
174
|
+
// (el) =>
|
|
175
|
+
// el.props.accessibilityLabel ===
|
|
176
|
+
// AccessibilityLabel.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
177
|
+
// );
|
|
178
|
+
// mock.onPost(API.UNIT.UNSTAR_UNIT(3)).reply(200);
|
|
179
|
+
// await act(async () => {
|
|
180
|
+
// iconRemoveStarSharedUnit.props.onPress();
|
|
181
|
+
// });
|
|
182
|
+
// mock.onPost(API.UNIT.UNSTAR_UNIT(3)).reply(400);
|
|
183
|
+
// await act(async () => {
|
|
184
|
+
// iconRemoveStarSharedUnit.props.onPress();
|
|
185
|
+
// });
|
|
186
|
+
// const iconRemoveStar = instance.findAll(
|
|
187
|
+
// (el) =>
|
|
188
|
+
// el.props.accessibilityLabel ===
|
|
189
|
+
// AccessibilityLabel.ICON_REMOVE_STAR_SHARED_UNIT + '-69'
|
|
190
|
+
// );
|
|
191
|
+
// expect(iconRemoveStar).toHaveLength(3);
|
|
192
|
+
// });
|
|
204
193
|
});
|
|
@@ -8,22 +8,22 @@ import TextCustom from '../../../../commons/Text';
|
|
|
8
8
|
import { scaleValue, drawArc, polarToCartesian } from './helper';
|
|
9
9
|
|
|
10
10
|
const SegmentedRoundDisplay = ({
|
|
11
|
-
filledArcWidth,
|
|
12
|
-
emptyArcWidth,
|
|
13
|
-
arcSpacing,
|
|
14
|
-
totalArcSize,
|
|
15
|
-
emptyArcColor,
|
|
16
|
-
filledArcColor,
|
|
17
|
-
radius,
|
|
18
11
|
style,
|
|
19
12
|
totalValue,
|
|
20
13
|
value,
|
|
21
14
|
title,
|
|
22
|
-
pos, //array position
|
|
23
|
-
boxTitle,
|
|
24
|
-
textHeader,
|
|
25
|
-
initIndex,
|
|
26
15
|
valueText,
|
|
16
|
+
filledArcWidth = 0,
|
|
17
|
+
emptyArcWidth = 20,
|
|
18
|
+
arcSpacing = 1,
|
|
19
|
+
totalArcSize = 280,
|
|
20
|
+
emptyArcColor = Colors.Gray3,
|
|
21
|
+
filledArcColor = '#5ECCAA',
|
|
22
|
+
radius = 90,
|
|
23
|
+
pos = [0, 100, 200, 300, 400, 500],
|
|
24
|
+
boxTitle = false,
|
|
25
|
+
textHeader = '',
|
|
26
|
+
initIndex = 0,
|
|
27
27
|
}) => {
|
|
28
28
|
const [arcs, setArcs] = useState([]);
|
|
29
29
|
|
|
@@ -239,25 +239,6 @@ SegmentedRoundDisplay.propTypes = {
|
|
|
239
239
|
initIndex: PropTypes.number,
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
SegmentedRoundDisplay.defaultProps = {
|
|
243
|
-
filledArcWidth: 0,
|
|
244
|
-
emptyArcWidth: 20,
|
|
245
|
-
arcSpacing: 1,
|
|
246
|
-
totalArcSize: 280,
|
|
247
|
-
emptyArcColor: Colors.Gray3,
|
|
248
|
-
filledArcColor: '#5ECCAA',
|
|
249
|
-
animationDuration: 1000,
|
|
250
|
-
incompleteArcColor: '#23318C',
|
|
251
|
-
displayValue: false,
|
|
252
|
-
valueBoxColor: '#23318C',
|
|
253
|
-
valueFontColor: '#FFFFFF',
|
|
254
|
-
radius: 90,
|
|
255
|
-
pos: [0, 100, 200, 300, 400, 500],
|
|
256
|
-
boxTitle: false,
|
|
257
|
-
textHeader: '',
|
|
258
|
-
initIndex: 0,
|
|
259
|
-
};
|
|
260
|
-
|
|
261
242
|
export default SegmentedRoundDisplay;
|
|
262
243
|
|
|
263
244
|
const styles = StyleSheet.create({
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
2
|
import moment from 'moment';
|
|
3
3
|
|
|
4
4
|
import { API } from '../../../configs';
|
|
5
|
-
import HistoryChart from '../../../commons/Device/HistoryChart';
|
|
6
5
|
import { axiosGet } from '../../../utils/Apis/axios';
|
|
7
6
|
import { getPusher } from '../../../utils/Pusher';
|
|
8
7
|
|
|
@@ -39,11 +38,12 @@ export const useFetchConfigHistory = (
|
|
|
39
38
|
});
|
|
40
39
|
|
|
41
40
|
const timezone = moment().utcOffset();
|
|
42
|
-
startDate = startDate.subtract(timezone, 'minutes');
|
|
43
|
-
endDate = endDate.subtract(timezone, 'minutes');
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
const date_from = moment(startDate).subtract(timezone, 'minutes');
|
|
43
|
+
const date_to = moment(endDate).subtract(timezone, 'minutes');
|
|
44
|
+
|
|
45
|
+
params.append('date_from', date_from.format('YYYY-MM-DDTHH:mm:ss'));
|
|
46
|
+
params.append('date_to', date_to.format('YYYY-MM-DDTHH:mm:ss'));
|
|
47
47
|
|
|
48
48
|
const { success, data } = await axiosGet(endpoint, {
|
|
49
49
|
params,
|
|
@@ -122,58 +122,3 @@ export const updateConfigChart = async (
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
};
|
|
125
|
-
|
|
126
|
-
let timeoutId;
|
|
127
|
-
|
|
128
|
-
const ConfigHistoryChart = ({ configs }) => {
|
|
129
|
-
const [chartData, setChartData] = useState(configs);
|
|
130
|
-
const [startDate, setStartDate] = useState(
|
|
131
|
-
moment().subtract(1, 'days').valueOf()
|
|
132
|
-
);
|
|
133
|
-
const [endDate, setEndDate] = useState(moment().valueOf());
|
|
134
|
-
|
|
135
|
-
useEffect(() => {
|
|
136
|
-
const fetchData = async () => {
|
|
137
|
-
let params = new URLSearchParams();
|
|
138
|
-
let configuration = configs.filter((item) => item.id);
|
|
139
|
-
configuration.map((item) => {
|
|
140
|
-
params.append('configs', item.id);
|
|
141
|
-
});
|
|
142
|
-
params.append(
|
|
143
|
-
'date_from',
|
|
144
|
-
moment(startDate).utc().format('YYYY-MM-DD HH:mm:ss')
|
|
145
|
-
);
|
|
146
|
-
params.append(
|
|
147
|
-
'date_to',
|
|
148
|
-
moment(endDate).utc().format('YYYY-MM-DD HH:mm:ss')
|
|
149
|
-
);
|
|
150
|
-
const { success, data } = await axiosGet(
|
|
151
|
-
API.CONFIG.DISPLAY_HISTORY_V3(),
|
|
152
|
-
{
|
|
153
|
-
params,
|
|
154
|
-
}
|
|
155
|
-
);
|
|
156
|
-
updateConfigChart(success, data, configuration, setChartData);
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
timeoutId = setTimeout(fetchData, 200);
|
|
160
|
-
return () => {
|
|
161
|
-
clearTimeout(timeoutId);
|
|
162
|
-
};
|
|
163
|
-
}, [startDate, endDate, configs]);
|
|
164
|
-
|
|
165
|
-
if (!chartData.length) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return (
|
|
170
|
-
<HistoryChart
|
|
171
|
-
configuration={{ type: 'line_chart', date_format: 'DD.MM' }}
|
|
172
|
-
datas={chartData}
|
|
173
|
-
setStartDate={setStartDate}
|
|
174
|
-
setEndDate={setEndDate}
|
|
175
|
-
/>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export default ConfigHistoryChart;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { styles } from './IFrameStyles';
|
|
4
|
+
import IconComponent from '../../IconComponent';
|
|
5
|
+
import WebView from 'react-native-webview';
|
|
6
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
7
|
+
|
|
8
|
+
const IFrame = memo(
|
|
9
|
+
({ item = {}, widgetStyle, isWidgetBox, isSetting, isEditing }) => {
|
|
10
|
+
const ref = useRef();
|
|
11
|
+
const [urlWithEnv, setUrlWithEnv] = useState();
|
|
12
|
+
|
|
13
|
+
const { configuration } = item;
|
|
14
|
+
const { url } = configuration || {};
|
|
15
|
+
|
|
16
|
+
const reload = useCallback(() => {
|
|
17
|
+
ref.current.reload();
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!url) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!url.includes('?')) {
|
|
25
|
+
setUrlWithEnv(
|
|
26
|
+
`${url}?eraOrigin=${window.location.origin}&eraWidget=${item?.id}`
|
|
27
|
+
);
|
|
28
|
+
} else {
|
|
29
|
+
setUrlWithEnv(
|
|
30
|
+
`${url}&eraOrigin=${window.location.origin}&eraWidget=${item?.id}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}, [item?.id, url]);
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<View>
|
|
37
|
+
<TouchableOpacity
|
|
38
|
+
style={isEditing ? styles.reloadButtonEditing : styles.reloadButton}
|
|
39
|
+
onClick={reload}
|
|
40
|
+
>
|
|
41
|
+
<IconComponent icon="ReloadOutlined" />
|
|
42
|
+
</TouchableOpacity>
|
|
43
|
+
<WebView
|
|
44
|
+
source={{ uri: urlWithEnv }}
|
|
45
|
+
style={styles.iframe}
|
|
46
|
+
ref={ref}
|
|
47
|
+
title={item?.title}
|
|
48
|
+
/>
|
|
49
|
+
</View>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export default IFrame;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../../../configs';
|
|
3
|
+
|
|
4
|
+
export const styles = StyleSheet.create({
|
|
5
|
+
iframe: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
width: '100%',
|
|
8
|
+
height: '100%',
|
|
9
|
+
paddingHorizontal: 16,
|
|
10
|
+
},
|
|
11
|
+
reloadButton: {
|
|
12
|
+
position: 'absolute',
|
|
13
|
+
right: 16,
|
|
14
|
+
top: 5,
|
|
15
|
+
border: '1px solid #E6E6E6',
|
|
16
|
+
backgroundColor: Colors.White,
|
|
17
|
+
},
|
|
18
|
+
reloadButtonEditing: {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
right: 77,
|
|
21
|
+
top: 0,
|
|
22
|
+
width: 36,
|
|
23
|
+
marginLeft: 2,
|
|
24
|
+
paddingTop: 5,
|
|
25
|
+
paddingBottom: 5,
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
alignItems: 'center',
|
|
28
|
+
borderRadius: 4,
|
|
29
|
+
backgroundColor: Colors.White,
|
|
30
|
+
border: '1px solid #E6E6E6',
|
|
31
|
+
},
|
|
32
|
+
settingWidget: {
|
|
33
|
+
width: 256,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { act } from 'react-test-renderer';
|
|
3
|
+
|
|
4
|
+
import IFrame from '../IFrame';
|
|
5
|
+
import WebView from 'react-native-webview';
|
|
6
|
+
import { TouchableOpacity } from 'react-native';
|
|
7
|
+
import { render } from '../../../../../jest/render';
|
|
8
|
+
|
|
9
|
+
describe('Test IFrame', () => {
|
|
10
|
+
let item;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
item = {
|
|
13
|
+
id: 1,
|
|
14
|
+
configuration: {
|
|
15
|
+
url: 'http://localhost:3000/',
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('test with widget box', async () => {
|
|
21
|
+
const { root } = await render(<IFrame isWidgetBox item={item} />);
|
|
22
|
+
|
|
23
|
+
const iframes = root.findAllByType(WebView);
|
|
24
|
+
expect(iframes).toHaveLength(1);
|
|
25
|
+
|
|
26
|
+
expect(iframes[0].props.source?.uri).toEqual(
|
|
27
|
+
'http://localhost:3000/?eraOrigin=http://localhost&eraWidget=1'
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('test with query string', async () => {
|
|
32
|
+
item.configuration.url = 'http://localhost:3000/?test=1';
|
|
33
|
+
const { root } = await render(<IFrame isWidgetBox item={item} />);
|
|
34
|
+
|
|
35
|
+
const iframes = root.findAllByType(WebView);
|
|
36
|
+
expect(iframes).toHaveLength(1);
|
|
37
|
+
|
|
38
|
+
expect(iframes[0].props.source?.uri).toEqual(
|
|
39
|
+
'http://localhost:3000/?test=1&eraOrigin=http://localhost&eraWidget=1'
|
|
40
|
+
);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('test no url', async () => {
|
|
44
|
+
item.configuration.url = null;
|
|
45
|
+
const { root } = await render(<IFrame isWidgetBox item={item} />);
|
|
46
|
+
|
|
47
|
+
const iframes = root.findAllByType(WebView);
|
|
48
|
+
expect(iframes).toHaveLength(1);
|
|
49
|
+
|
|
50
|
+
expect(iframes[0].props.source?.uri).toEqual(undefined);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('test reload', async () => {
|
|
54
|
+
const ref = {
|
|
55
|
+
current: {},
|
|
56
|
+
};
|
|
57
|
+
useRef.mockReturnValue(ref);
|
|
58
|
+
|
|
59
|
+
const mockReload = jest.fn();
|
|
60
|
+
const { root } = await render(<IFrame isWidgetBox item={item} />);
|
|
61
|
+
ref.current = {
|
|
62
|
+
reload: mockReload,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const buttons = root.findAllByType(TouchableOpacity);
|
|
66
|
+
expect(buttons).toHaveLength(1);
|
|
67
|
+
|
|
68
|
+
await act(async () => {
|
|
69
|
+
buttons[0].props.onClick();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
expect(mockReload).toHaveBeenCalledTimes(1);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
File without changes
|