@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.
Files changed (305) hide show
  1. package/README.md +1 -1
  2. package/android/build.gradle +8 -10
  3. package/package.json +52 -69
  4. package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -2
  5. package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +3 -3
  6. package/src/commons/ActionGroup/OnOffSmartLock/AutoLock/ButtonWrapper.js +3 -3
  7. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/__test__/index.test.js +3 -3
  8. package/src/commons/ActionGroup/OnOffSmartLock/PasscodeList/index.js +3 -3
  9. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/ButtonWrapper.js +2 -2
  10. package/src/commons/ActionGroup/OnOffSmartLock/SetupGeneratePasscode/__test__/index.test.js +0 -15
  11. package/src/commons/ActionGroup/OnOffTemplate/OnOffSimpleTemplate.js +2 -2
  12. package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +2 -2
  13. package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +2 -2
  14. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/CircleButton.js +5 -5
  15. package/src/commons/ActionGroup/SmartTiviActionTemplate/component/ControlPlay.js +3 -3
  16. package/src/commons/ActionGroup/TerminalBoxTemplate.js +2 -2
  17. package/src/commons/ActionGroup/TextBoxTemplate.js +2 -2
  18. package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +4 -4
  19. package/src/commons/ActionGroup/TimerActionTemplate.js +3 -4
  20. package/src/commons/ActionGroup/TwoButtonTemplate/index.js +2 -2
  21. package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +2 -9
  22. package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +4 -11
  23. package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +2 -9
  24. package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +4 -18
  25. package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +2 -2
  26. package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +1 -8
  27. package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -7
  28. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +4 -15
  29. package/src/commons/ActionGroup/__test__/TerminalBoxTemplate.test.js +0 -7
  30. package/src/commons/ActionGroup/__test__/TextBoxTemplate.test.js +1 -8
  31. package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +1 -8
  32. package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +1 -8
  33. package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +2 -9
  34. package/src/commons/ActionGroup/__test__/index.test.js +14 -21
  35. package/src/commons/ActionTemplate/__test__/index.test.js +2 -0
  36. package/src/commons/ActionTemplate/__test__/utils.js +21 -0
  37. package/src/commons/ActionTemplate/index.js +1 -2
  38. package/src/commons/BackDefault/index.js +2 -2
  39. package/src/commons/ButtonPopup/index.js +2 -2
  40. package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +1 -12
  41. package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +27 -20
  42. package/src/commons/Dashboard/MyUnit/index.js +0 -1
  43. package/src/commons/DateTimeRangeChange/DateTimeButton.js +2 -2
  44. package/src/commons/Device/ConnectedViewHeader.js +2 -2
  45. package/src/commons/Device/DisconnectedView.js +2 -2
  46. package/src/commons/Device/Emergency/EmergencyDetail.js +3 -3
  47. package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +2 -2
  48. package/src/commons/Device/FlatListItems.js +3 -3
  49. package/src/commons/Device/Hanet/ItemHanetDevice.js +3 -3
  50. package/src/commons/Device/Hanet/ItemHanetDevice.test.js +3 -11
  51. package/src/commons/Device/HorizontalBarChart.js +1 -1
  52. package/src/commons/Device/ItemAddNew/index.js +2 -2
  53. package/src/commons/Device/ItemDevice.js +2 -2
  54. package/src/commons/Device/PowerConsumptionChart.js +154 -0
  55. package/src/commons/Device/SonosSpeaker/index.js +3 -3
  56. package/src/commons/Device/WaterPurifierStatus/AlertStatusMachine.js +2 -2
  57. package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +2 -6
  58. package/src/commons/DisplayChecking/index.js +2 -2
  59. package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
  60. package/src/commons/EmergencyButton/AlertSent.js +2 -2
  61. package/src/commons/FieldTemplate/ChooseUserField/index.js +2 -2
  62. package/src/commons/Form/CurrencyInput.js +1 -15
  63. package/src/commons/Header/HeaderCustom.js +3 -3
  64. package/src/commons/HeaderAni/index.js +2 -2
  65. package/src/commons/IconComponent/index.js +3 -3
  66. package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +1 -1
  67. package/src/commons/MenuActionList/__test__/MenuActionList.test.js +1 -0
  68. package/src/commons/NavBar/index.js +2 -2
  69. package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -3
  70. package/src/commons/PreventAccess/__test__/PreventAccess.test.js +1 -13
  71. package/src/commons/Processing/__test__/Connecting.test.js +3 -14
  72. package/src/commons/SearchLocation/index.js +2 -2
  73. package/src/commons/SelectActionCard/index.js +2 -2
  74. package/src/commons/SelectSubUnit/__test__/SelectSubUnit.test.js +1 -18
  75. package/src/commons/SelectSubUnit/index.js +2 -2
  76. package/src/commons/SelectUnit/__test__/SelectUnit.test.js +1 -13
  77. package/src/commons/Sharing/BtnRemoveMember.js +2 -2
  78. package/src/commons/Sharing/StationDevicePermissions.js +2 -2
  79. package/src/commons/Sharing/WrapHeaderScrollable.js +1 -1
  80. package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +1 -1
  81. package/src/commons/SubUnit/DeviceTemplate/ConfigAndEvaluation/ConfigAndEvaluation.js +2 -2
  82. package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -2
  83. package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -2
  84. package/src/commons/SubUnit/Item/index.js +2 -2
  85. package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -2
  86. package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +11 -8
  87. package/src/commons/SubUnit/__test__/Favorites.test.js +1 -13
  88. package/src/commons/SubUnit/__test__/ShortDetail.test.js +5 -16
  89. package/src/commons/Tabbar/__test__/index.test.js +0 -11
  90. package/src/commons/Unit/HeaderUnit/index.js +4 -4
  91. package/src/commons/Unit/SharedUnit.js +5 -5
  92. package/src/commons/Unit/__test__/HeaderUnit.test.js +3 -15
  93. package/src/commons/Unit/__test__/SharedUnit.test.js +94 -105
  94. package/src/commons/UnitSummary/AirQuality/SegmentedRoundDisplay/index.js +11 -30
  95. package/src/commons/UnitSummary/ConfigHistoryChart/index.js +6 -61
  96. package/src/commons/Widgets/IFrame/IFrame.js +54 -0
  97. package/src/commons/Widgets/IFrame/IFrameStyles.js +35 -0
  98. package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +74 -0
  99. package/src/commons/Widgets/IFrame/index.js +0 -0
  100. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfig.js +163 -0
  101. package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfigStyles.js +9 -0
  102. package/src/commons/Widgets/IFrameWithConfig/__tests__/IFrameWithConfig.test.js +284 -0
  103. package/src/commons/Widgets/IFrameWithConfig/index.js +0 -0
  104. package/src/commons/Widgets/Widget.js +0 -0
  105. package/src/commons/Widgets/index.js +0 -0
  106. package/src/configs/Constants.js +5 -0
  107. package/src/hooks/Common/__test__/useAndroidTranslucentStatusBar.test.js +4 -15
  108. package/src/hooks/Common/useDevicesStatus.js +23 -23
  109. package/src/hooks/IoT/__test__/useRemoteControl.test.js +1 -1
  110. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +0 -7
  111. package/src/iot/RemoteControl/HomeAssistant.js +1 -1
  112. package/src/iot/RemoteControl/__test__/Bluetooth.test.js +234 -232
  113. package/src/navigations/AutomateStack.js +2 -2
  114. package/src/navigations/EmergencyContactsStack.js +2 -2
  115. package/src/navigations/SharedStack.js +2 -2
  116. package/src/navigations/UnitStack.js +2 -2
  117. package/src/screens/ActivityLog/hooks/index.js +7 -4
  118. package/src/screens/ActivityLog/index.js +2 -2
  119. package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +4 -21
  120. package/src/screens/AddCommon/__test__/SelectUnit.test.js +7 -19
  121. package/src/screens/AddLocationMaps/__test__/index.test.js +3 -13
  122. package/src/screens/AddLocationMaps/index.js +4 -4
  123. package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +3 -20
  124. package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +11 -18
  125. package/src/screens/AddNewGateway/PlugAndPlay/__test__/ZigbeeDeviceConnectGuide.test.js +4 -21
  126. package/src/screens/AddNewGateway/RenameNewDevices.js +2 -2
  127. package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +3 -3
  128. package/src/screens/AddNewGateway/__test__/ConnectingModbusDevice.test.js +0 -17
  129. package/src/screens/AddNewGateway/__test__/ConnectingWifiDevice.test.js +4 -19
  130. package/src/screens/AddNewGateway/__test__/ConnectingWifiGuide.test.js +3 -15
  131. package/src/screens/AddNewGateway/__test__/ConnectingZigbeeDevice.test.js +31 -51
  132. package/src/screens/AddNewGateway/__test__/RenameNewDevices.test.js +9 -22
  133. package/src/screens/AddNewGateway/__test__/ScanGatewayQR.test.js +12 -19
  134. package/src/screens/AddNewGateway/__test__/ScanModbusQR.test.js +6 -16
  135. package/src/screens/AddNewGateway/__test__/ScanWifiDeviceQR.test.js +4 -15
  136. package/src/screens/AddNewGateway/__test__/SelectDeviceSubUnit.test.js +3 -3
  137. package/src/screens/AddNewGateway/__test__/SelectDeviceType.test.js +18 -10
  138. package/src/screens/AddNewGateway/__test__/SelectDeviceUnit.test.js +1 -1
  139. package/src/screens/AddNewGateway/__test__/SelectModbusGateway.test.js +12 -9
  140. package/src/screens/AddNewGateway/__test__/SelectZigbeeGateway.test.js +12 -9
  141. package/src/screens/AddNewGateway/__test__/ShareWifiPassword.test.js +7 -21
  142. package/src/screens/AddNewGateway/hooks/__Tests__/index.test.js +1 -10
  143. package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +0 -20
  144. package/src/screens/AllGateway/DetailConfigActionModbus/__test__/index.test.js +7 -24
  145. package/src/screens/AllGateway/DeviceGatewayInfo/__test__/index.test.js +0 -17
  146. package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +84 -100
  147. package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +64 -82
  148. package/src/screens/AllGateway/DeviceZigbeeDetail/__test__/index.test.js +36 -55
  149. package/src/screens/AllGateway/GatewayConnectionMethods/__test__/index.test.js +9 -18
  150. package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +10 -37
  151. package/src/screens/AllGateway/GatewayInfo/__test__/index.test.js +7 -32
  152. package/src/screens/AllGateway/__test__/index.test.js +1 -14
  153. package/src/screens/AllGateway/components/GatewayItem/__test__/index.test.js +0 -12
  154. package/src/screens/AllGateway/components/TabPaneCT/__test__/index.test.js +1 -13
  155. package/src/screens/AllGateway/components/TabPaneCT/index.js +1 -1
  156. package/src/screens/AllGateway/hooks/__test__/index.test.js +1 -8
  157. package/src/screens/AllGateway/test-utils.js +1 -1
  158. package/src/screens/Automate/AddNewAction/NewActionWrapper.js +2 -2
  159. package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +27 -28
  160. package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +3 -3
  161. package/src/screens/Automate/AddNewAction/__test__/ChooseConfig.test.js +8 -5
  162. package/src/screens/Automate/AddNewAction/__test__/SelectControlDevices.test.js +2 -2
  163. package/src/screens/Automate/AddNewAction/__test__/SelectMonitorDevices.test.js +1 -18
  164. package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +17 -15
  165. package/src/screens/Automate/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +4 -4
  166. package/src/screens/Automate/EditActionsList/__tests__/UpdateActionScript.test.js +38 -55
  167. package/src/screens/Automate/EditActionsList/__tests__/UpdateDelayScript.test.js +0 -18
  168. package/src/screens/Automate/EditActionsList/__tests__/UpdateNotifyScript.test.js +1 -19
  169. package/src/screens/Automate/EditActionsList/__tests__/index.test.js +14 -11
  170. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +3 -3
  171. package/src/screens/Automate/Scenario/__test__/AddNewOneTap.test.js +2 -2
  172. package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +2 -2
  173. package/src/screens/Automate/ScriptDetail/__test__/index.test.js +33 -25
  174. package/src/screens/Automate/ScriptDetail/index.js +5 -6
  175. package/src/screens/Automate/SetSchedule/__test__/index.test.js +4 -4
  176. package/src/screens/Automate/SetSchedule/components/RowItem.js +3 -3
  177. package/src/screens/Automate/__test__/MultiUnits.test.js +5 -5
  178. package/src/screens/Automate/__test__/index.test.js +6 -6
  179. package/src/screens/Automate/index.js +2 -2
  180. package/src/screens/ChangePosition/__test__/index.test.js +1 -14
  181. package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +0 -12
  182. package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +1 -11
  183. package/src/screens/Device/EditDevice/index.js +2 -2
  184. package/src/screens/Device/__test__/detail.test.js +11 -11
  185. package/src/screens/Device/__test__/sensorDisplayItem.test.js +3 -15
  186. package/src/screens/Device/components/SensorDisplayItem.js +23 -5
  187. package/src/screens/Device/components/__test__/VisualChart.test.js +2 -9
  188. package/src/screens/Device/detail.js +11 -10
  189. package/src/screens/Drawer/Drawer.test.js +3 -11
  190. package/src/screens/Drawer/index.js +3 -4
  191. package/src/screens/EmergencyContacts/EmergencyContactsList.js +4 -8
  192. package/src/screens/EmergencyContacts/EmergencyContactsSelectContacts.js +3 -3
  193. package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +4 -17
  194. package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +3 -14
  195. package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +0 -10
  196. package/src/screens/EmergencySetting/components/DropDownItem.js +2 -2
  197. package/src/screens/EnterPassword/__test__/EnterPassword.test.js +4 -17
  198. package/src/screens/GuestInfo/__test__/index.test.js +0 -11
  199. package/src/screens/GuestInfo/components/RowGuestInfo.js +2 -2
  200. package/src/screens/GuestInfo/index.js +2 -2
  201. package/src/screens/HanetCamera/Detail.js +2 -2
  202. package/src/screens/HanetCamera/ManageAccess.js +3 -4
  203. package/src/screens/HanetCamera/MemberInfo.js +4 -4
  204. package/src/screens/HanetCamera/__test__/CaptureFaceID.test.js +2 -16
  205. package/src/screens/HanetCamera/__test__/Detail.test.js +1 -12
  206. package/src/screens/HanetCamera/__test__/ManageAccess.test.js +5 -16
  207. package/src/screens/HanetCamera/__test__/MemberInfo.test.js +5 -18
  208. package/src/screens/HanetCamera/components/RequestFaceIDPopup.js +2 -2
  209. package/src/screens/ManageAccess/__test__/ManageAccess.test.js +3 -19
  210. package/src/screens/ManageAccess/index.js +3 -3
  211. package/src/screens/MoveToAnotherSubUnit/__test__/index.test.js +5 -5
  212. package/src/screens/Notification/__test__/NotificationItem.test.js +9 -19
  213. package/src/screens/Notification/index.js +3 -3
  214. package/src/screens/PlayBackCamera/Styles/index.js +2 -4
  215. package/src/screens/PlayBackCamera/Timer.js +65 -47
  216. package/src/screens/PlayBackCamera/__test__/index.test.js +32 -33
  217. package/src/screens/PlayBackCamera/index.js +115 -112
  218. package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +0 -11
  219. package/src/screens/ScanChipQR/components/QRScan/index.js +3 -3
  220. package/src/screens/SelectUnit/__test__/index.test.js +1 -21
  221. package/src/screens/SelectUnit/index.js +2 -2
  222. package/src/screens/SharedUnit/TabHeader.js +2 -2
  223. package/src/screens/Sharing/Components/EndDevice.js +3 -3
  224. package/src/screens/Sharing/UnitMemberList.js +2 -2
  225. package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +9 -4
  226. package/src/screens/Sharing/__test__/SelectShareDevice.test.js +2 -15
  227. package/src/screens/Sharing/__test__/SelectUser.test.js +2 -22
  228. package/src/screens/Sharing/__test__/UnitMemberList.test.js +2 -2
  229. package/src/screens/Sharing/__test__/UpdateShareDevice.test.js +4 -17
  230. package/src/screens/Sharing/hooks/__test__/index.test.js +2 -13
  231. package/src/screens/SmartAccount/Connecting/index.js +0 -2
  232. package/src/screens/SmartAccount/ListDevice/__test__/ListDevice.test.js +3 -18
  233. package/src/screens/SmartAccount/SuccessfullyConnected/__test__/SuccessfullyConnected.test.js +11 -21
  234. package/src/screens/SmartAccount/SuccessfullyConnected/index.js +3 -4
  235. package/src/screens/SmartAccount/__test__/Connecting.test.js +30 -36
  236. package/src/screens/SmartAccount/__test__/SmartAccount.test.js +12 -21
  237. package/src/screens/SmartIr/__test__/GroupButtonByType.test.js +7 -17
  238. package/src/screens/SmartIr/__test__/SelectBrand.test.js +1 -11
  239. package/src/screens/SmartIr/__test__/SelectDeviceType.test.js +1 -12
  240. package/src/screens/SmartIr/__test__/SmartIr.test.js +3 -11
  241. package/src/screens/SmartIr/components/GroupButtonByType/GroupButtonByType.js +3 -3
  242. package/src/screens/SmartIr/components/SelectBrand.js +2 -2
  243. package/src/screens/SubUnit/AddSubUnit.js +1 -0
  244. package/src/screens/SubUnit/EditSubUnit.js +3 -2
  245. package/src/screens/SubUnit/ManageSubUnit.js +4 -5
  246. package/src/screens/SubUnit/__test__/AddSubUnit.test.js +9 -31
  247. package/src/screens/SubUnit/__test__/Detail.test.js +4 -28
  248. package/src/screens/SubUnit/__test__/EditSubUnit.test.js +12 -30
  249. package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +2 -2
  250. package/src/screens/SubUnit/hooks/__test__/useManageSubUnit.test.js +0 -12
  251. package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +7 -20
  252. package/src/screens/Template/__test__/EditTemplate.test.js +2 -13
  253. package/src/screens/Template/__test__/GatewayList.test.js +0 -9
  254. package/src/screens/Template/__test__/detail.test.js +4 -4
  255. package/src/screens/Template/__test__/index.test.js +1 -12
  256. package/src/screens/Template/detail.js +2 -2
  257. package/src/screens/Unit/SelectAddToFavorites.js +2 -2
  258. package/src/screens/Unit/SelectAddress.js +4 -4
  259. package/src/screens/Unit/SmartAccountItem.js +2 -2
  260. package/src/screens/Unit/Summaries.js +3 -2
  261. package/src/screens/Unit/__test__/AddMenu.test.js +5 -2
  262. package/src/screens/Unit/__test__/CheckSendEmail.test.js +0 -12
  263. package/src/screens/Unit/__test__/ChooseLocation.test.js +1 -4
  264. package/src/screens/Unit/__test__/Detail.test.js +5 -5
  265. package/src/screens/Unit/__test__/ManageUnit.test.js +2 -17
  266. package/src/screens/Unit/__test__/MoreMenu.test.js +1 -11
  267. package/src/screens/Unit/__test__/SelectAddToFavorites.test.js +3 -14
  268. package/src/screens/Unit/__test__/SelectAddress.test.js +4 -17
  269. package/src/screens/Unit/__test__/SmartAccount.test.js +14 -11
  270. package/src/screens/Unit/__test__/SmartAccountItem.test.js +0 -11
  271. package/src/screens/Unit/__test__/Summaries.test.js +2 -14
  272. package/src/screens/Unit/components/AutomateScript/index.js +2 -2
  273. package/src/screens/Unit/components/ButtonWrapper/index.js +3 -4
  274. package/src/screens/Unit/components/Header/index.js +3 -3
  275. package/src/screens/Unit/components/SharedUnit/index.js +5 -5
  276. package/src/screens/Unit/components/__test__/Header.test.js +1 -14
  277. package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +1 -11
  278. package/src/screens/Unit/components/__test__/SharedUnit.test.js +1 -11
  279. package/src/screens/UnitSummary/__test__/index.test.js +51 -17
  280. package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +0 -12
  281. package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +10 -23
  282. package/src/screens/UnitSummary/components/AirQuality/__test__/index.test.js +1 -7
  283. package/src/screens/UnitSummary/components/AirQuality/index.js +3 -3
  284. package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +38 -14
  285. package/src/screens/UnitSummary/components/PowerConsumption/index.js +21 -30
  286. package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +1 -16
  287. package/src/screens/UnitSummary/components/Temperature/index.js +5 -1
  288. package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +0 -8
  289. package/src/screens/UnitSummary/components/UvIndex/index.js +2 -2
  290. package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +2 -2
  291. package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +14 -18
  292. package/src/screens/UnitSummary/index.js +4 -8
  293. package/src/utils/Converter/__test__/timer.test.js +8 -0
  294. package/src/utils/Functions/preloadImages.js +13 -14
  295. package/src/utils/Monitor.js +4 -4
  296. package/src/utils/Storage.js +1 -1
  297. package/src/commons/Device/HistoryChart.js +0 -225
  298. package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +0 -48
  299. package/src/commons/Device/WindSpeed/LinearChart/index.js +0 -155
  300. package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
  301. package/src/screens/Device/__test__/DetailHistoryChart.test.js +0 -69
  302. package/src/screens/Device/components/DetailHistoryChart.js +0 -118
  303. package/src/screens/UnitSummary/components/Temperature/ChartAverage/index.js +0 -62
  304. package/src/screens/UnitSummary/components/Temperature/__test__/ChartAverage.test.js +0 -17
  305. package/src/utils/dateHelper/getTickValues.js +0 -22
@@ -0,0 +1,163 @@
1
+ import moment from 'moment';
2
+ import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
3
+
4
+ import { styles as useIframeStyle } from '../IFrame/IFrameStyles';
5
+ import { styles } from './IFrameWithConfigStyles';
6
+ import IconComponent from '../../IconComponent';
7
+ import { useConfigGlobalState } from '../../../iot/states';
8
+ import { useFetchConfigHistory } from '../../UnitSummary/ConfigHistoryChart';
9
+ import API from '../../../configs/API';
10
+ import WebView from 'react-native-webview';
11
+ import { TouchableOpacity, View } from 'react-native';
12
+
13
+ const IFrameWithConfig = memo(
14
+ ({ item = {}, widgetStyle, isWidgetBox, isSetting, isEditing }) => {
15
+ const ref = useRef();
16
+
17
+ const { configuration } = item;
18
+ const { url } = configuration || {};
19
+
20
+ const [height, setHeight] = useState(200);
21
+ const [urlWithEnv, setUrlWithEnv] = useState();
22
+ const [isReady, setIsReady] = useState(false);
23
+
24
+ const [configValues] = useConfigGlobalState('configValues');
25
+ const [chartData, setChartData] = useState(configuration?.history_configs);
26
+ const fetchDataDisplayHistory = useFetchConfigHistory(
27
+ configuration?.history_configs,
28
+ setChartData,
29
+ API.CONFIG.DISPLAY_HISTORY_V4()
30
+ );
31
+
32
+ const postMessage = useCallback((message) => {
33
+ ref.current?.injectJavaScript(
34
+ 'window.postMessage(' + JSON.stringify(message) + ', "*")'
35
+ );
36
+ }, []);
37
+
38
+ useEffect(() => {
39
+ if (!isReady || !ref.current) {
40
+ return;
41
+ }
42
+ if (!configuration?.history_configs?.length) {
43
+ return;
44
+ }
45
+ postMessage({
46
+ source: 'eraIframeWidget',
47
+ type: 'histories',
48
+ data: chartData,
49
+ eraWidgetId: item.id,
50
+ });
51
+ }, [
52
+ chartData,
53
+ configuration?.history_configs?.length,
54
+ configuration.realtime_configs,
55
+ isReady,
56
+ item.id,
57
+ postMessage,
58
+ ]);
59
+
60
+ useEffect(() => {
61
+ const appendix = `eraOrigin=http://localhost:3000&eraWidget=${item?.id}`;
62
+ if (!url.includes('?')) {
63
+ setUrlWithEnv(`${url}?${appendix}`);
64
+ } else {
65
+ setUrlWithEnv(`${url}&${appendix}`);
66
+ }
67
+ }, [item?.id, url]);
68
+
69
+ const onMessage = useCallback(
70
+ async (event) => {
71
+ const eventData = event.nativeEvent.data
72
+ ? JSON.parse(event.nativeEvent.data)
73
+ : {};
74
+ if (
75
+ eventData?.source !== 'eraIframeWidget' ||
76
+ eventData?.eraWidgetId !== item.id
77
+ ) {
78
+ return;
79
+ }
80
+ const { type, data } = eventData;
81
+
82
+ switch (type) {
83
+ case 'ready':
84
+ postMessage({
85
+ source: 'eraIframeWidget',
86
+ type: 'configuration',
87
+ data: configuration,
88
+ eraWidgetId: item.id,
89
+ });
90
+ setIsReady(true);
91
+ break;
92
+ case 'requestHistories':
93
+ await fetchDataDisplayHistory(moment(data[0]), moment(data[1]));
94
+ break;
95
+ case 'requestAdjustMobileHeight':
96
+ setHeight(data);
97
+ break;
98
+ }
99
+ },
100
+ [configuration, fetchDataDisplayHistory, item.id, postMessage]
101
+ );
102
+
103
+ useEffect(() => {
104
+ if (!isReady || !ref?.current) {
105
+ return;
106
+ }
107
+ if (!configuration?.realtime_configs?.length) {
108
+ return;
109
+ }
110
+ const values = {};
111
+ configuration?.realtime_configs.map((config) => {
112
+ return (values[config.id] = configValues[config.id]);
113
+ });
114
+ postMessage({
115
+ source: 'eraIframeWidget',
116
+ type: 'values',
117
+ data: values,
118
+ eraWidgetId: item.id,
119
+ });
120
+ }, [
121
+ isReady,
122
+ configValues,
123
+ configuration?.realtime_configs,
124
+ item.id,
125
+ postMessage,
126
+ ]);
127
+
128
+ const reload = useCallback(() => {
129
+ setIsReady(false);
130
+ ref.current.reload();
131
+ }, []);
132
+
133
+ return (
134
+ <View
135
+ style={
136
+ isSetting
137
+ ? styles.settingWidget
138
+ : { ...styles.wrapper, height: height }
139
+ }
140
+ >
141
+ <TouchableOpacity
142
+ className={
143
+ isEditing
144
+ ? useIframeStyle.reloadButtonEditing
145
+ : useIframeStyle.reloadButton
146
+ }
147
+ onClick={reload}
148
+ >
149
+ <IconComponent name="ReloadOutlined" />
150
+ </TouchableOpacity>
151
+ <WebView
152
+ source={{ uri: urlWithEnv }}
153
+ className={useIframeStyle.iframe}
154
+ ref={ref}
155
+ title={item?.title}
156
+ onMessage={onMessage}
157
+ />
158
+ </View>
159
+ );
160
+ }
161
+ );
162
+
163
+ export default IFrameWithConfig;
@@ -0,0 +1,9 @@
1
+ export const styles = {
2
+ settingWidget: {
3
+ width: 256,
4
+ },
5
+ wrapper: {
6
+ width: '100%',
7
+ display: 'flex',
8
+ },
9
+ };
@@ -0,0 +1,284 @@
1
+ import React from 'react';
2
+ import { act } from 'react-test-renderer';
3
+
4
+ import IFrameWithConfig from '../IFrameWithConfig';
5
+ import { useConfigGlobalState } from '../../../../iot/states';
6
+ import { render } from '../../../../../jest/render';
7
+ import API from '../../../../configs/API';
8
+ import MockAdapter from 'axios-mock-adapter';
9
+ import api from '../../../../utils/Apis/axios';
10
+ import WebView from 'react-native-webview';
11
+ import { TouchableOpacity, View } from 'react-native';
12
+ import { refFunctions } from '../../../../../__mocks__/react-native-webview';
13
+
14
+ jest.mock('../../../../iot/states', () => {
15
+ return {
16
+ ...jest.requireActual('../../../../iot/states'),
17
+ useConfigGlobalState: jest.fn(),
18
+ };
19
+ });
20
+
21
+ describe('Test IFrame With Config', () => {
22
+ let item;
23
+ let configValues = {
24
+ 1: {
25
+ value: 0.5,
26
+ },
27
+ };
28
+
29
+ beforeEach(() => {
30
+ item = {
31
+ id: 1,
32
+ configuration: {
33
+ url: 'http://localhost:3000/',
34
+ realtime_configs: [{ id: 1 }],
35
+ },
36
+ };
37
+ useConfigGlobalState.mockImplementation(() => [configValues]);
38
+ refFunctions.injectJavaScript.mockClear();
39
+ });
40
+
41
+ test('test with widget box', async () => {
42
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
43
+
44
+ const iframes = root.findAllByType(WebView);
45
+ expect(iframes).toHaveLength(1);
46
+
47
+ expect(iframes[0].props.source?.uri).toEqual(
48
+ 'http://localhost:3000/?eraOrigin=http://localhost:3000&eraWidget=1'
49
+ );
50
+ });
51
+
52
+ test('test with query string', async () => {
53
+ item.configuration.url = 'http://localhost:3000/?test=1';
54
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
55
+
56
+ const iframes = root.findAllByType(WebView);
57
+ expect(iframes).toHaveLength(1);
58
+
59
+ expect(iframes[0].props.source?.uri).toEqual(
60
+ 'http://localhost:3000/?test=1&eraOrigin=http://localhost:3000&eraWidget=1'
61
+ );
62
+ });
63
+
64
+ test('test reload', async () => {
65
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
66
+
67
+ const buttons = root.findAllByType(TouchableOpacity);
68
+ expect(buttons).toHaveLength(1);
69
+
70
+ await act(async () => {
71
+ buttons[0].props.onClick();
72
+ });
73
+
74
+ expect(refFunctions.reload).toHaveBeenCalledTimes(1);
75
+ });
76
+
77
+ test('test iframe is ready', async () => {
78
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
79
+ const webview = root.findByType(WebView);
80
+
81
+ await act(async () => {
82
+ await webview.props.onMessage({
83
+ nativeEvent: {
84
+ data: JSON.stringify({
85
+ type: 'ready',
86
+ eraWidgetId: 1,
87
+ source: 'eraIframeWidget',
88
+ }),
89
+ origin: 'http://localhost',
90
+ },
91
+ });
92
+ });
93
+ expectSendMessage(
94
+ {
95
+ source: 'eraIframeWidget',
96
+ type: 'configuration',
97
+ data: item.configuration,
98
+ eraWidgetId: 1,
99
+ },
100
+ 'http://localhost:3000'
101
+ );
102
+ expectSendMessage(
103
+ {
104
+ source: 'eraIframeWidget',
105
+ type: 'values',
106
+ data: configValues,
107
+ eraWidgetId: 1,
108
+ },
109
+ 'http://localhost:3000'
110
+ );
111
+ unexpectSendMessage(
112
+ {
113
+ source: 'eraIframeWidget',
114
+ type: 'histories',
115
+ data: [{ id: 1 }],
116
+ eraWidgetId: 1,
117
+ },
118
+ 'http://localhost:3000'
119
+ );
120
+ });
121
+
122
+ test('test iframe request more height', async () => {
123
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
124
+ const webview = root.findByType(WebView);
125
+
126
+ await act(async () => {
127
+ await webview.props.onMessage({
128
+ nativeEvent: {
129
+ data: JSON.stringify({
130
+ type: 'requestAdjustMobileHeight',
131
+ data: 100,
132
+ eraWidgetId: 1,
133
+ source: 'eraIframeWidget',
134
+ }),
135
+ origin: 'http://localhost',
136
+ },
137
+ });
138
+ });
139
+
140
+ const wrapper = root.findAllByType(View)[0];
141
+ expect(wrapper.props.style.height).toEqual(100);
142
+ });
143
+
144
+ test('test iframe receive message from unexpected origin', async () => {
145
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
146
+ const webview = root.findByType(WebView);
147
+
148
+ await act(async () => {
149
+ webview.props.onMessage({
150
+ nativeEvent: {
151
+ data: JSON.stringify({
152
+ type: 'ready',
153
+ eraWidgetId: 2,
154
+ source: 'eraIframeWidget',
155
+ }),
156
+ origin: 'http://localhost',
157
+ },
158
+ });
159
+ });
160
+ expect(refFunctions.injectJavaScript).toHaveBeenCalledTimes(0);
161
+
162
+ await act(async () => {
163
+ webview.props.onMessage({
164
+ nativeEvent: {
165
+ data: JSON.stringify({
166
+ type: 'ready',
167
+ eraWidgetId: 1,
168
+ source: 'eraIframeWidget-wrong',
169
+ }),
170
+ origin: 'http://localhost',
171
+ },
172
+ });
173
+ });
174
+ expect(refFunctions.injectJavaScript).toHaveBeenCalledTimes(0);
175
+ });
176
+
177
+ test('test iframe init chart data', async () => {
178
+ item.configuration.history_configs = [{ id: 1 }];
179
+ item.configuration.realtime_configs = [];
180
+
181
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
182
+ const webview = root.findByType(WebView);
183
+
184
+ await act(async () => {
185
+ webview.props.onMessage({
186
+ nativeEvent: {
187
+ data: JSON.stringify({
188
+ type: 'ready',
189
+ eraWidgetId: 1,
190
+ source: 'eraIframeWidget',
191
+ }),
192
+ origin: 'http://localhost',
193
+ },
194
+ });
195
+ });
196
+ unexpectSendMessage(
197
+ {
198
+ source: 'eraIframeWidget',
199
+ type: 'configValues',
200
+ data: configValues,
201
+ eraWidgetId: 1,
202
+ },
203
+ 'http://localhost:3000'
204
+ );
205
+ expectSendMessage(
206
+ {
207
+ source: 'eraIframeWidget',
208
+ type: 'histories',
209
+ data: [{ id: 1 }],
210
+ eraWidgetId: 1,
211
+ },
212
+ 'http://localhost:3000'
213
+ );
214
+ });
215
+
216
+ test('test iframe request chart data', async () => {
217
+ item.configuration.history_configs = [{ id: 1 }];
218
+ item.configuration.realtime_configs = [];
219
+
220
+ const { root } = await render(<IFrameWithConfig isWidgetBox item={item} />);
221
+ const webview = root.findByType(WebView);
222
+
223
+ await act(async () => {
224
+ webview.props.onMessage({
225
+ nativeEvent: {
226
+ data: JSON.stringify({
227
+ type: 'ready',
228
+ eraWidgetId: 1,
229
+ source: 'eraIframeWidget',
230
+ }),
231
+ origin: 'http://localhost',
232
+ },
233
+ });
234
+ });
235
+
236
+ const mockAxios = new MockAdapter(api.axiosInstance);
237
+ mockAxios.onGet(API.CONFIG.DISPLAY_HISTORY_V4()).reply(200, {
238
+ configs: [
239
+ {
240
+ id: 1,
241
+ head: [],
242
+ tail: [{ x: 1000, y: 100 }],
243
+ middle: { ready: [], not_ready: [] },
244
+ },
245
+ ],
246
+ });
247
+ refFunctions.injectJavaScript.mockClear();
248
+
249
+ await act(async () => {
250
+ await webview.props.onMessage({
251
+ nativeEvent: {
252
+ data: JSON.stringify({
253
+ type: 'requestHistories',
254
+ eraWidgetId: 1,
255
+ source: 'eraIframeWidget',
256
+ data: [1, 2],
257
+ }),
258
+ origin: 'http://localhost',
259
+ },
260
+ });
261
+ });
262
+
263
+ expectSendMessage(
264
+ {
265
+ source: 'eraIframeWidget',
266
+ type: 'histories',
267
+ data: [{ id: 1, data: [{ x: 1000, y: 100 }] }],
268
+ eraWidgetId: 1,
269
+ },
270
+ 'http://localhost:3000'
271
+ );
272
+ });
273
+
274
+ const expectSendMessage = (message) => {
275
+ expect(refFunctions.injectJavaScript).toHaveBeenCalledWith(
276
+ 'window.postMessage(' + JSON.stringify(message) + ', "*")'
277
+ );
278
+ };
279
+ const unexpectSendMessage = (message) => {
280
+ expect(refFunctions.injectJavaScript).not.toHaveBeenCalledWith(
281
+ 'window.postMessage(' + JSON.stringify(message) + ', "*")'
282
+ );
283
+ };
284
+ });
File without changes
File without changes
File without changes
@@ -285,3 +285,8 @@ export const CHART_TIME = {
285
285
  month: 672,
286
286
  year: 12 * 672,
287
287
  };
288
+
289
+ export const WIDGET_TYPE = {
290
+ iframe: 'IFrame',
291
+ iframeWithConfig: 'IFrameWithConfig',
292
+ };
@@ -4,6 +4,7 @@ import { renderHook } from '@testing-library/react-hooks';
4
4
  import { useAndroidTranslucentStatusBar } from '../index';
5
5
  import { SCProvider } from '../../../context';
6
6
  import { mockSCStore } from '../../../context/mockStore';
7
+ import { useNavigation } from '@react-navigation/native';
7
8
 
8
9
  const mockedSetAction = jest.fn();
9
10
 
@@ -16,20 +17,8 @@ const mockUseContext = jest.fn().mockImplementation(() => ({
16
17
 
17
18
  React.useContext = mockUseContext;
18
19
 
19
- const mockAddListener = jest.fn();
20
- jest.mock('@react-navigation/native', () => {
21
- return {
22
- ...jest.requireActual('@react-navigation/native'),
23
- useNavigation: () => ({
24
- addListener: mockAddListener,
25
- }),
26
- };
27
- });
28
-
29
20
  describe('test useAndroidTranslucentStatusBar', () => {
30
- beforeEach(() => {
31
- mockAddListener.mockClear();
32
- });
21
+ const { addListener } = useNavigation();
33
22
 
34
23
  it('test useAndroidTranslucentStatusBar android', async () => {
35
24
  Platform.OS = 'android';
@@ -39,7 +28,7 @@ describe('test useAndroidTranslucentStatusBar', () => {
39
28
  wrapper,
40
29
  }
41
30
  );
42
- expect(mockAddListener).not.toBeCalled();
31
+ expect(addListener).not.toBeCalled();
43
32
  });
44
33
 
45
34
  it('test useAndroidTranslucentStatusBar ios', async () => {
@@ -50,6 +39,6 @@ describe('test useAndroidTranslucentStatusBar', () => {
50
39
  wrapper,
51
40
  }
52
41
  );
53
- expect(mockAddListener).not.toBeCalled();
42
+ expect(addListener).not.toBeCalled();
54
43
  });
55
44
  });
@@ -5,20 +5,21 @@ import { axiosGet } from '../../utils/Apis/axios';
5
5
  import { API } from '../../configs';
6
6
  import { Action } from '../../context/actionType';
7
7
 
8
+ let timeoutId = null;
9
+
8
10
  const useDevicesStatus = (unit, devices) => {
9
11
  const { setAction } = useContext(SCContext);
10
12
  const isNetworkConnected = useSCContextSelector(
11
13
  (state) => state.app.isNetworkConnected
12
14
  );
13
15
  const isFocused = useIsFocused();
14
- const timeoutIdRef = useRef(null);
15
- const hasFetchedRef = useRef(false);
16
+ const hasFetched = useRef(false); // Track if data has been fetched
16
17
 
17
18
  const getDevicesStatus = useCallback(
18
19
  async (_unit, _devices) => {
19
- if (timeoutIdRef.current) {
20
- clearTimeout(timeoutIdRef.current);
21
- timeoutIdRef.current = null;
20
+ if (timeoutId) {
21
+ clearTimeout(timeoutId);
22
+ timeoutId = null;
22
23
  }
23
24
  const params = new URLSearchParams();
24
25
  _devices.forEach((device) => {
@@ -30,24 +31,17 @@ const useDevicesStatus = (unit, devices) => {
30
31
  params: params,
31
32
  }
32
33
  );
33
- if (success) {
34
- setAction(Action.SET_DEVICES_STATUS, data);
35
- }
36
- timeoutIdRef.current = setTimeout(
37
- () => getDevicesStatus(_unit, _devices),
38
- 10000
39
- );
34
+ success && setAction(Action.SET_DEVICES_STATUS, data);
35
+ timeoutId = setTimeout(() => getDevicesStatus(_unit, _devices), 10000);
40
36
  },
41
37
  [setAction]
42
38
  );
43
39
 
44
40
  useEffect(() => {
45
- if (
46
- !isFocused ||
47
- !devices?.length ||
48
- !isNetworkConnected ||
49
- hasFetchedRef.current
50
- ) {
41
+ if (!isFocused || !isNetworkConnected || hasFetched.current) {
42
+ return;
43
+ }
44
+ if (!devices?.length) {
51
45
  return;
52
46
  }
53
47
 
@@ -57,19 +51,25 @@ const useDevicesStatus = (unit, devices) => {
57
51
  if (!managedDevices.length) {
58
52
  return;
59
53
  }
54
+
60
55
  getDevicesStatus(unit, devices);
61
- hasFetchedRef.current = true;
56
+ hasFetched.current = true; // Mark as fetched
62
57
  return () => {
63
- if (timeoutIdRef.current) {
64
- clearTimeout(timeoutIdRef.current);
65
- timeoutIdRef.current = null;
58
+ if (timeoutId) {
59
+ clearTimeout(timeoutId);
60
+ timeoutId = null;
66
61
  }
67
62
  };
68
63
  }, [getDevicesStatus, unit, devices, isNetworkConnected, isFocused]);
69
64
 
70
65
  useEffect(() => {
66
+ // Reset the hasFetched flag when the component is no longer focused
71
67
  if (!isFocused) {
72
- hasFetchedRef.current = false;
68
+ hasFetched.current = false;
69
+ if (timeoutId) {
70
+ clearTimeout(timeoutId); // Clear timeout when losing focus
71
+ timeoutId = null;
72
+ }
73
73
  }
74
74
  }, [isFocused]);
75
75
  };
@@ -45,7 +45,7 @@ describe('Test useRemoteControl', () => {
45
45
  command_prefer_over_googlehome: false,
46
46
  command_prefer_over_internet: false,
47
47
  googlehome_actions: [],
48
- icon: 'caret-up',
48
+ icon: 'caretup',
49
49
  id: 1,
50
50
  key: '2b949045-8e03-4c07-a855-7794ade2e69c',
51
51
  };
@@ -20,13 +20,6 @@ jest.mock('react', () => {
20
20
  };
21
21
  });
22
22
 
23
- jest.mock('@react-navigation/native', () => {
24
- return {
25
- ...jest.requireActual('@react-navigation/native'),
26
- useFocusEffect: (func) => func(),
27
- };
28
- });
29
-
30
23
  jest.mock('../../../iot/Monitor');
31
24
 
32
25
  describe('Test useWatchConfigs', () => {
@@ -127,7 +127,7 @@ export const homeAssistantConnect = async (
127
127
  for (let i = 0; i < options.length; i++) {
128
128
  const option = options[i];
129
129
 
130
- option.config_maps.forEach((configMap) => {
130
+ option.config_maps?.forEach((configMap) => {
131
131
  if (option.text_maps) {
132
132
  textMaps[configMap.entity_id] = option.text_maps;
133
133
  }