@eohjsc/react-native-smart-city 0.4.56 → 0.4.57
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 +1 -1
- package/src/commons/ActionTemplate/OnOffSimpleAction.js +4 -1
- package/src/commons/ActionTemplate/index.js +2 -1
- package/src/commons/Calendar/styles.js +1 -0
- package/src/commons/Header/HeaderCustom.js +22 -18
- package/src/commons/Header/Styles/HeaderCustomStyles.js +3 -1
- package/src/commons/HeaderAni/index.js +3 -2
- package/src/commons/OneTapTemplate/NumberUpDownActionTemplate.js +3 -1
- package/src/commons/OneTapTemplate/OptionsDropdownActionTemplate.js +2 -0
- package/src/commons/OneTapTemplate/StatesGridActionTemplate.js +1 -0
- package/src/commons/Unit/HeaderUnit/index.js +23 -20
- package/src/commons/Unit/__test__/HeaderUnit.test.js +0 -8
- package/src/commons/WheelDateTimePicker/styles.js +1 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/screens/Automate/AddNewAction/ChooseAction.js +18 -18
- package/src/screens/Automate/AddNewAction/ChooseConfig.js +64 -32
- package/src/screens/Automate/AddNewAction/SelectMonitorDevices.js +8 -3
- package/src/screens/Automate/AddNewAction/Styles/SelectActionStyles.js +6 -0
- package/src/screens/Automate/AddNewAction/__test__/ChooseAction.test.js +73 -0
- package/src/screens/Automate/ScriptDetail/index.js +3 -2
- package/src/screens/Automate/SetSchedule/styles/indexStyles.js +1 -0
- package/src/screens/Device/detail.js +11 -8
- package/src/screens/Device/styles.js +2 -0
- package/src/screens/SelectUnit/index.js +3 -2
- package/src/screens/Template/__test__/GatewayList.test.js +1 -1
- package/src/screens/Template/__test__/Information.test.js +1 -1
- package/src/utils/I18n/translations/en.js +3 -0
- package/src/utils/I18n/translations/vi.js +3 -0
package/package.json
CHANGED
|
@@ -40,7 +40,10 @@ const OnOffSimpleAction = ({ configuration, onPress, template }) => {
|
|
|
40
40
|
{t('text_on')}
|
|
41
41
|
</Text>
|
|
42
42
|
</TouchableOpacity>
|
|
43
|
-
<TouchableOpacity
|
|
43
|
+
<TouchableOpacity
|
|
44
|
+
accessibilityLabel={AccessibilityLabel.ON_OFF_SIMPLE_ACTION_OFF}
|
|
45
|
+
onPress={onPressActionOff}
|
|
46
|
+
>
|
|
44
47
|
<Text type="H4" style={styles.textWithLine}>
|
|
45
48
|
{t('text_off')}
|
|
46
49
|
</Text>
|
|
@@ -37,13 +37,14 @@ const ActionTemplate = memo(({ device, item, onSelectAction }) => {
|
|
|
37
37
|
setActionName(action?.name);
|
|
38
38
|
onSelectAction &&
|
|
39
39
|
onSelectAction({
|
|
40
|
+
index: item?.index,
|
|
40
41
|
action_name: action?.name,
|
|
41
42
|
action: action?.action,
|
|
42
43
|
data: actionData,
|
|
43
44
|
template: action?.template,
|
|
44
45
|
});
|
|
45
46
|
},
|
|
46
|
-
[device?.device_type, onSelectAction]
|
|
47
|
+
[device?.device_type, item?.index, onSelectAction]
|
|
47
48
|
);
|
|
48
49
|
|
|
49
50
|
const renderAction = useMemo(() => {
|
|
@@ -50,14 +50,13 @@ const HeaderCustom = ({
|
|
|
50
50
|
style={[styles.wrap, isShowSeparator && styles.separator, headerStyles]}
|
|
51
51
|
>
|
|
52
52
|
{isCanBack && (
|
|
53
|
-
<TouchableOpacity
|
|
54
|
-
style={[styles.buttonBack, buttonBackStyles]}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
/>
|
|
53
|
+
<TouchableOpacity onPress={handleGoback}>
|
|
54
|
+
<View style={[styles.buttonBack, buttonBackStyles]}>
|
|
55
|
+
<Image
|
|
56
|
+
source={iconLeft || Images.arrowBack}
|
|
57
|
+
style={[styles.iconBack, iconBackStyle]}
|
|
58
|
+
/>
|
|
59
|
+
</View>
|
|
61
60
|
</TouchableOpacity>
|
|
62
61
|
)}
|
|
63
62
|
<View style={[styles.wrapTitle, wrapTitleStyle]}>
|
|
@@ -83,27 +82,32 @@ const HeaderCustom = ({
|
|
|
83
82
|
{isShowRight && (
|
|
84
83
|
<>
|
|
85
84
|
{!isDisableRefresh && (
|
|
86
|
-
<TouchableOpacity
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
85
|
+
<TouchableOpacity onPress={onRefresh}>
|
|
86
|
+
<View style={styles.buttonBack}>
|
|
87
|
+
<Image
|
|
88
|
+
source={Images.refresh}
|
|
89
|
+
style={styles.iconFresh}
|
|
90
|
+
resizeMode={'contain'}
|
|
91
|
+
/>
|
|
92
|
+
</View>
|
|
92
93
|
</TouchableOpacity>
|
|
93
94
|
)}
|
|
94
95
|
<TouchableOpacity
|
|
95
|
-
style={styles.buttonBack}
|
|
96
96
|
onPress={handleShowMenuAction}
|
|
97
97
|
ref={refMenuAction}
|
|
98
98
|
accessibilityLabel={AccessibilityLabel.MENU_POPPER_MORE}
|
|
99
99
|
>
|
|
100
|
-
<
|
|
100
|
+
<View style={styles.buttonBack}>
|
|
101
|
+
<Icon name={'more'} size={27} color={Colors.Black} />
|
|
102
|
+
</View>
|
|
101
103
|
</TouchableOpacity>
|
|
102
104
|
</>
|
|
103
105
|
)}
|
|
104
106
|
{isShowClose && (
|
|
105
|
-
<TouchableOpacity
|
|
106
|
-
<
|
|
107
|
+
<TouchableOpacity onPress={handleClose}>
|
|
108
|
+
<View style={styles.buttonAdd}>
|
|
109
|
+
<Icon name={'close'} size={24} color={Colors.Black} />
|
|
110
|
+
</View>
|
|
107
111
|
</TouchableOpacity>
|
|
108
112
|
)}
|
|
109
113
|
{rightComponent}
|
|
@@ -21,13 +21,15 @@ export default StyleSheet.create({
|
|
|
21
21
|
height: 18,
|
|
22
22
|
},
|
|
23
23
|
buttonBack: {
|
|
24
|
-
width:
|
|
24
|
+
width: 45,
|
|
25
25
|
height: 40,
|
|
26
26
|
justifyContent: 'center',
|
|
27
27
|
alignItems: 'center',
|
|
28
28
|
},
|
|
29
29
|
buttonAdd: {
|
|
30
30
|
paddingRight: 6,
|
|
31
|
+
width: 45,
|
|
32
|
+
height: 40,
|
|
31
33
|
justifyContent: 'center',
|
|
32
34
|
alignItems: 'center',
|
|
33
35
|
},
|
|
@@ -91,11 +91,12 @@ const HeaderAni = memo(
|
|
|
91
91
|
]}
|
|
92
92
|
>
|
|
93
93
|
<TouchableOpacity
|
|
94
|
-
style={styles.btnBack}
|
|
95
94
|
onPress={onPressLeft}
|
|
96
95
|
accessibilityLabel={AccessibilityLabel.ICON_BACK}
|
|
97
96
|
>
|
|
98
|
-
<
|
|
97
|
+
<View style={styles.btnBack}>
|
|
98
|
+
<Icon name={'left'} size={27} color={Colors.Gray9} />
|
|
99
|
+
</View>
|
|
99
100
|
</TouchableOpacity>
|
|
100
101
|
<View styles={styles.wrapRightComponent}>{rightComponent}</View>
|
|
101
102
|
</Animated.View>
|
|
@@ -75,16 +75,18 @@ const NumberUpDownActionTemplate = ({ device, item = {}, onSelectAction }) => {
|
|
|
75
75
|
setActionName(text_format.replace('{number}', value));
|
|
76
76
|
onSelectAction &&
|
|
77
77
|
onSelectAction({
|
|
78
|
+
index: item.index,
|
|
78
79
|
action,
|
|
79
80
|
data: actionData,
|
|
80
81
|
template,
|
|
81
82
|
});
|
|
82
83
|
onClose();
|
|
83
84
|
}, [
|
|
85
|
+
value,
|
|
84
86
|
device?.device_type,
|
|
85
87
|
text_format,
|
|
86
|
-
value,
|
|
87
88
|
onSelectAction,
|
|
89
|
+
item.index,
|
|
88
90
|
action,
|
|
89
91
|
template,
|
|
90
92
|
allow_config_store_value,
|
|
@@ -45,6 +45,7 @@ const OptionsDropdownActionTemplate = ({ device, item, onSelectAction }) => {
|
|
|
45
45
|
|
|
46
46
|
onSelectAction &&
|
|
47
47
|
onSelectAction({
|
|
48
|
+
index: item.index,
|
|
48
49
|
action,
|
|
49
50
|
data: actionData,
|
|
50
51
|
template,
|
|
@@ -58,6 +59,7 @@ const OptionsDropdownActionTemplate = ({ device, item, onSelectAction }) => {
|
|
|
58
59
|
config,
|
|
59
60
|
device?.device_type,
|
|
60
61
|
onSelectAction,
|
|
62
|
+
item.index,
|
|
61
63
|
action,
|
|
62
64
|
template,
|
|
63
65
|
]);
|
|
@@ -44,14 +44,15 @@ const HeaderUnit = memo(
|
|
|
44
44
|
<View style={[styles.container, bottomBorder && styles.bottomBorder]}>
|
|
45
45
|
<TouchableOpacity
|
|
46
46
|
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_BACK}
|
|
47
|
-
style={styles.btnLeft}
|
|
48
47
|
onPress={onPressBack}
|
|
49
48
|
>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
<View style={styles.btnLeft}>
|
|
50
|
+
<Icon
|
|
51
|
+
name={'left'}
|
|
52
|
+
size={27}
|
|
53
|
+
color={transparent ? Colors.White : Colors.Black}
|
|
54
|
+
/>
|
|
55
|
+
</View>
|
|
55
56
|
</TouchableOpacity>
|
|
56
57
|
<View style={[styles.boxTitle, styleBoxTitle]}>
|
|
57
58
|
{title && (
|
|
@@ -66,27 +67,29 @@ const HeaderUnit = memo(
|
|
|
66
67
|
{!hideRightPlus && (
|
|
67
68
|
<TouchableOpacity
|
|
68
69
|
accessibilityLabel={AccessibilityLabel.HEADER_UNIT_BUTTON_ADD}
|
|
69
|
-
style={styles.btnAdd}
|
|
70
70
|
onPress={onPressAdd}
|
|
71
71
|
>
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
<View style={styles.btnAdd}>
|
|
73
|
+
<Icon
|
|
74
|
+
name={'plus'}
|
|
75
|
+
size={27}
|
|
76
|
+
color={transparent ? Colors.White : Colors.Black}
|
|
77
|
+
/>
|
|
78
|
+
</View>
|
|
77
79
|
</TouchableOpacity>
|
|
78
80
|
)}
|
|
79
81
|
<TouchableOpacity
|
|
80
|
-
style={styles.btnMore}
|
|
81
82
|
onPress={onPressMore}
|
|
82
83
|
ref={buttonMoreRef}
|
|
83
84
|
accessibilityLabel={idButtonMore}
|
|
84
85
|
>
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
<View style={styles.btnMore}>
|
|
87
|
+
<Icon
|
|
88
|
+
name={'more'}
|
|
89
|
+
size={27}
|
|
90
|
+
color={transparent ? Colors.White : Colors.Black}
|
|
91
|
+
/>
|
|
92
|
+
</View>
|
|
90
93
|
</TouchableOpacity>
|
|
91
94
|
</View>
|
|
92
95
|
)}
|
|
@@ -108,11 +111,11 @@ const styles = StyleSheet.create({
|
|
|
108
111
|
paddingTop: 15,
|
|
109
112
|
},
|
|
110
113
|
btnLeft: {
|
|
114
|
+
width: 40,
|
|
111
115
|
height: '100%',
|
|
112
116
|
paddingHorizontal: 8,
|
|
113
117
|
justifyContent: 'center',
|
|
114
118
|
alignItems: 'center',
|
|
115
|
-
width: 40,
|
|
116
119
|
},
|
|
117
120
|
boxRight: {
|
|
118
121
|
flexDirection: 'row',
|
|
@@ -127,10 +130,10 @@ const styles = StyleSheet.create({
|
|
|
127
130
|
},
|
|
128
131
|
btnMore: {
|
|
129
132
|
height: '100%',
|
|
133
|
+
width: 40,
|
|
130
134
|
justifyContent: 'center',
|
|
131
135
|
alignItems: 'center',
|
|
132
136
|
marginRight: 16,
|
|
133
|
-
width: 40,
|
|
134
137
|
},
|
|
135
138
|
txtHeader: {
|
|
136
139
|
fontSize: 16,
|
|
@@ -23,13 +23,6 @@ describe('Test HeaderUnit', () => {
|
|
|
23
23
|
const mockedOnBack = jest.fn();
|
|
24
24
|
it('HeaderUnit onPress', async () => {
|
|
25
25
|
let title = 'title';
|
|
26
|
-
let style = {
|
|
27
|
-
height: '100%',
|
|
28
|
-
paddingHorizontal: 8,
|
|
29
|
-
justifyContent: 'center',
|
|
30
|
-
alignItems: 'center',
|
|
31
|
-
width: 40,
|
|
32
|
-
};
|
|
33
26
|
await act(async () => {
|
|
34
27
|
tree = await create(
|
|
35
28
|
<HeaderUnit
|
|
@@ -46,7 +39,6 @@ describe('Test HeaderUnit', () => {
|
|
|
46
39
|
el.props.accessibilityLabel ===
|
|
47
40
|
AccessibilityLabel.HEADER_UNIT_BUTTON_BACK
|
|
48
41
|
);
|
|
49
|
-
expect(item.props.style).toEqual(style);
|
|
50
42
|
await act(async () => {
|
|
51
43
|
item.props.onPress();
|
|
52
44
|
});
|
|
@@ -14,7 +14,8 @@ import NewActionWrapper from './NewActionWrapper';
|
|
|
14
14
|
import moment from 'moment';
|
|
15
15
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
16
16
|
|
|
17
|
-
const RenderActionItem = ({ device, item, handleOnSelectAction }) => {
|
|
17
|
+
const RenderActionItem = ({ device, item, handleOnSelectAction, index }) => {
|
|
18
|
+
item.index = index;
|
|
18
19
|
switch (item.template) {
|
|
19
20
|
case 'on_off_button_action_template':
|
|
20
21
|
case 'one_button_action_template':
|
|
@@ -64,13 +65,8 @@ const RenderActionItem = ({ device, item, handleOnSelectAction }) => {
|
|
|
64
65
|
const ChooseAction = ({ route }) => {
|
|
65
66
|
const t = useTranslations();
|
|
66
67
|
const { navigate } = useNavigation();
|
|
67
|
-
const {
|
|
68
|
-
|
|
69
|
-
device,
|
|
70
|
-
automateId,
|
|
71
|
-
index = -1,
|
|
72
|
-
numberActionCanAdd,
|
|
73
|
-
} = route?.params || {};
|
|
68
|
+
const { unitId, device, automateId, numberActionCanAdd } =
|
|
69
|
+
route?.params || {};
|
|
74
70
|
const [data, setData] = useState([]);
|
|
75
71
|
const [actions, setActions] = useState([]);
|
|
76
72
|
|
|
@@ -117,14 +113,18 @@ const ChooseAction = ({ route }) => {
|
|
|
117
113
|
}, [actions, numberActionCanAdd, automateId, unitId, navigate, t]);
|
|
118
114
|
|
|
119
115
|
const handleOnSelectAction = (action) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
setActions((prevActions) => {
|
|
117
|
+
const index = prevActions.findIndex(
|
|
118
|
+
(item) => item.index === action.index
|
|
119
|
+
);
|
|
120
|
+
if (index !== -1) {
|
|
121
|
+
const newActions = [...prevActions];
|
|
122
|
+
newActions[index] = action;
|
|
123
|
+
return newActions;
|
|
124
|
+
} else {
|
|
125
|
+
return [...prevActions, action];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
128
|
};
|
|
129
129
|
|
|
130
130
|
useEffect(() => {
|
|
@@ -141,11 +141,11 @@ const ChooseAction = ({ route }) => {
|
|
|
141
141
|
>
|
|
142
142
|
<View>
|
|
143
143
|
{!!data?.length &&
|
|
144
|
-
data.map((item) => (
|
|
144
|
+
data.map((item, index) => (
|
|
145
145
|
<RenderActionItem
|
|
146
146
|
device={device}
|
|
147
147
|
item={item}
|
|
148
|
-
|
|
148
|
+
index={index}
|
|
149
149
|
handleOnSelectAction={handleOnSelectAction}
|
|
150
150
|
/>
|
|
151
151
|
))}
|
|
@@ -79,14 +79,6 @@ const ChooseConfig = ({ route }) => {
|
|
|
79
79
|
[configs]
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
const onPressItem = (item) => () => {
|
|
83
|
-
navigate(Routes.SetupConfigCondition, {
|
|
84
|
-
item,
|
|
85
|
-
defaultCondition: conditions[item.id],
|
|
86
|
-
closeScreen,
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
|
|
90
82
|
const renderCondition = useCallback(
|
|
91
83
|
(item) => {
|
|
92
84
|
return generateAutomationDataConditionText(
|
|
@@ -104,29 +96,17 @@ const ChooseConfig = ({ route }) => {
|
|
|
104
96
|
[automate?.type, conditions, t]
|
|
105
97
|
);
|
|
106
98
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<NewActionWrapper
|
|
121
|
-
name={t('set_up {name}', { name: device?.name })}
|
|
122
|
-
nextTitle={t('continue')}
|
|
123
|
-
onNext={onSave}
|
|
124
|
-
canNext={checkedItem?.id}
|
|
125
|
-
>
|
|
126
|
-
{isLoading ? (
|
|
127
|
-
<LoadingSelectAction style={styles.container} />
|
|
128
|
-
) : (
|
|
129
|
-
configs.map((item) => {
|
|
99
|
+
const renderConfigs = useCallback(
|
|
100
|
+
(configs) => {
|
|
101
|
+
const onPressItem = (item) => () => {
|
|
102
|
+
navigate(Routes.SetupConfigCondition, {
|
|
103
|
+
item,
|
|
104
|
+
defaultCondition: conditions[item.id],
|
|
105
|
+
closeScreen,
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
if (configs.length) {
|
|
109
|
+
return configs.map((item) => {
|
|
130
110
|
const hasCondition = conditions[item.id];
|
|
131
111
|
const isChecked = checkedItem?.id === item?.id;
|
|
132
112
|
const isDefault = automate?.config_id === item?.id;
|
|
@@ -170,7 +150,59 @@ const ChooseConfig = ({ route }) => {
|
|
|
170
150
|
</TouchableOpacity>
|
|
171
151
|
</View>
|
|
172
152
|
);
|
|
173
|
-
})
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
return (
|
|
156
|
+
<View style={styles.textCenter}>
|
|
157
|
+
<Text type="Body" center color={Colors.Gray7}>
|
|
158
|
+
{t('end_device_not_support_script', {
|
|
159
|
+
not_support: t(automate?.type),
|
|
160
|
+
support:
|
|
161
|
+
automate?.type === AUTOMATE_TYPE.EVENT
|
|
162
|
+
? t(AUTOMATE_TYPE.VALUE_CHANGE)
|
|
163
|
+
: t(AUTOMATE_TYPE.EVENT),
|
|
164
|
+
})}
|
|
165
|
+
</Text>
|
|
166
|
+
</View>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
[
|
|
171
|
+
automate,
|
|
172
|
+
checkedItem?.id,
|
|
173
|
+
closeScreen,
|
|
174
|
+
conditions,
|
|
175
|
+
navigate,
|
|
176
|
+
onChecked,
|
|
177
|
+
renderCondition,
|
|
178
|
+
t,
|
|
179
|
+
valueEvaluations,
|
|
180
|
+
]
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
fetchData();
|
|
185
|
+
}, [fetchData]);
|
|
186
|
+
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
newCondition &&
|
|
189
|
+
setConditions((prev) => ({
|
|
190
|
+
...prev,
|
|
191
|
+
[newCondition.config]: newCondition,
|
|
192
|
+
}));
|
|
193
|
+
}, [newCondition]);
|
|
194
|
+
|
|
195
|
+
return (
|
|
196
|
+
<NewActionWrapper
|
|
197
|
+
name={t('set_up {name}', { name: device?.name })}
|
|
198
|
+
nextTitle={t('continue')}
|
|
199
|
+
onNext={onSave}
|
|
200
|
+
canNext={checkedItem?.id}
|
|
201
|
+
>
|
|
202
|
+
{isLoading ? (
|
|
203
|
+
<LoadingSelectAction style={styles.container} />
|
|
204
|
+
) : (
|
|
205
|
+
renderConfigs(configs)
|
|
174
206
|
)}
|
|
175
207
|
</NewActionWrapper>
|
|
176
208
|
);
|
|
@@ -10,7 +10,12 @@ import { AUTOMATE_TYPE } from '../../../configs/Constants';
|
|
|
10
10
|
|
|
11
11
|
const SelectMonitorDevices = ({ route }) => {
|
|
12
12
|
const t = useTranslations();
|
|
13
|
-
const {
|
|
13
|
+
const {
|
|
14
|
+
automate = {},
|
|
15
|
+
isCreateNewAction,
|
|
16
|
+
closeScreen,
|
|
17
|
+
unit,
|
|
18
|
+
} = route?.params || {};
|
|
14
19
|
|
|
15
20
|
const [stations, setStations] = useState([]);
|
|
16
21
|
const [listStation, setListStation] = useState([]);
|
|
@@ -26,7 +31,7 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
26
31
|
configs.params.type = 'event';
|
|
27
32
|
}
|
|
28
33
|
await fetchWithCache(
|
|
29
|
-
API.UNIT.DEVICE_SENSOR(automate?.unit),
|
|
34
|
+
API.UNIT.DEVICE_SENSOR(automate?.unit ? automate?.unit : unit.id),
|
|
30
35
|
configs,
|
|
31
36
|
(response) => {
|
|
32
37
|
const { success, data } = response;
|
|
@@ -45,7 +50,7 @@ const SelectMonitorDevices = ({ route }) => {
|
|
|
45
50
|
}
|
|
46
51
|
);
|
|
47
52
|
setLoading(false);
|
|
48
|
-
}, [automate?.type, automate?.unit]);
|
|
53
|
+
}, [automate?.type, automate?.unit, unit.id]);
|
|
49
54
|
|
|
50
55
|
useEffect(() => {
|
|
51
56
|
if (!automate?.sensor_id) {
|
|
@@ -294,4 +294,77 @@ describe('Test ChooseAction', () => {
|
|
|
294
294
|
})
|
|
295
295
|
);
|
|
296
296
|
});
|
|
297
|
+
|
|
298
|
+
test('test press card on/off Simple Action repeatedly', async () => {
|
|
299
|
+
const config1 = 1;
|
|
300
|
+
const response = [
|
|
301
|
+
{
|
|
302
|
+
id: 1,
|
|
303
|
+
title: '',
|
|
304
|
+
template: 'OnOffSimpleActionTemplate',
|
|
305
|
+
configuration: {
|
|
306
|
+
allow_config_store_value: true,
|
|
307
|
+
config: config1,
|
|
308
|
+
action_on: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
309
|
+
action_off: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
];
|
|
313
|
+
mock.onGet(API.DEVICE.DISPLAY_ACTIONS(1)).reply(200, response);
|
|
314
|
+
await act(async () => {
|
|
315
|
+
tree = await renderer.create(wrapComponent(route));
|
|
316
|
+
});
|
|
317
|
+
const instance = tree.root;
|
|
318
|
+
|
|
319
|
+
const cards = instance.findAllByType(SelectActionCard);
|
|
320
|
+
// force all render
|
|
321
|
+
await act(async () => {
|
|
322
|
+
cards.map((card) => card.props.onPress());
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
const simpleActionOn = instance.find(
|
|
326
|
+
(el) =>
|
|
327
|
+
el.props.accessibilityLabel ===
|
|
328
|
+
AccessibilityLabel.ON_OFF_SIMPLE_ACTION_ON &&
|
|
329
|
+
el.type === TouchableOpacity
|
|
330
|
+
);
|
|
331
|
+
await act(async () => {
|
|
332
|
+
await simpleActionOn.props.onPress();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
const simpleActionOnOff = instance.find(
|
|
336
|
+
(el) =>
|
|
337
|
+
el.props.accessibilityLabel ===
|
|
338
|
+
AccessibilityLabel.ON_OFF_SIMPLE_ACTION_OFF &&
|
|
339
|
+
el.type === TouchableOpacity
|
|
340
|
+
);
|
|
341
|
+
await act(async () => {
|
|
342
|
+
await simpleActionOnOff.props.onPress();
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
mock.onPost(API.AUTOMATE.ADD_SCRIPT_ACTION(1)).reply(200);
|
|
346
|
+
const buttonSave = instance.find(
|
|
347
|
+
(el) =>
|
|
348
|
+
el.props.accessibilityLabel === AccessibilityLabel.BOTTOM_VIEW_MAIN &&
|
|
349
|
+
el.type === TouchableOpacity
|
|
350
|
+
);
|
|
351
|
+
await act(async () => {
|
|
352
|
+
await buttonSave.props.onPress();
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
expect(mock.history.post[0].data).toEqual(
|
|
356
|
+
JSON.stringify({
|
|
357
|
+
list_action: [
|
|
358
|
+
{
|
|
359
|
+
action: '94ae262d-46e3-42ff-9d10-516831ecc830',
|
|
360
|
+
data: {
|
|
361
|
+
state: 0,
|
|
362
|
+
config_id: config1,
|
|
363
|
+
config_value: 0,
|
|
364
|
+
},
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
})
|
|
368
|
+
);
|
|
369
|
+
});
|
|
297
370
|
});
|
|
@@ -157,10 +157,11 @@ const ScriptDetail = ({ route }) => {
|
|
|
157
157
|
<TouchableOpacity
|
|
158
158
|
onPress={handleShowMenuAction}
|
|
159
159
|
ref={refMenuAction}
|
|
160
|
-
style={[styles.headerButton, styles.moreButton]}
|
|
161
160
|
accessibilityLabel={AccessibilityLabel.ICON_MORE}
|
|
162
161
|
>
|
|
163
|
-
<
|
|
162
|
+
<View style={[styles.headerButton, styles.moreButton]}>
|
|
163
|
+
<Icon name={'more'} size={27} color={Colors.Black} />
|
|
164
|
+
</View>
|
|
164
165
|
</TouchableOpacity>
|
|
165
166
|
</View>
|
|
166
167
|
),
|
|
@@ -668,20 +668,23 @@ const DeviceDetail = ({ route }) => {
|
|
|
668
668
|
() => (
|
|
669
669
|
<View style={styles.headerRight}>
|
|
670
670
|
<TouchableOpacity
|
|
671
|
-
style={styles.buttonStar}
|
|
672
671
|
onPress={isFavorite ? removeFromFavorites : addToFavorites}
|
|
673
672
|
accessibilityLabel={AccessibilityLabel.HEADER_DEVICE_BUTTON_STAR}
|
|
674
673
|
>
|
|
675
|
-
{
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
674
|
+
<View style={styles.buttonStar}>
|
|
675
|
+
{isFavorite ? (
|
|
676
|
+
<IconFill name="star" size={25} color={Colors.Yellow6} />
|
|
677
|
+
) : (
|
|
678
|
+
<IconOutline name="star" size={25} />
|
|
679
|
+
)}
|
|
680
|
+
</View>
|
|
680
681
|
</TouchableOpacity>
|
|
681
682
|
|
|
682
683
|
{isShowSetupEmergencyContact && (
|
|
683
|
-
<TouchableOpacity
|
|
684
|
-
<
|
|
684
|
+
<TouchableOpacity onPress={onPressSetting}>
|
|
685
|
+
<View style={styles.button}>
|
|
686
|
+
<Icon name="setting" size={25} color={Colors.Black} />
|
|
687
|
+
</View>
|
|
685
688
|
</TouchableOpacity>
|
|
686
689
|
)}
|
|
687
690
|
|
|
@@ -128,11 +128,12 @@ const SelectUnit = () => {
|
|
|
128
128
|
const rightComponent = useMemo(
|
|
129
129
|
() => (
|
|
130
130
|
<TouchableOpacity
|
|
131
|
-
style={styles.buttonClose}
|
|
132
131
|
onPress={handleOnGoBackAndClose}
|
|
133
132
|
accessibilityLabel={AccessibilityLabel.ICON_CLOSE}
|
|
134
133
|
>
|
|
135
|
-
<
|
|
134
|
+
<View style={styles.buttonClose}>
|
|
135
|
+
<Icon name={'close'} size={24} color={Colors.Black} />
|
|
136
|
+
</View>
|
|
136
137
|
</TouchableOpacity>
|
|
137
138
|
),
|
|
138
139
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1037,6 +1037,9 @@ export default {
|
|
|
1037
1037
|
update_smart: 'Update Smart',
|
|
1038
1038
|
automate: 'Automate',
|
|
1039
1039
|
smart: 'Smart',
|
|
1040
|
+
end_device_not_support_script:
|
|
1041
|
+
// eslint-disable-next-line max-len
|
|
1042
|
+
'This device does not support installing "{not_support}" scripts, but you can use "{support}" scripts to perform the desired setup.',
|
|
1040
1043
|
smart_account: 'Smart account',
|
|
1041
1044
|
delete_smart_account: 'Delete smart account',
|
|
1042
1045
|
this_action_will_remove_all_related_devices:
|
|
@@ -1052,6 +1052,9 @@ export default {
|
|
|
1052
1052
|
smart: 'Thông minh',
|
|
1053
1053
|
smart_account: 'Tài khoản thông minh',
|
|
1054
1054
|
delete_smart_account: 'Xóa tài khoản thông minh',
|
|
1055
|
+
end_device_not_support_script:
|
|
1056
|
+
// eslint-disable-next-line max-len
|
|
1057
|
+
'Thiết bị này không hỗ trợ việc cài đặt kịch bản "{not_support}", nhưng bạn có thể sử dụng kịch bản "{support}" để thực hiện việc cài đặt mong muốn.',
|
|
1055
1058
|
this_action_will_remove_all_related_devices:
|
|
1056
1059
|
'Hành động này sẽ xóa tất cả các thiết bị liên quan và nó sẽ cài đặt vĩnh viễn. Bạn có muốn tiếp tục không?',
|
|
1057
1060
|
edit_device: 'Chỉnh sửa thiết bị',
|