@eohjsc/react-native-smart-city 0.3.61 → 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/index.js +4 -2
- 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/commons/Device/PMSensor/PMSensorIndicatior.js +2 -1
- package/src/commons/Header/HeaderCustom.js +4 -1
- 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 +68 -0
- package/src/navigations/Main.js +197 -197
- package/src/navigations/UnitStack.js +8 -0
- 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 +8 -2
- 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 +38 -26
- package/src/screens/{Gateway → AllGateway}/styles.js +9 -1
- package/src/screens/{Gateway → AllGateway}/utils/index.js +0 -0
- package/src/screens/Unit/MoreMenu.js +12 -1
- package/src/screens/WaterQualityGuide/__test__/index.test.js +8 -8
- package/src/screens/WaterQualityGuide/index.js +32 -53
- package/src/utils/Apis/axios.js +1 -1
- package/src/utils/Functions/preloadImages.js +39 -0
- package/src/utils/I18n/translations/en.json +22 -16
- package/src/utils/I18n/translations/vi.json +22 -19
- package/src/utils/Route/index.js +4 -0
- package/src/utils/Storage.js +6 -0
- package/src/utils/Utils.js +7 -0
package/index.js
CHANGED
|
@@ -19,8 +19,9 @@ import MyUnit from './src/commons/Dashboard/MyUnit';
|
|
|
19
19
|
import SharedUnit from './src/commons/Unit/SharedUnit';
|
|
20
20
|
import { Action } from './src/context/actionType';
|
|
21
21
|
import { withRemoteControl } from './src/hoc';
|
|
22
|
-
import DevModeStack from './src/navigations/Main';
|
|
22
|
+
// import DevModeStack from './src/navigations/Main';
|
|
23
23
|
import { SmartAccountStack } from './src/navigations/SmartAccountStack';
|
|
24
|
+
import { AllGatewayStack } from './src/navigations/AllGatewayStack';
|
|
24
25
|
|
|
25
26
|
export {
|
|
26
27
|
AddSubUnitStack,
|
|
@@ -46,6 +47,7 @@ export {
|
|
|
46
47
|
SCWrapper,
|
|
47
48
|
Action,
|
|
48
49
|
withRemoteControl,
|
|
49
|
-
DevModeStack,
|
|
50
|
+
// DevModeStack,
|
|
50
51
|
SmartAccountStack,
|
|
52
|
+
AllGatewayStack,
|
|
51
53
|
};
|
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 });
|
|
@@ -3,6 +3,7 @@ import { View } from 'react-native';
|
|
|
3
3
|
import { FlatList } from 'react-native';
|
|
4
4
|
import QualityIndicatorItem from '../WaterQualitySensor/QualityIndicatorsItem';
|
|
5
5
|
import styles from './PMSensorIndicatorStyles';
|
|
6
|
+
import { roundNumber } from '../../../utils/Utils';
|
|
6
7
|
|
|
7
8
|
//using for PM2.5-10, CO, UV, Rainflow Sensor
|
|
8
9
|
const keyExtractor = (item) => item.id.toString();
|
|
@@ -11,7 +12,7 @@ const PMSensorIndicatior = memo(({ data = [], style }) => {
|
|
|
11
12
|
({ item }) => {
|
|
12
13
|
const getValue = ['', null, undefined, NaN].includes(item?.value)
|
|
13
14
|
? '--'
|
|
14
|
-
: item?.value;
|
|
15
|
+
: roundNumber(item?.value);
|
|
15
16
|
return (
|
|
16
17
|
<QualityIndicatorItem
|
|
17
18
|
key={item.id.toString()}
|
|
@@ -28,6 +28,7 @@ const HeaderCustom = ({
|
|
|
28
28
|
isCanBack = true,
|
|
29
29
|
customTitle = false,
|
|
30
30
|
buttonBackStyles,
|
|
31
|
+
headerStyles,
|
|
31
32
|
}) => {
|
|
32
33
|
const t = useTranslations();
|
|
33
34
|
const { goBack } = useNavigation();
|
|
@@ -46,7 +47,9 @@ const HeaderCustom = ({
|
|
|
46
47
|
}, []);
|
|
47
48
|
|
|
48
49
|
return (
|
|
49
|
-
<View
|
|
50
|
+
<View
|
|
51
|
+
style={[styles.wrap, isShowSeparator && styles.separator, headerStyles]}
|
|
52
|
+
>
|
|
50
53
|
{isCanBack && (
|
|
51
54
|
<TouchableOpacity
|
|
52
55
|
style={[styles.buttonBack, buttonBackStyles]}
|
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
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { createStackNavigator } from '@react-navigation/stack';
|
|
3
|
+
|
|
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';
|
|
15
|
+
import Route from '../utils/Route'; // utils/Route
|
|
16
|
+
import { screenOptions } from './utils';
|
|
17
|
+
|
|
18
|
+
const Stack = createStackNavigator();
|
|
19
|
+
|
|
20
|
+
export const AllGatewayStack = memo(() => {
|
|
21
|
+
return (
|
|
22
|
+
<Stack.Navigator
|
|
23
|
+
screenOptions={{
|
|
24
|
+
...screenOptions,
|
|
25
|
+
headerShown: false,
|
|
26
|
+
}}
|
|
27
|
+
>
|
|
28
|
+
<Stack.Screen component={GatewayDetail} name={Route.GatewayDetail} />
|
|
29
|
+
<Stack.Screen component={GatewayInfo} name={Route.GatewayInfo} />
|
|
30
|
+
<Stack.Screen
|
|
31
|
+
component={DeviceGatewayInfo}
|
|
32
|
+
name={Route.DeviceGatewayInfo}
|
|
33
|
+
/>
|
|
34
|
+
<Stack.Screen
|
|
35
|
+
component={GatewayConnectionMethods}
|
|
36
|
+
name={Route.GatewayConnectionMethods}
|
|
37
|
+
/>
|
|
38
|
+
<Stack.Screen
|
|
39
|
+
component={DeviceInternalDetail}
|
|
40
|
+
name={Route.DeviceInternalDetail}
|
|
41
|
+
/>
|
|
42
|
+
<Stack.Screen
|
|
43
|
+
component={DeviceZigbeeDetail}
|
|
44
|
+
name={Route.DeviceZigbeeDetail}
|
|
45
|
+
/>
|
|
46
|
+
<Stack.Screen
|
|
47
|
+
component={DeviceModbusDetail}
|
|
48
|
+
name={Route.DeviceModbusDetail}
|
|
49
|
+
/>
|
|
50
|
+
<Stack.Screen
|
|
51
|
+
component={DetailConfigActionZigbee}
|
|
52
|
+
name={Route.DetailConfigActionZigbee}
|
|
53
|
+
/>
|
|
54
|
+
<Stack.Screen
|
|
55
|
+
component={DetailConfigActionInterval}
|
|
56
|
+
name={Route.DetailConfigActionInterval}
|
|
57
|
+
/>
|
|
58
|
+
<Stack.Screen
|
|
59
|
+
component={DetailConfigActionModbus}
|
|
60
|
+
name={Route.DetailConfigActionModbus}
|
|
61
|
+
/>
|
|
62
|
+
<Stack.Screen
|
|
63
|
+
component={DetailChildConfigActionModbus}
|
|
64
|
+
name={Route.DetailChildConfigActionModbus}
|
|
65
|
+
/>
|
|
66
|
+
</Stack.Navigator>
|
|
67
|
+
);
|
|
68
|
+
});
|