@eohjsc/react-native-smart-city 0.5.9 → 0.6.0-rc2
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/Monitor.js +4 -4
- 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
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import Svg, { G } from 'react-native-svg';
|
|
3
|
-
import {
|
|
4
|
-
VictoryLine,
|
|
5
|
-
VictoryAxis,
|
|
6
|
-
VictoryScatter,
|
|
7
|
-
VictoryTooltip,
|
|
8
|
-
} from 'victory-native';
|
|
9
|
-
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
10
|
-
|
|
11
|
-
import { Colors } from '../../../../configs';
|
|
12
|
-
import ChartLoading from '../../../ChartLoading';
|
|
13
|
-
import ValueBalloon from '../../../Device/WindSpeed/LinearChart/ValueBalloon';
|
|
14
|
-
import { getMaxValueIndex } from '../../../../utils/chartHelper/getMaxValueIndex';
|
|
15
|
-
import getTickValues from '../../../../utils/dateHelper/getTickValues';
|
|
16
|
-
|
|
17
|
-
const LinearChart = memo(
|
|
18
|
-
({
|
|
19
|
-
startTime,
|
|
20
|
-
endTime,
|
|
21
|
-
datasShow,
|
|
22
|
-
configuration,
|
|
23
|
-
datasColor,
|
|
24
|
-
chartOptions,
|
|
25
|
-
}) => {
|
|
26
|
-
const t = useTranslations();
|
|
27
|
-
const datas = chartOptions.showAll
|
|
28
|
-
? datasShow
|
|
29
|
-
: datasShow.filter((item, index) => index === chartOptions.index);
|
|
30
|
-
if (!datasShow[0].data) {
|
|
31
|
-
return <ChartLoading />;
|
|
32
|
-
}
|
|
33
|
-
if (!datasShow[0].data.length) {
|
|
34
|
-
return <ChartLoading message={t('no_data')} />;
|
|
35
|
-
}
|
|
36
|
-
const chartTick = getTickValues(datas[0], configuration).stringArr;
|
|
37
|
-
const maxValue = getMaxValueIndex(datas[0].data);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<Svg width={'100%'} height={300} style>
|
|
41
|
-
<G x={-12} y={-12}>
|
|
42
|
-
<VictoryAxis
|
|
43
|
-
dependentAxis
|
|
44
|
-
domain={[0, maxValue.max.y * 1.2]}
|
|
45
|
-
offsetX={50}
|
|
46
|
-
orientation="left"
|
|
47
|
-
standalone={false}
|
|
48
|
-
style={styleVerticalAxis}
|
|
49
|
-
/>
|
|
50
|
-
<VictoryAxis
|
|
51
|
-
crossAxis
|
|
52
|
-
scale="time"
|
|
53
|
-
standalone={false}
|
|
54
|
-
style={styleHorizontalAxis}
|
|
55
|
-
tickValues={chartTick}
|
|
56
|
-
/>
|
|
57
|
-
{datas.map((item, index) => {
|
|
58
|
-
const tickValues = getTickValues(item).arr;
|
|
59
|
-
const maxValueLine = getMaxValueIndex(item.data);
|
|
60
|
-
return (
|
|
61
|
-
<G key={index.toString()}>
|
|
62
|
-
<VictoryLine
|
|
63
|
-
data={item.data}
|
|
64
|
-
domain={{
|
|
65
|
-
x: [tickValues[0], tickValues[tickValues.length - 1]],
|
|
66
|
-
y: [0, maxValueLine.max.y * 1.2],
|
|
67
|
-
}}
|
|
68
|
-
style={{
|
|
69
|
-
data: { stroke: item.color },
|
|
70
|
-
}}
|
|
71
|
-
interpolation="monotoneX"
|
|
72
|
-
scale={{ x: 'time', y: 'linear' }}
|
|
73
|
-
standalone={false}
|
|
74
|
-
/>
|
|
75
|
-
</G>
|
|
76
|
-
);
|
|
77
|
-
})}
|
|
78
|
-
{datas.map((item, index) => {
|
|
79
|
-
const scatterValues = getTickValues(item).stringDataArr;
|
|
80
|
-
const maxValueLine = getMaxValueIndex(item.data);
|
|
81
|
-
return (
|
|
82
|
-
<G key={index}>
|
|
83
|
-
<VictoryScatter
|
|
84
|
-
standalone={false}
|
|
85
|
-
data={scatterValues}
|
|
86
|
-
labels={(datum) => {
|
|
87
|
-
if (item.measure === 'pH') {
|
|
88
|
-
return `${item.measure} ${datum.y.toString()}`;
|
|
89
|
-
}
|
|
90
|
-
return `${datum.y.toString()} ${item.measure}`;
|
|
91
|
-
}}
|
|
92
|
-
labelComponent={
|
|
93
|
-
<VictoryTooltip
|
|
94
|
-
flyoutComponent={<ValueBalloon />}
|
|
95
|
-
renderInPortal={false}
|
|
96
|
-
/>
|
|
97
|
-
}
|
|
98
|
-
domain={{ y: [0, maxValueLine.max.y * 1.2] }}
|
|
99
|
-
samples={25}
|
|
100
|
-
size={5}
|
|
101
|
-
style={{ ...styleScatter, data: { fill: item.color } }}
|
|
102
|
-
/>
|
|
103
|
-
</G>
|
|
104
|
-
);
|
|
105
|
-
})}
|
|
106
|
-
</G>
|
|
107
|
-
</Svg>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
export default LinearChart;
|
|
113
|
-
|
|
114
|
-
const styleVerticalAxis = {
|
|
115
|
-
axis: { stroke: Colors.Gray4, strokeWidth: 1 },
|
|
116
|
-
ticks: {
|
|
117
|
-
size: 5,
|
|
118
|
-
stroke: 'black',
|
|
119
|
-
strokeWidth: 0,
|
|
120
|
-
},
|
|
121
|
-
tickLabels: {
|
|
122
|
-
fill: Colors.Gray8,
|
|
123
|
-
fontFamily: 'SFProDisplay-Regular',
|
|
124
|
-
fontSize: 10,
|
|
125
|
-
},
|
|
126
|
-
grid: {
|
|
127
|
-
fill: 'none',
|
|
128
|
-
stroke: Colors.Gray4,
|
|
129
|
-
strokeDasharray: '5,5',
|
|
130
|
-
pointerEvents: 'painted',
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
const styleHorizontalAxis = {
|
|
135
|
-
axis: { stroke: 'black', strokeWidth: 0 },
|
|
136
|
-
ticks: {
|
|
137
|
-
size: 10,
|
|
138
|
-
stroke: 'black',
|
|
139
|
-
strokeWidth: 0,
|
|
140
|
-
},
|
|
141
|
-
tickLabels: {
|
|
142
|
-
fill: Colors.Gray8,
|
|
143
|
-
fontFamily: 'SFProDisplay-Regular',
|
|
144
|
-
fontSize: 10,
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const styleScatter = {
|
|
149
|
-
labels: {
|
|
150
|
-
fill: Colors.White,
|
|
151
|
-
padding: 14,
|
|
152
|
-
fontFamily: 'SFProDisplay-Regular',
|
|
153
|
-
fontSize: 12,
|
|
154
|
-
},
|
|
155
|
-
};
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { act, create } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
|
|
5
|
-
import ConfigHistoryChart from '../';
|
|
6
|
-
import api from '../../../../utils/Apis/axios';
|
|
7
|
-
import { mockSCStore } from '../../../../context/mockStore';
|
|
8
|
-
import { SCProvider } from '../../../../context';
|
|
9
|
-
import API from '../../../../configs/API';
|
|
10
|
-
import { getPusher } from '../../../../utils/Pusher';
|
|
11
|
-
import Highcharts from '../../../Highcharts';
|
|
12
|
-
|
|
13
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
14
|
-
|
|
15
|
-
const wrapComponent = (configs = []) => (
|
|
16
|
-
<SCProvider initState={mockSCStore({})}>
|
|
17
|
-
<ConfigHistoryChart configs={configs} />
|
|
18
|
-
</SCProvider>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
describe('Test HistoryChart', () => {
|
|
22
|
-
let tree;
|
|
23
|
-
|
|
24
|
-
beforeAll(() => {
|
|
25
|
-
jest.useFakeTimers();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
getPusher().subscribe.mockClear();
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const assertChartData = async (data) => {
|
|
33
|
-
const chart = tree.root.findByType(Highcharts);
|
|
34
|
-
expect(chart.props.options.series[0].data).toEqual(
|
|
35
|
-
data.map((i) => [i.x, i.y])
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
it('Test render null', async () => {
|
|
40
|
-
await act(async () => {
|
|
41
|
-
tree = create(wrapComponent());
|
|
42
|
-
});
|
|
43
|
-
const instance = tree.root;
|
|
44
|
-
const HistoryCharts = instance.findAllByType(Highcharts);
|
|
45
|
-
expect(HistoryCharts).toHaveLength(0);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('Test render chart empty data', async () => {
|
|
49
|
-
const response = {
|
|
50
|
-
data: {
|
|
51
|
-
configs: [
|
|
52
|
-
{
|
|
53
|
-
id: 1,
|
|
54
|
-
head: [],
|
|
55
|
-
tail: [],
|
|
56
|
-
middle: {
|
|
57
|
-
ready: [],
|
|
58
|
-
not_ready: [],
|
|
59
|
-
channel: '',
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
66
|
-
const configs = [{ id: 1 }];
|
|
67
|
-
await act(async () => {
|
|
68
|
-
tree = await create(wrapComponent(configs));
|
|
69
|
-
jest.runAllTimers();
|
|
70
|
-
});
|
|
71
|
-
await assertChartData([]);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it('Test render chart empty head data', async () => {
|
|
75
|
-
const response = {
|
|
76
|
-
data: {
|
|
77
|
-
configs: [
|
|
78
|
-
{
|
|
79
|
-
id: 1,
|
|
80
|
-
head: [],
|
|
81
|
-
tail: [{ x: 1, y: 2 }],
|
|
82
|
-
middle: {
|
|
83
|
-
ready: [],
|
|
84
|
-
not_ready: [],
|
|
85
|
-
channel: '',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
92
|
-
const configs = [{ id: 1 }];
|
|
93
|
-
await act(async () => {
|
|
94
|
-
tree = await create(wrapComponent(configs));
|
|
95
|
-
jest.runAllTimers();
|
|
96
|
-
});
|
|
97
|
-
await assertChartData([{ x: 1, y: 2 }]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('Test render chart empty tail data', async () => {
|
|
101
|
-
const response = {
|
|
102
|
-
data: {
|
|
103
|
-
configs: [
|
|
104
|
-
{
|
|
105
|
-
id: 1,
|
|
106
|
-
head: [{ x: 1, y: 2 }],
|
|
107
|
-
tail: [],
|
|
108
|
-
middle: {
|
|
109
|
-
ready: [],
|
|
110
|
-
not_ready: [],
|
|
111
|
-
channel: '',
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
118
|
-
const configs = [{ id: 1 }];
|
|
119
|
-
await act(async () => {
|
|
120
|
-
tree = await create(wrapComponent(configs));
|
|
121
|
-
jest.runAllTimers();
|
|
122
|
-
});
|
|
123
|
-
await assertChartData([{ x: 1, y: 2 }]);
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it('Test render chart merge head and tail data', async () => {
|
|
127
|
-
const response = {
|
|
128
|
-
data: {
|
|
129
|
-
configs: [
|
|
130
|
-
{
|
|
131
|
-
id: 1,
|
|
132
|
-
head: [{ x: 1, y: 2 }],
|
|
133
|
-
tail: [{ x: 2, y: 3 }],
|
|
134
|
-
middle: {
|
|
135
|
-
ready: [],
|
|
136
|
-
not_ready: [],
|
|
137
|
-
channel: '',
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
144
|
-
const configs = [{ id: 1 }];
|
|
145
|
-
await act(async () => {
|
|
146
|
-
tree = await create(wrapComponent(configs));
|
|
147
|
-
jest.runAllTimers();
|
|
148
|
-
});
|
|
149
|
-
await assertChartData([
|
|
150
|
-
{ x: 1, y: 2 },
|
|
151
|
-
{ x: 2, y: 3 },
|
|
152
|
-
]);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it('Test render chart merge fetch ready data', async () => {
|
|
156
|
-
const cacheUrl = 'https://s3.eoh.io/xxx.json';
|
|
157
|
-
const response = {
|
|
158
|
-
data: {
|
|
159
|
-
configs: [
|
|
160
|
-
{
|
|
161
|
-
id: 1,
|
|
162
|
-
head: [{ x: 1, y: 2 }],
|
|
163
|
-
tail: [{ x: 2, y: 3 }],
|
|
164
|
-
middle: {
|
|
165
|
-
ready: [{ date: '2022-03-03', url: cacheUrl }],
|
|
166
|
-
not_ready: [],
|
|
167
|
-
channel: '',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
174
|
-
mock.onGet(cacheUrl).reply(200, [{ x: 3, y: 4 }]);
|
|
175
|
-
const configs = [{ id: 1 }];
|
|
176
|
-
await act(async () => {
|
|
177
|
-
tree = await create(wrapComponent(configs));
|
|
178
|
-
jest.runAllTimers();
|
|
179
|
-
});
|
|
180
|
-
await assertChartData([
|
|
181
|
-
{ x: 1, y: 2 },
|
|
182
|
-
{ x: 3, y: 4 },
|
|
183
|
-
{ x: 2, y: 3 },
|
|
184
|
-
]);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it('Test render chart merge fetch not-ready data', async () => {
|
|
188
|
-
const cacheUrl = 'https://s3.eoh.io/xxx.json';
|
|
189
|
-
const response = {
|
|
190
|
-
data: {
|
|
191
|
-
configs: [
|
|
192
|
-
{
|
|
193
|
-
id: 1,
|
|
194
|
-
head: [{ x: 1, y: 2 }],
|
|
195
|
-
tail: [{ x: 2, y: 3 }],
|
|
196
|
-
middle: {
|
|
197
|
-
ready: [],
|
|
198
|
-
not_ready: [{ date: '2022-03-03', url: cacheUrl }],
|
|
199
|
-
channel: 'cache-xxx',
|
|
200
|
-
},
|
|
201
|
-
},
|
|
202
|
-
],
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
206
|
-
mock.onGet(cacheUrl).reply(200, [{ x: 3, y: 4 }]);
|
|
207
|
-
const configs = [{ id: 1 }];
|
|
208
|
-
await act(async () => {
|
|
209
|
-
tree = await create(wrapComponent(configs));
|
|
210
|
-
jest.runAllTimers();
|
|
211
|
-
});
|
|
212
|
-
await assertChartData([
|
|
213
|
-
{ x: 1, y: 2 },
|
|
214
|
-
{ x: 2, y: 3 },
|
|
215
|
-
]);
|
|
216
|
-
await act(async () => {
|
|
217
|
-
await getPusher()
|
|
218
|
-
.subscribe('cache-xxx')
|
|
219
|
-
.trigger('caching-value-log-process', {
|
|
220
|
-
success: true,
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
await assertChartData([
|
|
224
|
-
{ x: 1, y: 2 },
|
|
225
|
-
{ x: 3, y: 4 },
|
|
226
|
-
{ x: 2, y: 3 },
|
|
227
|
-
]);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('Test render chart merge fetch both ready and not-ready data', async () => {
|
|
231
|
-
const cacheUrl1 = 'https://s3.eoh.io/xxx1.json';
|
|
232
|
-
const cacheUrl2 = 'https://s3.eoh.io/xxx2.json';
|
|
233
|
-
const cacheUrl3 = 'https://s3.eoh.io/xxx3.json';
|
|
234
|
-
const cacheUrl4 = 'https://s3.eoh.io/xxx4.json';
|
|
235
|
-
const response = {
|
|
236
|
-
data: {
|
|
237
|
-
configs: [
|
|
238
|
-
{
|
|
239
|
-
id: 1,
|
|
240
|
-
head: [{ x: 1, y: 2 }],
|
|
241
|
-
tail: [{ x: 2, y: 3 }],
|
|
242
|
-
middle: {
|
|
243
|
-
ready: [
|
|
244
|
-
{ date: '2022-03-02', url: cacheUrl1 },
|
|
245
|
-
{ date: '2022-03-04', url: cacheUrl3 },
|
|
246
|
-
],
|
|
247
|
-
not_ready: [
|
|
248
|
-
{ date: '2022-03-03', url: cacheUrl2 },
|
|
249
|
-
{ date: '2022-03-05', url: cacheUrl4 },
|
|
250
|
-
],
|
|
251
|
-
channel: 'cache-xxx',
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
};
|
|
257
|
-
mock.onGet(API.CONFIG.DISPLAY_HISTORY_V3()).reply(200, response.data);
|
|
258
|
-
mock.onGet(cacheUrl1).reply(200, [{ x: 3, y: 4 }]);
|
|
259
|
-
mock.onGet(cacheUrl2).reply(200, [{ x: 4, y: 5 }]);
|
|
260
|
-
mock.onGet(cacheUrl3).reply(200, [{ x: 5, y: 6 }]);
|
|
261
|
-
mock.onGet(cacheUrl4).reply(200, [{ x: 7, y: 8 }]);
|
|
262
|
-
const configs = [{ id: 1 }];
|
|
263
|
-
await act(async () => {
|
|
264
|
-
tree = await create(wrapComponent(configs));
|
|
265
|
-
jest.runAllTimers();
|
|
266
|
-
});
|
|
267
|
-
await assertChartData([
|
|
268
|
-
{ x: 1, y: 2 },
|
|
269
|
-
{ x: 3, y: 4 },
|
|
270
|
-
{ x: 5, y: 6 },
|
|
271
|
-
{ x: 2, y: 3 },
|
|
272
|
-
]);
|
|
273
|
-
await act(async () => {
|
|
274
|
-
await getPusher()
|
|
275
|
-
.subscribe('cache-xxx')
|
|
276
|
-
.trigger('caching-value-log-process', {
|
|
277
|
-
success: true,
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
await assertChartData([
|
|
281
|
-
{ x: 1, y: 2 },
|
|
282
|
-
{ x: 3, y: 4 },
|
|
283
|
-
{ x: 4, y: 5 },
|
|
284
|
-
{ x: 5, y: 6 },
|
|
285
|
-
{ x: 7, y: 8 },
|
|
286
|
-
{ x: 2, y: 3 },
|
|
287
|
-
]);
|
|
288
|
-
});
|
|
289
|
-
});
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer, { act } from 'react-test-renderer';
|
|
3
|
-
import MockAdapter from 'axios-mock-adapter';
|
|
4
|
-
|
|
5
|
-
import { DetailHistoryChart } from '../components/DetailHistoryChart';
|
|
6
|
-
import { SCProvider } from '../../../context';
|
|
7
|
-
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
-
import HistoryChart from '../../../commons/Device/HistoryChart';
|
|
9
|
-
import api from '../../../utils/Apis/axios';
|
|
10
|
-
import { API } from '../../../configs';
|
|
11
|
-
|
|
12
|
-
const mock = new MockAdapter(api.axiosInstance);
|
|
13
|
-
|
|
14
|
-
const wrapComponent = (item, sensor) => (
|
|
15
|
-
<SCProvider initState={mockSCStore({})}>
|
|
16
|
-
<DetailHistoryChart item={item} sensor={sensor} />
|
|
17
|
-
</SCProvider>
|
|
18
|
-
);
|
|
19
|
-
describe('Test DetailHistoryChart', () => {
|
|
20
|
-
let tree;
|
|
21
|
-
let item = {
|
|
22
|
-
id: 10452,
|
|
23
|
-
order: 0,
|
|
24
|
-
template: 'history',
|
|
25
|
-
type: 'history',
|
|
26
|
-
configuration: {
|
|
27
|
-
type: 'horizontal_bar_chart',
|
|
28
|
-
date_format: 'DD.MM',
|
|
29
|
-
configs: [
|
|
30
|
-
{
|
|
31
|
-
id: 9848,
|
|
32
|
-
title: 'horizontal',
|
|
33
|
-
color: 'blue',
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
},
|
|
37
|
-
is_configuration_ready: true,
|
|
38
|
-
};
|
|
39
|
-
let sensor = {
|
|
40
|
-
name: 'Sensor name',
|
|
41
|
-
is_managed_by_backend: false,
|
|
42
|
-
};
|
|
43
|
-
it('create DetailHistoryChart', async () => {
|
|
44
|
-
mock
|
|
45
|
-
.onGet(API.VALUE_CONSUME.DISPLAY_HISTORY())
|
|
46
|
-
.reply(200, [{ data: [1, 2, 3] }]);
|
|
47
|
-
|
|
48
|
-
await act(async () => {
|
|
49
|
-
tree = await renderer.create(wrapComponent(item, sensor));
|
|
50
|
-
});
|
|
51
|
-
const instance = tree.root;
|
|
52
|
-
const historyChart = instance.findAllByType(HistoryChart);
|
|
53
|
-
expect(historyChart).toHaveLength(1);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('create DetailHistoryChart type line_chart', async () => {
|
|
57
|
-
mock.onGet(API.DEVICE.DISPLAY_HISTORY()).reply(200, [{ data: [1, 2, 3] }]);
|
|
58
|
-
item = {
|
|
59
|
-
...item,
|
|
60
|
-
configuration: { ...item?.configuration, type: 'line_chart' },
|
|
61
|
-
};
|
|
62
|
-
await act(async () => {
|
|
63
|
-
tree = await renderer.create(wrapComponent(item, sensor));
|
|
64
|
-
});
|
|
65
|
-
const instance = tree.root;
|
|
66
|
-
const historyChart = instance.findAllByType(HistoryChart);
|
|
67
|
-
expect(historyChart).toHaveLength(1);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
|
-
import { StyleSheet } from 'react-native';
|
|
4
|
-
import HistoryChart from '../../../commons/Device/HistoryChart';
|
|
5
|
-
import { API } from '../../../configs';
|
|
6
|
-
import { axiosGet } from '../../../utils/Apis/axios';
|
|
7
|
-
|
|
8
|
-
export const DetailHistoryChart = ({ item = {}, sensor = {} }) => {
|
|
9
|
-
const { configuration = {} } = item;
|
|
10
|
-
const { configs = [], type = '' } = configuration;
|
|
11
|
-
const [lineChartData, setLineChartData] = useState(configs);
|
|
12
|
-
const [horizontalChartData, setHorizontalChartData] = useState([]);
|
|
13
|
-
const [groupBy, setGroupBy] = useState('date');
|
|
14
|
-
const [startDate, setStartDate] = useState(
|
|
15
|
-
type === 'line_chart'
|
|
16
|
-
? moment().subtract(1, 'days').valueOf()
|
|
17
|
-
: moment().subtract(6, 'days')
|
|
18
|
-
);
|
|
19
|
-
const [endDate, setEndDate] = useState(
|
|
20
|
-
type === 'line_chart' ? moment().valueOf() : moment()
|
|
21
|
-
);
|
|
22
|
-
const [chartConfig, setChartConfig] = useState({
|
|
23
|
-
unit: '',
|
|
24
|
-
});
|
|
25
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
26
|
-
|
|
27
|
-
const fetchData = useCallback(async () => {
|
|
28
|
-
let params = new URLSearchParams();
|
|
29
|
-
configs.map((config) => {
|
|
30
|
-
params.append('config', config.id);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (type !== 'line_chart') {
|
|
34
|
-
params.append('group_by', groupBy);
|
|
35
|
-
if (groupBy === 'date') {
|
|
36
|
-
params.append('date_from', moment(startDate).format('YYYY-MM-DD'));
|
|
37
|
-
params.append('date_to', moment(endDate).format('YYYY-MM-DD'));
|
|
38
|
-
}
|
|
39
|
-
} else {
|
|
40
|
-
params.append('date_from', startDate / 1000);
|
|
41
|
-
params.append('date_to', endDate / 1000);
|
|
42
|
-
}
|
|
43
|
-
if (type === 'line_chart') {
|
|
44
|
-
const { success, data } = await axiosGet(
|
|
45
|
-
API.DEVICE.DISPLAY_HISTORY(sensor.id),
|
|
46
|
-
{ params }
|
|
47
|
-
);
|
|
48
|
-
if (success) {
|
|
49
|
-
for (let i = 0; i < data.length; i++) {
|
|
50
|
-
for (let j = 0; j < data[i].data.length; j++) {
|
|
51
|
-
data[i].data[j].x = moment(data[i].data[j].x).toDate();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const formatData = configs.map((config) => {
|
|
56
|
-
const dataChart = data.find((k) => k.config === config.id) || {
|
|
57
|
-
data: [],
|
|
58
|
-
};
|
|
59
|
-
return { ...config, data: dataChart.data };
|
|
60
|
-
});
|
|
61
|
-
setLineChartData(formatData);
|
|
62
|
-
setIsLoading(true);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (type === 'horizontal_bar_chart') {
|
|
66
|
-
const { success, data } = await axiosGet(
|
|
67
|
-
API.VALUE_CONSUME.DISPLAY_HISTORY(),
|
|
68
|
-
{
|
|
69
|
-
params,
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
if (success) {
|
|
73
|
-
if (data[0]?.data) {
|
|
74
|
-
setHorizontalChartData(data);
|
|
75
|
-
setIsLoading(true);
|
|
76
|
-
} else {
|
|
77
|
-
setIsLoading(false);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, [configs, endDate, groupBy, sensor.id, startDate, type]);
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
fetchData();
|
|
85
|
-
}, [fetchData]);
|
|
86
|
-
|
|
87
|
-
if (!lineChartData?.length) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return (
|
|
92
|
-
<>
|
|
93
|
-
{isLoading && (
|
|
94
|
-
<HistoryChart
|
|
95
|
-
configuration={item.configuration}
|
|
96
|
-
datas={type === 'line_chart' ? lineChartData : horizontalChartData}
|
|
97
|
-
setStartDate={setStartDate}
|
|
98
|
-
startDate={startDate}
|
|
99
|
-
setEndDate={setEndDate}
|
|
100
|
-
endDate={endDate}
|
|
101
|
-
groupBy={groupBy}
|
|
102
|
-
setGroupBy={setGroupBy}
|
|
103
|
-
chartConfig={chartConfig}
|
|
104
|
-
setChartConfig={setChartConfig}
|
|
105
|
-
formatType={type !== 'line_chart' && 'date'}
|
|
106
|
-
style={styles.chartStyle}
|
|
107
|
-
/>
|
|
108
|
-
)}
|
|
109
|
-
</>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const styles = StyleSheet.create({
|
|
114
|
-
chartStyle: {
|
|
115
|
-
paddingHorizontal: 16,
|
|
116
|
-
marginBottom: 16,
|
|
117
|
-
},
|
|
118
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import {
|
|
4
|
-
VictoryChart,
|
|
5
|
-
VictoryLine,
|
|
6
|
-
VictoryTheme,
|
|
7
|
-
VictoryScatter,
|
|
8
|
-
VictoryGroup,
|
|
9
|
-
VictoryAxis,
|
|
10
|
-
VictoryArea,
|
|
11
|
-
} from 'victory-native';
|
|
12
|
-
import { Colors } from '../../../../../configs';
|
|
13
|
-
|
|
14
|
-
const ChartAverage = memo(({ labels, tempData, humiData }) => {
|
|
15
|
-
const dataChartTemp = tempData;
|
|
16
|
-
const dataChartHumidity = humiData;
|
|
17
|
-
return (
|
|
18
|
-
<View style={{}}>
|
|
19
|
-
<VictoryChart
|
|
20
|
-
theme={VictoryTheme.material}
|
|
21
|
-
padding={{ top: 10, bottom: 30, left: 36, right: 36 }}
|
|
22
|
-
height={135}
|
|
23
|
-
>
|
|
24
|
-
<VictoryAxis
|
|
25
|
-
style={axisX}
|
|
26
|
-
tickFormat={(t, index) => {
|
|
27
|
-
if (index % 4 === 0) {
|
|
28
|
-
return t;
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}}
|
|
32
|
-
/>
|
|
33
|
-
<VictoryAxis dependentAxis style={axisY} />
|
|
34
|
-
<VictoryGroup color={'rgba(255,34,45,1)'} data={dataChartTemp}>
|
|
35
|
-
<VictoryLine />
|
|
36
|
-
<VictoryArea style={{ data: { fill: 'rgba(255,34,45,0.3)' } }} />
|
|
37
|
-
<VictoryScatter size={5} />
|
|
38
|
-
</VictoryGroup>
|
|
39
|
-
<VictoryGroup color={'rgba(24,144,255,1)'} data={dataChartHumidity}>
|
|
40
|
-
<VictoryLine />
|
|
41
|
-
<VictoryArea style={{ data: { fill: 'rgba(24,144,255,0.3)' } }} />
|
|
42
|
-
<VictoryScatter size={5} />
|
|
43
|
-
</VictoryGroup>
|
|
44
|
-
</VictoryChart>
|
|
45
|
-
</View>
|
|
46
|
-
);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const axisX = {
|
|
50
|
-
axis: { fill: Colors.Gray4, stroke: Colors.Gray4, strokeWidth: 2 },
|
|
51
|
-
grid: { fill: 'none', stroke: 'none' },
|
|
52
|
-
ticks: { size: 0 },
|
|
53
|
-
tickLabels: { fontSize: 12, fill: Colors.Gray8, padding: 13 },
|
|
54
|
-
};
|
|
55
|
-
const axisY = {
|
|
56
|
-
axis: { stroke: Colors.Gray4 },
|
|
57
|
-
axisLabel: { fontSize: 20, padding: 30 },
|
|
58
|
-
grid: { fill: 'none', stroke: 'none' },
|
|
59
|
-
ticks: { size: 0 },
|
|
60
|
-
tickLabels: { fontSize: 0 },
|
|
61
|
-
};
|
|
62
|
-
export default ChartAverage;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { act, create } from 'react-test-renderer';
|
|
4
|
-
|
|
5
|
-
import ChartAverage from '../ChartAverage';
|
|
6
|
-
|
|
7
|
-
describe('Test ChartAverage', () => {
|
|
8
|
-
let tree;
|
|
9
|
-
it('render ChartAverage', async () => {
|
|
10
|
-
await act(async () => {
|
|
11
|
-
tree = await create(<ChartAverage />);
|
|
12
|
-
});
|
|
13
|
-
const instance = tree.root;
|
|
14
|
-
const Views = instance.findAllByType(View);
|
|
15
|
-
expect(Views).toHaveLength(3);
|
|
16
|
-
});
|
|
17
|
-
});
|