@eohjsc/react-native-smart-city 0.4.84 → 0.4.86
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/assets/images/Notify.svg +9 -0
- package/package.json +1 -1
- package/src/commons/Automate/ItemAutomate.js +6 -1
- package/src/commons/Device/PMSensor/PMSensorIndicator.js +15 -8
- package/src/commons/Device/WaterQualitySensor/ListQualityIndicator.js +23 -15
- package/src/commons/Device/WaterQualitySensor/QualityIndicatorsItem.js +10 -9
- package/src/commons/MenuActionAddnew/index.js +6 -0
- package/src/commons/Sharing/WrapHeaderScrollable.js +1 -1
- package/src/commons/SubUnit/DeviceTemplate/ConfigValue/ConfigValue.js +2 -8
- package/src/commons/SubUnit/DeviceTemplate/EvaluationOverConfig/EvaluationOverConfig.js +2 -10
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +4 -3
- package/src/commons/SubUnit/OneTap/__test__/SubUnitAutomate.test.js +14 -1
- package/src/commons/SubUnit/ShortDetail.js +14 -4
- package/src/configs/API.js +10 -0
- package/src/configs/AccessibilityLabel.js +3 -0
- package/src/navigations/UnitStack.js +10 -2
- package/src/screens/Automate/AddNewAction/SetupScriptNotify.js +92 -0
- package/src/screens/Automate/AddNewAction/Styles/SetupScriptNotifyStyles.js +57 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupConfigCondition.test.js +13 -0
- package/src/screens/Automate/AddNewAction/__test__/SetupScriptNotify.test.js +84 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +15 -4
- package/src/screens/Automate/EditActionsList/index.js +130 -72
- package/src/screens/Automate/ScriptDetail/Components/AddActionScript.js +168 -0
- package/src/screens/Automate/ScriptDetail/__test__/index.test.js +75 -6
- package/src/screens/Automate/ScriptDetail/index.js +147 -84
- package/src/screens/Device/__test__/mqttDetail.test.js +20 -20
- package/src/screens/Device/detail.js +1 -3
- package/src/screens/Sharing/{MemberList.js → UnitMemberList.js} +4 -4
- package/src/screens/Sharing/__test__/{MemberList.test.js → UnitMemberList.test.js} +2 -2
- package/src/screens/UnitSummary/__test__/index.test.js +2 -1
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +37 -30
- package/src/screens/UnitSummary/components/3PPowerConsumption/index.js +105 -166
- package/src/screens/UnitSummary/components/AirQuality/SegmentedRoundChart.js +32 -0
- package/src/{commons/UnitSummary → screens/UnitSummary/components}/AirQuality/__test__/index.test.js +25 -15
- package/src/{commons/UnitSummary → screens/UnitSummary/components}/AirQuality/index.js +55 -71
- package/src/{commons/UnitSummary → screens/UnitSummary/components}/AirQuality/styles.js +1 -2
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js +26 -20
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +59 -87
- package/src/screens/UnitSummary/components/RunningDevices/index.js +27 -23
- package/src/screens/UnitSummary/components/Temperature/ItemTemperature/index.js +33 -20
- package/src/screens/UnitSummary/components/Temperature/index.js +52 -79
- package/src/screens/UnitSummary/components/UvIndex/SegmentedRoundChart.js +36 -0
- package/src/screens/UnitSummary/components/UvIndex/__test__/index.test.js +8 -0
- package/src/screens/UnitSummary/components/UvIndex/index.js +16 -72
- package/src/screens/UnitSummary/components/UvIndex/styles.js +48 -0
- package/src/screens/UnitSummary/components/WaterQuality/Item/index.js +6 -4
- package/src/screens/UnitSummary/components/WaterQuality/__test__/index.test.js +26 -12
- package/src/screens/UnitSummary/components/WaterQuality/index.js +93 -3
- package/src/screens/UnitSummary/index.js +1 -9
- package/src/utils/I18n/translations/en.js +16 -1
- package/src/utils/I18n/translations/vi.js +15 -1
- package/src/utils/Route/index.js +1 -0
- package/src/screens/UnitSummary/components/PowerConsumption/ItemPower/index.js +0 -53
- package/src/screens/UnitSummary/components/PowerConsumption/__test__/ItemPower.test.js +0 -20
|
@@ -1,84 +1,76 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { IconOutline } from '@ant-design/icons-react-native';
|
|
4
|
-
import { useTranslations } from '../../../hooks/Common/useTranslations';
|
|
5
4
|
|
|
6
|
-
import { Colors } from '../../../configs';
|
|
7
|
-
import { Section } from '../../../commons/index';
|
|
8
|
-
import Text from '../../../commons/Text';
|
|
9
|
-
import VisualChart from '../../../screens/Device/components/VisualChart';
|
|
10
|
-
|
|
11
|
-
import SegmentedRoundDisplay from './SegmentedRoundDisplay';
|
|
12
|
-
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
13
5
|
import styles from './styles';
|
|
14
6
|
|
|
7
|
+
import { Section, Text } from '../../../../commons';
|
|
8
|
+
import VisualChart from '../../../Device/components/VisualChart';
|
|
9
|
+
import { useTranslations } from '../../../../hooks/Common/useTranslations';
|
|
10
|
+
import { useWatchConfigs } from '../../../../hooks/IoT';
|
|
11
|
+
import { Colors } from '../../../../configs';
|
|
12
|
+
import AccessibilityLabel from '../../../../configs/AccessibilityLabel';
|
|
13
|
+
import SegmentedRoundChart from './SegmentedRoundChart';
|
|
14
|
+
|
|
15
15
|
const AirQuality = memo(({ summaryDetail }) => {
|
|
16
16
|
const t = useTranslations();
|
|
17
17
|
const {
|
|
18
|
-
outdoor_pm10_id,
|
|
19
|
-
outdoor_pm2_5_id,
|
|
20
|
-
outdoor_co_id,
|
|
21
18
|
outdoorColor,
|
|
22
19
|
outdoorColorLight,
|
|
23
20
|
outdoorStatus,
|
|
24
21
|
outdoorIcon,
|
|
25
22
|
advices,
|
|
23
|
+
listConfigs,
|
|
24
|
+
outdoor_pm2_5_color,
|
|
25
|
+
outdoor_pm10_color,
|
|
26
|
+
outdoor_co_color,
|
|
26
27
|
} = summaryDetail;
|
|
27
|
-
const outdoorValues = [];
|
|
28
|
-
if (summaryDetail.outdoor_pm2_5_value !== null) {
|
|
29
|
-
outdoorValues.push({
|
|
30
|
-
id: '0',
|
|
31
|
-
title: 'PM2.5',
|
|
32
|
-
value:
|
|
33
|
-
summaryDetail.outdoor_pm2_5_value !== undefined
|
|
34
|
-
? summaryDetail.outdoor_pm2_5_value
|
|
35
|
-
: t('loading'),
|
|
36
|
-
color: summaryDetail.outdoor_pm2_5_color,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
if (summaryDetail.outdoor_pm10_value !== null) {
|
|
40
|
-
outdoorValues.push({
|
|
41
|
-
id: '1',
|
|
42
|
-
title: 'PM10',
|
|
43
|
-
value:
|
|
44
|
-
summaryDetail.outdoor_pm10_value !== undefined
|
|
45
|
-
? summaryDetail.outdoor_pm10_value
|
|
46
|
-
: t('loading'),
|
|
47
|
-
color: summaryDetail.outdoor_pm10_color,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (summaryDetail.outdoor_co_value !== null) {
|
|
51
|
-
outdoorValues.push({
|
|
52
|
-
id: '2',
|
|
53
|
-
title: 'CO',
|
|
54
|
-
value:
|
|
55
|
-
summaryDetail.outdoor_co_value !== undefined
|
|
56
|
-
? summaryDetail.outdoor_co_value
|
|
57
|
-
: t('loading'),
|
|
58
|
-
color: summaryDetail.outdoor_co_color,
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
28
|
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
29
|
+
const { outdoor_co, outdoor_pm2_5, outdoor_pm10 } = listConfigs || {};
|
|
30
|
+
useWatchConfigs([outdoor_co, outdoor_pm2_5, outdoor_pm10]);
|
|
31
|
+
const [outdoor, setOutdoor] = useState();
|
|
32
|
+
const createDataItem = (id, color, title) => ({
|
|
33
|
+
id,
|
|
34
|
+
color,
|
|
35
|
+
title,
|
|
36
|
+
});
|
|
65
37
|
|
|
66
38
|
const configs = useMemo(() => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
39
|
+
const data = [];
|
|
40
|
+
|
|
41
|
+
if (outdoor_co) {
|
|
42
|
+
data.push(createDataItem(outdoor_co, outdoor_co_color, 'CO'));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (outdoor_pm2_5) {
|
|
46
|
+
data.push(createDataItem(outdoor_pm2_5, outdoor_pm2_5_color, 'PM2.5'));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (outdoor_pm10) {
|
|
50
|
+
data.push(createDataItem(outdoor_pm10, outdoor_pm10_color, 'PM10'));
|
|
51
|
+
}
|
|
52
|
+
setOutdoor(data[0] || {});
|
|
53
|
+
return data;
|
|
54
|
+
}, [
|
|
55
|
+
outdoor_co,
|
|
56
|
+
outdoor_co_color,
|
|
57
|
+
outdoor_pm10,
|
|
58
|
+
outdoor_pm10_color,
|
|
59
|
+
outdoor_pm2_5,
|
|
60
|
+
outdoor_pm2_5_color,
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
const showBoxHistory = useMemo(() => {
|
|
64
|
+
return !!configs.length;
|
|
65
|
+
}, [configs.length]);
|
|
73
66
|
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
setIndexOutdoor(i);
|
|
67
|
+
const onSelectOutdoor = useCallback((item) => {
|
|
68
|
+
setOutdoor(item);
|
|
77
69
|
}, []);
|
|
78
70
|
|
|
79
71
|
return (
|
|
80
72
|
<View>
|
|
81
|
-
{!!
|
|
73
|
+
{!!configs.length && (
|
|
82
74
|
<Section type={'border'} style={styles.boxOutdoor}>
|
|
83
75
|
<Text semibold style={styles.textOutdoor}>
|
|
84
76
|
{t('text_outdoor')}
|
|
@@ -101,8 +93,8 @@ const AirQuality = memo(({ summaryDetail }) => {
|
|
|
101
93
|
</View>
|
|
102
94
|
</View>
|
|
103
95
|
<View style={styles.boxOutdoorValues}>
|
|
104
|
-
{
|
|
105
|
-
let active =
|
|
96
|
+
{configs.map((item, i) => {
|
|
97
|
+
let active = item.id === outdoor?.id;
|
|
106
98
|
const borderWidth = active ? 0 : 1;
|
|
107
99
|
return (
|
|
108
100
|
<TouchableOpacity
|
|
@@ -117,7 +109,7 @@ const AirQuality = memo(({ summaryDetail }) => {
|
|
|
117
109
|
},
|
|
118
110
|
]}
|
|
119
111
|
key={i}
|
|
120
|
-
onPress={() => onSelectOutdoor(
|
|
112
|
+
onPress={() => onSelectOutdoor(item)}
|
|
121
113
|
>
|
|
122
114
|
<Text size={14} color={active ? Colors.White : Colors.Gray8}>
|
|
123
115
|
{item.title}
|
|
@@ -126,16 +118,8 @@ const AirQuality = memo(({ summaryDetail }) => {
|
|
|
126
118
|
);
|
|
127
119
|
})}
|
|
128
120
|
</View>
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
value={outdoorValues[indexOutdoor].value}
|
|
132
|
-
valueText={outdoorValues[indexOutdoor].value}
|
|
133
|
-
totalValue={500}
|
|
134
|
-
title={outdoorValues[indexOutdoor].title}
|
|
135
|
-
style={styles.segment}
|
|
136
|
-
textHeader={t('text_air_quality_index')}
|
|
137
|
-
/>
|
|
138
|
-
{!!advices && !!advices.length && (
|
|
121
|
+
{<SegmentedRoundChart data={outdoor} />}
|
|
122
|
+
{!!advices?.length && (
|
|
139
123
|
<View style={styles.boxHealth}>
|
|
140
124
|
<IconOutline name="alert" size={20} style={styles.iconMargin} />
|
|
141
125
|
<Text semibold color={Colors.Gray9} type="H4">
|
package/src/screens/UnitSummary/components/PowerConsumption/__test__/PowerConsumption.test.js
CHANGED
|
@@ -13,6 +13,17 @@ import { Today } from '../../../../../commons';
|
|
|
13
13
|
|
|
14
14
|
const mock = new MockAdapter(api.axiosInstance);
|
|
15
15
|
|
|
16
|
+
const mockedNavigate = jest.fn();
|
|
17
|
+
|
|
18
|
+
jest.mock('@react-navigation/native', () => {
|
|
19
|
+
return {
|
|
20
|
+
...jest.requireActual('@react-navigation/native'),
|
|
21
|
+
useNavigation: () => ({
|
|
22
|
+
navigate: mockedNavigate,
|
|
23
|
+
}),
|
|
24
|
+
useFocusEffect: (func) => func(),
|
|
25
|
+
};
|
|
26
|
+
});
|
|
16
27
|
const wrapComponent = (summaryDetail) => (
|
|
17
28
|
<SCProvider initState={mockSCStore({})}>
|
|
18
29
|
<PowerConsumption summaryDetail={summaryDetail} />
|
|
@@ -29,7 +40,13 @@ describe('Test PowerConsumption', () => {
|
|
|
29
40
|
activePowerValue: 10,
|
|
30
41
|
powerFactorValue: 30,
|
|
31
42
|
totalPowerValue: 20,
|
|
32
|
-
listConfigs:
|
|
43
|
+
listConfigs: {
|
|
44
|
+
volt: 1,
|
|
45
|
+
current: 2,
|
|
46
|
+
active_power: 3,
|
|
47
|
+
power_factor: 4,
|
|
48
|
+
total_power: 5,
|
|
49
|
+
},
|
|
33
50
|
};
|
|
34
51
|
await act(async () => {
|
|
35
52
|
tree = await renderer.create(wrapComponent(summaryDetail));
|
|
@@ -44,29 +61,25 @@ describe('Test PowerConsumption', () => {
|
|
|
44
61
|
const resultList = [
|
|
45
62
|
{
|
|
46
63
|
color: Colors.Red6,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
measure: '',
|
|
64
|
+
title: 'Voltage',
|
|
65
|
+
measure: 'V',
|
|
50
66
|
id: 1,
|
|
51
67
|
},
|
|
52
68
|
{
|
|
53
69
|
color: Colors.Blue10,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
measure: '',
|
|
70
|
+
title: 'Current',
|
|
71
|
+
measure: 'A',
|
|
57
72
|
id: 2,
|
|
58
73
|
},
|
|
59
74
|
{
|
|
60
75
|
color: Colors.Orange,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
measure: '',
|
|
76
|
+
title: 'Active Power',
|
|
77
|
+
measure: 'kW',
|
|
64
78
|
id: 3,
|
|
65
79
|
},
|
|
66
80
|
{
|
|
67
81
|
color: Colors.Green6,
|
|
68
|
-
|
|
69
|
-
value: summaryDetail.powerFactorValue,
|
|
82
|
+
title: 'Power Factor',
|
|
70
83
|
measure: '',
|
|
71
84
|
id: 4,
|
|
72
85
|
},
|
|
@@ -127,14 +140,7 @@ describe('Test PowerConsumption', () => {
|
|
|
127
140
|
|
|
128
141
|
it('render without value', async () => {
|
|
129
142
|
const summaryDetail = {
|
|
130
|
-
listConfigs: {
|
|
131
|
-
active_power: 208,
|
|
132
|
-
current: 210,
|
|
133
|
-
freq: null,
|
|
134
|
-
power_factor: 229,
|
|
135
|
-
total_power: 207,
|
|
136
|
-
volt: 209,
|
|
137
|
-
},
|
|
143
|
+
listConfigs: {},
|
|
138
144
|
};
|
|
139
145
|
|
|
140
146
|
await act(async () => {
|
|
@@ -12,71 +12,14 @@ import HistoryChart from '../../../../commons/Device/HistoryChart';
|
|
|
12
12
|
import { AccessibilityLabel } from '../../../../configs/Constants';
|
|
13
13
|
import { axiosGet } from '../../../../utils/Apis/axios';
|
|
14
14
|
import VisualChart from '../../../Device/components/VisualChart';
|
|
15
|
+
import { useWatchConfigs } from '../../../../hooks/IoT';
|
|
15
16
|
|
|
16
17
|
const PowerConsumption = memo(({ summaryDetail }) => {
|
|
17
18
|
const t = useTranslations();
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
powerFactorValue,
|
|
23
|
-
totalPowerValue,
|
|
24
|
-
listConfigs,
|
|
25
|
-
} = summaryDetail;
|
|
26
|
-
|
|
27
|
-
const showBoxHistory = useMemo(() => {
|
|
28
|
-
return !!listConfigs;
|
|
29
|
-
}, [listConfigs]);
|
|
30
|
-
|
|
31
|
-
const listIdsConfig = useMemo(() => {
|
|
32
|
-
return listConfigs;
|
|
33
|
-
}, [listConfigs]);
|
|
34
|
-
|
|
35
|
-
const voltItem = {
|
|
36
|
-
id: 1,
|
|
37
|
-
color: Colors.Red6,
|
|
38
|
-
standard: 'Voltage',
|
|
39
|
-
value: voltValue !== undefined ? voltValue : t('loading'),
|
|
40
|
-
measure: '',
|
|
41
|
-
};
|
|
42
|
-
const currentItem = {
|
|
43
|
-
id: 2,
|
|
44
|
-
color: Colors.Blue10,
|
|
45
|
-
standard: 'Current',
|
|
46
|
-
value: currentValue !== undefined ? currentValue : t('loading'),
|
|
47
|
-
measure: '',
|
|
48
|
-
};
|
|
49
|
-
const activeItem = {
|
|
50
|
-
id: 3,
|
|
51
|
-
color: Colors.Orange,
|
|
52
|
-
standard: 'Active Power',
|
|
53
|
-
value: activePowerValue !== undefined ? activePowerValue : t('loading'),
|
|
54
|
-
measure: '',
|
|
55
|
-
};
|
|
56
|
-
const powFactorItem = {
|
|
57
|
-
id: 4,
|
|
58
|
-
color: Colors.Green6,
|
|
59
|
-
standard: 'Power Factor',
|
|
60
|
-
value: powerFactorValue !== undefined ? powerFactorValue : t('loading'),
|
|
61
|
-
measure: '',
|
|
62
|
-
};
|
|
63
|
-
const totalPower = {
|
|
64
|
-
id: 5,
|
|
65
|
-
color: Colors.Green7,
|
|
66
|
-
standard: 'Total Power Consumption',
|
|
67
|
-
value: totalPowerValue !== undefined ? totalPowerValue : t('loading'),
|
|
68
|
-
measure: '',
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const dataList = [];
|
|
72
|
-
voltValue !== undefined && dataList.push(voltItem);
|
|
73
|
-
currentValue !== undefined && dataList.push(currentItem);
|
|
74
|
-
activePowerValue !== undefined && dataList.push(activeItem);
|
|
75
|
-
powerFactorValue !== undefined && dataList.push(powFactorItem);
|
|
76
|
-
|
|
77
|
-
const dataTotal = [];
|
|
78
|
-
dataTotal.push(totalPower);
|
|
79
|
-
|
|
19
|
+
const { listConfigs } = summaryDetail;
|
|
20
|
+
const { volt, current, active_power, power_factor, total_power } =
|
|
21
|
+
listConfigs || {};
|
|
22
|
+
useWatchConfigs([volt, current, active_power, power_factor, total_power]);
|
|
80
23
|
const [startDate, setStartDate] = useState(moment().subtract(6, 'days'));
|
|
81
24
|
const [endDate, setEndDate] = useState(moment());
|
|
82
25
|
const [groupBy, setGroupBy] = useState('date');
|
|
@@ -85,11 +28,61 @@ const PowerConsumption = memo(({ summaryDetail }) => {
|
|
|
85
28
|
unit: 'kWh',
|
|
86
29
|
price: '',
|
|
87
30
|
});
|
|
31
|
+
const showBoxHistory = useMemo(() => {
|
|
32
|
+
return !!listConfigs;
|
|
33
|
+
}, [listConfigs]);
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
+
const createDataItem = (id, color, title, measure) => ({
|
|
37
|
+
id,
|
|
38
|
+
color,
|
|
39
|
+
title,
|
|
40
|
+
measure,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const configs = useMemo(() => {
|
|
44
|
+
const data = [];
|
|
45
|
+
|
|
46
|
+
if (volt) {
|
|
47
|
+
data.push(createDataItem(volt, Colors.Red6, 'Voltage', 'V'));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (current) {
|
|
51
|
+
data.push(createDataItem(current, Colors.Blue10, 'Current', 'A'));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (active_power) {
|
|
55
|
+
data.push(
|
|
56
|
+
createDataItem(active_power, Colors.Orange, 'Active Power', 'kW')
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (power_factor) {
|
|
61
|
+
data.push(
|
|
62
|
+
createDataItem(power_factor, Colors.Green6, 'Power Factor', '')
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return data;
|
|
67
|
+
}, [active_power, createDataItem, current, power_factor, volt]);
|
|
68
|
+
|
|
69
|
+
const dataTotal = useMemo(() => {
|
|
70
|
+
return total_power
|
|
71
|
+
? [
|
|
72
|
+
createDataItem(
|
|
73
|
+
total_power,
|
|
74
|
+
Colors.Green7,
|
|
75
|
+
'Total Power Consumption',
|
|
76
|
+
'kWh'
|
|
77
|
+
),
|
|
78
|
+
]
|
|
79
|
+
: [];
|
|
80
|
+
}, [total_power]);
|
|
88
81
|
|
|
89
82
|
useEffect(() => {
|
|
90
83
|
const fetchData = async () => {
|
|
91
84
|
let params = new URLSearchParams();
|
|
92
|
-
params.append('config',
|
|
85
|
+
params.append('config', total_power);
|
|
93
86
|
params.append('group_by', groupBy);
|
|
94
87
|
if (groupBy === 'date') {
|
|
95
88
|
params.append('date_from', moment(startDate).format('YYYY-MM-DD'));
|
|
@@ -105,38 +98,17 @@ const PowerConsumption = memo(({ summaryDetail }) => {
|
|
|
105
98
|
setData(data);
|
|
106
99
|
}
|
|
107
100
|
};
|
|
108
|
-
if (
|
|
101
|
+
if (total_power) {
|
|
109
102
|
fetchData();
|
|
110
103
|
}
|
|
111
|
-
}, [startDate, endDate,
|
|
112
|
-
|
|
113
|
-
const configs = useMemo(() => {
|
|
114
|
-
return [
|
|
115
|
-
{ id: listIdsConfig?.volt, title: 'Volt', color: 'red' },
|
|
116
|
-
{
|
|
117
|
-
id: listIdsConfig?.current,
|
|
118
|
-
title: 'Current',
|
|
119
|
-
color: 'blue',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
id: listIdsConfig?.active_power,
|
|
123
|
-
title: 'Active Power',
|
|
124
|
-
color: 'orange',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
id: listIdsConfig?.power_factor,
|
|
128
|
-
title: 'Power Factor',
|
|
129
|
-
color: 'green',
|
|
130
|
-
},
|
|
131
|
-
];
|
|
132
|
-
}, [listIdsConfig]);
|
|
104
|
+
}, [startDate, endDate, total_power, groupBy]);
|
|
133
105
|
|
|
134
106
|
return (
|
|
135
107
|
<>
|
|
136
108
|
<Section type={'border'}>
|
|
137
109
|
<Today style={styles.textIndoor} />
|
|
138
110
|
<ListQualityIndicator
|
|
139
|
-
data={
|
|
111
|
+
data={configs}
|
|
140
112
|
style={styles.styleList}
|
|
141
113
|
accessibilityLabel={AccessibilityLabel.LIST_QUALITY_INDICATOR_PC}
|
|
142
114
|
/>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { memo, useCallback } from 'react';
|
|
2
|
+
import { FlatList, StyleSheet } from 'react-native';
|
|
3
3
|
import ItemDevice from '../../../../commons/Device/ItemDevice';
|
|
4
4
|
import { useDevicesStatus } from '../../../../hooks/Common';
|
|
5
5
|
import { useUnitConnectRemoteDevices } from '../../../Unit/hook/useUnitConnectRemoteDevices';
|
|
@@ -8,30 +8,34 @@ const RunningDevices = memo(({ unit, summaryDetail }) => {
|
|
|
8
8
|
const { devices } = summaryDetail;
|
|
9
9
|
|
|
10
10
|
useUnitConnectRemoteDevices(unit);
|
|
11
|
-
|
|
12
11
|
useDevicesStatus(unit, devices);
|
|
13
12
|
|
|
13
|
+
const renderItem = useCallback(
|
|
14
|
+
({ item, index }) => (
|
|
15
|
+
<ItemDevice
|
|
16
|
+
key={`sensor-${item.id}`}
|
|
17
|
+
id={item.id}
|
|
18
|
+
svgMain={item.icon || 'door'}
|
|
19
|
+
statusIcon={item.action && item.action.icon}
|
|
20
|
+
statusColor={item.action && item.action.color}
|
|
21
|
+
description={item.value}
|
|
22
|
+
title={item.name}
|
|
23
|
+
index={index}
|
|
24
|
+
sensor={item}
|
|
25
|
+
unit={unit}
|
|
26
|
+
station={item.station}
|
|
27
|
+
/>
|
|
28
|
+
),
|
|
29
|
+
[unit]
|
|
30
|
+
);
|
|
31
|
+
|
|
14
32
|
return (
|
|
15
|
-
<
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
id={item.id}
|
|
22
|
-
svgMain={item.icon || 'door'}
|
|
23
|
-
statusIcon={item.action && item.action.icon}
|
|
24
|
-
statusColor={item.action && item.action.color}
|
|
25
|
-
description={item.value}
|
|
26
|
-
title={item.name}
|
|
27
|
-
index={index}
|
|
28
|
-
sensor={item}
|
|
29
|
-
unit={unit}
|
|
30
|
-
station={item.station}
|
|
31
|
-
/>
|
|
32
|
-
);
|
|
33
|
-
})}
|
|
34
|
-
</View>
|
|
33
|
+
<FlatList
|
|
34
|
+
data={devices}
|
|
35
|
+
renderItem={renderItem}
|
|
36
|
+
keyExtractor={(item) => `sensor-${item.id}`}
|
|
37
|
+
contentContainerStyle={styles.container}
|
|
38
|
+
/>
|
|
35
39
|
);
|
|
36
40
|
});
|
|
37
41
|
const styles = StyleSheet.create({
|
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
import React, { memo } from 'react';
|
|
1
|
+
import React, { memo, useMemo } from 'react';
|
|
2
2
|
import { View, StyleSheet } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import Text from '../../../../../commons/Text';
|
|
5
5
|
import { Colors, Constants } from '../../../../../configs';
|
|
6
|
+
import { useConfigGlobalState } from '../../../../../iot/states';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const ItemTemperature = memo(
|
|
9
|
+
({ id, svgMain, title, des, measure, custom_get_value }) => {
|
|
10
|
+
const [configValues] = useConfigGlobalState('configValues');
|
|
11
|
+
|
|
12
|
+
const getValue = useMemo(() => {
|
|
13
|
+
if (custom_get_value) {
|
|
14
|
+
return custom_get_value[configValues?.[id]?.value] || '--';
|
|
15
|
+
} else if (configValues?.[id]?.value !== undefined) {
|
|
16
|
+
return `${configValues[id].value} ${measure}`;
|
|
17
|
+
} else {
|
|
18
|
+
return '--';
|
|
19
|
+
}
|
|
20
|
+
}, [configValues, custom_get_value, id, measure]);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.container}>
|
|
24
|
+
<Text type="H4" color={Colors.Gray8} style={styles.textTitle}>
|
|
25
|
+
{title}
|
|
26
|
+
</Text>
|
|
27
|
+
<Text size={24} color={Colors.Gray9} style={styles.textValue}>
|
|
28
|
+
{getValue}
|
|
29
|
+
</Text>
|
|
30
|
+
<Text type="H4" color={Colors.Gray8}>
|
|
31
|
+
{des}
|
|
32
|
+
</Text>
|
|
33
|
+
<View style={styles.boxSvg}>{svgMain}</View>
|
|
34
|
+
</View>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
8
38
|
|
|
9
|
-
const ItemTemperature = memo((props) => {
|
|
10
|
-
const { svgMain, title, des, value } = props;
|
|
11
|
-
return (
|
|
12
|
-
<View style={styles.container}>
|
|
13
|
-
<Text type="H4" color={Colors.Gray8} style={styles.textTitle}>
|
|
14
|
-
{title}
|
|
15
|
-
</Text>
|
|
16
|
-
<Text size={24} color={Colors.Gray9} style={styles.textValue}>
|
|
17
|
-
{value}
|
|
18
|
-
</Text>
|
|
19
|
-
<Text type="H4" color={Colors.Gray8}>
|
|
20
|
-
{des}
|
|
21
|
-
</Text>
|
|
22
|
-
<View style={styles.boxSvg}>{svgMain}</View>
|
|
23
|
-
</View>
|
|
24
|
-
);
|
|
25
|
-
});
|
|
26
39
|
export default ItemTemperature;
|
|
27
40
|
|
|
28
41
|
const styles = StyleSheet.create({
|
|
@@ -36,7 +49,7 @@ const styles = StyleSheet.create({
|
|
|
36
49
|
shadowOpacity: 0.1,
|
|
37
50
|
elevation: 5,
|
|
38
51
|
backgroundColor: Colors.White,
|
|
39
|
-
width:
|
|
52
|
+
width: (Constants.width - 48) / 2,
|
|
40
53
|
marginBottom: 16,
|
|
41
54
|
borderRadius: 5,
|
|
42
55
|
},
|