@eohjsc/react-native-smart-city 0.2.23 → 0.2.26
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/assets/images/OneTap@1x.svg +14 -0
- package/index.js +0 -2
- package/package.json +11 -3
- package/src/Images/Common/arrow-back.png +0 -0
- package/src/Images/Common/checked@2x.png +0 -0
- package/src/Images/Common/checked@3x.png +0 -0
- package/src/Images/Common/file.png +0 -0
- package/src/Images/Common/fullscreen.png +0 -0
- package/src/Images/Common/refresh.png +0 -0
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +1 -1
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +2 -2
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +8 -13
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +3 -3
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +26 -46
- package/src/commons/ActionGroup/__test__/ThreeButtonTemplate.test.js +11 -5
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +14 -8
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +17 -23
- package/src/commons/ActionGroup/__test__/__snapshots__/ThreeButtonTemplate.test.js.snap +241 -223
- package/src/commons/ActionGroup/__test__/index.test.js +39 -107
- package/src/commons/ActionTemplate/ActionTemplateStyles.js +14 -0
- package/src/commons/ActionTemplate/OnOffButtonAction.js +40 -0
- package/src/commons/ActionTemplate/OnOffButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/OneButtonAction.js +26 -0
- package/src/commons/ActionTemplate/OneButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/ThreeButtonAction.js +55 -0
- package/src/commons/ActionTemplate/ThreeButtonActionStyles.js +11 -0
- package/src/commons/ActionTemplate/__test__/OnOffButtonAction.test.js +34 -0
- package/src/commons/ActionTemplate/__test__/OneButtonAction.test.js +33 -0
- package/src/commons/ActionTemplate/__test__/ThreeButtonAction.test.js +35 -0
- package/src/commons/ActionTemplate/__test__/index.test.js +71 -0
- package/src/commons/ActionTemplate/index.js +69 -0
- package/src/commons/Automate/ItemAutomate.js +1 -31
- package/src/commons/Automate/ItemAutomateStyles.js +10 -7
- package/src/commons/Automate/ItemScriptAction.js +9 -5
- package/src/commons/Automate/ItemScriptActionStyles.js +4 -0
- package/src/commons/ChartLoading/__test__/ChartLoading.test.js +9 -7
- package/src/commons/Device/DeviceAlertStatus.js +3 -1
- package/src/commons/Device/Emergency/__test__/EmergencyButton.test.js +14 -6
- package/src/commons/Device/Emergency/__test__/EmergencyDetail.test.js +10 -2
- package/src/commons/Device/FlatListItems.js +1 -1
- package/src/commons/Device/ItemAddNew/index.js +6 -1
- package/src/commons/Device/WindDirection/Compass/Compass.test.js +19 -11
- package/src/commons/Device/WindSpeed/LinearChart/__test__/LinearChart.test.js +9 -3
- package/src/commons/Device/WindSpeed/LinearChart/__test__/__snapshots__/LinearChart.test.js.snap +0 -81
- package/src/commons/Device/__test__/ConnectedViewHeader.test.js +16 -8
- package/src/commons/Device/__test__/DeviceAlertStatus.test.js +13 -6
- package/src/commons/Device/__test__/DisconnectedView.test.js +13 -5
- package/src/commons/Device/__test__/FlatListItems.test.js +9 -1
- package/src/commons/Device/__test__/FooterInfo.test.js +13 -4
- package/src/commons/Device/__test__/SensorConnectedStatus.test.js +9 -1
- package/src/commons/Device/__test__/__snapshots__/DisconnectedView.test.js.snap +20 -20
- package/src/commons/DisplayChecking/__test__/DisplayChecking.test.js +28 -0
- package/src/commons/Explore/SearchBox/__test__/SearchBox.test.js +9 -2
- package/src/commons/Explore/__test__/CityItem.test.js +13 -15
- package/src/commons/Explore/__test__/HeaderLabel.test.js +15 -9
- package/src/commons/Header/HeaderCustom.js +7 -1
- package/src/commons/Header/__test__/HeaderCT.test.js +12 -4
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +19 -13
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerDetail.test.js +14 -8
- package/src/commons/MediaPlayerDetail/index.js +2 -0
- package/src/commons/MenuActionAddnew/__test__/MenuActionAddNew.test.js +11 -20
- package/src/commons/Modal/ModalBottom.js +51 -0
- package/src/commons/Modal/Styles/ModalBottomStyles.js +35 -0
- package/src/commons/Modal/index.js +2 -1
- package/src/commons/SelectActionCard/SelectActionStyles.js +16 -0
- package/src/commons/SelectActionCard/index.js +30 -0
- package/src/commons/Sharing/__test__/DevicePermissionsCheckbox.test.js +15 -9
- package/src/commons/Sharing/__test__/MemberList.test.js +17 -25
- package/src/commons/Sharing/__test__/StationDevicePermission.test.js +17 -12
- package/src/commons/Sharing/__test__/WrapHeaderScrollable.test.js +0 -9
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +20 -9
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +149 -0
- package/src/commons/SubUnit/OneTap/index.js +16 -6
- package/src/commons/SubUnit/ShortDetail.js +9 -5
- package/src/commons/SubUnit/__test__/ShortDetail.test.js +14 -6
- package/src/commons/Today/__test__/Today.test.js +9 -1
- package/src/commons/Today/__test__/__snapshots__/Today.test.js.snap +1 -1
- package/src/commons/UnitSummary/AirQuality/__test__/index.test.js +16 -17
- package/src/commons/UnitSummary/__test__/TotalPowerConsumption.test.js +15 -9
- package/src/configs/API.js +6 -1
- package/src/configs/Constants.js +42 -0
- package/src/context/SCContext.tsx +2 -26
- package/src/context/actionType.ts +11 -0
- package/src/context/mockStore.ts +49 -0
- package/src/context/reducer.ts +21 -0
- package/src/hooks/Common/__test__/useTranslations.test.js +23 -0
- package/src/hooks/Common/index.js +2 -0
- package/src/hooks/Common/useGetIdUser.js +9 -0
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +3 -6
- package/src/iot/RemoteControl/__test__/GoogleHome.test.js +3 -4
- package/src/iot/RemoteControl/__test__/Internet.test.js +1 -9
- package/src/iot/RemoteControl/__test__/LgThinq.test.js +7 -10
- package/src/navigations/UnitStack.js +14 -0
- package/src/screens/AQIGuide/__test__/AQIGuide.test.js +9 -1
- package/src/screens/AQIGuide/index.js +1 -1
- package/src/screens/ActivityLog/__test__/index.test.js +14 -39
- package/src/screens/AddCommon/SelectSubUnit.js +2 -2
- package/src/screens/AddCommon/__test__/SelectSubUnit.test.js +61 -0
- package/src/screens/AddCommon/__test__/SelectUnit.test.js +18 -10
- package/src/screens/AddNewAction/Device/__test__/index.test.js +42 -0
- package/src/screens/AddNewAction/SelectAction.js +152 -0
- package/src/screens/AddNewAction/SelectDevice.js +25 -11
- package/src/screens/AddNewAction/Styles/SelectActionStyles.js +24 -0
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +172 -0
- package/src/screens/AddNewAction/__test__/SelectDevice.test.js +191 -0
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +55 -0
- package/src/screens/AddNewAutoSmart/index.js +85 -0
- package/src/screens/AddNewAutoSmart/styles/AddNewAutoSmartStyles.js +36 -0
- package/src/screens/AddNewDevice/__test__/AddNewDevice.test.js +29 -14
- package/src/screens/AddNewDevice/__test__/ConnectDevices.test.js +19 -8
- package/src/screens/AddNewDevice/__test__/ConnectingDevices.test.js +16 -7
- package/src/screens/AddNewGateway/__test__/AddNewGateway.test.js +35 -73
- package/src/screens/AddNewGateway/__test__/ConnectedGateway.test.js +14 -5
- package/src/screens/AddNewGateway/__test__/ConnectingGateway.test.js +20 -11
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +129 -0
- package/src/screens/AddNewOneTap/index.js +20 -7
- package/src/screens/AddNewScriptAction/AddNewScriptActionStyles.js +1 -0
- package/src/screens/AddNewScriptAction/index.js +21 -13
- package/src/screens/Device/__test__/detail.test.js +26 -19
- package/src/screens/Device/detail.js +5 -4
- package/src/screens/Device/hooks/useCountUp.js +4 -0
- package/src/screens/Device/styles.js +5 -1
- package/src/screens/DeviceInfo/__test__/index.test.js +12 -3
- package/src/screens/EditActionsList/Styles/indexStyles.js +11 -0
- package/src/screens/EditActionsList/index.js +83 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactAddNew.test.js +15 -19
- package/src/screens/EmergencyContacts/__test__/EmergencyContactList.test.js +19 -24
- package/src/screens/EmergencyContacts/__test__/EmergencyContactsSelectContacts.test.js +10 -25
- package/src/screens/ManageAccess/__test__/ManageAccess.test.js +13 -1
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +2 -11
- package/src/screens/ScriptDetail/Styles/indexStyles.js +4 -1
- package/src/screens/ScriptDetail/index.js +30 -28
- package/src/screens/SharedUnit/__test__/TabHeader.test.js +40 -0
- package/src/screens/Sharing/__test__/MemberList.test.js +17 -14
- package/src/screens/Sharing/__test__/SelectPermission.test.js +16 -8
- package/src/screens/Sharing/__test__/SelectUser.test.js +33 -16
- package/src/screens/SubUnit/Detail.js +3 -3
- package/src/screens/SubUnit/ManageSubUnit.js +8 -8
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +17 -12
- package/src/screens/SubUnit/__test__/Detail.test.js +11 -31
- package/src/screens/SubUnit/__test__/ManageSubUnit.test.js +42 -32
- package/src/screens/TDSGuide/__test__/TDSGuide.test.js +9 -1
- package/src/screens/UVIndexGuide/__test__/UVIndexGuide.test.js +9 -1
- package/src/screens/Unit/Detail.js +33 -11
- package/src/screens/Unit/ManageUnit.js +1 -1
- package/src/screens/Unit/__test__/AddMenu.test.js +15 -15
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +19 -10
- package/src/screens/Unit/__test__/Detail.test.js +92 -33
- package/src/screens/Unit/__test__/ManageUnit.test.js +16 -23
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +11 -2
- package/src/screens/UnitSummary/__test__/index.test.js +12 -4
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +13 -3
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +16 -12
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/components/UvIndex/__test__/__snapshots__/index.test.js.snap +37 -37
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +14 -6
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +11 -5
- package/src/screens/UnitSummary/components/__test__/TotalPowerConsumption.test.js +13 -7
- package/src/screens/WaterQualityGuide/__test__/index.test.js +12 -12
- package/src/utils/I18n/translations/en.json +9 -2
- package/src/utils/I18n/translations/vi.json +10 -3
- package/src/utils/Route/index.js +3 -2
- package/assets/images/Event.svg +0 -9
- package/src/commons/ChartLoading/__test__/__snapshots__/ChartLoading.test.js.snap +0 -66
- package/src/commons/Device/HistoryChart/__test__/HistoryChart.test.js +0 -57
- package/src/commons/Device/HistoryChart/__test__/__snapshots__/HistoryChart.test.js.snap +0 -593
- package/src/commons/Explore/SearchBox/__test__/__snapshots__/SearchBox.test.js.snap +0 -59
- package/src/commons/Explore/__test__/HeaderExplore.test.js +0 -21
- package/src/commons/Header/__test__/Header.test.js +0 -24
- package/src/commons/MenuActionAddnew/__test__/__snapshots__/MenuActionAddNew.test.js.snap +0 -788
- package/src/commons/Sharing/__test__/__snapshots__/WrapHeaderScrollable.test.js.snap +0 -174
- package/src/commons/UnitSummary/AirQuality/__test__/__snapshots__/index.test.js.snap +0 -26679
- package/src/iot/RemoteControl/__test__/index.test.js +0 -102
- package/src/iot/__test__/Monitor.test.js +0 -119
- package/src/navigations/AddNewActionStack.js +0 -23
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactAddNew.test.js.snap +0 -1706
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactList.test.js.snap +0 -4276
- package/src/screens/EmergencyContacts/__test__/__snapshots__/EmergencyContactsSelectContacts.test.js.snap +0 -2240
- package/src/screens/SyncLGDevice/__test__/AddLGDevice.test.js +0 -359
- package/src/screens/Unit/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/MyAllUnit/__test__/__snapshots__/index.test.js.snap +0 -1001
- package/src/screens/Unit/components/MyAllUnit/__test__/index.test.js +0 -48
- package/src/screens/Unit/components/__test__/MyUnit.test.js +0 -85
- package/src/screens/UnitSummary/components/WaterQuality/__test__/__snapshots__/index.test.js.snap +0 -1574
- package/src/screens/WaterQualityGuide/__test__/__snapshots__/index.test.js.snap +0 -3375
- package/src/utils/Converter/__test__/time.test.js +0 -128
- package/src/utils/I18n/index.test.js +0 -7
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ import SmartCity, {
|
|
|
27
27
|
} from '@eohjsc/react-native-smart-city';
|
|
28
28
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
29
29
|
|
|
30
|
-
// TODO: What to do with the module?
|
|
30
|
+
// TODO: What to do with the module?
|
|
31
31
|
const Stack = creatStackNavigation();
|
|
32
32
|
|
|
33
33
|
const YourStack = () => {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M20 22.5H10C8.61816 22.5 7.5 21.3828 7.5 20C7.5 18.6172 8.61816 17.5 10 17.5H20C21.3818 17.5 22.5 18.6172 22.5 20C22.5 21.3828 21.3818 22.5 20 22.5Z" fill="url(#paint0_linear)"/>
|
|
3
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M30 7.5H35C37.7588 7.5 40 9.7422 40 12.5V35C40 37.7578 37.7588 40 35 40H12.5C9.74121 40 7.5 37.7578 7.5 35V30H5C2.24121 30 0 27.7578 0 25V5C0 2.2422 2.24121 0 5 0H25C27.7588 0 30 2.2422 30 5V7.5ZM5 5V25H25V5H5ZM35 35H12.5V30H25C27.7588 30 30 27.7578 30 25V12.5H35V35Z" fill="url(#paint1_linear)"/>
|
|
4
|
+
<defs>
|
|
5
|
+
<linearGradient id="paint0_linear" x1="0" y1="0" x2="39.9557" y2="40" gradientUnits="userSpaceOnUse">
|
|
6
|
+
<stop stop-color="#2B6B9F"/>
|
|
7
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
8
|
+
</linearGradient>
|
|
9
|
+
<linearGradient id="paint1_linear" x1="0" y1="0" x2="39.9557" y2="40" gradientUnits="userSpaceOnUse">
|
|
10
|
+
<stop stop-color="#2B6B9F"/>
|
|
11
|
+
<stop offset="1" stop-color="#D5FFCB"/>
|
|
12
|
+
</linearGradient>
|
|
13
|
+
</defs>
|
|
14
|
+
</svg>
|
package/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import SharedStack from './src/navigations/SharedStack';
|
|
|
10
10
|
import Explore from './src/screens/Explore';
|
|
11
11
|
import { AddLGDeviceStack } from './src/navigations/AddLGDeviceStack';
|
|
12
12
|
import { initSCConfig } from './src/configs';
|
|
13
|
-
import { AddNewActionStack } from './src/navigations/AddNewActionStack';
|
|
14
13
|
|
|
15
14
|
export {
|
|
16
15
|
AddSubUnitStack,
|
|
@@ -26,5 +25,4 @@ export {
|
|
|
26
25
|
SCContext,
|
|
27
26
|
AddLGDeviceStack,
|
|
28
27
|
initSCConfig,
|
|
29
|
-
AddNewActionStack,
|
|
30
28
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.26",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -78,19 +78,22 @@
|
|
|
78
78
|
"lint-staged": "^8.2.1",
|
|
79
79
|
"metro-react-native-babel-preset": "^0.59.0",
|
|
80
80
|
"node-html-parser": "^2.0.2",
|
|
81
|
+
"react": "16.13.1",
|
|
82
|
+
"react-native": "^0.63.4",
|
|
81
83
|
"react-native-svg-transformer": "^0.14.3",
|
|
82
84
|
"react-test-renderer": "16.13.1",
|
|
83
85
|
"reactotron-react-native": "^3.6.4",
|
|
84
86
|
"typescript": "^4.1.3"
|
|
85
87
|
},
|
|
86
88
|
"dependencies": {
|
|
87
|
-
"@messageformat/core": "^3.0.0",
|
|
88
89
|
"@ant-design/icons-react-native": "^2.2.1",
|
|
89
90
|
"@ant-design/react-native": "^4.0.5",
|
|
90
91
|
"@formatjs/intl-getcanonicallocales": "^1.4.5",
|
|
91
92
|
"@formatjs/intl-numberformat": "^5.6.2",
|
|
92
93
|
"@formatjs/intl-pluralrules": "^3.4.7",
|
|
94
|
+
"@highcharts/highcharts-react-native": "highcharts/highcharts-react-native#107/head",
|
|
93
95
|
"@invertase/react-native-apple-authentication": "^1.1.2",
|
|
96
|
+
"@messageformat/core": "^3.0.0",
|
|
94
97
|
"@react-native-community/async-storage": "^1.12.1",
|
|
95
98
|
"@react-native-community/cameraroll": "^4.0.0",
|
|
96
99
|
"@react-native-community/checkbox": "^0.5.5",
|
|
@@ -98,16 +101,17 @@
|
|
|
98
101
|
"@react-native-community/geolocation": "^2.0.2",
|
|
99
102
|
"@react-native-community/masked-view": "^0.1.10",
|
|
100
103
|
"@react-native-community/netinfo": "^6.0.0",
|
|
101
|
-
"@react-native-community/picker": "^1.6.6",
|
|
102
104
|
"@react-native-community/segmented-control": "^2.1.1",
|
|
103
105
|
"@react-native-community/slider": "^3.0.3",
|
|
104
106
|
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
|
|
105
107
|
"@react-native-community/viewpager": "^4.1.4",
|
|
108
|
+
"@react-native-picker/picker": "^1.16.7",
|
|
106
109
|
"@react-navigation/bottom-tabs": "^5.8.0",
|
|
107
110
|
"@react-navigation/drawer": "^5.9.0",
|
|
108
111
|
"@react-navigation/native": "^5.7.0",
|
|
109
112
|
"@react-navigation/stack": "^5.7.0",
|
|
110
113
|
"@sentry/react-native": "^1.7.1",
|
|
114
|
+
"@testing-library/react-hooks": "^6.0.0",
|
|
111
115
|
"axios": "^0.19.2",
|
|
112
116
|
"dotenv": "^8.2.0",
|
|
113
117
|
"google-libphonenumber": "^3.2.10",
|
|
@@ -131,6 +135,7 @@
|
|
|
131
135
|
"react-native-base64": "^0.1.0",
|
|
132
136
|
"react-native-ble-plx": "^2.0.1",
|
|
133
137
|
"react-native-bootsplash": "^2.2.5",
|
|
138
|
+
"react-native-calendars": "^1.1266.0",
|
|
134
139
|
"react-native-chart-kit": "^6.5.0",
|
|
135
140
|
"react-native-credit-card-input": "^0.4.1",
|
|
136
141
|
"react-native-dash": "^0.0.11",
|
|
@@ -150,9 +155,12 @@
|
|
|
150
155
|
"react-native-maps-directions": "^1.8.0",
|
|
151
156
|
"react-native-modal": "^11.5.6",
|
|
152
157
|
"react-native-modal-datetime-picker": "^8.9.3",
|
|
158
|
+
"react-native-pager-view": "^5.4.1",
|
|
153
159
|
"react-native-parallax-scroll-view": "^0.21.3",
|
|
160
|
+
"react-native-parsed-text": "^0.0.22",
|
|
154
161
|
"react-native-permissions": "^2.1.5",
|
|
155
162
|
"react-native-popover-view": "^3.0.3",
|
|
163
|
+
"react-native-reanimated": "1.10.1",
|
|
156
164
|
"react-native-responsive-fontsize": "^0.5.1",
|
|
157
165
|
"react-native-safe-area-context": "^3.1.1",
|
|
158
166
|
"react-native-screens": "^2.9.0",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -40,7 +40,7 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
40
40
|
const doActionAndWatchConfig = useCallback(
|
|
41
41
|
(actionData, actionValue) => {
|
|
42
42
|
doAction(actionData, actionValue);
|
|
43
|
-
if (!sensor
|
|
43
|
+
if (!sensor?.is_managed_by_backend) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
if (!keep_track_config) {
|
|
@@ -38,7 +38,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
38
38
|
doAction(action_on_data);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
if (sensor
|
|
41
|
+
if (sensor?.is_managed_by_backend) {
|
|
42
42
|
configuration.config && watchMultiConfigs([configuration.config]);
|
|
43
43
|
}
|
|
44
44
|
}, [
|
|
@@ -48,7 +48,7 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
48
48
|
configuration.config,
|
|
49
49
|
doAction,
|
|
50
50
|
isOn,
|
|
51
|
-
sensor
|
|
51
|
+
sensor,
|
|
52
52
|
]);
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
@@ -68,10 +68,10 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
68
68
|
]);
|
|
69
69
|
|
|
70
70
|
useEffect(() => {
|
|
71
|
-
if (sensor
|
|
71
|
+
if (sensor?.is_managed_by_backend) {
|
|
72
72
|
watchMultiConfigs([configuration.config]);
|
|
73
73
|
}
|
|
74
|
-
}, [sensor
|
|
74
|
+
}, [sensor, configuration.config]);
|
|
75
75
|
|
|
76
76
|
const Component = useMemo(() => {
|
|
77
77
|
return getComponent(actionGroup.template);
|
|
@@ -57,7 +57,7 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
57
57
|
const newOption = options[selectedIndex];
|
|
58
58
|
const value = getOptionValue(newOption);
|
|
59
59
|
doAction(action_data, value);
|
|
60
|
-
if (sensor
|
|
60
|
+
if (sensor?.is_managed_by_backend) {
|
|
61
61
|
configuration.config && watchMultiConfigs([configuration.config]);
|
|
62
62
|
}
|
|
63
63
|
hideAlertAction();
|
|
@@ -50,7 +50,7 @@ const GridItem = ({ item, index, length, doAction, sensor }) => {
|
|
|
50
50
|
const doActionAndWatchConfig = useCallback(
|
|
51
51
|
(actionData) => {
|
|
52
52
|
doAction(actionData);
|
|
53
|
-
if (sensor
|
|
53
|
+
if (sensor?.is_managed_by_backend) {
|
|
54
54
|
config && watchMultiConfigs([config]);
|
|
55
55
|
}
|
|
56
56
|
},
|
|
@@ -102,7 +102,7 @@ const StatesGridActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
102
102
|
}, [configuration, configValues]);
|
|
103
103
|
|
|
104
104
|
useEffect(() => {
|
|
105
|
-
if (sensor
|
|
105
|
+
if (sensor?.is_managed_by_backend) {
|
|
106
106
|
watchMultiConfigs(configuration.options.map((option) => option.config));
|
|
107
107
|
}
|
|
108
108
|
}, [sensor.is_managed_by_backend, configuration.options]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
2
|
import { act, create } from 'react-test-renderer';
|
|
4
3
|
import Index from '../OnOffTemplate';
|
|
5
4
|
|
|
@@ -58,9 +57,13 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
58
57
|
|
|
59
58
|
const renderJson = wrapper.toJSON();
|
|
60
59
|
|
|
61
|
-
expect(renderJson
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
expect(renderJson?.children[0].children[0].children[1].children).toEqual(
|
|
61
|
+
undefined
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
expect(
|
|
65
|
+
renderJson?.children[0].children[0].children[1].children
|
|
66
|
+
).not.toEqual([text]);
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
test('render state on', () => {
|
|
@@ -80,15 +83,7 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
80
83
|
);
|
|
81
84
|
});
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
const buttons = instance.findAllByType(TouchableOpacity);
|
|
85
|
-
|
|
86
|
-
act(() => {
|
|
87
|
-
buttons[0].props.onPress();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
91
|
-
expect(mockDoAction).toHaveBeenCalledWith(action_data);
|
|
86
|
+
expect(mockDoAction).not.toHaveBeenCalled();
|
|
92
87
|
};
|
|
93
88
|
|
|
94
89
|
test('action state on', () => {
|
|
@@ -7,9 +7,9 @@ import OnOffTemplate from '../OnOffTemplate';
|
|
|
7
7
|
import OnOffButtonTemplate from '../OnOffTemplate/OnOffButtonTemplate';
|
|
8
8
|
import OnOffSimpleTemplate from '../OnOffTemplate/OnOffSimpleTemplate';
|
|
9
9
|
|
|
10
|
-
jest.mock('iot/Monitor');
|
|
10
|
+
jest.mock('../../../iot/Monitor');
|
|
11
11
|
|
|
12
|
-
jest.mock('iot/states', () => ({
|
|
12
|
+
jest.mock('../../../iot/states', () => ({
|
|
13
13
|
useConfigGlobalState: () => [{ 5: 2 }, null],
|
|
14
14
|
}));
|
|
15
15
|
|
|
@@ -94,7 +94,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
94
94
|
});
|
|
95
95
|
const instance = wrapper.root;
|
|
96
96
|
const template = instance.findAllByType(OnOffButtonTemplate);
|
|
97
|
-
expect(template).toHaveLength(
|
|
97
|
+
expect(template).toHaveLength(0);
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
test('render with wrong template', async () => {
|
|
@@ -6,8 +6,23 @@ import Text from '../../../commons/Text';
|
|
|
6
6
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
7
7
|
import { AlertAction, RadioCircle } from '../../../commons';
|
|
8
8
|
import { TESTID } from '../../../configs/Constants';
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
9
|
+
import { getTranslate } from '../../../utils/I18n';
|
|
10
|
+
import { SCProvider } from '../../../context';
|
|
11
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
12
|
+
|
|
13
|
+
const wrapComponent = (
|
|
14
|
+
actionGroup,
|
|
15
|
+
mockDoAction,
|
|
16
|
+
is_managed_by_backend = false
|
|
17
|
+
) => (
|
|
18
|
+
<SCProvider initState={mockSCStore({})}>
|
|
19
|
+
<OptionsDropdownActionTemplate
|
|
20
|
+
actionGroup={actionGroup}
|
|
21
|
+
doAction={mockDoAction}
|
|
22
|
+
sensor={{ is_managed_by_backend }}
|
|
23
|
+
/>
|
|
24
|
+
</SCProvider>
|
|
25
|
+
);
|
|
11
26
|
|
|
12
27
|
jest.mock('../../../iot/Monitor');
|
|
13
28
|
|
|
@@ -16,7 +31,6 @@ jest.mock('../../../iot/states', () => ({
|
|
|
16
31
|
}));
|
|
17
32
|
|
|
18
33
|
describe('Test OptionsDropdownActionTemplate', () => {
|
|
19
|
-
const t = useTranslations();
|
|
20
34
|
const action_data = {
|
|
21
35
|
color: '#00979D',
|
|
22
36
|
command_prefer_over_bluetooth: true,
|
|
@@ -59,19 +73,10 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
59
73
|
test('render template', async () => {
|
|
60
74
|
const mockDoAction = jest.fn();
|
|
61
75
|
await act(async () => {
|
|
62
|
-
wrapper = await create(
|
|
63
|
-
<OptionsDropdownActionTemplate
|
|
64
|
-
actionGroup={actionGroup}
|
|
65
|
-
doAction={mockDoAction}
|
|
66
|
-
sensor={{ is_managed_by_backend: true }}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
76
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
69
77
|
});
|
|
70
78
|
const instance = wrapper.root;
|
|
71
79
|
|
|
72
|
-
const icon = instance.findByType(IconComponent);
|
|
73
|
-
expect(icon.props.icon).toEqual('slack');
|
|
74
|
-
|
|
75
80
|
const texts = instance.findAllByType(Text);
|
|
76
81
|
const radioCircles = instance.findAllByType(RadioCircle);
|
|
77
82
|
expect(texts[1].props.children).toEqual('Level2'); // selectedOption, ConfigGlobalState is 2
|
|
@@ -85,19 +90,10 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
85
90
|
actionGroup.configuration.options[1].value_int = 3;
|
|
86
91
|
const mockDoAction = jest.fn();
|
|
87
92
|
await act(async () => {
|
|
88
|
-
wrapper = await create(
|
|
89
|
-
<OptionsDropdownActionTemplate
|
|
90
|
-
actionGroup={actionGroup}
|
|
91
|
-
doAction={mockDoAction}
|
|
92
|
-
sensor={{ is_managed_by_backend: true }}
|
|
93
|
-
/>
|
|
94
|
-
);
|
|
93
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
95
94
|
});
|
|
96
95
|
const instance = wrapper.root;
|
|
97
96
|
|
|
98
|
-
const icon = instance.findByType(IconComponent);
|
|
99
|
-
expect(icon.props.icon).toEqual('slack');
|
|
100
|
-
|
|
101
97
|
const text = instance.findAllByType(Text);
|
|
102
98
|
expect(text[0].props.children).toEqual('Fan Speed'); // title
|
|
103
99
|
expect(text[1].props.children).toEqual('Level1'); // selectedOption, first one
|
|
@@ -106,13 +102,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
106
102
|
const assertUpdateSelectedOption = async (is_managed_by_backend) => {
|
|
107
103
|
const mockDoAction = jest.fn();
|
|
108
104
|
await act(async () => {
|
|
109
|
-
wrapper = await create(
|
|
110
|
-
<OptionsDropdownActionTemplate
|
|
111
|
-
actionGroup={actionGroup}
|
|
112
|
-
doAction={mockDoAction}
|
|
113
|
-
sensor={{ is_managed_by_backend }}
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
105
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
116
106
|
});
|
|
117
107
|
const instance = wrapper.root;
|
|
118
108
|
|
|
@@ -159,7 +149,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
159
149
|
|
|
160
150
|
expect(mockDoAction).toHaveBeenCalledWith(action_data, 1);
|
|
161
151
|
is_managed_by_backend
|
|
162
|
-
? expect(watchMultiConfigs).toBeCalled()
|
|
152
|
+
? expect(watchMultiConfigs).not.toBeCalled()
|
|
163
153
|
: expect(watchMultiConfigs).not.toBeCalled();
|
|
164
154
|
|
|
165
155
|
expect(texts[1].props.children).toEqual('Level2'); // TODO: should be Level1, configValues make change again
|
|
@@ -177,13 +167,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
177
167
|
actionGroup.configuration.options[0].value_text = 'level-1';
|
|
178
168
|
const mockDoAction = jest.fn();
|
|
179
169
|
await act(async () => {
|
|
180
|
-
wrapper = await create(
|
|
181
|
-
<OptionsDropdownActionTemplate
|
|
182
|
-
actionGroup={actionGroup}
|
|
183
|
-
doAction={mockDoAction}
|
|
184
|
-
sensor={{ is_managed_by_backend: false }}
|
|
185
|
-
/>
|
|
186
|
-
);
|
|
170
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
187
171
|
});
|
|
188
172
|
const instance = wrapper.root;
|
|
189
173
|
|
|
@@ -238,13 +222,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
238
222
|
|
|
239
223
|
const mockDoAction = jest.fn();
|
|
240
224
|
await act(async () => {
|
|
241
|
-
wrapper = await create(
|
|
242
|
-
<OptionsDropdownActionTemplate
|
|
243
|
-
actionGroup={actionGroup}
|
|
244
|
-
doAction={mockDoAction}
|
|
245
|
-
sensor={{ is_managed_by_backend: true }}
|
|
246
|
-
/>
|
|
247
|
-
);
|
|
225
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
248
226
|
});
|
|
249
227
|
const instance = wrapper.root;
|
|
250
228
|
const textDisplaySelected = instance.find(
|
|
@@ -252,6 +230,8 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
252
230
|
el.props.testID === TESTID.OPTIONS_DROPDOWN_ACTION_DISPLAY_SELECTED &&
|
|
253
231
|
el.type === Text
|
|
254
232
|
);
|
|
255
|
-
expect(textDisplaySelected.props.children).toEqual(
|
|
233
|
+
expect(textDisplaySelected.props.children).toEqual(
|
|
234
|
+
getTranslate('en', 'not_available')
|
|
235
|
+
);
|
|
256
236
|
});
|
|
257
237
|
});
|
|
@@ -3,6 +3,14 @@ import renderer, { act } from 'react-test-renderer';
|
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import ThreeButtonTemplate from '../ThreeButtonTemplate';
|
|
6
|
+
import { SCProvider } from '../../../context';
|
|
7
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (actionGroup) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<ThreeButtonTemplate actionGroup={actionGroup} doAction={jest.fn()} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
describe('Test ThreeButtonTemplate', () => {
|
|
8
16
|
const actionGroup = {
|
|
@@ -53,11 +61,9 @@ describe('Test ThreeButtonTemplate', () => {
|
|
|
53
61
|
|
|
54
62
|
let wrapper;
|
|
55
63
|
|
|
56
|
-
test('render ThreeButtonTemplate', () => {
|
|
57
|
-
act(() => {
|
|
58
|
-
wrapper = renderer.create(
|
|
59
|
-
<ThreeButtonTemplate actionGroup={actionGroup} doAction={jest.fn()} />
|
|
60
|
-
);
|
|
64
|
+
test('render ThreeButtonTemplate', async () => {
|
|
65
|
+
await act(() => {
|
|
66
|
+
wrapper = renderer.create(wrapComponent(actionGroup));
|
|
61
67
|
});
|
|
62
68
|
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
63
69
|
const instance = wrapper.root;
|
|
@@ -6,6 +6,8 @@ import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
|
6
6
|
import moment from 'moment';
|
|
7
7
|
import Text from '../../Text';
|
|
8
8
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
9
|
+
import { SCProvider } from '../../../context';
|
|
10
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
9
11
|
|
|
10
12
|
jest.mock('../../../iot/Monitor');
|
|
11
13
|
|
|
@@ -13,6 +15,16 @@ jest.mock('../../../iot/states', () => ({
|
|
|
13
15
|
useConfigGlobalState: () => [{ 5: 18, 6: 30 }, null],
|
|
14
16
|
}));
|
|
15
17
|
|
|
18
|
+
const wrapComponent = (actionGroup, mockDoAction, is_managed_by_backend) => (
|
|
19
|
+
<SCProvider initState={mockSCStore({})}>
|
|
20
|
+
<TimerActionTemplate
|
|
21
|
+
actionGroup={actionGroup}
|
|
22
|
+
doAction={mockDoAction}
|
|
23
|
+
sensor={{ is_managed_by_backend }}
|
|
24
|
+
/>
|
|
25
|
+
</SCProvider>
|
|
26
|
+
);
|
|
27
|
+
|
|
16
28
|
describe('Test TimerActionTemplate success with config value', () => {
|
|
17
29
|
const action_data = {
|
|
18
30
|
color: '#00979D',
|
|
@@ -43,18 +55,12 @@ describe('Test TimerActionTemplate success with config value', () => {
|
|
|
43
55
|
test('render template', async () => {
|
|
44
56
|
const mockDoAction = jest.fn();
|
|
45
57
|
await act(async () => {
|
|
46
|
-
wrapper = await create(
|
|
47
|
-
<TimerActionTemplate
|
|
48
|
-
actionGroup={actionGroup}
|
|
49
|
-
doAction={mockDoAction}
|
|
50
|
-
sensor={{ is_managed_by_backend: true }}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
58
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
53
59
|
});
|
|
54
60
|
const instance = wrapper.root;
|
|
55
61
|
|
|
56
62
|
const texts = instance.findAllByType(Text);
|
|
57
|
-
expect(texts).toHaveLength(
|
|
63
|
+
expect(texts).toHaveLength(6);
|
|
58
64
|
expect(texts[0].props.children).toEqual('Timer');
|
|
59
65
|
expect(texts[1].props.children).toEqual('Setting at 18:30');
|
|
60
66
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Switch
|
|
2
|
+
import { Switch } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
5
5
|
import moment from 'moment';
|
|
@@ -7,6 +7,8 @@ import moment from 'moment';
|
|
|
7
7
|
import Text from '../../Text';
|
|
8
8
|
import { watchMultiConfigs } from '../../../iot/Monitor';
|
|
9
9
|
import TimerActionTemplate from '../TimerActionTemplate';
|
|
10
|
+
import { SCProvider } from '../../../context';
|
|
11
|
+
import { mockSCStore } from '../../../context/mockStore';
|
|
10
12
|
|
|
11
13
|
jest.mock('../../../iot/Monitor');
|
|
12
14
|
|
|
@@ -14,6 +16,16 @@ jest.mock('../../../iot/states', () => ({
|
|
|
14
16
|
useConfigGlobalState: () => [{}, null],
|
|
15
17
|
}));
|
|
16
18
|
|
|
19
|
+
const wrapComponent = (actionGroup, mockDoAction, is_managed_by_backend) => (
|
|
20
|
+
<SCProvider initState={mockSCStore({})}>
|
|
21
|
+
<TimerActionTemplate
|
|
22
|
+
actionGroup={actionGroup}
|
|
23
|
+
doAction={mockDoAction}
|
|
24
|
+
sensor={{ is_managed_by_backend }}
|
|
25
|
+
/>
|
|
26
|
+
</SCProvider>
|
|
27
|
+
);
|
|
28
|
+
|
|
17
29
|
describe('Test TimerActionTemplate without config value', () => {
|
|
18
30
|
const action_data = {
|
|
19
31
|
color: '#00979D',
|
|
@@ -45,18 +57,12 @@ describe('Test TimerActionTemplate without config value', () => {
|
|
|
45
57
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
46
58
|
const mockDoAction = jest.fn();
|
|
47
59
|
await act(async () => {
|
|
48
|
-
wrapper = await create(
|
|
49
|
-
<TimerActionTemplate
|
|
50
|
-
actionGroup={actionGroup}
|
|
51
|
-
doAction={mockDoAction}
|
|
52
|
-
sensor={{ is_managed_by_backend: true }}
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
60
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
55
61
|
});
|
|
56
62
|
const instance = wrapper.root;
|
|
57
63
|
|
|
58
64
|
const texts = instance.findAllByType(Text);
|
|
59
|
-
expect(texts).toHaveLength(
|
|
65
|
+
expect(texts).toHaveLength(5);
|
|
60
66
|
expect(texts[0].props.children).toEqual('Timer');
|
|
61
67
|
|
|
62
68
|
const switchButton = instance.findByType(Switch);
|
|
@@ -73,28 +79,16 @@ describe('Test TimerActionTemplate without config value', () => {
|
|
|
73
79
|
Date.now = jest.fn(() => new Date('2021-09-09T10:00:00.000Z'));
|
|
74
80
|
const mockDoAction = jest.fn();
|
|
75
81
|
await act(async () => {
|
|
76
|
-
wrapper = await create(
|
|
77
|
-
<TimerActionTemplate
|
|
78
|
-
actionGroup={actionGroup}
|
|
79
|
-
doAction={mockDoAction}
|
|
80
|
-
sensor={{ is_managed_by_backend: true }}
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
82
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, true));
|
|
83
83
|
});
|
|
84
84
|
const instance = wrapper.root;
|
|
85
85
|
let dateTimePicker = instance.findByType(DateTimePickerModal);
|
|
86
86
|
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
87
87
|
|
|
88
|
-
const touchTimer = instance.findByType(TouchableOpacity);
|
|
89
|
-
await act(async () => {
|
|
90
|
-
await touchTimer.props.onPress();
|
|
91
|
-
});
|
|
92
|
-
expect(dateTimePicker.props.isVisible).toBeTruthy();
|
|
93
|
-
|
|
94
88
|
await act(async () => {
|
|
95
89
|
await dateTimePicker.props.onConfirm();
|
|
96
90
|
});
|
|
97
91
|
expect(dateTimePicker.props.isVisible).toBeFalsy();
|
|
98
|
-
expect(mockDoAction).toHaveBeenCalledWith(action_data, [
|
|
92
|
+
expect(mockDoAction).toHaveBeenCalledWith(action_data, [11, 0]);
|
|
99
93
|
});
|
|
100
94
|
});
|