@eohjsc/react-native-smart-city 0.2.45 → 0.2.49
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 +9 -0
- package/index.js +6 -0
- package/package.json +23 -3
- package/src/Images/Common/logo.png +0 -0
- package/src/Images/Common/logo@2x.png +0 -0
- package/src/Images/Common/logo@3x.png +0 -0
- package/src/commons/ActionTemplate/index.js +40 -25
- package/src/commons/Automate/ItemAutomate.js +2 -2
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +82 -0
- package/src/commons/Dashboard/MyPinnedSharedUnit/styles.js +78 -0
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +60 -0
- package/src/commons/Dashboard/MyUnit/index.js +111 -0
- package/src/commons/Dashboard/MyUnit/styles.js +61 -0
- package/src/commons/Device/ConnectedViewHeader.js +4 -1
- package/src/commons/Form/TextInput.js +1 -1
- package/src/commons/MediaPlayer/index.js +6 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +3 -3
- package/src/{screens/Unit/components → commons}/SearchLocation/RowLocation.js +2 -2
- package/src/{screens/Unit/components → commons}/SearchLocation/RowLocationStyles.js +1 -1
- package/src/{screens/Unit/components → commons}/SearchLocation/SearchBarLocationStyles.js +1 -1
- package/src/{screens/Unit/components → commons}/SearchLocation/__test__/RowLocation.test.js +2 -2
- package/src/{screens/Unit/components → commons}/SearchLocation/index.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +3 -1
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +2 -0
- package/src/commons/SubUnit/ShortDetail.js +1 -1
- package/src/commons/Unit/SharedUnit.js +2 -2
- package/src/configs/API.js +11 -4
- package/src/configs/Constants.js +19 -6
- package/src/configs/Images.js +1 -0
- package/src/iot/RemoteControl/Bluetooth.js +10 -1
- package/src/iot/RemoteControl/Internet.js +0 -2
- package/src/navigations/AddDeviceStack.js +5 -0
- package/src/navigations/AddUnitStack.js +2 -0
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/ActivityLog/FilterPopup.js +24 -17
- package/src/screens/ActivityLog/ItemLog.js +26 -22
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +1 -0
- package/src/screens/ActivityLog/__test__/ItemLog.test.js +0 -20
- package/src/screens/ActivityLog/__test__/index.test.js +3 -0
- package/src/screens/ActivityLog/hooks/__test__/index.test.js +8 -0
- package/src/screens/ActivityLog/hooks/index.js +5 -9
- package/src/screens/ActivityLog/index.js +4 -4
- package/src/screens/ActivityLog/styles/filterPopupStyles.js +3 -0
- package/src/screens/AddCommon/SelectSubUnit.js +10 -1
- package/src/screens/AddCommon/SelectUnit.js +11 -0
- package/src/screens/AddLocationMaps/index.js +124 -74
- package/src/screens/AddLocationMaps/indexStyle.js +58 -0
- package/src/screens/AddNewAction/SelectAction.js +59 -4
- package/src/screens/AddNewAction/SelectSensorDevices.js +27 -5
- package/src/screens/AddNewAction/SetupSensor.js +1 -6
- package/src/screens/AddNewAction/__test__/SelectAction.test.js +6 -4
- package/src/screens/AddNewAutoSmart/__test__/AddNewAutoSmart.test.js +11 -1
- package/src/screens/AddNewAutoSmart/index.js +24 -13
- package/src/screens/AddNewDevice/ConnectingDevices.js +3 -0
- package/src/screens/AddNewGateway/ConnectingGatewayStyles.js +10 -1
- package/src/screens/AddNewOneTap/__test__/AddNewOneTap.test.js +9 -1
- package/src/screens/AddNewOneTap/index.js +11 -6
- package/src/screens/Automate/MultiUnits.js +14 -53
- package/src/screens/Automate/__test__/MultiUnits.test.js +5 -246
- package/src/screens/Automate/__test__/index.test.js +1 -0
- package/src/screens/Automate/index.js +1 -0
- package/src/screens/Device/__test__/detail.test.js +14 -0
- package/src/screens/Device/components/DetailHistoryChart.js +63 -0
- package/src/screens/Device/components/EmergencyCountdown.js +29 -0
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +57 -0
- package/src/screens/Device/components/SensorDisplayItem.js +127 -0
- package/src/screens/Device/detail.js +81 -294
- package/src/screens/Device/hooks/useDisconnectedDevice.js +63 -0
- package/src/screens/Device/styles.js +0 -10
- package/src/screens/GuestInfo/components/RecurringDetail.js +2 -2
- package/src/screens/Notification/components/NotificationItem.js +31 -14
- package/src/screens/Notification/styles/NotificationItemStyles.js +5 -0
- package/src/screens/ScanChipQR/__test__/ScanChipQR.test.js +12 -3
- package/src/screens/ScanChipQR/components/QRScan/__test__/QRScan.test.js +11 -2
- package/src/screens/ScanSensorQR/__test__/ScanSensorQR.test.js +12 -3
- package/src/screens/ScriptDetail/__test__/index.test.js +83 -3
- package/src/screens/ScriptDetail/hooks/index.js +4 -0
- package/src/screens/ScriptDetail/index.js +65 -4
- package/src/screens/SetSchedule/__test__/SelectWeekday.test.js +2 -2
- package/src/screens/SetSchedule/__test__/index.test.js +8 -0
- package/src/screens/SetSchedule/components/SelectWeekday.js +13 -7
- package/src/screens/SetSchedule/index.js +28 -6
- package/src/screens/Sharing/Components/__test__/TitleCheckBox.test.js +38 -0
- package/src/screens/SubUnit/AddSubUnit.js +113 -29
- package/src/screens/SubUnit/AddSubUnitStyles.js +10 -0
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +1 -0
- package/src/screens/TDSGuide/index.js +15 -19
- package/src/screens/Unit/MoreMenu.js +6 -1
- package/src/screens/Unit/SelectLocation.js +2 -3
- package/src/screens/Unit/SmartAccount.js +141 -0
- package/src/screens/Unit/SmartAccountItem.js +51 -0
- package/src/screens/Unit/SmartAccountStyles.js +46 -0
- package/src/screens/Unit/__test__/SmartAccount.test.js +58 -0
- package/src/screens/Unit/hook/useStateAlertRemove.js +36 -0
- package/src/utils/I18n/translations/en.json +26 -2
- package/src/utils/I18n/translations/vi.json +38 -14
- package/src/utils/Route/index.js +4 -0
- package/src/utils/Validation.js +3 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { memo, useEffect } from 'react';
|
|
2
2
|
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
4
|
+
|
|
3
5
|
import { API, Colors } from '../../configs';
|
|
4
6
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
5
7
|
import Text from '../../commons/Text';
|
|
@@ -44,6 +46,7 @@ const styles = StyleSheet.create({
|
|
|
44
46
|
wrap: {
|
|
45
47
|
flex: 1,
|
|
46
48
|
backgroundColor: Colors.Gray2,
|
|
49
|
+
paddingTop: getStatusBarHeight(true),
|
|
47
50
|
},
|
|
48
51
|
txtHeader: {
|
|
49
52
|
marginTop: 16,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
1
|
+
import { StyleSheet, StatusBar, Platform } from 'react-native';
|
|
2
2
|
import { Colors } from '../../configs';
|
|
3
3
|
import { colorOpacity } from '../../utils/Converter/color';
|
|
4
|
+
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
4
5
|
|
|
5
6
|
export default StyleSheet.create({
|
|
6
7
|
wrap: {
|
|
7
8
|
flex: 1,
|
|
9
|
+
...Platform.select({
|
|
10
|
+
android: {
|
|
11
|
+
paddingTop: StatusBar.currentHeight,
|
|
12
|
+
},
|
|
13
|
+
ios: {
|
|
14
|
+
paddingTop: getStatusBarHeight(),
|
|
15
|
+
},
|
|
16
|
+
}),
|
|
8
17
|
},
|
|
9
18
|
txtHeader: {
|
|
10
19
|
marginTop: 16,
|
|
@@ -52,7 +52,12 @@ describe('test AddNewOneTap', () => {
|
|
|
52
52
|
test('create AddNewOneTap success', async () => {
|
|
53
53
|
Platform.OS = 'ios';
|
|
54
54
|
let route = {
|
|
55
|
-
params: {
|
|
55
|
+
params: {
|
|
56
|
+
type: 'one_tap',
|
|
57
|
+
unit: { id: 1 },
|
|
58
|
+
isMultiUnits: false,
|
|
59
|
+
isAutomateTab: false,
|
|
60
|
+
},
|
|
56
61
|
};
|
|
57
62
|
|
|
58
63
|
const response = {
|
|
@@ -103,6 +108,9 @@ describe('test AddNewOneTap', () => {
|
|
|
103
108
|
id: 1,
|
|
104
109
|
},
|
|
105
110
|
isCreateScriptSuccess: true,
|
|
111
|
+
automate: {},
|
|
112
|
+
isAutomateTab: false,
|
|
113
|
+
isMultiUnits: false,
|
|
106
114
|
});
|
|
107
115
|
});
|
|
108
116
|
test('create AddNewOneTap fail', async () => {
|
|
@@ -13,13 +13,14 @@ import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
|
13
13
|
import { axiosPost, axiosPut } from '../../utils/Apis/axios';
|
|
14
14
|
import Routes from '../../utils/Route';
|
|
15
15
|
import { popAction } from '../../navigations/utils';
|
|
16
|
-
import {
|
|
16
|
+
import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
17
17
|
|
|
18
18
|
const AddNewOneTap = memo(({ route }) => {
|
|
19
19
|
const {
|
|
20
20
|
type,
|
|
21
21
|
unit,
|
|
22
22
|
automateData = {},
|
|
23
|
+
automate = {},
|
|
23
24
|
isAutomateTab,
|
|
24
25
|
isMultiUnits,
|
|
25
26
|
automateId,
|
|
@@ -45,13 +46,12 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
45
46
|
id: data.id,
|
|
46
47
|
name: name,
|
|
47
48
|
type: type,
|
|
49
|
+
automate,
|
|
48
50
|
havePermission: true,
|
|
49
51
|
isCreateScriptSuccess: true,
|
|
50
52
|
isAutomateTab: automateId ? false : isAutomateTab,
|
|
51
53
|
isMultiUnits,
|
|
52
54
|
});
|
|
53
|
-
} else {
|
|
54
|
-
ToastBottomHelper.error(t('error_please_try_later'));
|
|
55
55
|
}
|
|
56
56
|
}, [
|
|
57
57
|
isMultiUnits,
|
|
@@ -60,9 +60,9 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
60
60
|
name,
|
|
61
61
|
automateData,
|
|
62
62
|
automateId,
|
|
63
|
+
automate,
|
|
63
64
|
navigate,
|
|
64
65
|
isAutomateTab,
|
|
65
|
-
t,
|
|
66
66
|
]);
|
|
67
67
|
|
|
68
68
|
const onChangeName = useCallback((text) => {
|
|
@@ -89,6 +89,11 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
89
89
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
90
|
}, [isAutomateTab]);
|
|
91
91
|
|
|
92
|
+
const textForNewTap =
|
|
93
|
+
type === AUTOMATE_TYPE.ONE_TAP
|
|
94
|
+
? t('name_your_button')
|
|
95
|
+
: t('name_your_script');
|
|
96
|
+
|
|
92
97
|
return (
|
|
93
98
|
<SafeAreaView
|
|
94
99
|
style={
|
|
@@ -106,10 +111,10 @@ const AddNewOneTap = memo(({ route }) => {
|
|
|
106
111
|
color={Colors.Gray9}
|
|
107
112
|
style={styles.textHeader}
|
|
108
113
|
>
|
|
109
|
-
{
|
|
114
|
+
{textForNewTap}
|
|
110
115
|
</Text>
|
|
111
116
|
<_TextInput
|
|
112
|
-
placeholder={
|
|
117
|
+
placeholder={textForNewTap}
|
|
113
118
|
wrapStyle={styles.noMarginTop}
|
|
114
119
|
onChange={onChangeName}
|
|
115
120
|
textInputStyle={styles.textInput}
|
|
@@ -17,7 +17,6 @@ import ItemOneTap from '../../commons/SubUnit/OneTap/ItemOneTap';
|
|
|
17
17
|
import Routes from '../../utils/Route';
|
|
18
18
|
import { useGetIdUser } from '../../hooks/Common';
|
|
19
19
|
import ItemAddNew from '../../commons/Device/ItemAddNew';
|
|
20
|
-
import { REPEAT_OPTIONS } from '../SetSchedule/components/RepeatOptionsPopup';
|
|
21
20
|
|
|
22
21
|
const MultiUnits = () => {
|
|
23
22
|
const t = useTranslations();
|
|
@@ -53,55 +52,6 @@ const MultiUnits = () => {
|
|
|
53
52
|
setTabActive(tab);
|
|
54
53
|
};
|
|
55
54
|
|
|
56
|
-
const textCondition = useCallback(
|
|
57
|
-
(item) => {
|
|
58
|
-
const {
|
|
59
|
-
type,
|
|
60
|
-
condition,
|
|
61
|
-
config,
|
|
62
|
-
value,
|
|
63
|
-
repeat,
|
|
64
|
-
date_repeat,
|
|
65
|
-
time_repeat,
|
|
66
|
-
weekday_repeat,
|
|
67
|
-
} = item;
|
|
68
|
-
|
|
69
|
-
if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
70
|
-
let _condition;
|
|
71
|
-
if (condition === '>') {
|
|
72
|
-
_condition = 'higher_than';
|
|
73
|
-
} else if (condition === '<') {
|
|
74
|
-
_condition = 'lower_than';
|
|
75
|
-
} else if (condition === '=') {
|
|
76
|
-
_condition = 'equal';
|
|
77
|
-
}
|
|
78
|
-
return `${config} ${t(_condition)} ${value}`;
|
|
79
|
-
} else if (type === AUTOMATE_TYPE.SCHEDULE) {
|
|
80
|
-
const time = time_repeat.substring(0, time_repeat.length - 3);
|
|
81
|
-
const date = date_repeat.split('-').reverse().join('/');
|
|
82
|
-
const weekday = {
|
|
83
|
-
0: 'Mon',
|
|
84
|
-
1: 'Tue',
|
|
85
|
-
2: 'Wed',
|
|
86
|
-
3: 'Thu',
|
|
87
|
-
4: 'Fri',
|
|
88
|
-
5: 'Sat',
|
|
89
|
-
6: 'Sun',
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
if (repeat === REPEAT_OPTIONS.ONCE) {
|
|
93
|
-
return `${time} ${date}`;
|
|
94
|
-
} else if (repeat === REPEAT_OPTIONS.EVERYDAY) {
|
|
95
|
-
return `${t('every_day_at', { time })}`;
|
|
96
|
-
} else if (repeat === REPEAT_OPTIONS.EVERYWEEK) {
|
|
97
|
-
return weekday_repeat.map((item) => weekday[item]).join(', ');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
},
|
|
102
|
-
[t]
|
|
103
|
-
);
|
|
104
|
-
|
|
105
55
|
const onPressItem = (item) => () => {
|
|
106
56
|
navigate(Routes.UnitStack, {
|
|
107
57
|
screen: Routes.ScriptDetail,
|
|
@@ -112,7 +62,7 @@ const MultiUnits = () => {
|
|
|
112
62
|
havePermission: idUser === item?.user,
|
|
113
63
|
unit,
|
|
114
64
|
isMultiUnits,
|
|
115
|
-
|
|
65
|
+
automate: item,
|
|
116
66
|
},
|
|
117
67
|
});
|
|
118
68
|
};
|
|
@@ -125,8 +75,9 @@ const MultiUnits = () => {
|
|
|
125
75
|
tabActive === t('Scenario')
|
|
126
76
|
? AUTOMATE_TYPE.ONE_TAP_ONLY
|
|
127
77
|
: AUTOMATE_TYPE.VALUE_CHANGE,
|
|
78
|
+
unit: { id: unit?.id },
|
|
128
79
|
isAutomateTab: true,
|
|
129
|
-
isMultiUnits
|
|
80
|
+
isMultiUnits,
|
|
130
81
|
},
|
|
131
82
|
});
|
|
132
83
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -163,9 +114,19 @@ const MultiUnits = () => {
|
|
|
163
114
|
: item?.type !== AUTOMATE_TYPE.ONE_TAP
|
|
164
115
|
);
|
|
165
116
|
|
|
117
|
+
const listFavorite = listItems.filter(
|
|
118
|
+
(item) => item.script?.is_star === true
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const listNotFavorite = listItems.filter(
|
|
122
|
+
(item) => item.script?.is_star === false
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const newListItems = listFavorite.concat(listNotFavorite);
|
|
126
|
+
|
|
166
127
|
return (
|
|
167
128
|
<View style={styles.wrapItem}>
|
|
168
|
-
{
|
|
129
|
+
{newListItems.map((item, index) => (
|
|
169
130
|
<ItemOneTap
|
|
170
131
|
isOwner={idUser === item?.user}
|
|
171
132
|
automate={item}
|
|
@@ -70,6 +70,7 @@ describe('Test MultiUnits', () => {
|
|
|
70
70
|
id: 1,
|
|
71
71
|
name: 'Tap to up down up down coc coc coc coc coc',
|
|
72
72
|
icon: null,
|
|
73
|
+
is_star: true,
|
|
73
74
|
icon_kit:
|
|
74
75
|
'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
|
|
75
76
|
},
|
|
@@ -86,6 +87,7 @@ describe('Test MultiUnits', () => {
|
|
|
86
87
|
id: 300,
|
|
87
88
|
name: 'p14',
|
|
88
89
|
icon: null,
|
|
90
|
+
is_star: true,
|
|
89
91
|
icon_kit: null,
|
|
90
92
|
},
|
|
91
93
|
},
|
|
@@ -126,13 +128,13 @@ describe('Test MultiUnits', () => {
|
|
|
126
128
|
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
127
129
|
screen: Routes.ScriptDetail,
|
|
128
130
|
params: {
|
|
131
|
+
automate: response.data[1],
|
|
129
132
|
id: response.data[1].id,
|
|
130
133
|
name: response.data[1].script?.name,
|
|
131
134
|
type: response.data[1].type,
|
|
132
135
|
havePermission: false,
|
|
133
136
|
unit: null,
|
|
134
137
|
isMultiUnits: true,
|
|
135
|
-
textCondition: 'Light Value lower than 0',
|
|
136
138
|
},
|
|
137
139
|
});
|
|
138
140
|
const ItemAddNews = instance.findAllByType(ItemAddNew);
|
|
@@ -145,6 +147,7 @@ describe('Test MultiUnits', () => {
|
|
|
145
147
|
type: AUTOMATE_TYPE.VALUE_CHANGE,
|
|
146
148
|
isAutomateTab: true,
|
|
147
149
|
isMultiUnits: true,
|
|
150
|
+
unit: { id: undefined },
|
|
148
151
|
},
|
|
149
152
|
});
|
|
150
153
|
});
|
|
@@ -219,6 +222,7 @@ describe('Test MultiUnits', () => {
|
|
|
219
222
|
type: AUTOMATE_TYPE.ONE_TAP_ONLY,
|
|
220
223
|
isAutomateTab: true,
|
|
221
224
|
isMultiUnits: true,
|
|
225
|
+
unit: { id: undefined },
|
|
222
226
|
},
|
|
223
227
|
});
|
|
224
228
|
});
|
|
@@ -234,249 +238,4 @@ describe('Test MultiUnits', () => {
|
|
|
234
238
|
const WrapHeaderScrollables = instance.findAllByType(WrapHeaderScrollable);
|
|
235
239
|
expect(WrapHeaderScrollables[0].props.title).toEqual('');
|
|
236
240
|
});
|
|
237
|
-
|
|
238
|
-
it('Test render textCondition', async () => {
|
|
239
|
-
const response = {
|
|
240
|
-
status: 200,
|
|
241
|
-
data: [
|
|
242
|
-
{
|
|
243
|
-
id: 1,
|
|
244
|
-
user: 223,
|
|
245
|
-
type: 'schedule',
|
|
246
|
-
config: null,
|
|
247
|
-
value: null,
|
|
248
|
-
activate_at: '2021-09-22T14:16:54Z',
|
|
249
|
-
condition: null,
|
|
250
|
-
script: {
|
|
251
|
-
id: 1,
|
|
252
|
-
name: 'Tap to up down up down coc coc coc coc coc',
|
|
253
|
-
icon: null,
|
|
254
|
-
icon_kit:
|
|
255
|
-
'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
|
|
256
|
-
},
|
|
257
|
-
repeat: 'once',
|
|
258
|
-
date_repeat: '2022-01-02',
|
|
259
|
-
time_repeat: '09:10:00',
|
|
260
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
id: 299,
|
|
264
|
-
user: 223,
|
|
265
|
-
type: 'value_change',
|
|
266
|
-
config: 'Light Value',
|
|
267
|
-
value: 0,
|
|
268
|
-
activate_at: null,
|
|
269
|
-
condition: '>',
|
|
270
|
-
script: {
|
|
271
|
-
id: 300,
|
|
272
|
-
name: 'p14',
|
|
273
|
-
icon: null,
|
|
274
|
-
icon_kit: null,
|
|
275
|
-
},
|
|
276
|
-
repeat: 'once',
|
|
277
|
-
date_repeat: '2022-01-02',
|
|
278
|
-
time_repeat: '09:10:00',
|
|
279
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
id: 300,
|
|
283
|
-
user: 223,
|
|
284
|
-
type: 'value_change',
|
|
285
|
-
config: 'Light Value',
|
|
286
|
-
value: 0,
|
|
287
|
-
activate_at: null,
|
|
288
|
-
condition: '=',
|
|
289
|
-
script: {
|
|
290
|
-
id: 300,
|
|
291
|
-
name: 'p15',
|
|
292
|
-
icon: null,
|
|
293
|
-
icon_kit: null,
|
|
294
|
-
},
|
|
295
|
-
repeat: 'once',
|
|
296
|
-
date_repeat: '2022-01-02',
|
|
297
|
-
time_repeat: '09:10:00',
|
|
298
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
id: 301,
|
|
302
|
-
user: 223,
|
|
303
|
-
type: 'schedule',
|
|
304
|
-
config: null,
|
|
305
|
-
value: null,
|
|
306
|
-
activate_at: '2021-09-22T14:16:54Z',
|
|
307
|
-
condition: null,
|
|
308
|
-
script: {
|
|
309
|
-
id: 1,
|
|
310
|
-
name: 'Tap to up down up down coc coc coc coc coc',
|
|
311
|
-
icon: null,
|
|
312
|
-
icon_kit:
|
|
313
|
-
'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
|
|
314
|
-
},
|
|
315
|
-
repeat: 'once',
|
|
316
|
-
date_repeat: '2022-01-02',
|
|
317
|
-
time_repeat: '09:10:00',
|
|
318
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
id: 302,
|
|
322
|
-
user: 223,
|
|
323
|
-
type: 'schedule',
|
|
324
|
-
config: null,
|
|
325
|
-
value: null,
|
|
326
|
-
activate_at: '2021-09-22T14:16:54Z',
|
|
327
|
-
condition: null,
|
|
328
|
-
script: {
|
|
329
|
-
id: 1,
|
|
330
|
-
name: 'Tap to up down up down coc coc coc coc coc',
|
|
331
|
-
icon: null,
|
|
332
|
-
icon_kit:
|
|
333
|
-
'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
|
|
334
|
-
},
|
|
335
|
-
repeat: 'every_day',
|
|
336
|
-
date_repeat: '2022-01-02',
|
|
337
|
-
time_repeat: '09:10:00',
|
|
338
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
339
|
-
},
|
|
340
|
-
{
|
|
341
|
-
id: 302,
|
|
342
|
-
user: 223,
|
|
343
|
-
type: 'schedule',
|
|
344
|
-
config: null,
|
|
345
|
-
value: null,
|
|
346
|
-
activate_at: '2021-09-22T14:16:54Z',
|
|
347
|
-
condition: null,
|
|
348
|
-
script: {
|
|
349
|
-
id: 1,
|
|
350
|
-
name: 'Tap to up down up down coc coc coc coc coc',
|
|
351
|
-
icon: null,
|
|
352
|
-
icon_kit:
|
|
353
|
-
'https://eoh-gateway-backend.eoh.io/_Category_Sensors_Type_Garage_door_StyleC_olorful.png',
|
|
354
|
-
},
|
|
355
|
-
repeat: 'every_week',
|
|
356
|
-
date_repeat: '2022-01-02',
|
|
357
|
-
time_repeat: '09:10:00',
|
|
358
|
-
weekday_repeat: ['1', '2', '4', '6'],
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
};
|
|
362
|
-
await axios.get.mockImplementation(async () => {
|
|
363
|
-
return response;
|
|
364
|
-
});
|
|
365
|
-
useRoute.mockReturnValue({
|
|
366
|
-
params: {
|
|
367
|
-
isMultiUnits: true,
|
|
368
|
-
unitName: null,
|
|
369
|
-
unit: null,
|
|
370
|
-
},
|
|
371
|
-
});
|
|
372
|
-
useState.mockImplementationOnce(() => [response.data, mockSetState]);
|
|
373
|
-
useState.mockImplementationOnce(() => [
|
|
374
|
-
getTranslate('en', 'Automation'),
|
|
375
|
-
mockSetState,
|
|
376
|
-
]);
|
|
377
|
-
await act(() => {
|
|
378
|
-
tree = create(wrapComponent());
|
|
379
|
-
});
|
|
380
|
-
const instance = tree.root;
|
|
381
|
-
const WrapHeaderScrollables = instance.findAllByType(WrapHeaderScrollable);
|
|
382
|
-
expect(WrapHeaderScrollables[0].props.title).toEqual(
|
|
383
|
-
getTranslate('en', 'multi_units_automate')
|
|
384
|
-
);
|
|
385
|
-
const TouchableOpacities = instance.findAllByType(TouchableOpacity);
|
|
386
|
-
act(() => {
|
|
387
|
-
TouchableOpacities[2].props.onPress();
|
|
388
|
-
});
|
|
389
|
-
expect(mockSetState).toBeCalledWith(getTranslate('en', 'Automation'));
|
|
390
|
-
const ItemOneTaps = instance.findAllByType(ItemOneTap);
|
|
391
|
-
act(() => {
|
|
392
|
-
ItemOneTaps[0].props.onPressItem();
|
|
393
|
-
});
|
|
394
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
395
|
-
screen: Routes.ScriptDetail,
|
|
396
|
-
params: {
|
|
397
|
-
id: response.data[0].id,
|
|
398
|
-
name: response.data[0].script?.name,
|
|
399
|
-
type: response.data[0].type,
|
|
400
|
-
havePermission: false,
|
|
401
|
-
unit: null,
|
|
402
|
-
isMultiUnits: true,
|
|
403
|
-
textCondition: '09:10 02/01/2022',
|
|
404
|
-
},
|
|
405
|
-
});
|
|
406
|
-
act(() => {
|
|
407
|
-
ItemOneTaps[1].props.onPressItem();
|
|
408
|
-
});
|
|
409
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
410
|
-
screen: Routes.ScriptDetail,
|
|
411
|
-
params: {
|
|
412
|
-
id: response.data[1].id,
|
|
413
|
-
name: response.data[1].script?.name,
|
|
414
|
-
type: response.data[1].type,
|
|
415
|
-
havePermission: false,
|
|
416
|
-
unit: null,
|
|
417
|
-
isMultiUnits: true,
|
|
418
|
-
textCondition: 'Light Value higher than 0',
|
|
419
|
-
},
|
|
420
|
-
});
|
|
421
|
-
act(() => {
|
|
422
|
-
ItemOneTaps[2].props.onPressItem();
|
|
423
|
-
});
|
|
424
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
425
|
-
screen: Routes.ScriptDetail,
|
|
426
|
-
params: {
|
|
427
|
-
id: response.data[2].id,
|
|
428
|
-
name: response.data[2].script?.name,
|
|
429
|
-
type: response.data[2].type,
|
|
430
|
-
havePermission: false,
|
|
431
|
-
unit: null,
|
|
432
|
-
isMultiUnits: true,
|
|
433
|
-
textCondition: 'Light Value equal 0',
|
|
434
|
-
},
|
|
435
|
-
});
|
|
436
|
-
act(() => {
|
|
437
|
-
ItemOneTaps[3].props.onPressItem();
|
|
438
|
-
});
|
|
439
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
440
|
-
screen: Routes.ScriptDetail,
|
|
441
|
-
params: {
|
|
442
|
-
id: response.data[3].id,
|
|
443
|
-
name: response.data[3].script?.name,
|
|
444
|
-
type: response.data[3].type,
|
|
445
|
-
havePermission: false,
|
|
446
|
-
unit: null,
|
|
447
|
-
isMultiUnits: true,
|
|
448
|
-
textCondition: '09:10 02/01/2022',
|
|
449
|
-
},
|
|
450
|
-
});
|
|
451
|
-
act(() => {
|
|
452
|
-
ItemOneTaps[4].props.onPressItem();
|
|
453
|
-
});
|
|
454
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
455
|
-
screen: Routes.ScriptDetail,
|
|
456
|
-
params: {
|
|
457
|
-
id: response.data[4].id,
|
|
458
|
-
name: response.data[4].script?.name,
|
|
459
|
-
type: response.data[4].type,
|
|
460
|
-
havePermission: false,
|
|
461
|
-
unit: null,
|
|
462
|
-
isMultiUnits: true,
|
|
463
|
-
textCondition: 'Every day at 09:10',
|
|
464
|
-
},
|
|
465
|
-
});
|
|
466
|
-
act(() => {
|
|
467
|
-
ItemOneTaps[5].props.onPressItem();
|
|
468
|
-
});
|
|
469
|
-
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
470
|
-
screen: Routes.ScriptDetail,
|
|
471
|
-
params: {
|
|
472
|
-
id: response.data[5].id,
|
|
473
|
-
name: response.data[5].script?.name,
|
|
474
|
-
type: response.data[5].type,
|
|
475
|
-
havePermission: false,
|
|
476
|
-
unit: null,
|
|
477
|
-
isMultiUnits: true,
|
|
478
|
-
textCondition: 'Tue, Wed, Fri, Sun',
|
|
479
|
-
},
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
241
|
});
|
|
@@ -152,6 +152,7 @@ describe('Test Automate', () => {
|
|
|
152
152
|
expect(mockedNavigate).toBeCalledWith(Routes.UnitStack, {
|
|
153
153
|
screen: Routes.ScriptDetail,
|
|
154
154
|
params: {
|
|
155
|
+
automate: response.data[0].automates[0],
|
|
155
156
|
isAutomateTab: true,
|
|
156
157
|
isMultiUnits: true,
|
|
157
158
|
name: 'script',
|
|
@@ -43,6 +43,16 @@ jest.mock('react-redux', () => {
|
|
|
43
43
|
};
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
jest.mock('@react-native-community/netinfo', () => {
|
|
47
|
+
return {
|
|
48
|
+
useNetInfo: () => {
|
|
49
|
+
return {
|
|
50
|
+
isConnected: true,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
46
56
|
jest.mock('react', () => ({
|
|
47
57
|
...jest.requireActual('react'),
|
|
48
58
|
useLayoutEffect: jest.fn(),
|
|
@@ -807,6 +817,10 @@ describe('test DeviceDetail', () => {
|
|
|
807
817
|
expect(mockedNavigate).toHaveBeenCalledWith(Routes.ActivityLog, {
|
|
808
818
|
id: route.params.sensor.id,
|
|
809
819
|
type: 'action',
|
|
820
|
+
filterEnabled: {
|
|
821
|
+
date: false,
|
|
822
|
+
user: false,
|
|
823
|
+
},
|
|
810
824
|
});
|
|
811
825
|
});
|
|
812
826
|
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import React, { 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 [chartData, setChartData] = useState(item.configuration.configs);
|
|
10
|
+
const [startDate, setStartDate] = useState(
|
|
11
|
+
moment().subtract(1, 'days').valueOf()
|
|
12
|
+
);
|
|
13
|
+
const [endDate, setEndDate] = useState(moment().valueOf());
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const fetchData = async () => {
|
|
16
|
+
let params = new URLSearchParams();
|
|
17
|
+
item.configuration.configs.map((config) => {
|
|
18
|
+
params.append('config', config.id);
|
|
19
|
+
});
|
|
20
|
+
params.append('date_from', startDate / 1000);
|
|
21
|
+
params.append('date_to', endDate / 1000);
|
|
22
|
+
const { success, data } = await axiosGet(
|
|
23
|
+
API.SENSOR.DISPLAY_HISTORY(sensor.id),
|
|
24
|
+
{ params }
|
|
25
|
+
);
|
|
26
|
+
if (success) {
|
|
27
|
+
for (let i = 0; i < data.length; i++) {
|
|
28
|
+
for (let j = 0; j < data[i].data.length; j++) {
|
|
29
|
+
data[i].data[j].x = moment(data[i].data[j].x).toDate();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const formatData = item.configuration.configs.map((config) => {
|
|
34
|
+
const dataChart = data.find((k) => k.config === config.id) || {
|
|
35
|
+
data: [],
|
|
36
|
+
};
|
|
37
|
+
return { ...config, data: dataChart.data };
|
|
38
|
+
});
|
|
39
|
+
setChartData(formatData);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
fetchData();
|
|
43
|
+
}, [startDate, endDate, item, sensor]);
|
|
44
|
+
if (!chartData.length) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<HistoryChart
|
|
50
|
+
configuration={item.configuration}
|
|
51
|
+
datas={chartData}
|
|
52
|
+
style={styles.chartStyle}
|
|
53
|
+
setStartDate={setStartDate}
|
|
54
|
+
setEndDate={setEndDate}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const styles = StyleSheet.create({
|
|
60
|
+
chartStyle: {
|
|
61
|
+
paddingHorizontal: 16,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import Text from '../../../commons/Text';
|
|
4
|
+
import { Colors } from '../../../configs';
|
|
5
|
+
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
6
|
+
|
|
7
|
+
export const EmergencyCountdown = memo(({ countUpStr }) => {
|
|
8
|
+
const t = useTranslations();
|
|
9
|
+
return (
|
|
10
|
+
<View style={styles.countDown}>
|
|
11
|
+
<Text type="Label" center style={styles.messageCountDown}>
|
|
12
|
+
{t('time_since_the_emergency_button_was_pressed')}
|
|
13
|
+
</Text>
|
|
14
|
+
<Text type="H3" center semibold color={Colors.Red6}>
|
|
15
|
+
{countUpStr}
|
|
16
|
+
</Text>
|
|
17
|
+
</View>
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
countDown: {
|
|
23
|
+
marginBottom: 16,
|
|
24
|
+
marginTop: 8,
|
|
25
|
+
},
|
|
26
|
+
messageCountDown: {
|
|
27
|
+
marginBottom: 8,
|
|
28
|
+
},
|
|
29
|
+
});
|