@eohjsc/react-native-smart-city 0.7.26 → 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/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/components/SensorDisplayItem.js +16 -14
- package/src/screens/Device/styles.js +0 -5
package/package.json
CHANGED
|
@@ -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
|
},
|
|
@@ -134,20 +134,22 @@ export const SensorDisplayItem = ({
|
|
|
134
134
|
switch (item.template) {
|
|
135
135
|
case 'camera':
|
|
136
136
|
return (
|
|
137
|
-
<View
|
|
138
|
-
style={
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
137
|
+
<View>
|
|
138
|
+
<Text style={styles.widgetLabel}>{label}</Text>
|
|
139
|
+
<View
|
|
140
|
+
style={[styles.mediaContainer, isWidgetOrder && styles.cameraOrder]}
|
|
141
|
+
>
|
|
142
|
+
<MediaPlayerDetail
|
|
143
|
+
uri={uri}
|
|
144
|
+
thumbnail={{
|
|
145
|
+
uri: background,
|
|
146
|
+
}}
|
|
147
|
+
key={`camera-device-${id}`}
|
|
148
|
+
cameraName={name}
|
|
149
|
+
width={standardizeWidth}
|
|
150
|
+
height={standardizeHeight}
|
|
151
|
+
/>
|
|
152
|
+
</View>
|
|
151
153
|
</View>
|
|
152
154
|
);
|
|
153
155
|
// change response format, todo Bang refactor after fix
|
|
@@ -105,11 +105,6 @@ export default StyleSheet.create({
|
|
|
105
105
|
marginHorizontal: 20,
|
|
106
106
|
marginBottom: 4,
|
|
107
107
|
},
|
|
108
|
-
widgetLabelCamera: {
|
|
109
|
-
fontSize: 16,
|
|
110
|
-
color: Colors.Black,
|
|
111
|
-
marginBottom: 4,
|
|
112
|
-
},
|
|
113
108
|
widgetLabelHistory: {
|
|
114
109
|
fontSize: 16,
|
|
115
110
|
color: Colors.Black,
|