@eohjsc/react-native-smart-city 0.2.79 → 0.2.83
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/package.json +4 -4
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +32 -21
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +8 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +11 -3
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +10 -7
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +5 -2
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +7 -3
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +33 -24
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +18 -6
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +9 -1
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +25 -13
- package/src/commons/ActionGroup/__test__/index.test.js +48 -14
- package/src/commons/Device/HorizontalBarChart.js +8 -2
- package/src/commons/Device/ItemDevice.js +8 -5
- package/src/commons/Device/LinearChart.js +1 -1
- package/src/commons/EmergencyButton/AlertSendConfirm.js +2 -2
- package/src/commons/EmergencyButton/AlertSent.js +2 -2
- package/src/commons/ImagePicker/__test__/ImagePicker.test.js +24 -3
- package/src/commons/MediaPlayerDetail/index.js +1 -0
- package/src/commons/SubUnit/Favorites/index.js +2 -0
- package/src/commons/SubUnit/ShortDetail.js +7 -1
- package/src/configs/API.js +2 -4
- package/src/configs/Constants.js +5 -0
- package/src/iot/RemoteControl/Internet.js +8 -1
- package/src/iot/RemoteControl/index.js +4 -2
- package/src/screens/AddCommon/SelectSubUnit.js +6 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +52 -0
- package/src/screens/AllCamera/index.js +76 -44
- package/src/screens/Device/EditDevice/__test__/EditDevice.test.js +2 -2
- package/src/screens/Device/EditDevice/index.js +2 -2
- package/src/screens/Device/__test__/detail.test.js +18 -11
- package/src/screens/Device/components/SensorConnectStatusViewHeader.js +2 -2
- package/src/screens/Device/components/SensorDisplayItem.js +2 -2
- package/src/screens/Device/detail.js +58 -20
- package/src/screens/Notification/__test__/NotificationItem.test.js +186 -14
- package/src/screens/Notification/components/NotificationItem.js +147 -3
- package/src/screens/Notification/index.js +4 -1
- package/src/screens/Notification/styles/NotificationItemStyles.js +3 -3
- package/src/screens/Sharing/SelectUser.js +17 -10
- package/src/screens/Sharing/__test__/SelectUser.test.js +73 -0
- package/src/screens/SubUnit/AddSubUnit.js +4 -1
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +148 -0
- package/src/screens/Unit/Detail.js +28 -4
- package/src/screens/Unit/ManageUnit.js +88 -32
- package/src/screens/Unit/ManageUnitStyles.js +20 -0
- package/src/screens/Unit/SmartAccount.js +6 -2
- package/src/screens/Unit/Summaries.js +2 -2
- package/src/screens/Unit/__test__/CheckSendEmail.test.js +10 -0
- package/src/screens/Unit/__test__/Detail.test.js +53 -0
- package/src/screens/Unit/__test__/ManageUnit.test.js +69 -0
- package/src/screens/Unit/__test__/SmartAccount.test.js +37 -8
- package/src/screens/Unit/components/__test__/SharedUnit.test.js +21 -2
- package/src/screens/Unit/hook/useStateAlertRemove.js +1 -1
- package/src/screens/UnitSummary/__test__/index.test.js +3 -3
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +2 -2
- package/src/screens/UnitSummary/index.js +52 -9
- package/src/utils/Apis/axios.js +7 -2
- package/src/utils/I18n/translations/en.json +10 -1
- package/src/utils/I18n/translations/vi.json +10 -1
- package/src/{screens/Notification → utils}/Monitor.js +1 -1
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.83",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -97,10 +97,10 @@
|
|
|
97
97
|
"dependencies": {
|
|
98
98
|
"@ant-design/icons-react-native": "^2.2.1",
|
|
99
99
|
"@ant-design/react-native": "^4.0.5",
|
|
100
|
+
"@eohjsc/highcharts": "^1.0.3",
|
|
100
101
|
"@formatjs/intl-getcanonicallocales": "^1.4.5",
|
|
101
102
|
"@formatjs/intl-numberformat": "^5.6.2",
|
|
102
103
|
"@formatjs/intl-pluralrules": "^3.4.7",
|
|
103
|
-
"@highcharts/highcharts-react-native": "https://github.com/hinh-eoh/highcharts",
|
|
104
104
|
"@invertase/react-native-apple-authentication": "^1.1.2",
|
|
105
105
|
"@messageformat/core": "^3.0.0",
|
|
106
106
|
"@react-native-community/async-storage": "^1.12.1",
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
"react-native-image-resizer": "^1.4.5",
|
|
162
162
|
"react-native-input-credit-card": "^0.5.5",
|
|
163
163
|
"react-native-iphone-x-helper": "^1.2.1",
|
|
164
|
-
"react-native-keyboard-aware-scroll-view": "
|
|
164
|
+
"react-native-keyboard-aware-scroll-view": "https://github.com/hinh-eoh/react-native-keyboard-aware-scroll-view.git",
|
|
165
165
|
"react-native-linear-gradient": "^2.5.6",
|
|
166
166
|
"react-native-localize": "^1.4.1",
|
|
167
167
|
"react-native-maps": "0.27.1",
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
"react-native-udp": "^4.1.3",
|
|
187
187
|
"react-native-unimodules": "^0.11.0",
|
|
188
188
|
"react-native-version-check": "^3.4.2",
|
|
189
|
-
"react-native-vlc-media-player": "
|
|
189
|
+
"react-native-vlc-media-player": "https://github.com/razorRun/react-native-vlc-media-player.git",
|
|
190
190
|
"react-native-webview": "^10.9.3",
|
|
191
191
|
"react-native-wheel-scrollview-picker": "^1.2.2",
|
|
192
192
|
"react-native-wifi-reborn": "^4.5.0",
|
|
@@ -6,35 +6,46 @@ import Text from '../Text';
|
|
|
6
6
|
import { TESTID } from '../../configs/Constants';
|
|
7
7
|
import { Colors, Images } from '../../configs';
|
|
8
8
|
|
|
9
|
-
const CurtainButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
9
|
+
const CurtainButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
10
10
|
const { configuration } = actionGroup;
|
|
11
|
+
const {
|
|
12
|
+
text_open,
|
|
13
|
+
open_action_data,
|
|
14
|
+
text_stop,
|
|
15
|
+
stop_action_data,
|
|
16
|
+
text_close,
|
|
17
|
+
close_action_data,
|
|
18
|
+
action_off_data,
|
|
19
|
+
action_on_data,
|
|
20
|
+
} = configuration || {};
|
|
11
21
|
const [lock, setLock] = useState(false);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
22
|
+
|
|
23
|
+
const onButtonOpenPress = useCallback(() => {
|
|
24
|
+
const actionName = `${sensor?.name} ${text_open?.toLowerCase()}`;
|
|
25
|
+
doAction(open_action_data, null, actionName);
|
|
26
|
+
}, [open_action_data, text_open, doAction, sensor?.name]);
|
|
27
|
+
|
|
28
|
+
const onButtonStopPress = useCallback(() => {
|
|
29
|
+
const actionName = `${sensor?.name} ${text_stop?.toLowerCase()}`;
|
|
30
|
+
doAction(stop_action_data, null, actionName);
|
|
31
|
+
}, [stop_action_data, text_stop, doAction, sensor?.name]);
|
|
32
|
+
|
|
33
|
+
const onButtonClosePress = useCallback(() => {
|
|
34
|
+
const actionName = `${sensor?.name} ${text_close?.toLowerCase()}`;
|
|
35
|
+
doAction(close_action_data, null, actionName);
|
|
36
|
+
}, [close_action_data, text_close, doAction, sensor?.name]);
|
|
37
|
+
|
|
24
38
|
const onChangeSwitch = useCallback(() => {
|
|
25
39
|
if (lock) {
|
|
40
|
+
const actionName = `${sensor?.name} unlock`;
|
|
26
41
|
setLock(false);
|
|
27
|
-
doAction(
|
|
42
|
+
doAction(action_off_data, null, actionName);
|
|
28
43
|
return;
|
|
29
44
|
}
|
|
30
|
-
|
|
45
|
+
const actionName = `${sensor?.name} lock`;
|
|
46
|
+
doAction(action_on_data, null, actionName);
|
|
31
47
|
setLock(true);
|
|
32
|
-
}, [
|
|
33
|
-
configuration.action_off_data,
|
|
34
|
-
configuration.action_on_data,
|
|
35
|
-
doAction,
|
|
36
|
-
lock,
|
|
37
|
-
]);
|
|
48
|
+
}, [action_off_data, action_on_data, doAction, lock, sensor?.name]);
|
|
38
49
|
|
|
39
50
|
const RenderThreeButtonActions = () => {
|
|
40
51
|
const buttons = [
|
|
@@ -38,8 +38,8 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
38
38
|
}, [configValues, config, keep_track_config]);
|
|
39
39
|
|
|
40
40
|
const doActionAndWatchConfig = useCallback(
|
|
41
|
-
(actionData, actionValue) => {
|
|
42
|
-
doAction(actionData, actionValue);
|
|
41
|
+
(actionData, actionValue, actionName) => {
|
|
42
|
+
doAction(actionData, actionValue, actionName);
|
|
43
43
|
if (!sensor?.is_managed_by_backend) {
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
@@ -56,16 +56,18 @@ const NumberUpDownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
const doActionUp = useCallback(async () => {
|
|
59
|
+
const actionName = `${sensor?.name} temp up`;
|
|
59
60
|
const newValue = checkMinMax(value + 1);
|
|
60
|
-
doActionAndWatchConfig(action_data, newValue);
|
|
61
|
+
doActionAndWatchConfig(action_data, newValue, actionName);
|
|
61
62
|
setValue(newValue);
|
|
62
|
-
}, [checkMinMax, value, doActionAndWatchConfig, action_data]);
|
|
63
|
+
}, [sensor?.name, checkMinMax, value, doActionAndWatchConfig, action_data]);
|
|
63
64
|
|
|
64
65
|
const doActionDown = useCallback(async () => {
|
|
66
|
+
const actionName = `${sensor?.name} temp down`;
|
|
65
67
|
const newValue = checkMinMax(value - 1);
|
|
66
|
-
doActionAndWatchConfig(action_data, newValue);
|
|
68
|
+
doActionAndWatchConfig(action_data, newValue, actionName);
|
|
67
69
|
setValue(newValue);
|
|
68
|
-
}, [checkMinMax, value, doActionAndWatchConfig, action_data]);
|
|
70
|
+
}, [sensor?.name, checkMinMax, value, doActionAndWatchConfig, action_data]);
|
|
69
71
|
|
|
70
72
|
const checkMinMax = useCallback(
|
|
71
73
|
(tempValue) => {
|
|
@@ -34,22 +34,30 @@ const OnOffTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
|
34
34
|
}
|
|
35
35
|
if (action_on_data && action_off_data) {
|
|
36
36
|
if (isOn) {
|
|
37
|
-
|
|
37
|
+
const actionName = `${
|
|
38
|
+
sensor?.name
|
|
39
|
+
} ${actionGroup?.title?.toLowerCase()} off`;
|
|
40
|
+
doAction(action_off_data, null, actionName);
|
|
38
41
|
} else {
|
|
39
|
-
|
|
42
|
+
const actionName = `${
|
|
43
|
+
sensor?.name
|
|
44
|
+
} ${actionGroup?.title?.toLowerCase()} on`;
|
|
45
|
+
doAction(action_on_data, null, actionName);
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
if (sensor?.is_managed_by_backend) {
|
|
43
49
|
configuration.config && watchMultiConfigs([configuration.config]);
|
|
44
50
|
}
|
|
45
51
|
}, [
|
|
52
|
+
actionGroup?.title,
|
|
46
53
|
action_data,
|
|
47
54
|
action_off_data,
|
|
48
55
|
action_on_data,
|
|
49
56
|
configuration.config,
|
|
50
57
|
doAction,
|
|
51
58
|
isOn,
|
|
52
|
-
sensor,
|
|
59
|
+
sensor?.is_managed_by_backend,
|
|
60
|
+
sensor?.name,
|
|
53
61
|
]);
|
|
54
62
|
|
|
55
63
|
useEffect(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { Icon } from '@ant-design/react-native';
|
|
4
4
|
import Text from '../Text';
|
|
@@ -6,19 +6,22 @@ import Text from '../Text';
|
|
|
6
6
|
import { Colors } from '../../configs';
|
|
7
7
|
import styles from './OneBigButtonTemplateStyle';
|
|
8
8
|
|
|
9
|
-
const OneBigButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
9
|
+
const OneBigButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
10
10
|
const { configuration } = actionGroup;
|
|
11
|
+
const { text, action_data } = configuration || {};
|
|
12
|
+
|
|
13
|
+
const onPressDoAction = useCallback(() => {
|
|
14
|
+
const actionName = `${sensor?.name} ${text?.toLowerCase()}`;
|
|
15
|
+
doAction(action_data, null, actionName);
|
|
16
|
+
}, [action_data, text, doAction, sensor?.name]);
|
|
11
17
|
|
|
12
18
|
return (
|
|
13
19
|
<>
|
|
14
20
|
<View style={styles.barrierControlContainer}>
|
|
15
|
-
<TouchableOpacity
|
|
16
|
-
style={styles.bigCircle}
|
|
17
|
-
onPress={() => doAction(configuration.action_data)}
|
|
18
|
-
>
|
|
21
|
+
<TouchableOpacity style={styles.bigCircle} onPress={onPressDoAction}>
|
|
19
22
|
<View style={styles.smallCircle}>
|
|
20
23
|
<Icon name={configuration.icon} size={44} color={Colors.Green7} />
|
|
21
|
-
<Text style={styles.textBig}>{
|
|
24
|
+
<Text style={styles.textBig}>{text}</Text>
|
|
22
25
|
</View>
|
|
23
26
|
</TouchableOpacity>
|
|
24
27
|
</View>
|
|
@@ -56,7 +56,8 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
56
56
|
const onDone = useCallback(() => {
|
|
57
57
|
const newOption = options[selectedIndex];
|
|
58
58
|
const value = getOptionValue(newOption);
|
|
59
|
-
|
|
59
|
+
const actionName = `${sensor?.name} ${title?.toLowerCase()} ${value}`;
|
|
60
|
+
doAction(action_data, value, actionName);
|
|
60
61
|
if (sensor?.is_managed_by_backend) {
|
|
61
62
|
configuration.config && watchMultiConfigs([configuration.config]);
|
|
62
63
|
}
|
|
@@ -68,7 +69,9 @@ const OptionsDropdownActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
68
69
|
hideAlertAction,
|
|
69
70
|
options,
|
|
70
71
|
selectedIndex,
|
|
71
|
-
sensor
|
|
72
|
+
sensor?.is_managed_by_backend,
|
|
73
|
+
sensor?.name,
|
|
74
|
+
title,
|
|
72
75
|
]);
|
|
73
76
|
|
|
74
77
|
const iconKit = !!icon_kit_data && icon_kit_data.icon;
|
|
@@ -20,7 +20,7 @@ const buttonStyle = {
|
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const GridItem = ({ item, index, length, doAction, sensor }) => {
|
|
23
|
+
const GridItem = ({ item, index, length, doAction, sensor, title }) => {
|
|
24
24
|
const isFirst = index === 0;
|
|
25
25
|
const isLast = index === length - 1;
|
|
26
26
|
const isNextLine = index % 4 === 0;
|
|
@@ -49,12 +49,15 @@ const GridItem = ({ item, index, length, doAction, sensor }) => {
|
|
|
49
49
|
|
|
50
50
|
const doActionAndWatchConfig = useCallback(
|
|
51
51
|
(actionData) => {
|
|
52
|
-
|
|
52
|
+
const actionName = `${
|
|
53
|
+
sensor?.name
|
|
54
|
+
} ${title?.toLowerCase()} ${text?.toLowerCase()}`;
|
|
55
|
+
doAction(actionData, null, actionName);
|
|
53
56
|
if (sensor?.is_managed_by_backend) {
|
|
54
57
|
config && watchMultiConfigs([config]);
|
|
55
58
|
}
|
|
56
59
|
},
|
|
57
|
-
[config, doAction, sensor
|
|
60
|
+
[config, doAction, sensor?.is_managed_by_backend, sensor?.name, text, title]
|
|
58
61
|
);
|
|
59
62
|
|
|
60
63
|
const iconKit = !!icon_kit_data && icon_kit_data.icon;
|
|
@@ -121,6 +124,7 @@ const StatesGridActionTemplate = ({ actionGroup, doAction, sensor }) => {
|
|
|
121
124
|
length={options.length}
|
|
122
125
|
doAction={doAction}
|
|
123
126
|
sensor={sensor}
|
|
127
|
+
title={title}
|
|
124
128
|
/>
|
|
125
129
|
))}
|
|
126
130
|
</View>
|
|
@@ -8,9 +8,19 @@ import { TESTID } from '../../configs/Constants';
|
|
|
8
8
|
import { Colors } from '../../configs';
|
|
9
9
|
import { Card } from '../../commons/CardShadow';
|
|
10
10
|
|
|
11
|
-
const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
11
|
+
const ThreeButtonTemplate = memo(({ actionGroup, doAction, sensor }) => {
|
|
12
12
|
const t = useTranslations();
|
|
13
13
|
const { configuration } = actionGroup;
|
|
14
|
+
const {
|
|
15
|
+
text1,
|
|
16
|
+
action1_data,
|
|
17
|
+
text2,
|
|
18
|
+
action2_data,
|
|
19
|
+
text3,
|
|
20
|
+
action3_data,
|
|
21
|
+
action_off_data,
|
|
22
|
+
action_on_data,
|
|
23
|
+
} = configuration;
|
|
14
24
|
const [lock, setLock] = useState(false);
|
|
15
25
|
const iconCustom = (icon) => {
|
|
16
26
|
return icon === 'stop' ? (
|
|
@@ -19,32 +29,31 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
19
29
|
<Icon name={icon} size={30} color={Colors.Primary} />
|
|
20
30
|
);
|
|
21
31
|
};
|
|
22
|
-
const onButton1Press = useCallback(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const onButton1Press = useCallback(() => {
|
|
33
|
+
const actionName = `${sensor?.name} ${text1?.toLowerCase()}`;
|
|
34
|
+
doAction(action1_data, null, actionName);
|
|
35
|
+
}, [action1_data, text1, doAction, sensor?.name]);
|
|
36
|
+
|
|
37
|
+
const onButton2Press = useCallback(() => {
|
|
38
|
+
const actionName = `${sensor?.name} ${text2?.toLowerCase()}`;
|
|
39
|
+
doAction(action2_data, null, actionName);
|
|
40
|
+
}, [action2_data, text2, doAction, sensor?.name]);
|
|
41
|
+
|
|
42
|
+
const onButton3Press = useCallback(() => {
|
|
43
|
+
const actionName = `${sensor?.name} ${text3?.toLowerCase()}`;
|
|
44
|
+
doAction(action3_data, null, actionName);
|
|
45
|
+
}, [action3_data, text3, doAction, sensor?.name]);
|
|
46
|
+
|
|
34
47
|
const onChangeSwitch = useCallback(() => {
|
|
35
48
|
if (lock) {
|
|
36
49
|
setLock(false);
|
|
37
|
-
doAction(
|
|
50
|
+
doAction(action_off_data);
|
|
38
51
|
return;
|
|
39
52
|
}
|
|
40
|
-
doAction(
|
|
53
|
+
doAction(action_on_data);
|
|
41
54
|
setLock(true);
|
|
42
|
-
}, [
|
|
43
|
-
|
|
44
|
-
configuration.action_on_data,
|
|
45
|
-
doAction,
|
|
46
|
-
lock,
|
|
47
|
-
]);
|
|
55
|
+
}, [action_off_data, action_on_data, doAction, lock]);
|
|
56
|
+
|
|
48
57
|
const itemLock = (icon, color) => {
|
|
49
58
|
return (
|
|
50
59
|
<>
|
|
@@ -84,7 +93,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
84
93
|
color={Colors.Primary}
|
|
85
94
|
/>
|
|
86
95
|
</View>
|
|
87
|
-
<Text style={styles.text}>{
|
|
96
|
+
<Text style={styles.text}>{text1}</Text>
|
|
88
97
|
</TouchableOpacity>
|
|
89
98
|
|
|
90
99
|
<TouchableOpacity
|
|
@@ -96,7 +105,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
96
105
|
<View style={styles.imageButton}>
|
|
97
106
|
{iconCustom(configuration.icon2)}
|
|
98
107
|
</View>
|
|
99
|
-
<Text style={styles.text}>{
|
|
108
|
+
<Text style={styles.text}>{text2}</Text>
|
|
100
109
|
</TouchableOpacity>
|
|
101
110
|
|
|
102
111
|
<TouchableOpacity
|
|
@@ -112,7 +121,7 @@ const ThreeButtonTemplate = memo(({ actionGroup, doAction }) => {
|
|
|
112
121
|
color={Colors.Primary}
|
|
113
122
|
/>
|
|
114
123
|
</View>
|
|
115
|
-
<Text style={styles.text}>{
|
|
124
|
+
<Text style={styles.text}>{text3}</Text>
|
|
116
125
|
</TouchableOpacity>
|
|
117
126
|
</View>
|
|
118
127
|
<View style={styles.lockSwitch}>
|
|
@@ -146,7 +146,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
146
146
|
<OnOffTemplate
|
|
147
147
|
actionGroup={actionGroup}
|
|
148
148
|
doAction={mockDoAction}
|
|
149
|
-
sensor={{}}
|
|
149
|
+
sensor={{ name: 'Sensor name' }}
|
|
150
150
|
/>
|
|
151
151
|
);
|
|
152
152
|
});
|
|
@@ -157,7 +157,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
157
157
|
await act(async () => {
|
|
158
158
|
await template.props.triggerAction();
|
|
159
159
|
});
|
|
160
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
160
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
161
|
+
action_off_data,
|
|
162
|
+
null,
|
|
163
|
+
'Sensor name turn on / off off'
|
|
164
|
+
);
|
|
161
165
|
expect(watchMultiConfigs).toBeCalledTimes(0);
|
|
162
166
|
});
|
|
163
167
|
|
|
@@ -169,7 +173,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
169
173
|
<OnOffTemplate
|
|
170
174
|
actionGroup={actionGroup}
|
|
171
175
|
doAction={mockDoAction}
|
|
172
|
-
sensor={{}}
|
|
176
|
+
sensor={{ name: 'Sensor name' }}
|
|
173
177
|
/>
|
|
174
178
|
);
|
|
175
179
|
});
|
|
@@ -180,7 +184,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
180
184
|
await act(async () => {
|
|
181
185
|
await template.props.triggerAction();
|
|
182
186
|
});
|
|
183
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
187
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
188
|
+
action_on_data,
|
|
189
|
+
null,
|
|
190
|
+
'Sensor name turn on / off on'
|
|
191
|
+
);
|
|
184
192
|
});
|
|
185
193
|
|
|
186
194
|
test('template OnOffSimpleActionTemplate doAction with is_on_value and is_managed_by_backend', async () => {
|
|
@@ -190,7 +198,7 @@ describe('Test OnOffTemplate', () => {
|
|
|
190
198
|
<OnOffTemplate
|
|
191
199
|
actionGroup={actionGroup}
|
|
192
200
|
doAction={mockDoAction}
|
|
193
|
-
sensor={{ is_managed_by_backend: true }}
|
|
201
|
+
sensor={{ name: 'Sensor name', is_managed_by_backend: true }}
|
|
194
202
|
/>
|
|
195
203
|
);
|
|
196
204
|
});
|
|
@@ -201,7 +209,11 @@ describe('Test OnOffTemplate', () => {
|
|
|
201
209
|
await act(async () => {
|
|
202
210
|
await template.props.triggerAction();
|
|
203
211
|
});
|
|
204
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
212
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
213
|
+
action_off_data,
|
|
214
|
+
null,
|
|
215
|
+
'Sensor name turn on / off off'
|
|
216
|
+
);
|
|
205
217
|
expect(watchMultiConfigs).toBeCalledTimes(2);
|
|
206
218
|
});
|
|
207
219
|
|
|
@@ -23,6 +23,9 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
23
23
|
text: 'UP',
|
|
24
24
|
},
|
|
25
25
|
};
|
|
26
|
+
const sensor = {
|
|
27
|
+
name: 'Sensor name',
|
|
28
|
+
};
|
|
26
29
|
let wrapper;
|
|
27
30
|
|
|
28
31
|
test('render OneBigButtonTemplate', () => {
|
|
@@ -32,6 +35,7 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
32
35
|
<OneBigButtonTemplate
|
|
33
36
|
actionGroup={actionGroup}
|
|
34
37
|
doAction={mockDoAction}
|
|
38
|
+
sensor={sensor}
|
|
35
39
|
/>
|
|
36
40
|
);
|
|
37
41
|
});
|
|
@@ -45,6 +49,10 @@ describe('Test OneBigButtonTemplate', () => {
|
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
expect(mockDoAction).toHaveBeenCalledTimes(1);
|
|
48
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
52
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
53
|
+
action_data,
|
|
54
|
+
null,
|
|
55
|
+
'Sensor name up'
|
|
56
|
+
);
|
|
49
57
|
});
|
|
50
58
|
});
|
|
@@ -10,16 +10,12 @@ import { getTranslate } from '../../../utils/I18n';
|
|
|
10
10
|
import { SCProvider } from '../../../context';
|
|
11
11
|
import { mockSCStore } from '../../../context/mockStore';
|
|
12
12
|
|
|
13
|
-
const wrapComponent = (
|
|
14
|
-
actionGroup,
|
|
15
|
-
mockDoAction,
|
|
16
|
-
is_managed_by_backend = false
|
|
17
|
-
) => (
|
|
13
|
+
const wrapComponent = (actionGroup, mockDoAction, sensor) => (
|
|
18
14
|
<SCProvider initState={mockSCStore({})}>
|
|
19
15
|
<OptionsDropdownActionTemplate
|
|
20
16
|
actionGroup={actionGroup}
|
|
21
17
|
doAction={mockDoAction}
|
|
22
|
-
sensor={
|
|
18
|
+
sensor={sensor}
|
|
23
19
|
/>
|
|
24
20
|
</SCProvider>
|
|
25
21
|
);
|
|
@@ -43,6 +39,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
43
39
|
};
|
|
44
40
|
|
|
45
41
|
let actionGroup;
|
|
42
|
+
let sensor;
|
|
46
43
|
let wrapper;
|
|
47
44
|
|
|
48
45
|
beforeEach(() => {
|
|
@@ -68,12 +65,17 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
68
65
|
icon: 'slack',
|
|
69
66
|
},
|
|
70
67
|
};
|
|
68
|
+
sensor = {
|
|
69
|
+
name: 'Sensor name',
|
|
70
|
+
is_managed_by_backend: false,
|
|
71
|
+
};
|
|
71
72
|
});
|
|
72
73
|
|
|
73
74
|
test('render template', async () => {
|
|
74
75
|
const mockDoAction = jest.fn();
|
|
76
|
+
sensor.is_managed_by_backend = true;
|
|
75
77
|
await act(async () => {
|
|
76
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
78
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
77
79
|
});
|
|
78
80
|
const instance = wrapper.root;
|
|
79
81
|
|
|
@@ -88,9 +90,10 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
88
90
|
|
|
89
91
|
test('render template without selectedOption match, get first one', async () => {
|
|
90
92
|
actionGroup.configuration.options[1].value_int = 3;
|
|
93
|
+
sensor.is_managed_by_backend = true;
|
|
91
94
|
const mockDoAction = jest.fn();
|
|
92
95
|
await act(async () => {
|
|
93
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
96
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
94
97
|
});
|
|
95
98
|
const instance = wrapper.root;
|
|
96
99
|
|
|
@@ -102,7 +105,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
102
105
|
const assertUpdateSelectedOption = async (is_managed_by_backend) => {
|
|
103
106
|
const mockDoAction = jest.fn();
|
|
104
107
|
await act(async () => {
|
|
105
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
108
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
106
109
|
});
|
|
107
110
|
const instance = wrapper.root;
|
|
108
111
|
|
|
@@ -147,7 +150,11 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
147
150
|
});
|
|
148
151
|
expect(alertAction.props.visible).toBeFalsy();
|
|
149
152
|
|
|
150
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
153
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
154
|
+
action_data,
|
|
155
|
+
1,
|
|
156
|
+
'Sensor name fan speed 1'
|
|
157
|
+
);
|
|
151
158
|
is_managed_by_backend
|
|
152
159
|
? expect(watchMultiConfigs).not.toBeCalled()
|
|
153
160
|
: expect(watchMultiConfigs).not.toBeCalled();
|
|
@@ -167,7 +174,7 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
167
174
|
actionGroup.configuration.options[0].value_text = 'level-1';
|
|
168
175
|
const mockDoAction = jest.fn();
|
|
169
176
|
await act(async () => {
|
|
170
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction));
|
|
177
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
171
178
|
});
|
|
172
179
|
const instance = wrapper.root;
|
|
173
180
|
|
|
@@ -212,17 +219,22 @@ describe('Test OptionsDropdownActionTemplate', () => {
|
|
|
212
219
|
});
|
|
213
220
|
expect(alertAction.props.visible).toBeFalsy();
|
|
214
221
|
|
|
215
|
-
expect(mockDoAction).toHaveBeenCalledWith(
|
|
222
|
+
expect(mockDoAction).toHaveBeenCalledWith(
|
|
223
|
+
action_data,
|
|
224
|
+
'level-1',
|
|
225
|
+
'Sensor name fan speed level-1'
|
|
226
|
+
); // doAction with text instead of int
|
|
216
227
|
|
|
217
228
|
expect(texts[1].props.children).toEqual('Level2');
|
|
218
229
|
});
|
|
219
230
|
|
|
220
231
|
test('render template without read config', async () => {
|
|
221
232
|
delete actionGroup.configuration.config;
|
|
233
|
+
sensor.is_managed_by_backend = true;
|
|
222
234
|
|
|
223
235
|
const mockDoAction = jest.fn();
|
|
224
236
|
await act(async () => {
|
|
225
|
-
wrapper = await create(wrapComponent(actionGroup, mockDoAction,
|
|
237
|
+
wrapper = await create(wrapComponent(actionGroup, mockDoAction, sensor));
|
|
226
238
|
});
|
|
227
239
|
const instance = wrapper.root;
|
|
228
240
|
const textDisplaySelected = instance.find(
|