@eohjsc/react-native-smart-city 0.5.4-rc9 → 0.5.5
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 +2 -3
- package/src/commons/Grid/GridItemStyles.js +2 -6
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +14 -11
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +34 -7
- package/src/screens/Sharing/SelectShareDevice.js +1 -2
- package/src/utils/I18n/translations/en.js +2 -2
- package/src/utils/I18n/translations/vi.js +2 -2
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.5.
|
|
4
|
+
"version": "0.5.5",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -171,7 +171,6 @@
|
|
|
171
171
|
"react-native-geocoder": "^0.5.0",
|
|
172
172
|
"react-native-gesture-handler": "^1.7.0",
|
|
173
173
|
"react-native-get-location": "^2.0.0",
|
|
174
|
-
"react-native-highcharts2": "^1.2.0",
|
|
175
174
|
"react-native-image-crop-picker": "^0.37.2",
|
|
176
175
|
"react-native-image-resizer": "^1.4.5",
|
|
177
176
|
"react-native-input-credit-card": "^0.5.5",
|
|
@@ -195,7 +194,7 @@
|
|
|
195
194
|
"react-native-safe-area-context": "^3.1.1",
|
|
196
195
|
"react-native-screens": "^2.9.0",
|
|
197
196
|
"react-native-super-grid": "^4.0.3",
|
|
198
|
-
"react-native-svg": "
|
|
197
|
+
"react-native-svg": "^12.1.0",
|
|
199
198
|
"react-native-toast-message": "^2.1.1",
|
|
200
199
|
"react-native-udp": "4.1.3",
|
|
201
200
|
"react-native-version-check": "^3.4.2",
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const marginItem = 12;
|
|
5
|
-
const marginHorizontal = 16;
|
|
6
|
-
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
2
|
+
import { Colors } from '../../configs';
|
|
7
3
|
|
|
8
4
|
export default StyleSheet.create({
|
|
9
5
|
container: {
|
|
@@ -17,7 +13,7 @@ export default StyleSheet.create({
|
|
|
17
13
|
shadowOpacity: 0.1,
|
|
18
14
|
shadowRadius: 3,
|
|
19
15
|
elevation: 4,
|
|
20
|
-
width:
|
|
16
|
+
width: '100%',
|
|
21
17
|
backgroundColor: Colors.White,
|
|
22
18
|
justifyContent: 'space-between',
|
|
23
19
|
marginBottom: 16,
|
|
@@ -17,10 +17,11 @@ import Routes from '../../../utils/Route';
|
|
|
17
17
|
import ModalCustom from '../../../commons/Modal/ModalCustom';
|
|
18
18
|
import { ToastBottomHelper } from '../../../utils/Utils';
|
|
19
19
|
|
|
20
|
-
const valueEvaluationToOptions = (valueEvaluation) => {
|
|
20
|
+
const valueEvaluationToOptions = (valueEvaluation, config, t) => {
|
|
21
21
|
if (valueEvaluation.template === 'range') {
|
|
22
22
|
return valueEvaluation.configuration.ranges.map((range, index) => ({
|
|
23
|
-
|
|
23
|
+
// eslint-disable-next-line max-len
|
|
24
|
+
title: `${range.evaluate?.text} (${range.start} ${range.start_condition} "${config.name}" ${range.end_condition} ${range.end})`,
|
|
24
25
|
condition: 'value_evaluation',
|
|
25
26
|
value: [valueEvaluation.id, index],
|
|
26
27
|
}));
|
|
@@ -28,12 +29,12 @@ const valueEvaluationToOptions = (valueEvaluation) => {
|
|
|
28
29
|
if (valueEvaluation.template === 'boolean') {
|
|
29
30
|
return [
|
|
30
31
|
{
|
|
31
|
-
title: valueEvaluation.configuration?.off?.text
|
|
32
|
+
title: `${valueEvaluation.configuration?.off?.text} ("${config.name}" = 0)`,
|
|
32
33
|
condition: 'value_evaluation',
|
|
33
34
|
value: [valueEvaluation.id, 0],
|
|
34
35
|
},
|
|
35
36
|
{
|
|
36
|
-
title: valueEvaluation.configuration?.on?.text
|
|
37
|
+
title: `${valueEvaluation.configuration?.on?.text} ("${config.name}" = 1)`,
|
|
37
38
|
condition: 'value_evaluation',
|
|
38
39
|
value: [valueEvaluation.id, 1],
|
|
39
40
|
},
|
|
@@ -69,14 +70,13 @@ const SetupConfigCondition = () => {
|
|
|
69
70
|
if (config?.value_evaluations?.length) {
|
|
70
71
|
const options = [];
|
|
71
72
|
config.value_evaluations.forEach((valueEvaluation) => {
|
|
72
|
-
options.push(...valueEvaluationToOptions(valueEvaluation));
|
|
73
|
+
options.push(...valueEvaluationToOptions(valueEvaluation, config, t));
|
|
73
74
|
});
|
|
74
75
|
return options;
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
return [];
|
|
78
|
-
}, [config
|
|
79
|
-
|
|
79
|
+
}, [config, t]);
|
|
80
80
|
const setupCustomCondition = () => {
|
|
81
81
|
setSelectedCondition('custom');
|
|
82
82
|
setIsShowModal(true);
|
|
@@ -117,7 +117,7 @@ const SetupConfigCondition = () => {
|
|
|
117
117
|
setupCustomCondition('custom');
|
|
118
118
|
}}
|
|
119
119
|
>
|
|
120
|
-
<Text type="Body">{t('customize
|
|
120
|
+
<Text type="Body">{t('customize')}</Text>
|
|
121
121
|
</GridItem>
|
|
122
122
|
</View>
|
|
123
123
|
<ModalCustom
|
|
@@ -126,7 +126,9 @@ const SetupConfigCondition = () => {
|
|
|
126
126
|
style={styles.modal}
|
|
127
127
|
>
|
|
128
128
|
<View style={styles.modalContent}>
|
|
129
|
-
<Text type="Body">
|
|
129
|
+
<Text type="Body">
|
|
130
|
+
{t('when_value_is', { config_name: config.name })}
|
|
131
|
+
</Text>
|
|
130
132
|
<List renderHeader={t('condition')}>
|
|
131
133
|
{normalConditions.map((item) => {
|
|
132
134
|
return (
|
|
@@ -147,9 +149,10 @@ const SetupConfigCondition = () => {
|
|
|
147
149
|
<InputItem
|
|
148
150
|
keyboardType="decimal-pad"
|
|
149
151
|
type="number"
|
|
150
|
-
maxLength={
|
|
152
|
+
maxLength={10}
|
|
151
153
|
onChange={(value) => {
|
|
152
|
-
|
|
154
|
+
const floatValue = parseFloat(value.replace(',', '.'));
|
|
155
|
+
automate.value = floatValue;
|
|
153
156
|
}}
|
|
154
157
|
style={styles.numberInput}
|
|
155
158
|
/>
|
|
@@ -57,6 +57,7 @@ describe('Test SetupConfigCondition', () => {
|
|
|
57
57
|
params: {
|
|
58
58
|
config: {
|
|
59
59
|
id: 1,
|
|
60
|
+
name: 'config name',
|
|
60
61
|
decimal_behind: 0,
|
|
61
62
|
title: 'is below (<)',
|
|
62
63
|
sensor_type: 'air_quality',
|
|
@@ -67,16 +68,28 @@ describe('Test SetupConfigCondition', () => {
|
|
|
67
68
|
configuration: {
|
|
68
69
|
ranges: [
|
|
69
70
|
{
|
|
71
|
+
end: 1,
|
|
72
|
+
end_condition: '<',
|
|
73
|
+
start: 2,
|
|
74
|
+
start_condition: '>=',
|
|
70
75
|
evaluate: {
|
|
71
76
|
text: 'Case 1',
|
|
72
77
|
},
|
|
73
78
|
},
|
|
74
79
|
{
|
|
80
|
+
end: 1,
|
|
81
|
+
end_condition: '<',
|
|
82
|
+
start: 2,
|
|
83
|
+
start_condition: '>=',
|
|
75
84
|
evaluate: {
|
|
76
85
|
text: 'Case 2',
|
|
77
86
|
},
|
|
78
87
|
},
|
|
79
88
|
{
|
|
89
|
+
end: 1,
|
|
90
|
+
end_condition: '<',
|
|
91
|
+
start: 2,
|
|
92
|
+
start_condition: '>=',
|
|
80
93
|
evaluate: {
|
|
81
94
|
text: 'Case 3',
|
|
82
95
|
},
|
|
@@ -108,9 +121,15 @@ describe('Test SetupConfigCondition', () => {
|
|
|
108
121
|
|
|
109
122
|
const gridItems = instance.findAllByType(GridItem);
|
|
110
123
|
|
|
111
|
-
expect(gridItems[0].findByType(Text).props.children).toEqual(
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
expect(gridItems[0].findByType(Text).props.children).toEqual(
|
|
125
|
+
'Case 1 (2 >= "config name" < 1)'
|
|
126
|
+
);
|
|
127
|
+
expect(gridItems[1].findByType(Text).props.children).toEqual(
|
|
128
|
+
'Case 2 (2 >= "config name" < 1)'
|
|
129
|
+
);
|
|
130
|
+
expect(gridItems[2].findByType(Text).props.children).toEqual(
|
|
131
|
+
'Case 3 (2 >= "config name" < 1)'
|
|
132
|
+
);
|
|
114
133
|
});
|
|
115
134
|
|
|
116
135
|
it('render boolean value evaluation', async () => {
|
|
@@ -118,6 +137,7 @@ describe('Test SetupConfigCondition', () => {
|
|
|
118
137
|
params: {
|
|
119
138
|
config: {
|
|
120
139
|
id: 1,
|
|
140
|
+
name: 'config name',
|
|
121
141
|
title: 'is below (<)',
|
|
122
142
|
sensor_type: 'air_quality',
|
|
123
143
|
value_evaluations: [BOOLEAN_VALUE_EVALUATION_CONFIGURATION],
|
|
@@ -132,10 +152,14 @@ describe('Test SetupConfigCondition', () => {
|
|
|
132
152
|
|
|
133
153
|
const gridItems = instance.findAllByType(GridItem);
|
|
134
154
|
expect(gridItems).toHaveLength(3);
|
|
135
|
-
expect(gridItems[0].findByType(Text).props.children).toEqual(
|
|
136
|
-
|
|
155
|
+
expect(gridItems[0].findByType(Text).props.children).toEqual(
|
|
156
|
+
'Case Off ("config name" = 0)'
|
|
157
|
+
);
|
|
158
|
+
expect(gridItems[1].findByType(Text).props.children).toEqual(
|
|
159
|
+
'Case On ("config name" = 1)'
|
|
160
|
+
);
|
|
137
161
|
expect(gridItems[2].findByType(Text).props.children).toEqual(
|
|
138
|
-
'Customize
|
|
162
|
+
'Customize conditions'
|
|
139
163
|
);
|
|
140
164
|
});
|
|
141
165
|
|
|
@@ -145,6 +169,7 @@ describe('Test SetupConfigCondition', () => {
|
|
|
145
169
|
automate: {},
|
|
146
170
|
config: {
|
|
147
171
|
id: 1,
|
|
172
|
+
name: 'config name',
|
|
148
173
|
title: 'is below (<)',
|
|
149
174
|
sensor_type: 'air_quality',
|
|
150
175
|
value_evaluations: [BOOLEAN_VALUE_EVALUATION_CONFIGURATION],
|
|
@@ -178,6 +203,7 @@ describe('Test SetupConfigCondition', () => {
|
|
|
178
203
|
automate: {},
|
|
179
204
|
config: {
|
|
180
205
|
id: 1,
|
|
206
|
+
name: 'config name',
|
|
181
207
|
title: 'is below (<)',
|
|
182
208
|
},
|
|
183
209
|
},
|
|
@@ -229,8 +255,9 @@ describe('Test SetupConfigCondition', () => {
|
|
|
229
255
|
const testConditionValue = async (value, message) => {
|
|
230
256
|
useRoute.mockReturnValue({
|
|
231
257
|
params: {
|
|
232
|
-
|
|
258
|
+
config: {
|
|
233
259
|
id: 1,
|
|
260
|
+
name: 'config name',
|
|
234
261
|
decimal_behind: 0,
|
|
235
262
|
title: 'is below (<)',
|
|
236
263
|
sensor_type: 'air_quality',
|
|
@@ -222,9 +222,8 @@ const SelectShareDevice = ({ route }) => {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
|
|
225
|
+
setLoading(false);
|
|
226
226
|
if (read_permissions.length === 0 && control_permissions.length === 0) {
|
|
227
|
-
setLoading(false);
|
|
228
227
|
Alert.alert('', t('choose_at_least_one'));
|
|
229
228
|
return;
|
|
230
229
|
}
|
|
@@ -1466,9 +1466,9 @@ export default {
|
|
|
1466
1466
|
bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
|
|
1467
1467
|
widget_have_not_been_shared:
|
|
1468
1468
|
'{widget} widget have not been shared. Please contact the owner',
|
|
1469
|
-
|
|
1469
|
+
customize: 'Customize conditions',
|
|
1470
1470
|
uri_invalid: 'URI invalid',
|
|
1471
|
-
when_value_is: '
|
|
1471
|
+
when_value_is: 'Activates when "{config_name}" value is',
|
|
1472
1472
|
template_not_supported: 'Widget "{template}" not yet supported',
|
|
1473
1473
|
invited_user: 'Invited user {user}',
|
|
1474
1474
|
enter_value: 'Enter value',
|
|
@@ -1476,9 +1476,9 @@ export default {
|
|
|
1476
1476
|
bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
|
|
1477
1477
|
widget_have_not_been_shared:
|
|
1478
1478
|
'Tiện ích {widget} chưa được chia sẽ. Vui lòng liên hệ với chủ sở hữu',
|
|
1479
|
-
|
|
1479
|
+
customize: 'Tùy chỉnh điều kiện',
|
|
1480
1480
|
uri_invalid: 'URI không hợp lệ',
|
|
1481
|
-
when_value_is: '
|
|
1481
|
+
when_value_is: 'Kích hoạt khi giá trị "{config_name}"',
|
|
1482
1482
|
template_not_supported: 'Tiện ích "{template}" chưa được hỗ trợ',
|
|
1483
1483
|
invited_user: 'Đã mời người dùng {user}',
|
|
1484
1484
|
enter_value: 'Nhập giá trị',
|