@eohjsc/react-native-smart-city 0.3.62 → 0.3.63
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/Dashboard/MyPinnedSharedUnit/index.js +10 -0
- package/src/commons/Dashboard/MyUnit/index.js +9 -3
- package/src/commons/Device/HorizontalBarChart.js +3 -3
- package/src/configs/API.js +14 -0
- package/src/configs/Constants.js +1 -0
- package/src/context/actionType.ts +1 -0
- package/src/context/reducer.ts +10 -0
- package/src/navigations/AllGatewayStack.js +19 -9
- package/src/navigations/UnitStack.js +1 -1
- package/src/screens/AllGateway/DetailConfigActionInternal/__test__/index.test.js +104 -0
- package/src/screens/AllGateway/DetailConfigActionInternal/index.js +97 -0
- package/src/screens/{Gateway/DetailConfigActionModbus → AllGateway/DetailConfigActionInternal}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionModbus/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionModbus/index.js +0 -0
- package/src/screens/{Gateway/DeviceGatewayInfo → AllGateway/DetailConfigActionModbus}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DetailConfigActionZigbee/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceGatewayInfo/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceGatewayInfo/index.js +26 -2
- package/src/screens/{Gateway/GatewayInfo → AllGateway/DeviceGatewayInfo}/styles.js +0 -0
- package/src/screens/AllGateway/DeviceInternalDetail/__test__/index.test.js +387 -0
- package/src/screens/AllGateway/DeviceInternalDetail/index.js +188 -0
- package/src/screens/{Gateway/DeviceModbusDetail → AllGateway/DeviceInternalDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceModbusDetail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceModbusDetail/index.js +9 -17
- package/src/screens/{Gateway/DeviceZigbeeDetail → AllGateway/DeviceModbusDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceZigbeeDetail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/DeviceZigbeeDetail/index.js +9 -17
- package/src/screens/{Gateway/GatewayDetail → AllGateway/DeviceZigbeeDetail}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayConnectionMethods/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayDetail/__test__/index.test.js +71 -31
- package/src/screens/{Gateway → AllGateway}/GatewayDetail/index.js +62 -42
- package/src/screens/AllGateway/GatewayDetail/styles.js +12 -0
- package/src/screens/{Gateway → AllGateway}/GatewayInfo/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/GatewayInfo/index.js +14 -17
- package/src/screens/AllGateway/GatewayInfo/styles.js +12 -0
- package/src/screens/{Gateway → AllGateway}/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Detail/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Detail/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Detail/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailActionModbus/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/DetailConfigAction/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/GatewayItem/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/Information/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/RowItem/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/__test__/index.test.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/index.js +0 -0
- package/src/screens/{Gateway → AllGateway}/components/TabPaneCT/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/hooks/__test__/index.test.js +15 -2
- package/src/screens/{Gateway → AllGateway}/hooks/useGateway.js +91 -11
- package/src/screens/{Gateway → AllGateway}/index.js +2 -2
- package/src/screens/{Gateway → AllGateway}/styles.js +0 -0
- package/src/screens/{Gateway → AllGateway}/utils/index.js +0 -0
- package/src/screens/WaterQualityGuide/__test__/index.test.js +8 -8
- package/src/screens/WaterQualityGuide/index.js +32 -53
- package/src/utils/Functions/preloadImages.js +39 -0
- package/src/utils/I18n/translations/en.json +21 -16
- package/src/utils/I18n/translations/vi.json +21 -19
- package/src/utils/Route/index.js +2 -0
- package/src/utils/Storage.js +6 -0
package/package.json
CHANGED
|
@@ -11,6 +11,8 @@ import { AccessibilityLabel } from '../../../configs/Constants';
|
|
|
11
11
|
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
12
12
|
import SharedUnit from '../../Unit/SharedUnit';
|
|
13
13
|
import { fetchWithCache } from '../../../utils/Apis/axios';
|
|
14
|
+
import { preloadImagesFromUnits } from '../../../utils/Functions/preloadImages';
|
|
15
|
+
import { STORAGE_KEY } from '../../../utils/Storage';
|
|
14
16
|
|
|
15
17
|
const MyPinnedSharedUnit = ({ refreshing }) => {
|
|
16
18
|
const t = useTranslations();
|
|
@@ -40,6 +42,14 @@ const MyPinnedSharedUnit = ({ refreshing }) => {
|
|
|
40
42
|
}
|
|
41
43
|
}, [fetchSharedUnitDashboard, isFocused, refreshing]);
|
|
42
44
|
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
sharedUnits?.length &&
|
|
47
|
+
preloadImagesFromUnits(
|
|
48
|
+
sharedUnits,
|
|
49
|
+
STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_SHARE_UNIT
|
|
50
|
+
);
|
|
51
|
+
}, [sharedUnits]);
|
|
52
|
+
|
|
43
53
|
return (
|
|
44
54
|
<>
|
|
45
55
|
<Section>
|
|
@@ -30,6 +30,8 @@ import Carousel from 'react-native-snap-carousel';
|
|
|
30
30
|
import { AccessibilityLabel, DEVICE_TYPE } from '../../../configs/Constants';
|
|
31
31
|
import Routes from '../../../utils/Route';
|
|
32
32
|
import MyUnitDevice from '../../../screens/Unit/components/MyUnitDevice';
|
|
33
|
+
import { STORAGE_KEY } from '../../../utils/Storage';
|
|
34
|
+
import { preloadImagesFromUnits } from '../../../utils/Functions/preloadImages';
|
|
33
35
|
|
|
34
36
|
let screenWidth = Dimensions.get('window').width;
|
|
35
37
|
|
|
@@ -106,12 +108,11 @@ const MyUnit = ({ refreshing }) => {
|
|
|
106
108
|
useWatchConfigs(configsNeedWatching);
|
|
107
109
|
|
|
108
110
|
const goToDetail = useCallback(
|
|
109
|
-
(item) => {
|
|
111
|
+
(item) => () => {
|
|
110
112
|
navigation.navigate(Routes.UnitStack, {
|
|
111
113
|
screen: Routes.UnitDetail,
|
|
112
114
|
params: {
|
|
113
115
|
unitId: item.id,
|
|
114
|
-
unitData: item,
|
|
115
116
|
},
|
|
116
117
|
});
|
|
117
118
|
},
|
|
@@ -130,7 +131,7 @@ const MyUnit = ({ refreshing }) => {
|
|
|
130
131
|
}}
|
|
131
132
|
>
|
|
132
133
|
<TouchableOpacity
|
|
133
|
-
onPress={
|
|
134
|
+
onPress={goToDetail(item)}
|
|
134
135
|
style={styles.btnItem}
|
|
135
136
|
activeOpacity={0.75}
|
|
136
137
|
accessibilityLabel={`${AccessibilityLabel.MY_UNIT_GO_TO_DETAIL}-${index}`}
|
|
@@ -153,6 +154,11 @@ const MyUnit = ({ refreshing }) => {
|
|
|
153
154
|
[myUnits, goToDetail]
|
|
154
155
|
);
|
|
155
156
|
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
myUnits?.length &&
|
|
159
|
+
preloadImagesFromUnits(myUnits, STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_UNITS);
|
|
160
|
+
}, [myUnits]);
|
|
161
|
+
|
|
156
162
|
return (
|
|
157
163
|
<>
|
|
158
164
|
<Section style={styles.boxTxtMyUnit}>
|
|
@@ -105,7 +105,7 @@ const HorizontalBarChart = memo(({ datas, config }) => {
|
|
|
105
105
|
});
|
|
106
106
|
|
|
107
107
|
const heightChart = useMemo(() => {
|
|
108
|
-
const dataX = datas[0]
|
|
108
|
+
const dataX = (datas[0]?.data || []).map((item) => item.x);
|
|
109
109
|
return dataX.length > 1
|
|
110
110
|
? dataX.length === 2
|
|
111
111
|
? dataX.length * 55 + 30
|
|
@@ -114,13 +114,13 @@ const HorizontalBarChart = memo(({ datas, config }) => {
|
|
|
114
114
|
}, [datas]);
|
|
115
115
|
|
|
116
116
|
useEffect(() => {
|
|
117
|
-
const dataY = datas[0]
|
|
117
|
+
const dataY = (datas[0]?.data || []).map((item, index) => {
|
|
118
118
|
return {
|
|
119
119
|
color: index % 2 === 0 ? Colors.Primary + '20' : Colors.Primary + '16',
|
|
120
120
|
y: item.y,
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
|
-
const dataX = datas[0].data.map((item) => item.x);
|
|
123
|
+
const dataX = (datas[0].data || []).map((item) => item.x);
|
|
124
124
|
const maxY = getMaxValueIndex(dataY);
|
|
125
125
|
if (!isEmpty(maxY.max)) {
|
|
126
126
|
dataY.splice(maxY._index, 1, { ...maxY.max, color: Colors.Primary });
|
package/src/configs/API.js
CHANGED
|
@@ -219,6 +219,20 @@ const API = {
|
|
|
219
219
|
DETAIL: (id) => `/chip_manager/developer_mode_chips/${id}/`,
|
|
220
220
|
REBOOT: (id) => `/chip_manager/developer_mode_chips/${id}/reboot_chip/`,
|
|
221
221
|
},
|
|
222
|
+
ARDUINO: {
|
|
223
|
+
DEVICE: (gatewayId) =>
|
|
224
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/`,
|
|
225
|
+
DEVICE_DETAIL: (gatewayId, deviceId) =>
|
|
226
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/`,
|
|
227
|
+
CONFIG_PINS: (gatewayId, deviceId) =>
|
|
228
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/pins/`,
|
|
229
|
+
CONFIG_PIN_DETAIL: (gatewayId, deviceId, configPinId) =>
|
|
230
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/pins/${configPinId}/`,
|
|
231
|
+
ACTION: (gatewayId, deviceId) =>
|
|
232
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/actions/`,
|
|
233
|
+
ACTION_DETAIL: (gatewayId, deviceId, actionId) =>
|
|
234
|
+
`/iot/modules/arduino/gateways/${gatewayId}/devices/${deviceId}/actions/${actionId}/`,
|
|
235
|
+
},
|
|
222
236
|
ZIGBEE: {
|
|
223
237
|
SEARCH_DEVICE: (id) => `/iot/modules/zigbee/chips/${id}/search_device/`,
|
|
224
238
|
DEVICE_CONFIGURATION: (id, deviceId) =>
|
package/src/configs/Constants.js
CHANGED
package/src/context/reducer.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
BluetoothType,
|
|
16
16
|
} from './actionType';
|
|
17
17
|
import { uniq, reduce } from 'lodash';
|
|
18
|
+
import { STORAGE_KEY, removeMultiple } from '../utils/Storage.js';
|
|
18
19
|
|
|
19
20
|
export type ContextData = {
|
|
20
21
|
auth: AuthData;
|
|
@@ -481,6 +482,15 @@ export const reducer = (currentState: ContextData, action: Action) => {
|
|
|
481
482
|
},
|
|
482
483
|
};
|
|
483
484
|
|
|
485
|
+
case Action.LOGOUT:
|
|
486
|
+
removeMultiple([
|
|
487
|
+
STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_UNITS,
|
|
488
|
+
STORAGE_KEY.IS_FIRST_TIME_LOAD_MY_SHARE_UNIT,
|
|
489
|
+
]);
|
|
490
|
+
return {
|
|
491
|
+
...currentState,
|
|
492
|
+
};
|
|
493
|
+
|
|
484
494
|
default:
|
|
485
495
|
return currentState;
|
|
486
496
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
2
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
3
|
|
|
4
|
-
import GatewayDetail from '../screens/
|
|
5
|
-
import GatewayInfo from '../screens/
|
|
6
|
-
import GatewayConnectionMethods from '../screens/
|
|
7
|
-
import DeviceZigbeeDetail from '../screens/
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
4
|
+
import GatewayDetail from '../screens/AllGateway/GatewayDetail';
|
|
5
|
+
import GatewayInfo from '../screens/AllGateway/GatewayInfo';
|
|
6
|
+
import GatewayConnectionMethods from '../screens/AllGateway/GatewayConnectionMethods';
|
|
7
|
+
import DeviceZigbeeDetail from '../screens/AllGateway/DeviceZigbeeDetail';
|
|
8
|
+
import DeviceInternalDetail from '../screens/AllGateway/DeviceInternalDetail';
|
|
9
|
+
import DeviceGatewayInfo from '../screens/AllGateway/DeviceGatewayInfo';
|
|
10
|
+
import DetailConfigActionZigbee from '../screens/AllGateway/DetailConfigActionZigbee';
|
|
11
|
+
import DeviceModbusDetail from '../screens/AllGateway/DeviceModbusDetail';
|
|
12
|
+
import DetailConfigActionModbus from '../screens/AllGateway/DetailConfigActionModbus';
|
|
13
|
+
import DetailChildConfigActionModbus from '../screens/AllGateway/DetailConfigActionModbus';
|
|
14
|
+
import DetailConfigActionInterval from '../screens/AllGateway/DetailConfigActionInternal';
|
|
13
15
|
import Route from '../utils/Route'; // utils/Route
|
|
14
16
|
import { screenOptions } from './utils';
|
|
15
17
|
|
|
@@ -33,6 +35,10 @@ export const AllGatewayStack = memo(() => {
|
|
|
33
35
|
component={GatewayConnectionMethods}
|
|
34
36
|
name={Route.GatewayConnectionMethods}
|
|
35
37
|
/>
|
|
38
|
+
<Stack.Screen
|
|
39
|
+
component={DeviceInternalDetail}
|
|
40
|
+
name={Route.DeviceInternalDetail}
|
|
41
|
+
/>
|
|
36
42
|
<Stack.Screen
|
|
37
43
|
component={DeviceZigbeeDetail}
|
|
38
44
|
name={Route.DeviceZigbeeDetail}
|
|
@@ -45,6 +51,10 @@ export const AllGatewayStack = memo(() => {
|
|
|
45
51
|
component={DetailConfigActionZigbee}
|
|
46
52
|
name={Route.DetailConfigActionZigbee}
|
|
47
53
|
/>
|
|
54
|
+
<Stack.Screen
|
|
55
|
+
component={DetailConfigActionInterval}
|
|
56
|
+
name={Route.DetailConfigActionInterval}
|
|
57
|
+
/>
|
|
48
58
|
<Stack.Screen
|
|
49
59
|
component={DetailConfigActionModbus}
|
|
50
60
|
name={Route.DetailConfigActionModbus}
|
|
@@ -53,7 +53,7 @@ import EmergencySetting from '../screens/EmergencySetting';
|
|
|
53
53
|
import ConfirmUnitDeletion from '../screens/ConfirmUnitDeletion';
|
|
54
54
|
import InfoMemberUnit from '../screens/Sharing/InfoMemberUnit';
|
|
55
55
|
import EnterPassword from '../screens/EnterPassword';
|
|
56
|
-
import AllGateway from '../screens/
|
|
56
|
+
import AllGateway from '../screens/AllGateway';
|
|
57
57
|
import SelectAddToFavorites from '../screens/Unit/SelectAddToFavorites';
|
|
58
58
|
import { HanetCameraStack } from './HanetCameraStack';
|
|
59
59
|
import { axiosGet, fetchWithCache } from '../utils/Apis/axios';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { create, act } from 'react-test-renderer';
|
|
3
|
+
import { useRoute } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import { SCProvider } from '../../../../context';
|
|
6
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
7
|
+
import DetailConfigAction from '../../components/DetailConfigAction';
|
|
8
|
+
import DetailConfigActionInternal from '..';
|
|
9
|
+
|
|
10
|
+
const wrapComponent = () => (
|
|
11
|
+
<SCProvider initState={mockSCStore({})}>
|
|
12
|
+
<DetailConfigActionInternal />
|
|
13
|
+
</SCProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
jest.mock('@react-navigation/native', () => {
|
|
17
|
+
return {
|
|
18
|
+
...jest.requireActual('@react-navigation/native'),
|
|
19
|
+
useRoute: jest.fn(),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const mockNavigate = jest.fn();
|
|
24
|
+
jest.mock('@react-navigation/native', () => {
|
|
25
|
+
return {
|
|
26
|
+
...jest.requireActual('@react-navigation/native'),
|
|
27
|
+
useNavigation: () => ({
|
|
28
|
+
navigate: mockNavigate,
|
|
29
|
+
pop: jest.fn(),
|
|
30
|
+
}),
|
|
31
|
+
useRoute: jest.fn(),
|
|
32
|
+
useIsFocused: () => true,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('Test DetailConfigActionInternal', () => {
|
|
37
|
+
let tree;
|
|
38
|
+
it('test render DetailConfigActionInternal isConfigRead', async () => {
|
|
39
|
+
useRoute.mockReturnValue({
|
|
40
|
+
params: {
|
|
41
|
+
isConfigRead: true,
|
|
42
|
+
isConfigWrite: false,
|
|
43
|
+
isAction: false,
|
|
44
|
+
itemActionConfig: {
|
|
45
|
+
id: 1,
|
|
46
|
+
config: { name: 'config1' },
|
|
47
|
+
value_type: 'boolean',
|
|
48
|
+
pin_number: 0,
|
|
49
|
+
pin_mode: 1,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
await act(async () => {
|
|
54
|
+
tree = await create(wrapComponent());
|
|
55
|
+
});
|
|
56
|
+
const instance = tree.root;
|
|
57
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
58
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
59
|
+
});
|
|
60
|
+
it('test render DetailConfigActionInternal isConfigWrite', async () => {
|
|
61
|
+
useRoute.mockReturnValue({
|
|
62
|
+
params: {
|
|
63
|
+
isConfigRead: false,
|
|
64
|
+
isConfigWrite: true,
|
|
65
|
+
isAction: false,
|
|
66
|
+
itemActionConfig: {
|
|
67
|
+
id: 1,
|
|
68
|
+
config: { name: 'config1' },
|
|
69
|
+
value_type: 'boolean',
|
|
70
|
+
pin_number: 0,
|
|
71
|
+
pin_mode: 1,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
await act(async () => {
|
|
76
|
+
tree = await create(wrapComponent());
|
|
77
|
+
});
|
|
78
|
+
const instance = tree.root;
|
|
79
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
80
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
81
|
+
});
|
|
82
|
+
it('test render DetailConfigActionInternal isAction', async () => {
|
|
83
|
+
useRoute.mockReturnValue({
|
|
84
|
+
params: {
|
|
85
|
+
isConfigRead: false,
|
|
86
|
+
isConfigWrite: false,
|
|
87
|
+
isAction: true,
|
|
88
|
+
isChildAction: false,
|
|
89
|
+
itemActionConfig: {
|
|
90
|
+
id: 1,
|
|
91
|
+
action: { name: 'config1' },
|
|
92
|
+
pin: 'boolean',
|
|
93
|
+
default_value: 0,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
await act(async () => {
|
|
98
|
+
tree = await create(wrapComponent());
|
|
99
|
+
});
|
|
100
|
+
const instance = tree.root;
|
|
101
|
+
const detailConfigAction = instance?.findAllByType(DetailConfigAction);
|
|
102
|
+
expect(detailConfigAction).toHaveLength(1);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { useRoute } from '@react-navigation/native';
|
|
4
|
+
|
|
5
|
+
import styles from './styles';
|
|
6
|
+
import DetailConfigAction from '../components/DetailConfigAction';
|
|
7
|
+
|
|
8
|
+
const DetailConfigActionInternal = () => {
|
|
9
|
+
const { params = {} } = useRoute();
|
|
10
|
+
const {
|
|
11
|
+
device = {},
|
|
12
|
+
itemActionConfig,
|
|
13
|
+
isConfigRead,
|
|
14
|
+
isConfigWrite,
|
|
15
|
+
isAction,
|
|
16
|
+
} = params;
|
|
17
|
+
|
|
18
|
+
const listData = useMemo(() => {
|
|
19
|
+
if (isConfigRead || isConfigWrite) {
|
|
20
|
+
return [
|
|
21
|
+
{
|
|
22
|
+
id: 1,
|
|
23
|
+
title: 'config_name',
|
|
24
|
+
data: itemActionConfig?.config?.name || '--',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: 2,
|
|
28
|
+
title: 'config_type',
|
|
29
|
+
data:
|
|
30
|
+
itemActionConfig?.value_type === 'boolean'
|
|
31
|
+
? 'Digital'
|
|
32
|
+
: itemActionConfig?.value_type === 'integer'
|
|
33
|
+
? 'Analog'
|
|
34
|
+
: '--',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 3,
|
|
38
|
+
title: 'pin',
|
|
39
|
+
data: itemActionConfig?.pin_number || '0',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 4,
|
|
43
|
+
title: 'pin_mode',
|
|
44
|
+
data: itemActionConfig?.pin_mode || '--',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
if (isAction) {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
id: 1,
|
|
52
|
+
title: 'action_name',
|
|
53
|
+
data: itemActionConfig?.action?.name || '--',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
title: 'pin_number',
|
|
58
|
+
data: itemActionConfig?.pin || '0',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 3,
|
|
62
|
+
title: 'default_value',
|
|
63
|
+
data: itemActionConfig?.default_value || '--',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
return [];
|
|
68
|
+
}, [isAction, isConfigRead, isConfigWrite, itemActionConfig]);
|
|
69
|
+
|
|
70
|
+
const title = useMemo(
|
|
71
|
+
() =>
|
|
72
|
+
((isConfigRead || isConfigWrite) && itemActionConfig?.config?.name) ||
|
|
73
|
+
(isAction && itemActionConfig?.action?.name) ||
|
|
74
|
+
'',
|
|
75
|
+
[
|
|
76
|
+
isConfigRead,
|
|
77
|
+
isConfigWrite,
|
|
78
|
+
itemActionConfig?.config?.name,
|
|
79
|
+
itemActionConfig?.action?.name,
|
|
80
|
+
isAction,
|
|
81
|
+
]
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const subTitle = useMemo(() => device?.sensor?.name || '--', [device]);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View style={styles.wrap}>
|
|
88
|
+
<DetailConfigAction
|
|
89
|
+
title={title}
|
|
90
|
+
subTitle={subTitle}
|
|
91
|
+
listData={listData}
|
|
92
|
+
/>
|
|
93
|
+
</View>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default memo(DetailConfigActionInternal);
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/screens/{Gateway/DeviceGatewayInfo → AllGateway/DetailConfigActionModbus}/styles.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -8,7 +8,12 @@ import Information from '../components/Information';
|
|
|
8
8
|
|
|
9
9
|
const DeviceGatewayInfo = () => {
|
|
10
10
|
const { params = {} } = useRoute();
|
|
11
|
-
const {
|
|
11
|
+
const {
|
|
12
|
+
device = {},
|
|
13
|
+
isZigbee = false,
|
|
14
|
+
isModbus = false,
|
|
15
|
+
isInternal = false,
|
|
16
|
+
} = params;
|
|
12
17
|
const {
|
|
13
18
|
ieee_address = '',
|
|
14
19
|
model_name = '',
|
|
@@ -16,9 +21,26 @@ const DeviceGatewayInfo = () => {
|
|
|
16
21
|
delay = '',
|
|
17
22
|
index = '',
|
|
18
23
|
sensor = {},
|
|
24
|
+
used_pins = [],
|
|
19
25
|
} = device;
|
|
20
26
|
const { name = '', connection_time = '' } = sensor;
|
|
21
27
|
|
|
28
|
+
const deviceInformationInternal = useMemo(
|
|
29
|
+
() => [
|
|
30
|
+
{
|
|
31
|
+
id: 1,
|
|
32
|
+
title: 'device_name',
|
|
33
|
+
data: name,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 2,
|
|
37
|
+
title: 'used_pin',
|
|
38
|
+
data: used_pins?.join(','),
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[name, used_pins]
|
|
42
|
+
);
|
|
43
|
+
|
|
22
44
|
const deviceInformationZigbee = useMemo(
|
|
23
45
|
() => [
|
|
24
46
|
{
|
|
@@ -81,7 +103,9 @@ const DeviceGatewayInfo = () => {
|
|
|
81
103
|
<Information
|
|
82
104
|
buttonBackStyles={styles.buttonBack}
|
|
83
105
|
listInformation={
|
|
84
|
-
|
|
106
|
+
isInternal
|
|
107
|
+
? deviceInformationInternal
|
|
108
|
+
: isZigbee
|
|
85
109
|
? deviceInformationZigbee
|
|
86
110
|
: isModbus
|
|
87
111
|
? deviceInformationModbus
|
|
File without changes
|