@eohjsc/react-native-smart-city 0.3.59 → 0.3.60
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/configs/API.js +3 -4
- package/src/screens/Device/components/SensorDisplayItem.js +1 -1
- package/src/screens/Template/__test__/EditTemplate.test.js +1 -1
- package/src/screens/Template/__test__/index.test.js +44 -0
- package/src/screens/Template/detail.js +1 -1
- package/src/screens/Template/index.js +6 -0
- package/src/utils/Apis/axios.js +0 -1
package/package.json
CHANGED
package/src/configs/API.js
CHANGED
|
@@ -209,11 +209,10 @@ const API = {
|
|
|
209
209
|
// NOTE: DEV MODE
|
|
210
210
|
DEV_MODE: {
|
|
211
211
|
DASHBOARD: {
|
|
212
|
-
DETAIL: (id) =>
|
|
213
|
-
|
|
214
|
-
GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/templates/',
|
|
212
|
+
DETAIL: (id) => `/property_manager/iot_dashboard/dev_mode/units/${id}/`,
|
|
213
|
+
GET_TEMPLATES: '/property_manager/iot_dashboard/dev_mode/units/',
|
|
215
214
|
GET_WIDGETS: (templateId) =>
|
|
216
|
-
`/property_manager/iot_dashboard/dev_mode/
|
|
215
|
+
`/property_manager/iot_dashboard/dev_mode/units/${templateId}/widgets/`,
|
|
217
216
|
},
|
|
218
217
|
GATEWAY: {
|
|
219
218
|
LIST: () => '/chip_manager/developer_mode_chips/',
|
|
@@ -62,7 +62,7 @@ export const SensorDisplayItem = ({
|
|
|
62
62
|
if (type === 'compass') {
|
|
63
63
|
setShowWindDirection && setShowWindDirection(true);
|
|
64
64
|
}
|
|
65
|
-
switch (item.
|
|
65
|
+
switch (item.template) {
|
|
66
66
|
case 'camera':
|
|
67
67
|
return (
|
|
68
68
|
<CardDevMode title={t('camera')} id={idTemplate} isWrap>
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { FlatList, TouchableOpacity } from 'react-native';
|
|
4
4
|
import { act, create } from 'react-test-renderer';
|
|
5
5
|
import Template from '..';
|
|
6
|
+
import { Search } from '../../../commons/DevMode';
|
|
6
7
|
import { API } from '../../../configs';
|
|
7
8
|
import api from '../../../utils/Apis/axios';
|
|
8
9
|
|
|
@@ -39,4 +40,47 @@ describe('Test Template screen', () => {
|
|
|
39
40
|
await TouchableOpacities[0].props.onPress();
|
|
40
41
|
expect(mockNavigate).toBeCalled();
|
|
41
42
|
});
|
|
43
|
+
|
|
44
|
+
it('Test onSearch', async () => {
|
|
45
|
+
mock.onGet(API.DEV_MODE.DASHBOARD.GET_TEMPLATES).reply(200, [
|
|
46
|
+
{
|
|
47
|
+
id: 1,
|
|
48
|
+
name: 'Template1',
|
|
49
|
+
description: 'test',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 1,
|
|
53
|
+
name: 'Template2',
|
|
54
|
+
description: 'test2',
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
await act(async () => {
|
|
58
|
+
tree = await create(<Template />);
|
|
59
|
+
});
|
|
60
|
+
const instance = tree.root;
|
|
61
|
+
const search = instance.findByType(Search);
|
|
62
|
+
await act(async () => {
|
|
63
|
+
await search.props.onSearch('Template1');
|
|
64
|
+
});
|
|
65
|
+
const flatList = instance.findByType(FlatList);
|
|
66
|
+
expect(flatList.props.data).toEqual([
|
|
67
|
+
{ description: 'test', id: 1, name: 'Template1' },
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
await act(async () => {
|
|
71
|
+
await search.props.onSearch('');
|
|
72
|
+
});
|
|
73
|
+
expect(flatList.props.data).toEqual([
|
|
74
|
+
{
|
|
75
|
+
id: 1,
|
|
76
|
+
name: 'Template1',
|
|
77
|
+
description: 'test',
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 1,
|
|
81
|
+
name: 'Template2',
|
|
82
|
+
description: 'test2',
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
42
86
|
});
|
|
@@ -184,7 +184,7 @@ const TemplateDetail = () => {
|
|
|
184
184
|
return;
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
const _data = _item?.configuration?.configs.map((config) => {
|
|
187
|
+
const _data = (_item?.configuration?.configs || []).map((config) => {
|
|
188
188
|
const configValue = configValues[config.id]?.value;
|
|
189
189
|
if ([null, undefined, NaN].includes(configValue)) {
|
|
190
190
|
return;
|
|
@@ -22,6 +22,7 @@ const Template = () => {
|
|
|
22
22
|
const [data, setData] = useState([]);
|
|
23
23
|
const { navigate } = useNavigation();
|
|
24
24
|
const isFocused = useIsFocused();
|
|
25
|
+
const [isRefreshing, setIsRefreshing] = useState(false);
|
|
25
26
|
|
|
26
27
|
const onSearch = useCallback((value) => {
|
|
27
28
|
if (value === '') {
|
|
@@ -42,6 +43,7 @@ const Template = () => {
|
|
|
42
43
|
);
|
|
43
44
|
|
|
44
45
|
const getTemplates = useCallback(async () => {
|
|
46
|
+
setIsRefreshing(true);
|
|
45
47
|
const { success, data: dataDashboard } = await axiosGet(
|
|
46
48
|
API.DEV_MODE.DASHBOARD.GET_TEMPLATES
|
|
47
49
|
);
|
|
@@ -49,6 +51,7 @@ const Template = () => {
|
|
|
49
51
|
setData(dataDashboard || []);
|
|
50
52
|
arrTemplates = dataDashboard;
|
|
51
53
|
}
|
|
54
|
+
setIsRefreshing(false);
|
|
52
55
|
}, []);
|
|
53
56
|
|
|
54
57
|
const renderListEmptyComponent = useMemo(() => {
|
|
@@ -84,6 +87,9 @@ const Template = () => {
|
|
|
84
87
|
extraData={data}
|
|
85
88
|
ListEmptyComponent={renderListEmptyComponent}
|
|
86
89
|
numColumns={2}
|
|
90
|
+
showsVerticalScrollIndicator={false}
|
|
91
|
+
refreshing={isRefreshing}
|
|
92
|
+
onRefresh={getTemplates}
|
|
87
93
|
/>
|
|
88
94
|
</View>
|
|
89
95
|
</TouchableWithoutFeedback>
|