@eohjsc/react-native-smart-city 0.7.25 → 0.7.27
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/Images/Common/search-menu.svg +7 -0
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplateStyle.js +2 -1
- package/src/commons/ActionGroup/OneBigButtonTemplateStyle.js +1 -2
- package/src/commons/ActionGroup/SliderRangeTemplate.js +1 -3
- package/src/commons/ActionGroup/TerminalBoxTemplate.js +1 -4
- package/src/commons/ActionGroup/TextBoxTemplate.js +1 -5
- package/src/commons/ActionGroup/ThreeButtonTemplate/components/ThreeButtonDefaultStyles.js +1 -1
- package/src/commons/ActionGroup/__test__/index.test.js +51 -0
- package/src/commons/ActionGroup/index.js +4 -0
- package/src/commons/Dashboard/MyPinnedSharedUnit/index.js +0 -10
- package/src/commons/Dashboard/MyUnit/__test__/MyUnit.test.js +114 -48
- package/src/commons/Dashboard/MyUnit/index.js +74 -27
- package/src/commons/Dashboard/MyUnit/styles.js +16 -1
- package/src/commons/DateTimeRangeChange/index.js +1 -1
- package/src/commons/SelectUnit/index.js +19 -5
- package/src/commons/SelectUnit/styles.js +0 -1
- package/src/commons/Widgets/IFrame/IFrameStyles.js +1 -0
- package/src/commons/Widgets/IFrameWithConfig/IFrameWithConfigStyles.js +1 -0
- package/src/configs/API.js +4 -0
- package/src/configs/Constants.js +3 -0
- package/src/context/reducer.ts +0 -5
- package/src/navigations/UnitStack.js +8 -0
- package/src/screens/ActivityLog/FilterPopup.js +4 -79
- package/src/screens/ActivityLog/__test__/FilterPopup.test.js +2 -6
- package/src/screens/ActivityLog/__test__/index.test.js +51 -29
- package/src/screens/ActivityLog/index.js +0 -1
- package/src/screens/ActivityLog/styles/filterPopupStyles.js +5 -2
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +27 -0
- package/src/screens/Device/components/DonutChart.js +5 -14
- package/src/screens/Device/components/SensorDisplayItem.js +107 -74
- package/src/screens/Device/components/VisualChart.js +0 -12
- package/src/screens/Device/styles.js +11 -0
- package/src/screens/SubUnit/AddSubUnit.js +18 -8
- package/src/screens/SubUnit/__test__/AddSubUnit.test.js +5 -3
- package/src/screens/Unit/GoToDetailUnit.js +30 -0
- package/src/screens/Unit/__test__/GoToDetailUnit.test.js +103 -0
- package/src/utils/I18n/translations/en.js +1 -0
- package/src/utils/I18n/translations/vi.js +1 -0
- package/src/utils/Route/index.js +1 -0
- package/src/utils/Storage.js +0 -2
- package/src/utils/Utils.js +2 -1
- package/src/utils/Functions/preloadImages.js +0 -38
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useNavigation } from '@react-navigation/native';
|
|
2
|
-
import {
|
|
3
|
-
import React, { memo, useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
4
3
|
import { ScrollView, TouchableOpacity, View } from 'react-native';
|
|
5
4
|
|
|
6
5
|
import { API } from '../../configs';
|
|
7
6
|
import { RadioCircle, Section, ViewButtonBottom } from '../../commons';
|
|
7
|
+
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
8
8
|
import { axiosGet } from '../../utils/Apis/axios';
|
|
9
|
+
import { convertToSlug } from '../../utils/Functions/Search';
|
|
9
10
|
import Text from '../../commons/Text';
|
|
11
|
+
import { Search } from '../../commons/DevMode';
|
|
10
12
|
import AccessibilityLabel from '../../configs/AccessibilityLabel';
|
|
11
13
|
import styles from './styles';
|
|
12
14
|
import { HeaderCustom } from '../Header';
|
|
@@ -48,11 +50,20 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
|
|
|
48
50
|
const t = useTranslations();
|
|
49
51
|
const { goBack } = useNavigation();
|
|
50
52
|
const [selectedIndex, setSelectedIndex] = useState(-1);
|
|
53
|
+
const [search, setSearch] = useState('');
|
|
51
54
|
const [units, setUnits] = useState([]);
|
|
52
55
|
|
|
56
|
+
const filterUnits = useMemo(() => {
|
|
57
|
+
setSelectedIndex(-1);
|
|
58
|
+
return units.filter((unit) => {
|
|
59
|
+
const text = convertToSlug(search);
|
|
60
|
+
return convertToSlug(unit.name).includes(text);
|
|
61
|
+
});
|
|
62
|
+
}, [units, search]);
|
|
63
|
+
|
|
53
64
|
const onRightClick = useCallback(() => {
|
|
54
|
-
onPressNext(
|
|
55
|
-
}, [onPressNext, selectedIndex,
|
|
65
|
+
onPressNext(filterUnits[selectedIndex]);
|
|
66
|
+
}, [onPressNext, selectedIndex, filterUnits]);
|
|
56
67
|
|
|
57
68
|
useEffect(() => {
|
|
58
69
|
(async () => {
|
|
@@ -66,6 +77,7 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
|
|
|
66
77
|
}
|
|
67
78
|
})();
|
|
68
79
|
}, []);
|
|
80
|
+
|
|
69
81
|
return (
|
|
70
82
|
<View
|
|
71
83
|
style={styles.container}
|
|
@@ -73,6 +85,7 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
|
|
|
73
85
|
>
|
|
74
86
|
<HeaderCustom title={title} isShowSeparator />
|
|
75
87
|
<Text style={styles.subtitle}>{subTitle}</Text>
|
|
88
|
+
<Search onSearch={setSearch} />
|
|
76
89
|
<View style={styles.contentContainer}>
|
|
77
90
|
<ScrollView
|
|
78
91
|
style={styles.scrollContainer}
|
|
@@ -80,13 +93,14 @@ const SelectUnit = ({ title, subTitle, onPressNext }) => {
|
|
|
80
93
|
scrollIndicatorInsets={{ right: 1 }}
|
|
81
94
|
>
|
|
82
95
|
<Section type={'border'}>
|
|
83
|
-
{
|
|
96
|
+
{filterUnits.map((item, index) => (
|
|
84
97
|
<UnitItem
|
|
85
98
|
key={item?.id?.toString()}
|
|
86
99
|
item={item}
|
|
87
100
|
index={index}
|
|
88
101
|
setSelectedIndex={setSelectedIndex}
|
|
89
102
|
selectedIndex={selectedIndex}
|
|
103
|
+
accessibilityLabel={AccessibilityLabel.ITEM_UNIT}
|
|
90
104
|
/>
|
|
91
105
|
))}
|
|
92
106
|
</Section>
|
package/src/configs/API.js
CHANGED
|
@@ -41,6 +41,10 @@ const API = {
|
|
|
41
41
|
STAR_AUTOMATE_SCRIPTS: (id) =>
|
|
42
42
|
`/property_manager/units/${id}/star_automate_scripts/`,
|
|
43
43
|
},
|
|
44
|
+
UNIT_V2: {
|
|
45
|
+
MY_UNITS: (page, pageSize) =>
|
|
46
|
+
`/property_manager/units_v2/my_with_devices/?page=${page}&page_size=${pageSize}`,
|
|
47
|
+
},
|
|
44
48
|
SUB_UNIT: {
|
|
45
49
|
END_DEVICES_STATUS: (stationId) =>
|
|
46
50
|
`/property_manager/iot_dashboard/stations_v2/${stationId}/end_devices_status/`,
|
package/src/configs/Constants.js
CHANGED
|
@@ -98,6 +98,9 @@ const marginItem = 12;
|
|
|
98
98
|
const marginHorizontal = 16;
|
|
99
99
|
const widthItem = (Constants.width - marginHorizontal * 2 - marginItem) / 2;
|
|
100
100
|
const heightItem = (widthItem / 166) * 106;
|
|
101
|
+
|
|
102
|
+
export const PAGE_SIZE = 10;
|
|
103
|
+
|
|
101
104
|
export const DEVICE_SIZE = {
|
|
102
105
|
width: widthItem,
|
|
103
106
|
height: heightItem,
|
package/src/context/reducer.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
BluetoothType,
|
|
16
16
|
} from './actionType';
|
|
17
17
|
import _ from 'lodash';
|
|
18
|
-
import { STORAGE_KEY, removeMultiple } from '../utils/Storage.js';
|
|
19
18
|
import { AppState } from 'react-native';
|
|
20
19
|
|
|
21
20
|
export type ContextData = {
|
|
@@ -582,10 +581,6 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
582
581
|
};
|
|
583
582
|
|
|
584
583
|
case Action.LOGOUT:
|
|
585
|
-
removeMultiple([
|
|
586
|
-
STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_UNITS,
|
|
587
|
-
STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_SHARE_UNIT,
|
|
588
|
-
]);
|
|
589
584
|
return {
|
|
590
585
|
...currentState,
|
|
591
586
|
};
|
|
@@ -60,6 +60,7 @@ import TDSGuide from '../screens/TDSGuide';
|
|
|
60
60
|
import ChooseLocation from '../screens/Unit/ChooseLocation';
|
|
61
61
|
import UnitDetail from '../screens/Unit/Detail';
|
|
62
62
|
import ManageUnit from '../screens/Unit/ManageUnit';
|
|
63
|
+
import GoToDetailUnit from '../screens/Unit/GoToDetailUnit';
|
|
63
64
|
import SelectAddress from '../screens/Unit/SelectAddress';
|
|
64
65
|
import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
|
|
65
66
|
import ListSmartAccount from '../screens/Unit/SmartAccount';
|
|
@@ -223,6 +224,13 @@ export const UnitStack = memo((props) => {
|
|
|
223
224
|
headerShown: false,
|
|
224
225
|
}}
|
|
225
226
|
/>
|
|
227
|
+
<Stack.Screen
|
|
228
|
+
name={Route.GoToDetailUnit}
|
|
229
|
+
component={GoToDetailUnit}
|
|
230
|
+
options={{
|
|
231
|
+
headerShown: false,
|
|
232
|
+
}}
|
|
233
|
+
/>
|
|
226
234
|
<Stack.Screen
|
|
227
235
|
name={Route.ListSmartAccount}
|
|
228
236
|
component={ListSmartAccount}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useState, useCallback } from 'react';
|
|
2
2
|
import { View, ScrollView, TouchableOpacity } from 'react-native';
|
|
3
|
-
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
4
3
|
import moment from 'moment';
|
|
5
4
|
|
|
6
5
|
import BottomButtonView from '../../commons/BottomButtonView';
|
|
@@ -8,7 +7,6 @@ import Text from '../../commons/Text';
|
|
|
8
7
|
import RadioCircle from '../../commons/RadioCircle';
|
|
9
8
|
import DateTimeRangeChange from '../../commons/DateTimeRangeChange';
|
|
10
9
|
import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
11
|
-
import { useBoolean } from '../../hooks/Common';
|
|
12
10
|
|
|
13
11
|
import { Colors } from '../../configs';
|
|
14
12
|
import styles from './styles/filterPopupStyles';
|
|
@@ -42,21 +40,16 @@ const RowMember = ({ member, isSelected, onSelect }) => {
|
|
|
42
40
|
const FilterPopup = ({
|
|
43
41
|
isVisible,
|
|
44
42
|
onHide,
|
|
45
|
-
onShow,
|
|
46
43
|
members,
|
|
47
44
|
filters,
|
|
48
45
|
userFilterEnabled,
|
|
49
46
|
onApply,
|
|
50
47
|
}) => {
|
|
51
48
|
const t = useTranslations();
|
|
52
|
-
const [lockShowing, acquireLockShowing, releaseLockShowing] =
|
|
53
|
-
useBoolean(false);
|
|
54
49
|
const [selectedUsers, setSelectedUsers] = useState(filters.users);
|
|
55
50
|
const [stateDatePicker, setStateDatePicker] = useState({
|
|
56
|
-
visible: false,
|
|
57
51
|
startDate: filters.date_from,
|
|
58
52
|
endDate: filters.date_to,
|
|
59
|
-
currentTimeChange: 'start',
|
|
60
53
|
});
|
|
61
54
|
|
|
62
55
|
const handleOnSelectUser = useCallback(
|
|
@@ -78,90 +71,38 @@ const FilterPopup = ({
|
|
|
78
71
|
[selectedUsers, setSelectedUsers]
|
|
79
72
|
);
|
|
80
73
|
|
|
81
|
-
const selectStart = useCallback(() => {
|
|
82
|
-
onHide();
|
|
83
|
-
acquireLockShowing();
|
|
84
|
-
setStateDatePicker((state) => ({
|
|
85
|
-
...state,
|
|
86
|
-
visible: true,
|
|
87
|
-
currentTimeChange: 'start',
|
|
88
|
-
}));
|
|
89
|
-
}, [onHide, acquireLockShowing]);
|
|
90
|
-
|
|
91
|
-
const selectEnd = useCallback(() => {
|
|
92
|
-
onHide();
|
|
93
|
-
acquireLockShowing();
|
|
94
|
-
setStateDatePicker((state) => ({
|
|
95
|
-
...state,
|
|
96
|
-
visible: true,
|
|
97
|
-
currentTimeChange: 'end',
|
|
98
|
-
}));
|
|
99
|
-
}, [onHide, acquireLockShowing]);
|
|
100
|
-
|
|
101
|
-
const onConfirmStartDate = useCallback((date) => {
|
|
74
|
+
const selectStart = useCallback((date) => {
|
|
102
75
|
setStateDatePicker((state) => {
|
|
103
76
|
if (moment(date).valueOf() < state.endDate) {
|
|
104
77
|
return {
|
|
105
78
|
...state,
|
|
106
|
-
visible: false,
|
|
107
79
|
startDate: moment(date).valueOf(),
|
|
108
80
|
};
|
|
109
81
|
}
|
|
110
82
|
return {
|
|
111
83
|
...state,
|
|
112
|
-
visible: false,
|
|
113
84
|
startDate: moment(date).valueOf(),
|
|
114
85
|
endDate: moment(date).add(1, 'days').valueOf(),
|
|
115
86
|
};
|
|
116
87
|
});
|
|
117
88
|
}, []);
|
|
118
89
|
|
|
119
|
-
const
|
|
90
|
+
const selectEnd = useCallback((date) => {
|
|
120
91
|
setStateDatePicker((state) => {
|
|
121
92
|
if (moment(date).valueOf() > state.startDate) {
|
|
122
93
|
return {
|
|
123
94
|
...state,
|
|
124
|
-
visible: false,
|
|
125
95
|
endDate: moment(date).valueOf(),
|
|
126
96
|
};
|
|
127
97
|
}
|
|
128
98
|
return {
|
|
129
99
|
...state,
|
|
130
|
-
visible: false,
|
|
131
100
|
startDate: moment(date).add(-1, 'days').valueOf(),
|
|
132
101
|
endDate: moment(date).valueOf(),
|
|
133
102
|
};
|
|
134
103
|
});
|
|
135
104
|
}, []);
|
|
136
105
|
|
|
137
|
-
const onConfirmDate = useCallback(
|
|
138
|
-
(date) => {
|
|
139
|
-
if (stateDatePicker.currentTimeChange === 'start') {
|
|
140
|
-
onConfirmStartDate(date);
|
|
141
|
-
} else {
|
|
142
|
-
onConfirmEndDate(date);
|
|
143
|
-
}
|
|
144
|
-
onShow();
|
|
145
|
-
acquireLockShowing();
|
|
146
|
-
},
|
|
147
|
-
[
|
|
148
|
-
onConfirmStartDate,
|
|
149
|
-
onConfirmEndDate,
|
|
150
|
-
stateDatePicker,
|
|
151
|
-
acquireLockShowing,
|
|
152
|
-
onShow,
|
|
153
|
-
]
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const onPickerCancel = useCallback(() => {
|
|
157
|
-
setStateDatePicker((state) => ({
|
|
158
|
-
...state,
|
|
159
|
-
visible: false,
|
|
160
|
-
}));
|
|
161
|
-
acquireLockShowing();
|
|
162
|
-
onShow();
|
|
163
|
-
}, [acquireLockShowing, onShow]);
|
|
164
|
-
|
|
165
106
|
const handleOnApply = useCallback(() => {
|
|
166
107
|
onApply({
|
|
167
108
|
users: selectedUsers,
|
|
@@ -184,10 +125,9 @@ const FilterPopup = ({
|
|
|
184
125
|
return (
|
|
185
126
|
<>
|
|
186
127
|
<ModalCustom
|
|
187
|
-
isVisible={isVisible
|
|
128
|
+
isVisible={isVisible}
|
|
188
129
|
onBackButtonPress={handleOnCancel}
|
|
189
130
|
onBackdropPress={handleOnCancel}
|
|
190
|
-
onModalHide={releaseLockShowing}
|
|
191
131
|
useNativeDriver={true}
|
|
192
132
|
useNativeDriverForBackdrop={true}
|
|
193
133
|
animationIn={'zoomIn'}
|
|
@@ -211,6 +151,7 @@ const FilterPopup = ({
|
|
|
211
151
|
selectStart={selectStart}
|
|
212
152
|
selectEnd={selectEnd}
|
|
213
153
|
formatType="date"
|
|
154
|
+
style={styles.datePicker}
|
|
214
155
|
inline={true}
|
|
215
156
|
/>
|
|
216
157
|
{userFilterEnabled && (
|
|
@@ -245,22 +186,6 @@ const FilterPopup = ({
|
|
|
245
186
|
/>
|
|
246
187
|
</View>
|
|
247
188
|
</ModalCustom>
|
|
248
|
-
<DateTimePickerModal
|
|
249
|
-
isVisible={stateDatePicker.visible && !lockShowing}
|
|
250
|
-
date={
|
|
251
|
-
stateDatePicker.currentTimeChange === 'start'
|
|
252
|
-
? new Date(stateDatePicker.startDate)
|
|
253
|
-
: new Date(stateDatePicker.endDate)
|
|
254
|
-
}
|
|
255
|
-
mode={'date'}
|
|
256
|
-
onConfirm={onConfirmDate}
|
|
257
|
-
onCancel={onPickerCancel}
|
|
258
|
-
onHide={releaseLockShowing}
|
|
259
|
-
display="spinner"
|
|
260
|
-
headerTextIOS={t('pick_a_date')}
|
|
261
|
-
cancelTextIOS={t('cancel')}
|
|
262
|
-
confirmTextIOS={t('confirm')}
|
|
263
|
-
/>
|
|
264
189
|
</>
|
|
265
190
|
);
|
|
266
191
|
};
|
|
@@ -8,7 +8,6 @@ import RadioCircle from '../../../commons/RadioCircle';
|
|
|
8
8
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
9
9
|
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
10
10
|
import DateTimeRangeChange from '../../../commons/DateTimeRangeChange';
|
|
11
|
-
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
12
11
|
import moment from 'moment';
|
|
13
12
|
|
|
14
13
|
const wrapComponent = (props) => (
|
|
@@ -125,7 +124,6 @@ it('test date picker pick valid and invalid date', async () => {
|
|
|
125
124
|
});
|
|
126
125
|
const instance = tree.root;
|
|
127
126
|
const dateTimeRangeChange = instance.findByType(DateTimeRangeChange);
|
|
128
|
-
const datePicker = instance.findAllByType(DateTimePickerModal)[2];
|
|
129
127
|
|
|
130
128
|
expect(dateTimeRangeChange.props.startTime).toBe(dateFrom.valueOf());
|
|
131
129
|
expect(dateTimeRangeChange.props.endTime).toBe(dateTo.valueOf());
|
|
@@ -133,11 +131,9 @@ it('test date picker pick valid and invalid date', async () => {
|
|
|
133
131
|
const _pickDateAndTest = async (timeChange) => {
|
|
134
132
|
await act(async () => {
|
|
135
133
|
if (timeChange === 'start') {
|
|
136
|
-
await dateTimeRangeChange.props.selectStart();
|
|
137
|
-
await datePicker.props.onConfirm(moment(dateFrom));
|
|
134
|
+
await dateTimeRangeChange.props.selectStart(dateFrom);
|
|
138
135
|
} else {
|
|
139
|
-
await dateTimeRangeChange.props.selectEnd();
|
|
140
|
-
await datePicker.props.onConfirm(moment(dateTo));
|
|
136
|
+
await dateTimeRangeChange.props.selectEnd(dateTo);
|
|
141
137
|
}
|
|
142
138
|
});
|
|
143
139
|
expect(dateTimeRangeChange.props.startTime).toBe(dateFrom.valueOf());
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { act } from '@testing-library/react-hooks';
|
|
2
|
+
import MockAdapter from 'axios-mock-adapter';
|
|
1
3
|
import React from 'react';
|
|
2
4
|
import { SectionList, Text } from 'react-native';
|
|
3
5
|
import { create } from 'react-test-renderer';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
+
import DateTimePickerModal from 'react-native-modal-datetime-picker';
|
|
7
|
+
import moment from 'moment';
|
|
6
8
|
|
|
7
9
|
import ActivityLog from '../';
|
|
8
10
|
import { API, Constants } from '../../../configs';
|
|
9
11
|
import { SCProvider } from '../../../context';
|
|
10
12
|
import { mockSCStore } from '../../../context/mockStore';
|
|
11
13
|
import ItemLog from '../ItemLog';
|
|
14
|
+
import FilterPopup from '../FilterPopup';
|
|
15
|
+
import BottomButtonView from '../../../commons/BottomButtonView';
|
|
12
16
|
import DateTimeRangeChange from '../../../commons/DateTimeRangeChange';
|
|
13
|
-
import
|
|
14
|
-
import Modal from 'react-native-modal';
|
|
17
|
+
import DateTimeButton from '../../../commons/DateTimeRangeChange/DateTimeButton';
|
|
15
18
|
import { AUTOMATE_TYPE, AccessibilityLabel } from '../../../configs/Constants';
|
|
16
19
|
import api from '../../../utils/Apis/axios';
|
|
17
20
|
|
|
@@ -88,13 +91,15 @@ describe('Test Activity log', () => {
|
|
|
88
91
|
expect(items).toHaveLength(1);
|
|
89
92
|
});
|
|
90
93
|
|
|
91
|
-
it('test
|
|
94
|
+
it('test filter and date picker popup', async () => {
|
|
95
|
+
const dateFrom = moment('2025-08-18T10:00:00.000Z');
|
|
96
|
+
const dateTo = moment(dateFrom).add(7, 'days');
|
|
92
97
|
await act(async () => {
|
|
93
98
|
tree = await create(wrapComponent(route));
|
|
94
99
|
});
|
|
95
100
|
const instance = tree.root;
|
|
96
|
-
const filterPopup = instance.
|
|
97
|
-
expect(filterPopup
|
|
101
|
+
const filterPopup = instance.findByType(FilterPopup);
|
|
102
|
+
expect(filterPopup.props.isVisible).toBeFalsy();
|
|
98
103
|
|
|
99
104
|
const filterButton = instance.findByProps({
|
|
100
105
|
accessibilityLabel: AccessibilityLabel.FILTER_BUTTON,
|
|
@@ -102,43 +107,60 @@ describe('Test Activity log', () => {
|
|
|
102
107
|
await act(async () => {
|
|
103
108
|
filterButton.props.onPress();
|
|
104
109
|
});
|
|
105
|
-
expect(filterPopup
|
|
110
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
106
111
|
|
|
107
112
|
const dateTimeRangeChange = instance.findByType(DateTimeRangeChange);
|
|
108
|
-
const
|
|
113
|
+
const datePickers = instance.findAllByType(DateTimePickerModal);
|
|
114
|
+
const buttonPickers = instance.findAllByType(DateTimeButton);
|
|
115
|
+
|
|
116
|
+
// open popup start date
|
|
117
|
+
await act(async () => {
|
|
118
|
+
await buttonPickers[0].props.onPress();
|
|
119
|
+
});
|
|
120
|
+
expect(datePickers[0].props.isVisible).toBeTruthy();
|
|
121
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
109
122
|
|
|
110
123
|
// pick start date
|
|
111
124
|
await act(async () => {
|
|
112
|
-
await dateTimeRangeChange.props.selectStart();
|
|
113
|
-
await filterPopup[0].props.onModalHide();
|
|
125
|
+
await dateTimeRangeChange.props.selectStart(dateFrom);
|
|
114
126
|
});
|
|
115
|
-
expect(
|
|
116
|
-
|
|
127
|
+
expect(datePickers[0].props.isVisible).toBeTruthy();
|
|
128
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
129
|
+
|
|
130
|
+
// cancel start date
|
|
117
131
|
await act(async () => {
|
|
118
|
-
await
|
|
119
|
-
await datePicker.props.onHide();
|
|
132
|
+
await datePickers[0].props.onCancel();
|
|
120
133
|
});
|
|
121
|
-
expect(
|
|
122
|
-
expect(
|
|
123
|
-
|
|
134
|
+
expect(datePickers[0].props.isVisible).toBeFalsy();
|
|
135
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
136
|
+
|
|
137
|
+
// open popup end date
|
|
124
138
|
await act(async () => {
|
|
125
|
-
await
|
|
139
|
+
await buttonPickers[1].props.onPress();
|
|
126
140
|
});
|
|
127
|
-
expect(
|
|
141
|
+
expect(datePickers[1].props.isVisible).toBeTruthy();
|
|
142
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
143
|
+
|
|
128
144
|
// pick end date
|
|
129
145
|
await act(async () => {
|
|
130
|
-
await dateTimeRangeChange.props.selectEnd();
|
|
131
|
-
await filterPopup[0].props.onModalHide();
|
|
146
|
+
await dateTimeRangeChange.props.selectEnd(dateTo);
|
|
132
147
|
});
|
|
133
|
-
expect(
|
|
134
|
-
expect(
|
|
135
|
-
|
|
148
|
+
expect(datePickers[1].props.isVisible).toBeTruthy();
|
|
149
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
150
|
+
|
|
151
|
+
// confirm end date
|
|
152
|
+
await act(async () => {
|
|
153
|
+
await datePickers[1].props.onConfirm();
|
|
154
|
+
});
|
|
155
|
+
expect(datePickers[1].props.isVisible).toBeFalsy();
|
|
156
|
+
expect(filterPopup.props.isVisible).toBeTruthy();
|
|
157
|
+
|
|
158
|
+
// apply filter
|
|
159
|
+
const applyButton = instance.findByType(BottomButtonView);
|
|
136
160
|
await act(async () => {
|
|
137
|
-
await
|
|
138
|
-
await datePicker.props.onHide();
|
|
161
|
+
await applyButton.props.onPressMain();
|
|
139
162
|
});
|
|
140
|
-
expect(filterPopup
|
|
141
|
-
expect(datePicker.props.isVisible).toBeFalsy();
|
|
163
|
+
expect(filterPopup.props.isVisible).toBeFalsy();
|
|
142
164
|
});
|
|
143
165
|
|
|
144
166
|
const setUpActionLogScreen = () => {
|
|
@@ -3,16 +3,19 @@ import { StyleSheet } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
wrapPopup: {
|
|
6
|
-
marginHorizontal:
|
|
6
|
+
marginHorizontal: 12,
|
|
7
7
|
},
|
|
8
8
|
popup: {
|
|
9
9
|
backgroundColor: Colors.White,
|
|
10
10
|
width: '100%',
|
|
11
11
|
height: (Constants.height * 80) / 100,
|
|
12
|
-
padding:
|
|
12
|
+
padding: 20,
|
|
13
13
|
paddingBottom: 100,
|
|
14
14
|
borderRadius: 10,
|
|
15
15
|
},
|
|
16
|
+
datePicker: {
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
},
|
|
16
19
|
heigh50percent: {
|
|
17
20
|
height: (Constants.height * 50) / 100,
|
|
18
21
|
},
|
|
@@ -18,6 +18,7 @@ import MockAdapter from 'axios-mock-adapter';
|
|
|
18
18
|
import api from '../../../utils/Apis/axios';
|
|
19
19
|
import CurrentRainSensor from '../../../commons/Device/RainningSensor/CurrentRainSensor';
|
|
20
20
|
import LabelValue from '../../../commons/Device/LabelValue';
|
|
21
|
+
import Text from '../../../commons/Text';
|
|
21
22
|
|
|
22
23
|
jest.mock('../../../iot/states', () => ({
|
|
23
24
|
useConfigGlobalState: () => [{}, null],
|
|
@@ -51,6 +52,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
51
52
|
},
|
|
52
53
|
],
|
|
53
54
|
},
|
|
55
|
+
label: 'Chart',
|
|
54
56
|
is_configuration_ready: true,
|
|
55
57
|
};
|
|
56
58
|
|
|
@@ -65,6 +67,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
65
67
|
const instance = tree.root;
|
|
66
68
|
const visualChart = instance.findAllByType(VisualChart);
|
|
67
69
|
expect(visualChart).toHaveLength(1);
|
|
70
|
+
const labels = instance.findAllByType(Text);
|
|
71
|
+
expect(labels[0].props.children).toEqual('Chart');
|
|
68
72
|
});
|
|
69
73
|
|
|
70
74
|
it('render ActionGroup', async () => {
|
|
@@ -82,6 +86,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
82
86
|
},
|
|
83
87
|
],
|
|
84
88
|
},
|
|
89
|
+
label: 'LED',
|
|
85
90
|
is_configuration_ready: true,
|
|
86
91
|
};
|
|
87
92
|
|
|
@@ -96,6 +101,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
96
101
|
const instance = tree.root;
|
|
97
102
|
const actionGroup = instance.findAllByType(ActionGroup);
|
|
98
103
|
expect(actionGroup).toHaveLength(1);
|
|
104
|
+
const labels = instance.findAllByType(Text);
|
|
105
|
+
expect(labels[0].props.children).toEqual('LED');
|
|
99
106
|
});
|
|
100
107
|
|
|
101
108
|
it('render camera', async () => {
|
|
@@ -113,6 +120,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
113
120
|
},
|
|
114
121
|
],
|
|
115
122
|
},
|
|
123
|
+
label: 'Camera',
|
|
116
124
|
is_configuration_ready: true,
|
|
117
125
|
};
|
|
118
126
|
|
|
@@ -127,6 +135,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
127
135
|
const instance = tree.root;
|
|
128
136
|
const mediaPlayerDetail = instance.findAllByType(MediaPlayerDetail);
|
|
129
137
|
expect(mediaPlayerDetail).toHaveLength(1);
|
|
138
|
+
const labels = instance.findAllByType(Text);
|
|
139
|
+
expect(labels[0].props.children).toEqual('Camera');
|
|
130
140
|
});
|
|
131
141
|
|
|
132
142
|
it('render flat_list', async () => {
|
|
@@ -213,6 +223,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
213
223
|
configuration: {
|
|
214
224
|
template: 'gauge',
|
|
215
225
|
},
|
|
226
|
+
label: 'Gauge',
|
|
216
227
|
is_configuration_ready: true,
|
|
217
228
|
};
|
|
218
229
|
|
|
@@ -227,6 +238,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
227
238
|
const instance = tree.root;
|
|
228
239
|
const flatListItems = instance.findAllByType(Anemometer);
|
|
229
240
|
expect(flatListItems).toHaveLength(1);
|
|
241
|
+
const labels = instance.findAllByType(Text);
|
|
242
|
+
expect(labels[0].props.children).toEqual('Gauge');
|
|
230
243
|
});
|
|
231
244
|
|
|
232
245
|
it('test render progress_bar', async () => {
|
|
@@ -237,6 +250,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
237
250
|
configuration: {
|
|
238
251
|
template: 'progress_bar',
|
|
239
252
|
},
|
|
253
|
+
label: 'Brightness',
|
|
240
254
|
is_configuration_ready: true,
|
|
241
255
|
};
|
|
242
256
|
|
|
@@ -251,6 +265,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
251
265
|
const instance = tree.root;
|
|
252
266
|
const flatListItems = instance.findAllByType(ProgressBar);
|
|
253
267
|
expect(flatListItems).toHaveLength(1);
|
|
268
|
+
const labels = instance.findAllByType(Text);
|
|
269
|
+
expect(labels[0].props.children).toEqual('Brightness');
|
|
254
270
|
});
|
|
255
271
|
|
|
256
272
|
it('test render Compass', async () => {
|
|
@@ -261,6 +277,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
261
277
|
configuration: {
|
|
262
278
|
template: 'compass',
|
|
263
279
|
},
|
|
280
|
+
label: 'Compass',
|
|
264
281
|
is_configuration_ready: true,
|
|
265
282
|
};
|
|
266
283
|
|
|
@@ -275,6 +292,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
275
292
|
const instance = tree.root;
|
|
276
293
|
const flatListItems = instance.findAllByType(Compass);
|
|
277
294
|
expect(flatListItems).toHaveLength(1);
|
|
295
|
+
const labels = instance.findAllByType(Text);
|
|
296
|
+
expect(labels[0].props.children).toEqual('Compass');
|
|
278
297
|
});
|
|
279
298
|
|
|
280
299
|
it('test render alert_status', async () => {
|
|
@@ -314,6 +333,8 @@ describe('Test SensorDisplayItem', () => {
|
|
|
314
333
|
|
|
315
334
|
const currentRainSensor = instance.findByType(CurrentRainSensor);
|
|
316
335
|
expect(currentRainSensor.props).toEqual(expectProps);
|
|
336
|
+
const labels = instance.findAllByType(Text);
|
|
337
|
+
expect(labels[0].props.children).toEqual('Circle');
|
|
317
338
|
};
|
|
318
339
|
|
|
319
340
|
it('render circle_mini', async () => {
|
|
@@ -332,6 +353,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
332
353
|
color: 'blue',
|
|
333
354
|
},
|
|
334
355
|
},
|
|
356
|
+
label: 'Circle',
|
|
335
357
|
is_configuration_ready: true,
|
|
336
358
|
};
|
|
337
359
|
|
|
@@ -371,6 +393,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
371
393
|
color: 'blue',
|
|
372
394
|
},
|
|
373
395
|
},
|
|
396
|
+
label: 'Circle',
|
|
374
397
|
is_configuration_ready: true,
|
|
375
398
|
};
|
|
376
399
|
|
|
@@ -400,6 +423,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
400
423
|
configuration: {
|
|
401
424
|
config: null,
|
|
402
425
|
},
|
|
426
|
+
label: 'Circle',
|
|
403
427
|
is_configuration_ready: true,
|
|
404
428
|
};
|
|
405
429
|
|
|
@@ -417,6 +441,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
417
441
|
order: 0,
|
|
418
442
|
template: 'LabelValue',
|
|
419
443
|
configuration: {},
|
|
444
|
+
label: 'Label',
|
|
420
445
|
is_configuration_ready: true,
|
|
421
446
|
};
|
|
422
447
|
|
|
@@ -431,5 +456,7 @@ describe('Test SensorDisplayItem', () => {
|
|
|
431
456
|
const instance = tree.root;
|
|
432
457
|
const displayItems = instance.findAllByType(LabelValue);
|
|
433
458
|
expect(displayItems).toHaveLength(1);
|
|
459
|
+
const labels = instance.findAllByType(Text);
|
|
460
|
+
expect(labels[0].props.children).toEqual('Label');
|
|
434
461
|
});
|
|
435
462
|
});
|