@eohjsc/react-native-smart-city 0.3.65 → 0.3.67
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 -5
- package/src/commons/Action/ItemQuickAction.js +1 -2
- package/src/commons/Action/__test__/ItemQuickAction.test.js +2 -21
- package/src/commons/ActionGroup/CurtainButtonTemplate.js +7 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +19 -6
- package/src/commons/ActionGroup/OnOffTemplate/index.js +31 -57
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +2 -2
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +4 -8
- package/src/commons/ActionGroup/StatesGridActionTemplateStyle.js +1 -1
- package/src/commons/ActionGroup/ThreeButtonTemplate.js +6 -2
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +36 -23
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +16 -10
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +0 -2
- package/src/commons/ActionGroup/__test__/index.test.js +0 -26
- package/src/commons/ActionTemplate/index.js +6 -6
- package/src/commons/Device/LinearChart.js +2 -2
- package/src/commons/Device/PMSensor/{PMSensorIndicatior.js → PMSensorIndicator.js} +5 -4
- package/src/commons/IconComponent/index.js +31 -14
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +6 -6
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +6 -6
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +3 -3
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +7 -1
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -1
- package/src/configs/API.js +2 -0
- package/src/configs/Constants.js +15 -1
- package/src/iot/RemoteControl/Internet.js +3 -0
- package/src/screens/AddNewAction/SelectAction.js +69 -15
- package/src/screens/AddNewAction/SelectSensorDevices.js +3 -0
- package/src/screens/AddNewAutoSmart/index.js +2 -0
- package/src/screens/AllGateway/GatewayDetail/__test__/index.test.js +1 -1
- package/src/screens/AllGateway/GatewayDetail/index.js +2 -2
- package/src/screens/Device/components/SensorDisplayItem.js +2 -5
- package/src/screens/Device/detail.js +17 -47
- package/src/screens/Notification/components/NotificationItem.js +2 -1
- package/src/screens/ScriptDetail/index.js +7 -3
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +2 -2
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -2
- package/src/utils/I18n/translations/en.json +2 -1
- package/src/utils/I18n/translations/vi.json +2 -1
|
@@ -22,16 +22,16 @@ const ActionTemplate = memo(({ device, data, onSelectAction }) => {
|
|
|
22
22
|
|
|
23
23
|
const onPressSelectAction = useCallback(
|
|
24
24
|
(action) => {
|
|
25
|
-
let
|
|
25
|
+
let actionData = null;
|
|
26
26
|
if (device?.device_type === DEVICE_TYPE.ZIGBEE) {
|
|
27
27
|
const state = action?.action_on ? 1 : 0;
|
|
28
|
-
|
|
28
|
+
actionData = { state: state };
|
|
29
29
|
if (action?.allow_config_store_value && action?.config) {
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
actionData.config_id = action.config;
|
|
31
|
+
actionData.config_value = state;
|
|
32
32
|
}
|
|
33
33
|
} else if (device?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
34
|
-
|
|
34
|
+
actionData = { value: action?.action_on ? 1 : 0 };
|
|
35
35
|
}
|
|
36
36
|
setVisible(false);
|
|
37
37
|
setActionName(action?.name);
|
|
@@ -39,7 +39,7 @@ const ActionTemplate = memo(({ device, data, onSelectAction }) => {
|
|
|
39
39
|
onSelectAction({
|
|
40
40
|
action_name: action?.name,
|
|
41
41
|
action: action?.action,
|
|
42
|
-
data:
|
|
42
|
+
data: actionData,
|
|
43
43
|
template: action?.template,
|
|
44
44
|
});
|
|
45
45
|
},
|
|
@@ -32,7 +32,7 @@ const chartOptions = {
|
|
|
32
32
|
{
|
|
33
33
|
name: 'AQI',
|
|
34
34
|
data: [],
|
|
35
|
-
type: '
|
|
35
|
+
type: 'line',
|
|
36
36
|
tooltip: {
|
|
37
37
|
valueDecimals: 2,
|
|
38
38
|
},
|
|
@@ -79,7 +79,7 @@ function LinearChart({ datas }) {
|
|
|
79
79
|
series.push({
|
|
80
80
|
name: datas[i].title,
|
|
81
81
|
data: arr,
|
|
82
|
-
type: '
|
|
82
|
+
type: 'line',
|
|
83
83
|
color: datas[i].color,
|
|
84
84
|
states: {
|
|
85
85
|
inactive: {
|
|
@@ -6,8 +6,10 @@ import styles from './PMSensorIndicatorStyles';
|
|
|
6
6
|
import { roundNumber } from '../../../utils/Utils';
|
|
7
7
|
|
|
8
8
|
//using for PM2.5-10, CO, UV, Rainflow Sensor
|
|
9
|
-
const keyExtractor = (item) =>
|
|
10
|
-
|
|
9
|
+
const keyExtractor = (item, index) => {
|
|
10
|
+
return index;
|
|
11
|
+
};
|
|
12
|
+
const PMSensorIndicator = memo(({ data = [], style }) => {
|
|
11
13
|
const renderItem = useCallback(
|
|
12
14
|
({ item }) => {
|
|
13
15
|
const getValue = ['', null, undefined, NaN].includes(item?.value)
|
|
@@ -15,7 +17,6 @@ const PMSensorIndicatior = memo(({ data = [], style }) => {
|
|
|
15
17
|
: roundNumber(item?.value);
|
|
16
18
|
return (
|
|
17
19
|
<QualityIndicatorItem
|
|
18
|
-
key={item.id.toString()}
|
|
19
20
|
color={item.color}
|
|
20
21
|
standard={item.standard}
|
|
21
22
|
value={getValue}
|
|
@@ -49,4 +50,4 @@ const PMSensorIndicatior = memo(({ data = [], style }) => {
|
|
|
49
50
|
);
|
|
50
51
|
});
|
|
51
52
|
|
|
52
|
-
export default
|
|
53
|
+
export default PMSensorIndicator;
|
|
@@ -3,22 +3,37 @@ import React, { memo, useMemo } from 'react';
|
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
4
|
import { Colors } from '../../configs';
|
|
5
5
|
import FImage from '../FImage';
|
|
6
|
-
import Text from '../Text';
|
|
7
6
|
|
|
8
7
|
// Priority: icon - icon_outlined
|
|
9
8
|
const IconComponent = memo(
|
|
10
9
|
({
|
|
11
|
-
icon_outlined,
|
|
12
10
|
icon,
|
|
13
11
|
isSendingCommand = false,
|
|
14
|
-
size =
|
|
15
|
-
iconSize =
|
|
12
|
+
size = 30,
|
|
13
|
+
iconSize = 30,
|
|
16
14
|
style,
|
|
15
|
+
color,
|
|
17
16
|
}) => {
|
|
18
17
|
let extraStyle = {
|
|
19
18
|
width: size,
|
|
20
19
|
height: size,
|
|
21
20
|
};
|
|
21
|
+
const displayIcon = useMemo(() => {
|
|
22
|
+
let newIcon = `${icon}`;
|
|
23
|
+
if (newIcon && newIcon[0] === newIcon[0].toUpperCase()) {
|
|
24
|
+
newIcon = newIcon[0].toLowerCase() + newIcon.substring(1);
|
|
25
|
+
if (newIcon.includes('Outlined')) {
|
|
26
|
+
newIcon = newIcon.substring(0, newIcon.length - 'Outlined'.length);
|
|
27
|
+
} else if (newIcon.includes('Filled')) {
|
|
28
|
+
newIcon = newIcon.substring(0, newIcon.length - 'Filled'.length);
|
|
29
|
+
} else if (newIcon.includes('TwoTone')) {
|
|
30
|
+
newIcon = newIcon.substring(0, newIcon.length - 'TwoTone'.length);
|
|
31
|
+
}
|
|
32
|
+
newIcon = newIcon.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
33
|
+
}
|
|
34
|
+
return newIcon;
|
|
35
|
+
}, [icon]);
|
|
36
|
+
|
|
22
37
|
const isUrlImage = useMemo(() => {
|
|
23
38
|
if (!icon) {
|
|
24
39
|
return false;
|
|
@@ -30,33 +45,35 @@ const IconComponent = memo(
|
|
|
30
45
|
return isUrl !== null;
|
|
31
46
|
}, [icon]);
|
|
32
47
|
|
|
48
|
+
if (!icon) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
33
51
|
if (isUrlImage) {
|
|
34
52
|
return (
|
|
35
53
|
<FImage
|
|
36
|
-
source={{ uri:
|
|
54
|
+
source={{ uri: displayIcon }}
|
|
37
55
|
style={[styles.iconAction, extraStyle, style]}
|
|
38
56
|
/>
|
|
39
57
|
);
|
|
40
|
-
} else if (icon) {
|
|
58
|
+
} else if (icon.includes('Filled')) {
|
|
41
59
|
return (
|
|
42
60
|
<IconFill
|
|
43
|
-
name={
|
|
44
|
-
color={isSendingCommand ? Colors.TextGray : Colors.Green7}
|
|
61
|
+
name={displayIcon}
|
|
62
|
+
color={isSendingCommand ? Colors.TextGray : color || Colors.Green7}
|
|
45
63
|
size={iconSize}
|
|
46
|
-
style={style}
|
|
64
|
+
style={[extraStyle, style]}
|
|
47
65
|
/>
|
|
48
66
|
);
|
|
49
|
-
} else
|
|
67
|
+
} else {
|
|
50
68
|
return (
|
|
51
69
|
<IconOutline
|
|
52
|
-
name={
|
|
53
|
-
color={isSendingCommand ? Colors.TextGray : Colors.Green7}
|
|
70
|
+
name={displayIcon}
|
|
71
|
+
color={isSendingCommand ? Colors.TextGray : color || Colors.Green7}
|
|
54
72
|
size={iconSize}
|
|
55
|
-
style={style}
|
|
73
|
+
style={[extraStyle, style]}
|
|
56
74
|
/>
|
|
57
75
|
);
|
|
58
76
|
}
|
|
59
|
-
return <Text />;
|
|
60
77
|
}
|
|
61
78
|
);
|
|
62
79
|
|
|
@@ -56,15 +56,15 @@ const NumberUpDownActionTemplate = ({ device, data = {}, onSelectAction }) => {
|
|
|
56
56
|
}, [value, max_value]);
|
|
57
57
|
|
|
58
58
|
const onPressDone = useCallback(() => {
|
|
59
|
-
let
|
|
59
|
+
let actionData = String(value);
|
|
60
60
|
if (device?.device_type !== DEVICE_TYPE.GOOGLE_HOME) {
|
|
61
|
-
|
|
61
|
+
actionData = { temperature: value };
|
|
62
62
|
if (allow_config_store_value && config) {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
actionData.config_id = config;
|
|
64
|
+
actionData.config_value = value;
|
|
65
65
|
}
|
|
66
66
|
} else if (device?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
67
|
-
|
|
67
|
+
actionData = {
|
|
68
68
|
temperature: {
|
|
69
69
|
targetTemperature: value,
|
|
70
70
|
unit: 'C',
|
|
@@ -76,7 +76,7 @@ const NumberUpDownActionTemplate = ({ device, data = {}, onSelectAction }) => {
|
|
|
76
76
|
onSelectAction &&
|
|
77
77
|
onSelectAction({
|
|
78
78
|
action,
|
|
79
|
-
data:
|
|
79
|
+
data: actionData,
|
|
80
80
|
template,
|
|
81
81
|
});
|
|
82
82
|
onClose();
|
|
@@ -29,24 +29,24 @@ const OptionsDropdownActionTemplate = ({ device, data, onSelectAction }) => {
|
|
|
29
29
|
|
|
30
30
|
const onPressDone = useCallback(() => {
|
|
31
31
|
const { value_text, value_int } = options[activeAction];
|
|
32
|
-
let
|
|
32
|
+
let actionData = { level: value_text, key_code: value_int };
|
|
33
33
|
if (allow_config_store_value && config) {
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
actionData.config_id = config;
|
|
35
|
+
actionData.config_value = value_int;
|
|
36
36
|
} else if (device?.device_type === DEVICE_TYPE.LG_THINQ) {
|
|
37
|
-
|
|
37
|
+
actionData = {
|
|
38
38
|
airFlow: {
|
|
39
39
|
windStrength: value_text,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
} else if (device?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
43
|
-
|
|
43
|
+
actionData = value_text;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
onSelectAction &&
|
|
47
47
|
onSelectAction({
|
|
48
48
|
action,
|
|
49
|
-
data:
|
|
49
|
+
data: actionData,
|
|
50
50
|
template,
|
|
51
51
|
});
|
|
52
52
|
setActionName(options[activeAction]?.text);
|
|
@@ -19,16 +19,16 @@ const StatesGridActionTemplate = ({ device, data, onSelectAction }) => {
|
|
|
19
19
|
|
|
20
20
|
const hanleSelectAction = useCallback(
|
|
21
21
|
(item) => {
|
|
22
|
-
let
|
|
22
|
+
let actionData = null;
|
|
23
23
|
const { allow_config_store_value, config, is_on_value } = item;
|
|
24
24
|
if (allow_config_store_value && config) {
|
|
25
|
-
|
|
25
|
+
actionData = { config_id: config, config_value: is_on_value };
|
|
26
26
|
}
|
|
27
27
|
setActionName(item.text);
|
|
28
28
|
onSelectAction &&
|
|
29
29
|
onSelectAction({
|
|
30
30
|
action: item.action,
|
|
31
|
-
data:
|
|
31
|
+
data: actionData,
|
|
32
32
|
template,
|
|
33
33
|
});
|
|
34
34
|
setVisible(false);
|
|
@@ -93,7 +93,13 @@ const ItemOneTap = memo(
|
|
|
93
93
|
return <OneTap />;
|
|
94
94
|
} else if (type === AUTOMATE_TYPE.VALUE_CHANGE) {
|
|
95
95
|
return <ValueChange />;
|
|
96
|
-
} else if (
|
|
96
|
+
} else if (
|
|
97
|
+
[
|
|
98
|
+
AUTOMATE_TYPE.EVENT,
|
|
99
|
+
AUTOMATE_TYPE.EVENT_ACTION,
|
|
100
|
+
AUTOMATE_TYPE.EVENT_SENSOR,
|
|
101
|
+
].includes(type)
|
|
102
|
+
) {
|
|
97
103
|
return <Event />;
|
|
98
104
|
} else {
|
|
99
105
|
return <Schedule />;
|
|
@@ -64,7 +64,7 @@ export const updateConfigChart = async (
|
|
|
64
64
|
data.configs.map((config) => {
|
|
65
65
|
if (config.middle.not_ready.length > 0) {
|
|
66
66
|
const channel = getPusher().subscribe(config.middle.channel);
|
|
67
|
-
channel.bind('caching-value-log-process', async (
|
|
67
|
+
channel.bind('caching-value-log-process', async () => {
|
|
68
68
|
await Promise.all(
|
|
69
69
|
config.middle.not_ready.map((item) =>
|
|
70
70
|
(async () => {
|
package/src/configs/API.js
CHANGED
|
@@ -71,6 +71,8 @@ const API = {
|
|
|
71
71
|
ACTIVITY_LOG: () => SCConfig.apiRoot + '/chip_manager/action_log',
|
|
72
72
|
DISPLAY_ACTIONS: (id) =>
|
|
73
73
|
SCConfig.apiRoot + `/property_manager/sensors/${id}/display_actions/`,
|
|
74
|
+
DISPLAY_EVENTS: (id) =>
|
|
75
|
+
SCConfig.apiRoot + `/property_manager/sensors/${id}/display_events/`,
|
|
74
76
|
CHANGE_SUB_UNIT: (unit_id, station_id, id) =>
|
|
75
77
|
`/property_manager/${unit_id}/sub_units/${station_id}/devices/${id}/change_sub_unit/`,
|
|
76
78
|
ADD_TO_FAVOURITES: (id) =>
|
package/src/configs/Constants.js
CHANGED
|
@@ -83,7 +83,7 @@ export const DEVICE_TYPE = {
|
|
|
83
83
|
GOOGLE_HOME: 'GOOGLE_HOME',
|
|
84
84
|
WIFI_DEVICE: 'WIFI_DEVICE',
|
|
85
85
|
MODBUS: 'MODBUS',
|
|
86
|
-
|
|
86
|
+
IO: 'INPUT/OUTPUT',
|
|
87
87
|
};
|
|
88
88
|
export const PERMISSION_TYPE = {
|
|
89
89
|
ACTION: 'ACTION',
|
|
@@ -119,6 +119,8 @@ export const AUTOMATE_TYPE = {
|
|
|
119
119
|
VALUE_CHANGE: 'value_change',
|
|
120
120
|
SCHEDULE: 'schedule',
|
|
121
121
|
EVENT: 'event',
|
|
122
|
+
EVENT_ACTION: 'event_action',
|
|
123
|
+
EVENT_SENSOR: 'event_sensor',
|
|
122
124
|
ONE_TAP_ONLY: 'one_tap_only',
|
|
123
125
|
AUTOMATE: 'automate',
|
|
124
126
|
AUTOMATION: 'automation',
|
|
@@ -201,6 +203,18 @@ export const AUTOMATES = {
|
|
|
201
203
|
explanation: 'setup_the_conditions',
|
|
202
204
|
icon: Event,
|
|
203
205
|
},
|
|
206
|
+
event_sensor: {
|
|
207
|
+
value: AUTOMATE_TYPE.EVENT_SENSOR,
|
|
208
|
+
title: 'event',
|
|
209
|
+
explanation: 'setup_the_conditions',
|
|
210
|
+
icon: Event,
|
|
211
|
+
},
|
|
212
|
+
event_action: {
|
|
213
|
+
value: AUTOMATE_TYPE.EVENT_ACTION,
|
|
214
|
+
title: 'event',
|
|
215
|
+
explanation: 'setup_the_conditions',
|
|
216
|
+
icon: Event,
|
|
217
|
+
},
|
|
204
218
|
};
|
|
205
219
|
|
|
206
220
|
export const UNIT_TYPES = {
|
|
@@ -10,6 +10,9 @@ export const sendCommandOverInternet = async (sensor, action, data, source) => {
|
|
|
10
10
|
data = data.toString(16).toUpperCase();
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
if (typeof data === 'object') {
|
|
14
|
+
data = JSON.stringify(data);
|
|
15
|
+
}
|
|
13
16
|
ToastBottomHelper.success(t('Sending command via internet'));
|
|
14
17
|
const { success } = await axiosPost(API.DEVICE.TRIGGER_ACTION(sensor.id), {
|
|
15
18
|
key: action.key,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { memo, useCallback, useEffect, useState, useMemo } from 'react';
|
|
2
|
-
import { Image, TouchableOpacity, View } from 'react-native';
|
|
2
|
+
import { Alert, Image, TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { useNavigation } from '@react-navigation/native';
|
|
4
4
|
import { Icon } from '@ant-design/react-native';
|
|
5
5
|
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
CONDITION_TYPES,
|
|
17
17
|
STATE_VALUE_SENSOR_TYPES,
|
|
18
18
|
AccessibilityLabel,
|
|
19
|
+
AUTOMATE_TYPE,
|
|
19
20
|
} from '../../configs/Constants';
|
|
20
21
|
import Routes from '../../utils/Route';
|
|
21
22
|
import styles from './Styles/SelectActionStyles';
|
|
@@ -42,6 +43,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
42
43
|
isCreateNewAction,
|
|
43
44
|
isMultiUnits,
|
|
44
45
|
oldType,
|
|
46
|
+
isSetupEvent,
|
|
45
47
|
} = route?.params || {};
|
|
46
48
|
const [data, setData] = useState([]);
|
|
47
49
|
const [actions, setActions] = useState([]);
|
|
@@ -56,6 +58,8 @@ const SelectAction = memo(({ route }) => {
|
|
|
56
58
|
const { success, data: automateData } = await axiosGet(
|
|
57
59
|
isSelectSensor
|
|
58
60
|
? API.AUTOMATE.GET_SENSOR_CONFIG(device.id)
|
|
61
|
+
: isSetupEvent
|
|
62
|
+
? API.DEVICE.DISPLAY_EVENTS(device.id)
|
|
59
63
|
: API.DEVICE.DISPLAY_ACTIONS(device.id),
|
|
60
64
|
isSelectSensor && {},
|
|
61
65
|
isSelectSensor && true
|
|
@@ -97,7 +101,12 @@ const SelectAction = memo(({ route }) => {
|
|
|
97
101
|
setSensorData(automateData);
|
|
98
102
|
}
|
|
99
103
|
} else {
|
|
100
|
-
|
|
104
|
+
if (isSetupEvent) {
|
|
105
|
+
setData(automateData?.actions);
|
|
106
|
+
setSensorData(automateData?.config_events);
|
|
107
|
+
} else {
|
|
108
|
+
setData(automateData);
|
|
109
|
+
}
|
|
101
110
|
}
|
|
102
111
|
}
|
|
103
112
|
setIsfetched(false);
|
|
@@ -111,6 +120,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
111
120
|
automate.value,
|
|
112
121
|
device.id,
|
|
113
122
|
isSelectSensor,
|
|
123
|
+
isSetupEvent,
|
|
114
124
|
t,
|
|
115
125
|
]);
|
|
116
126
|
|
|
@@ -123,7 +133,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
123
133
|
value: itemTemp?.value,
|
|
124
134
|
config: itemTemp?.id,
|
|
125
135
|
},
|
|
126
|
-
type,
|
|
136
|
+
type: isSetupEvent ? AUTOMATE_TYPE.EVENT_SENSOR : type,
|
|
127
137
|
unit,
|
|
128
138
|
isAutomateTab,
|
|
129
139
|
isSelectSensor,
|
|
@@ -155,7 +165,11 @@ const SelectAction = memo(({ route }) => {
|
|
|
155
165
|
t,
|
|
156
166
|
]);
|
|
157
167
|
const onSave = useCallback(async () => {
|
|
158
|
-
if (
|
|
168
|
+
if (actions.length && !!checkedItem.id) {
|
|
169
|
+
Alert.alert('', t('choose_only_one'));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (isSelectSensor || isSetupEvent) {
|
|
159
173
|
await checkConditionToContinue();
|
|
160
174
|
} else {
|
|
161
175
|
if (automateId) {
|
|
@@ -214,7 +228,7 @@ const SelectAction = memo(({ route }) => {
|
|
|
214
228
|
automateData: {
|
|
215
229
|
action: actions[0].action,
|
|
216
230
|
},
|
|
217
|
-
type,
|
|
231
|
+
type: AUTOMATE_TYPE.EVENT_ACTION,
|
|
218
232
|
unit,
|
|
219
233
|
isAutomateTab,
|
|
220
234
|
isSelectSensor,
|
|
@@ -420,12 +434,55 @@ const SelectAction = memo(({ route }) => {
|
|
|
420
434
|
})
|
|
421
435
|
)
|
|
422
436
|
) : (
|
|
423
|
-
<
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
437
|
+
<View>
|
|
438
|
+
<RenderActionItem
|
|
439
|
+
data={data}
|
|
440
|
+
device={device}
|
|
441
|
+
onSelectAction={handleOnSelectAction}
|
|
442
|
+
accessibilityLabel={AccessibilityLabel.ACTION_ITEM}
|
|
443
|
+
/>
|
|
444
|
+
{/* TODO: Huy - refactor/combine with value_change case */}
|
|
445
|
+
{!!sensorData &&
|
|
446
|
+
sensorData.map((item) => {
|
|
447
|
+
const isHasValue = !!item?.value;
|
|
448
|
+
return (
|
|
449
|
+
<View style={styles.wrapItem} key={item?.id}>
|
|
450
|
+
<TitleCheckBox
|
|
451
|
+
onPress={onChecked}
|
|
452
|
+
id={item?.id}
|
|
453
|
+
title={item?.name}
|
|
454
|
+
titleStyle={styles.titleStyle}
|
|
455
|
+
wrapStyle={styles.wrapStyleCheckBox}
|
|
456
|
+
isChecked={checkedItem?.id === item?.id}
|
|
457
|
+
/>
|
|
458
|
+
<TouchableOpacity
|
|
459
|
+
onPress={onPressItem(item)}
|
|
460
|
+
style={[styles.wrapCondition, styles.shadowView]}
|
|
461
|
+
>
|
|
462
|
+
<Text type="Body" color={Colors.Gray7}>
|
|
463
|
+
{t('condition')}
|
|
464
|
+
</Text>
|
|
465
|
+
<Text
|
|
466
|
+
numberOfLines={1}
|
|
467
|
+
type="H4"
|
|
468
|
+
semibold={isHasValue}
|
|
469
|
+
style={styles.description}
|
|
470
|
+
>
|
|
471
|
+
{isHasValue
|
|
472
|
+
? RenderCondition(item)
|
|
473
|
+
: `${t('no')} ${t('condition')}`}
|
|
474
|
+
</Text>
|
|
475
|
+
{isHasValue && (
|
|
476
|
+
<Image
|
|
477
|
+
source={Images.arrowBack}
|
|
478
|
+
style={styles.arrowRight}
|
|
479
|
+
/>
|
|
480
|
+
)}
|
|
481
|
+
</TouchableOpacity>
|
|
482
|
+
</View>
|
|
483
|
+
);
|
|
484
|
+
})}
|
|
485
|
+
</View>
|
|
429
486
|
)}
|
|
430
487
|
{data?.length === 0 && sensorData?.length === 0 && !isfetched && (
|
|
431
488
|
<View style={styles.noneData}>
|
|
@@ -441,15 +498,12 @@ const SelectAction = memo(({ route }) => {
|
|
|
441
498
|
});
|
|
442
499
|
|
|
443
500
|
const RenderActionItem = ({ device, data, onSelectAction }) => {
|
|
444
|
-
if (!data.length) {
|
|
445
|
-
return null;
|
|
446
|
-
}
|
|
447
501
|
const actionTemplate = [];
|
|
448
502
|
const optionsDropdownActionTemplates = [];
|
|
449
503
|
const numberUpDownActionTemplates = [];
|
|
450
504
|
const statesGridActionTemplates = [];
|
|
451
505
|
|
|
452
|
-
data
|
|
506
|
+
data?.forEach((item) => {
|
|
453
507
|
switch (item.template) {
|
|
454
508
|
case 'on_off_button_action_template':
|
|
455
509
|
case 'one_button_action_template':
|
|
@@ -29,6 +29,7 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
29
29
|
isCreateNewAction,
|
|
30
30
|
isMultiUnits,
|
|
31
31
|
oldType,
|
|
32
|
+
isSetupEvent,
|
|
32
33
|
} = route?.params || {};
|
|
33
34
|
|
|
34
35
|
const [listStation, setListStation] = useState([]);
|
|
@@ -117,6 +118,7 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
117
118
|
isCreateNewAction,
|
|
118
119
|
isMultiUnits,
|
|
119
120
|
oldType,
|
|
121
|
+
isSetupEvent,
|
|
120
122
|
});
|
|
121
123
|
}, [
|
|
122
124
|
navigate,
|
|
@@ -133,6 +135,7 @@ const SelectSensorDevices = memo(({ route }) => {
|
|
|
133
135
|
isCreateNewAction,
|
|
134
136
|
isMultiUnits,
|
|
135
137
|
oldType,
|
|
138
|
+
isSetupEvent,
|
|
136
139
|
]);
|
|
137
140
|
|
|
138
141
|
const onPressClose = useCallback(() => {
|
|
@@ -48,6 +48,7 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
48
48
|
route: Routes.SelectSensorDevices,
|
|
49
49
|
data: {
|
|
50
50
|
title: AUTOMATE_SELECT.SELECT_DEVICE,
|
|
51
|
+
isSetupEvent: true,
|
|
51
52
|
},
|
|
52
53
|
},
|
|
53
54
|
],
|
|
@@ -68,6 +69,7 @@ const AddNewAutoSmart = memo(({ route }) => {
|
|
|
68
69
|
route: Routes.SelectSensorDevices,
|
|
69
70
|
data: {
|
|
70
71
|
title: AUTOMATE_SELECT.SELECT_DEVICE,
|
|
72
|
+
isSetupEvent: true,
|
|
71
73
|
},
|
|
72
74
|
},
|
|
73
75
|
],
|
|
@@ -181,7 +181,7 @@ describe('Test GatewayDetail', () => {
|
|
|
181
181
|
expect(tabPaneCT.props.listTabs[0].data).toEqual([
|
|
182
182
|
{ id: 1, name: 'device 1' },
|
|
183
183
|
]);
|
|
184
|
-
expect(tabPaneCT.props.listTabs[0].title).toEqual(DEVICE_TYPE.
|
|
184
|
+
expect(tabPaneCT.props.listTabs[0].title).toEqual(DEVICE_TYPE.IO);
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
it('test render GatewayDetail onPress TabPanel zigbee', async () => {
|
|
@@ -37,7 +37,7 @@ const GatewayDetail = () => {
|
|
|
37
37
|
() => [
|
|
38
38
|
{
|
|
39
39
|
id: 1,
|
|
40
|
-
title: DEVICE_TYPE.
|
|
40
|
+
title: DEVICE_TYPE.IO,
|
|
41
41
|
data: gatewayDevices?.internal,
|
|
42
42
|
},
|
|
43
43
|
{
|
|
@@ -132,7 +132,7 @@ const GatewayDetail = () => {
|
|
|
132
132
|
]);
|
|
133
133
|
|
|
134
134
|
const isInternal = useMemo(() => {
|
|
135
|
-
return listTabs[selectedIndex]?.title === DEVICE_TYPE.
|
|
135
|
+
return listTabs[selectedIndex]?.title === DEVICE_TYPE.IO;
|
|
136
136
|
}, [listTabs, selectedIndex]);
|
|
137
137
|
|
|
138
138
|
const isModbus = useMemo(() => {
|
|
@@ -6,7 +6,7 @@ import { AccessibilityLabel } from '../../../configs/Constants';
|
|
|
6
6
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
7
7
|
import { DetailHistoryChart } from './DetailHistoryChart';
|
|
8
8
|
import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
|
|
9
|
-
import
|
|
9
|
+
import PMSensorIndicator from '../../../commons/Device/PMSensor/PMSensorIndicator';
|
|
10
10
|
import Anemometer from '../../../commons/Device/WindSpeed/Anemometer';
|
|
11
11
|
import styles from '../styles';
|
|
12
12
|
import Compass from '../../../commons/Device/WindDirection/Compass';
|
|
@@ -109,10 +109,7 @@ export const SensorDisplayItem = ({
|
|
|
109
109
|
);
|
|
110
110
|
case 'simple_list':
|
|
111
111
|
return (
|
|
112
|
-
<
|
|
113
|
-
data={getData(item)}
|
|
114
|
-
style={styles.simpleList}
|
|
115
|
-
/>
|
|
112
|
+
<PMSensorIndicator data={getData(item)} style={styles.simpleList} />
|
|
116
113
|
);
|
|
117
114
|
case 'gauge':
|
|
118
115
|
return (
|