@eohjsc/react-native-smart-city 0.4.42 → 0.4.43
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/android/build.gradle +19 -24
- package/package.json +14 -12
- package/src/commons/Action/ItemQuickAction.js +1 -0
- package/src/commons/ActionGroup/ColorPickerTemplate.js +3 -4
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +7 -10
- package/src/commons/ActionGroup/OnOffSmartLock/OnOffSmartLock.js +2 -2
- package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplate.js +4 -5
- package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OnOffTemplate/index.js +6 -5
- package/src/commons/ActionGroup/OneBigButtonTemplate.js +4 -4
- package/src/commons/ActionGroup/OptionsDropdownActionTemplate.js +6 -17
- package/src/commons/ActionGroup/SliderRangeTemplate.js +5 -3
- package/src/commons/ActionGroup/SmartTiviActionTemplate/SmartTiviActionTemplate.js +7 -7
- package/src/commons/ActionGroup/StatesGridActionTemplate.js +6 -20
- package/src/commons/ActionGroup/ThreeButtonTemplate/__test__/ThreeButtonTemplate.test.js +6 -6
- package/src/commons/ActionGroup/ThreeButtonTemplate/index.js +2 -2
- package/src/commons/ActionGroup/TimerActionTemplate.js +3 -2
- package/src/commons/ActionGroup/TwoButtonTemplate/index.js +133 -135
- package/src/commons/ActionGroup/__test__/ColorPickerTemplate.test.js +37 -14
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +75 -32
- package/src/commons/ActionGroup/__test__/OnOffButtonTemplate.test.js +11 -11
- package/src/commons/ActionGroup/__test__/OnOffSmartLock.test.js +13 -17
- package/src/commons/ActionGroup/__test__/OnOffTemplate.test.js +44 -48
- package/src/commons/ActionGroup/__test__/OneBigButtonTemplate.test.js +56 -22
- package/src/commons/ActionGroup/__test__/OptionsDropdownTemplate.test.js +123 -21
- package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +12 -16
- package/src/commons/ActionGroup/__test__/StatesGridActionTemplate.test.js +73 -38
- package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplate.test.js +11 -15
- package/src/commons/ActionGroup/__test__/TimerActionTemplateWithutConfigValue.test.js +9 -9
- package/src/commons/ActionGroup/__test__/TwoButtonTemplate.test.js +21 -31
- package/src/commons/ActionGroup/__test__/index.test.js +36 -21
- package/src/commons/ActionGroup/index.js +4 -7
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +0 -5
- package/src/commons/Dashboard/MyUnit/index.js +10 -8
- package/src/commons/DateTimeRangeChange/index.js +3 -3
- package/src/commons/Device/HistoryChart.js +1 -1
- package/src/commons/Device/HorizontalBarChart.js +3 -4
- package/src/commons/Device/LinearChart.js +3 -5
- package/src/commons/FlatListDnD/__test__/index.test.js +27 -25
- package/src/commons/GroupCheckBox/__test__/GroupCheckBox.test.js +1 -22
- package/src/commons/HeaderAni/index.js +12 -2
- package/src/commons/Highcharts/index.js +111 -0
- package/src/commons/MediaPlayerDetail/__test__/MediaPlayerFull.test.js +1 -23
- package/src/commons/Modal/ModalCustom.js +2 -2
- package/src/commons/OneTapTemplate/__test__/NumberUpDownActionTemplate.test.js +5 -3
- package/src/commons/Processing/index.js +1 -0
- package/src/commons/Processing/styles.js +3 -0
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +2 -0
- package/src/commons/Unit/HeaderUnit/index.js +15 -8
- package/src/commons/UnitSummary/ConfigHistoryChart/index.js +1 -59
- package/src/commons/icon/index.js +57 -0
- package/src/configs/AccessibilityLabel.js +2 -0
- package/src/hooks/IoT/__test__/useRemoteControl.test.js +52 -51
- package/src/hooks/IoT/__test__/useWatchConfigs.test.js +3 -2
- package/src/hooks/useMqtt.js +5 -2
- package/src/iot/mqtt.js +2 -0
- package/src/navigations/UnitStack.js +2 -2
- package/src/screens/AddNewGateway/ConnectingDevice.js +2 -2
- package/src/screens/AddNewGateway/ShareWifiPassword.js +2 -2
- package/src/screens/AllGateway/DeviceModbusDetail/__test__/index.test.js +31 -32
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +19 -2
- package/src/screens/Automate/AddNewAction/__test__/{SetupSensor.test.js → SetupConfigCondition.test.js} +97 -0
- package/src/screens/Automate/EditActionsList/__tests__/index.test.js +69 -68
- package/src/screens/ChangePosition/__test__/index.test.js +34 -32
- package/src/screens/ConfirmUnitDeletion/__test__/ConfirmUnitDeletion.test.js +1 -11
- package/src/screens/Device/__test__/detail.test.js +101 -46
- package/src/screens/Device/__test__/sensorDisplayItem.test.js +14 -2
- package/src/screens/Device/components/ChartWrapper.js +14 -12
- package/src/screens/Device/components/SensorDisplayItem.js +18 -2
- package/src/screens/Device/components/VisualChart.js +17 -3
- package/src/screens/Device/components/__test__/VisualChart.test.js +12 -15
- package/src/screens/Device/detail.js +49 -36
- package/src/screens/Device/hooks/__test__/useEvaluateValue.test.js +20 -18
- package/src/screens/Device/styles.js +3 -0
- package/src/screens/Sharing/InfoMemberUnit.js +3 -1
- package/src/screens/Sharing/MemberList.js +16 -3
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +2 -0
- package/src/screens/Sharing/__test__/SelectPermission.test.js +96 -137
- package/src/screens/Template/__test__/EditTemplate.test.js +48 -45
- package/src/screens/Unit/SelectAddToFavorites.js +1 -0
- package/src/screens/Unit/__test__/SelectAddress.test.js +4 -11
- package/src/screens/UnitSummary/components/3PPowerConsumption/__test__/3PPowerConsumption.test.js +1 -11
- package/src/utils/Apis/axios.js +1 -0
- package/src/utils/I18n/translations/en.js +2 -0
- package/src/utils/I18n/translations/vi.js +2 -0
- package/src/utils/Monitor.js +2 -2
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +0 -289
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { act, create } from 'react-test-renderer';
|
|
3
3
|
import { TouchableOpacity } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
6
6
|
import GroupCheckBox from '..';
|
|
7
7
|
|
|
8
|
-
jest.mock('react', () => ({
|
|
9
|
-
...jest.requireActual('react'),
|
|
10
|
-
useState: jest.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
8
|
describe('Test Group CheckBox', () => {
|
|
14
9
|
let tree;
|
|
15
|
-
const mockSetState = () => {
|
|
16
|
-
const setState = jest.fn();
|
|
17
|
-
useState.mockImplementation((init) => [init, setState]);
|
|
18
|
-
return setState;
|
|
19
|
-
};
|
|
20
10
|
|
|
21
11
|
const findGroupCheckBoxItem = (instance) => {
|
|
22
12
|
const item = instance.find(
|
|
@@ -34,7 +24,6 @@ describe('Test Group CheckBox', () => {
|
|
|
34
24
|
description: 'description',
|
|
35
25
|
},
|
|
36
26
|
];
|
|
37
|
-
mockSetState();
|
|
38
27
|
await act(async () => {
|
|
39
28
|
tree = await create(<GroupCheckBox data={data} />);
|
|
40
29
|
});
|
|
@@ -51,7 +40,6 @@ describe('Test Group CheckBox', () => {
|
|
|
51
40
|
},
|
|
52
41
|
];
|
|
53
42
|
const mockFunc = jest.fn();
|
|
54
|
-
const setState = mockSetState();
|
|
55
43
|
await act(async () => {
|
|
56
44
|
tree = await create(
|
|
57
45
|
<GroupCheckBox data={data} onSelect={mockFunc} multiple />
|
|
@@ -62,9 +50,6 @@ describe('Test Group CheckBox', () => {
|
|
|
62
50
|
await act(async () => {
|
|
63
51
|
item.props.onSelect(0);
|
|
64
52
|
});
|
|
65
|
-
expect(setState).toHaveBeenCalledTimes(2);
|
|
66
|
-
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
67
|
-
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
68
53
|
expect(mockFunc).toHaveBeenCalledWith([
|
|
69
54
|
{ description: 'description', source: 'source', title: 'testItem' },
|
|
70
55
|
]);
|
|
@@ -85,7 +70,6 @@ describe('Test Group CheckBox', () => {
|
|
|
85
70
|
},
|
|
86
71
|
];
|
|
87
72
|
const mockFunc = jest.fn();
|
|
88
|
-
const setState = mockSetState();
|
|
89
73
|
await act(async () => {
|
|
90
74
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
91
75
|
});
|
|
@@ -94,8 +78,6 @@ describe('Test Group CheckBox', () => {
|
|
|
94
78
|
await act(async () => {
|
|
95
79
|
item.props.onSelect(0);
|
|
96
80
|
});
|
|
97
|
-
expect(setState).toHaveBeenNthCalledWith(1, [0]);
|
|
98
|
-
expect(setState).toHaveBeenNthCalledWith(2, [0]);
|
|
99
81
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
100
82
|
description: 'description 1',
|
|
101
83
|
title: 'title 1',
|
|
@@ -114,8 +96,6 @@ describe('Test Group CheckBox', () => {
|
|
|
114
96
|
},
|
|
115
97
|
];
|
|
116
98
|
const mockFunc = jest.fn();
|
|
117
|
-
const setState = jest.fn();
|
|
118
|
-
useState.mockImplementation((init) => [[0], setState]);
|
|
119
99
|
await act(async () => {
|
|
120
100
|
tree = await create(<GroupCheckBox data={data} onSelect={mockFunc} />);
|
|
121
101
|
});
|
|
@@ -128,7 +108,6 @@ describe('Test Group CheckBox', () => {
|
|
|
128
108
|
await act(async () => {
|
|
129
109
|
items[1].props.onSelect(0);
|
|
130
110
|
});
|
|
131
|
-
expect(setState).toHaveBeenCalledWith([]); // called 1 time
|
|
132
111
|
expect(mockFunc).toHaveBeenCalledWith({
|
|
133
112
|
description: 'description 1',
|
|
134
113
|
title: 'title 1',
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import React, { memo, useCallback } from 'react';
|
|
2
2
|
import { Icon } from '@ant-design/react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
TouchableOpacity,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Animated,
|
|
7
|
+
View,
|
|
8
|
+
Platform,
|
|
9
|
+
} from 'react-native';
|
|
4
10
|
import { useNavigation } from '@react-navigation/native';
|
|
5
11
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
6
12
|
|
|
@@ -95,7 +101,11 @@ const HeaderAni = memo(
|
|
|
95
101
|
onPress={onPressLeft}
|
|
96
102
|
accessibilityLabel={AccessibilityLabel.ICON_BACK}
|
|
97
103
|
>
|
|
98
|
-
<Icon
|
|
104
|
+
<Icon
|
|
105
|
+
name={Platform.OS === 'android' ? 'left-square' : 'left'}
|
|
106
|
+
size={27}
|
|
107
|
+
color={Colors.Gray9}
|
|
108
|
+
/>
|
|
99
109
|
</TouchableOpacity>
|
|
100
110
|
<View styles={styles.wrapRightComponent}>{rightComponent}</View>
|
|
101
111
|
</Animated.View>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import WebView from 'react-native-webview';
|
|
3
|
+
|
|
4
|
+
const Highcharts = (props) => {
|
|
5
|
+
const [init] = useState(`<html>
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
|
|
7
|
+
<style media="screen" type="text/css">
|
|
8
|
+
#container {
|
|
9
|
+
width:100%;
|
|
10
|
+
height:100%;
|
|
11
|
+
top:0;
|
|
12
|
+
left:0;
|
|
13
|
+
right:0;
|
|
14
|
+
bottom:0;
|
|
15
|
+
position:absolute;
|
|
16
|
+
user-select: none;
|
|
17
|
+
-webkit-user-select: none;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
<head>
|
|
21
|
+
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
|
22
|
+
${
|
|
23
|
+
props.stock
|
|
24
|
+
? '<script src="https://code.highcharts.com/stock/highstock.js"></script>'
|
|
25
|
+
: '<script src="https://code.highcharts.com/highcharts.js"></script>'
|
|
26
|
+
}
|
|
27
|
+
${
|
|
28
|
+
props.more
|
|
29
|
+
? '<script src="https://code.highcharts.com/highcharts-more.js"></script>'
|
|
30
|
+
: ''
|
|
31
|
+
}
|
|
32
|
+
${
|
|
33
|
+
props.guage
|
|
34
|
+
? '<script src="https://code.highcharts.com/modules/solid-gauge.js"></script>'
|
|
35
|
+
: ''
|
|
36
|
+
}
|
|
37
|
+
<script src="https://code.highcharts.com/modules/exporting.js"></script>
|
|
38
|
+
<script>
|
|
39
|
+
$(function () {
|
|
40
|
+
Highcharts.setOptions(${JSON.stringify(
|
|
41
|
+
props.options
|
|
42
|
+
)});
|
|
43
|
+
Highcharts.${
|
|
44
|
+
props.stock ? 'stockChart' : 'chart'
|
|
45
|
+
}('container', `);
|
|
46
|
+
const [end] = useState(` );
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
49
|
+
</head>
|
|
50
|
+
<body>
|
|
51
|
+
<div id="container">
|
|
52
|
+
</div>
|
|
53
|
+
</body>
|
|
54
|
+
</html>`);
|
|
55
|
+
|
|
56
|
+
const flattenText = (item, key) => {
|
|
57
|
+
let str = '';
|
|
58
|
+
if (item && typeof item === 'object' && item.length === undefined) {
|
|
59
|
+
str += flattenObject(item);
|
|
60
|
+
} else if (item && typeof item === 'object' && item.length !== undefined) {
|
|
61
|
+
str += '[';
|
|
62
|
+
item.forEach((k2) => {
|
|
63
|
+
str += `${flattenText(k2)}, `;
|
|
64
|
+
});
|
|
65
|
+
if (item.length > 0) {
|
|
66
|
+
str = str.slice(0, str.length - 2);
|
|
67
|
+
}
|
|
68
|
+
str += ']';
|
|
69
|
+
} else if (typeof item === 'string' && item.slice(0, 8) === 'function') {
|
|
70
|
+
str += `${item}`;
|
|
71
|
+
} else if (typeof item === 'string') {
|
|
72
|
+
// eslint-disable-next-line no-useless-escape
|
|
73
|
+
str += `\"${item.replace(/"/g, '\\"')}\"`;
|
|
74
|
+
} else {
|
|
75
|
+
str += `${item}`;
|
|
76
|
+
}
|
|
77
|
+
return str;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const flattenObject = (obj, str = '{') => {
|
|
81
|
+
Object.keys(obj).forEach(function (key) {
|
|
82
|
+
str += `${key}: ${flattenText(obj[key])}, `;
|
|
83
|
+
});
|
|
84
|
+
return `${str.slice(0, str.length - 2)}}`;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
let config = JSON.stringify(props.options, (key, value) => {
|
|
88
|
+
return typeof value === 'function' ? value.toString() : value;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
config = JSON.parse(config);
|
|
92
|
+
const concatHTML = `${init}${flattenObject(config)}${end}`.replace(
|
|
93
|
+
': }',
|
|
94
|
+
': {}'
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<WebView
|
|
99
|
+
style={[props.styles, props.webviewStyles]}
|
|
100
|
+
source={{ html: concatHTML }}
|
|
101
|
+
javaScriptEnabled={true}
|
|
102
|
+
domStorageEnabled={true}
|
|
103
|
+
scalesPageToFit={true}
|
|
104
|
+
scrollEnabled={false}
|
|
105
|
+
automaticallyAdjustContentInsets={true}
|
|
106
|
+
{...props}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export default Highcharts;
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { TouchableOpacity } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
4
|
import { SCProvider } from '../../../context';
|
|
5
5
|
import { mockSCStore } from '../../../context/mockStore';
|
|
6
6
|
import MediaPlayerFull from '../MediaPlayerFull';
|
|
7
7
|
|
|
8
|
-
const mockSetState = jest.fn();
|
|
9
|
-
jest.mock('react', () => {
|
|
10
|
-
return {
|
|
11
|
-
...jest.requireActual('react'),
|
|
12
|
-
useState: jest.fn((init) => [init, mockSetState]),
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
|
|
16
8
|
const wrapComponent = (props) => (
|
|
17
9
|
<SCProvider initState={mockSCStore({})}>
|
|
18
10
|
<MediaPlayerFull {...props} />
|
|
@@ -22,14 +14,7 @@ const wrapComponent = (props) => (
|
|
|
22
14
|
describe('Test MediaPlayerFull', () => {
|
|
23
15
|
let tree;
|
|
24
16
|
|
|
25
|
-
afterEach(() => {
|
|
26
|
-
useState.mockClear();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
17
|
it('Test render', async () => {
|
|
30
|
-
useState.mockImplementationOnce((init) => [false, mockSetState]);
|
|
31
|
-
useState.mockImplementationOnce((init) => [false, mockSetState]);
|
|
32
|
-
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
33
18
|
await act(async () => {
|
|
34
19
|
tree = await create(
|
|
35
20
|
wrapComponent({
|
|
@@ -44,18 +29,13 @@ describe('Test MediaPlayerFull', () => {
|
|
|
44
29
|
await act(async () => {
|
|
45
30
|
TouchableOpacities[0].props.onPress();
|
|
46
31
|
});
|
|
47
|
-
expect(mockSetState).toBeCalledWith(false);
|
|
48
32
|
await act(async () => {
|
|
49
33
|
TouchableOpacities[1].props.onPress();
|
|
50
34
|
TouchableOpacities[2].props.onPress();
|
|
51
35
|
});
|
|
52
|
-
expect(mockSetState).toBeCalledWith(true);
|
|
53
36
|
});
|
|
54
37
|
|
|
55
38
|
it('Test render 2', async () => {
|
|
56
|
-
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
57
|
-
useState.mockImplementationOnce((init) => [true, mockSetState]);
|
|
58
|
-
useState.mockImplementationOnce((init) => [init, mockSetState]);
|
|
59
39
|
await act(async () => {
|
|
60
40
|
tree = await create(
|
|
61
41
|
wrapComponent({
|
|
@@ -72,11 +52,9 @@ describe('Test MediaPlayerFull', () => {
|
|
|
72
52
|
await act(async () => {
|
|
73
53
|
TouchableOpacities[0].props.onPress();
|
|
74
54
|
});
|
|
75
|
-
expect(mockSetState).toBeCalledWith(false);
|
|
76
55
|
await act(async () => {
|
|
77
56
|
TouchableOpacities[1].props.onPress();
|
|
78
57
|
TouchableOpacities[2].props.onPress();
|
|
79
58
|
});
|
|
80
|
-
expect(mockSetState).toBeCalledWith(true);
|
|
81
59
|
});
|
|
82
60
|
});
|
|
@@ -16,8 +16,8 @@ const ModalCustom = (props) => {
|
|
|
16
16
|
useNativeDriver
|
|
17
17
|
animationIn={'slideInUp'}
|
|
18
18
|
animationOut={'slideOutDown'}
|
|
19
|
-
animationInTiming={
|
|
20
|
-
animationOutTiming={
|
|
19
|
+
animationInTiming={400}
|
|
20
|
+
animationOutTiming={400}
|
|
21
21
|
backdropColor={Colors.BlackTransparent5}
|
|
22
22
|
hideModalContentWhileAnimating
|
|
23
23
|
{...props}
|
|
@@ -11,11 +11,12 @@ import SelectActionCard from '../../SelectActionCard';
|
|
|
11
11
|
|
|
12
12
|
const mockOnSelectAction = jest.fn();
|
|
13
13
|
|
|
14
|
-
const wrapComponent = (item) => (
|
|
14
|
+
const wrapComponent = (item, params = {}) => (
|
|
15
15
|
<SCProvider initState={mockSCStore({})}>
|
|
16
16
|
<NumberUpDownActionTemplate
|
|
17
17
|
item={item}
|
|
18
18
|
onSelectAction={mockOnSelectAction}
|
|
19
|
+
{...params}
|
|
19
20
|
/>
|
|
20
21
|
</SCProvider>
|
|
21
22
|
);
|
|
@@ -35,9 +36,9 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
35
36
|
},
|
|
36
37
|
};
|
|
37
38
|
|
|
38
|
-
const renderOptions = async () => {
|
|
39
|
+
const renderOptions = async (params = {}) => {
|
|
39
40
|
await act(async () => {
|
|
40
|
-
tree = await create(wrapComponent(data));
|
|
41
|
+
tree = await create(wrapComponent(data, params));
|
|
41
42
|
});
|
|
42
43
|
const instance = tree.root;
|
|
43
44
|
const card = instance.findByType(SelectActionCard);
|
|
@@ -98,6 +99,7 @@ describe('Test NumberUpDownActionTemplate', () => {
|
|
|
98
99
|
});
|
|
99
100
|
expect(mockOnSelectAction).toHaveBeenCalled();
|
|
100
101
|
});
|
|
102
|
+
|
|
101
103
|
it('Test config null show valueDefault', async () => {
|
|
102
104
|
data.configuration.config = null;
|
|
103
105
|
const instance = await renderOptions();
|
|
@@ -60,6 +60,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
|
60
60
|
const activateAt = activate_at
|
|
61
61
|
? timeDifference(new Date(), moment(activate_at), true)
|
|
62
62
|
: null;
|
|
63
|
+
|
|
63
64
|
return (
|
|
64
65
|
<TouchableWithoutFeedback
|
|
65
66
|
onPress={onPressItem || goToDetail}
|
|
@@ -88,6 +89,7 @@ const ItemOneTap = memo(({ automate = {}, wrapSyles, onPressItem }) => {
|
|
|
88
89
|
color={Colors.Gray9}
|
|
89
90
|
type="Body"
|
|
90
91
|
style={styles.name}
|
|
92
|
+
accessibilityLabel={AccessibilityLabel.TEXT_AUTOMATE_NAME}
|
|
91
93
|
>
|
|
92
94
|
{script?.name}
|
|
93
95
|
</Text>
|
|
@@ -4,9 +4,11 @@ import { Icon } from '@ant-design/react-native';
|
|
|
4
4
|
import { useNavigation } from '@react-navigation/native';
|
|
5
5
|
import { getStatusBarHeight } from 'react-native-iphone-x-helper';
|
|
6
6
|
|
|
7
|
-
import { Colors, Device } from '../../../configs';
|
|
7
|
+
import { Colors, Device, Images } from '../../../configs';
|
|
8
8
|
import Text from '../../Text';
|
|
9
9
|
import { AccessibilityLabel } from '../../../configs/Constants';
|
|
10
|
+
import { Image } from 'react-native';
|
|
11
|
+
import { Platform } from 'react-native';
|
|
10
12
|
|
|
11
13
|
const HeaderUnit = memo(
|
|
12
14
|
({
|
|
@@ -47,11 +49,7 @@ const HeaderUnit = memo(
|
|
|
47
49
|
style={styles.btnLeft}
|
|
48
50
|
onPress={onPressBack}
|
|
49
51
|
>
|
|
50
|
-
<
|
|
51
|
-
name={'left'}
|
|
52
|
-
size={27}
|
|
53
|
-
color={transparent ? Colors.White : Colors.Black}
|
|
54
|
-
/>
|
|
52
|
+
<Image source={Images.arrowLeft} style={styles.iconBack} />
|
|
55
53
|
</TouchableOpacity>
|
|
56
54
|
<View style={[styles.boxTitle, styleBoxTitle]}>
|
|
57
55
|
{title && (
|
|
@@ -70,7 +68,7 @@ const HeaderUnit = memo(
|
|
|
70
68
|
onPress={onPressAdd}
|
|
71
69
|
>
|
|
72
70
|
<Icon
|
|
73
|
-
name={'plus'}
|
|
71
|
+
name={Platform.OS === 'android' ? 'plus-square' : 'plus'}
|
|
74
72
|
size={27}
|
|
75
73
|
color={transparent ? Colors.White : Colors.Black}
|
|
76
74
|
/>
|
|
@@ -83,9 +81,10 @@ const HeaderUnit = memo(
|
|
|
83
81
|
accessibilityLabel={idButtonMore}
|
|
84
82
|
>
|
|
85
83
|
<Icon
|
|
86
|
-
name={'
|
|
84
|
+
name={'ellipsis'}
|
|
87
85
|
size={27}
|
|
88
86
|
color={transparent ? Colors.White : Colors.Black}
|
|
87
|
+
style={styles.iconMore}
|
|
89
88
|
/>
|
|
90
89
|
</TouchableOpacity>
|
|
91
90
|
</View>
|
|
@@ -146,4 +145,12 @@ const styles = StyleSheet.create({
|
|
|
146
145
|
borderBottomWidth: 1,
|
|
147
146
|
borderBottomColor: Colors.Gray4,
|
|
148
147
|
},
|
|
148
|
+
iconMore: {
|
|
149
|
+
transform: [{ rotate: '90deg' }],
|
|
150
|
+
},
|
|
151
|
+
iconBack: {
|
|
152
|
+
tintColor: Colors.White,
|
|
153
|
+
width: 16,
|
|
154
|
+
height: 20,
|
|
155
|
+
},
|
|
149
156
|
});
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import moment from 'moment';
|
|
1
|
+
import { useCallback } from 'react';
|
|
3
2
|
|
|
4
3
|
import { API } from '../../../configs';
|
|
5
|
-
import HistoryChart from '../../../commons/Device/HistoryChart';
|
|
6
4
|
import { axiosGet } from '../../../utils/Apis/axios';
|
|
7
5
|
import { getPusher } from '../../../utils/Pusher';
|
|
8
6
|
|
|
@@ -101,7 +99,6 @@ export const updateConfigChart = async (
|
|
|
101
99
|
...config.middle.not_ready,
|
|
102
100
|
...config.middle.ready,
|
|
103
101
|
];
|
|
104
|
-
|
|
105
102
|
middleDataByDay.sort((a, b) => (a.date > b.date ? 1 : -1)); // small to large
|
|
106
103
|
const middleData = middleDataByDay.map((x) => x.data).flat();
|
|
107
104
|
data_by_id[config.id] = [...config.head, ...middleData, ...config.tail];
|
|
@@ -114,58 +111,3 @@ export const updateConfigChart = async (
|
|
|
114
111
|
}
|
|
115
112
|
});
|
|
116
113
|
};
|
|
117
|
-
|
|
118
|
-
let timeoutId;
|
|
119
|
-
|
|
120
|
-
const ConfigHistoryChart = ({ configs }) => {
|
|
121
|
-
const [chartData, setChartData] = useState(configs);
|
|
122
|
-
const [startDate, setStartDate] = useState(
|
|
123
|
-
moment().subtract(1, 'days').valueOf()
|
|
124
|
-
);
|
|
125
|
-
const [endDate, setEndDate] = useState(moment().valueOf());
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
const fetchData = async () => {
|
|
129
|
-
let params = new URLSearchParams();
|
|
130
|
-
let configuration = configs.filter((item) => item.id);
|
|
131
|
-
configuration.map((item) => {
|
|
132
|
-
params.append('configs', item.id);
|
|
133
|
-
});
|
|
134
|
-
params.append(
|
|
135
|
-
'date_from',
|
|
136
|
-
moment(startDate).utc().format('YYYY-MM-DD HH:mm:ss')
|
|
137
|
-
);
|
|
138
|
-
params.append(
|
|
139
|
-
'date_to',
|
|
140
|
-
moment(endDate).utc().format('YYYY-MM-DD HH:mm:ss')
|
|
141
|
-
);
|
|
142
|
-
const { success, data } = await axiosGet(
|
|
143
|
-
API.CONFIG.DISPLAY_HISTORY_V3(),
|
|
144
|
-
{
|
|
145
|
-
params,
|
|
146
|
-
}
|
|
147
|
-
);
|
|
148
|
-
updateConfigChart(success, data, configuration, setChartData);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
timeoutId = setTimeout(fetchData, 200);
|
|
152
|
-
return () => {
|
|
153
|
-
clearTimeout(timeoutId);
|
|
154
|
-
};
|
|
155
|
-
}, [startDate, endDate, configs]);
|
|
156
|
-
|
|
157
|
-
if (!chartData.length) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return (
|
|
162
|
-
<HistoryChart
|
|
163
|
-
configuration={{ type: 'line_chart', date_format: 'DD.MM' }}
|
|
164
|
-
datas={chartData}
|
|
165
|
-
setStartDate={setStartDate}
|
|
166
|
-
setEndDate={setEndDate}
|
|
167
|
-
/>
|
|
168
|
-
);
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
export default ConfigHistoryChart;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export const getIcon = (icon, width = 24, height = 24) => {
|
|
4
|
+
if (icon === 'clean-1') {
|
|
5
|
+
const SvgClean = require('../../../assets/images/Device/clean.svg');
|
|
6
|
+
return <SvgClean width={width} height={height} />;
|
|
7
|
+
}
|
|
8
|
+
if (icon === 'circulator-1') {
|
|
9
|
+
const SvgCirculator = require('../../../assets/images/Device/circulator.svg');
|
|
10
|
+
return <SvgCirculator width={width} height={height} />;
|
|
11
|
+
}
|
|
12
|
+
if (icon === 'auto-1') {
|
|
13
|
+
const SvgAuo = require('../../../assets/images/Device/auto.svg');
|
|
14
|
+
return <SvgAuo width={width} height={height} />;
|
|
15
|
+
}
|
|
16
|
+
if (icon === 'air-dry-1') {
|
|
17
|
+
const SvgAirDry = require('../../../assets/images/Device/air-dry.svg');
|
|
18
|
+
return <SvgAirDry width={width} height={height} />;
|
|
19
|
+
}
|
|
20
|
+
if (icon === 'door-state-1') {
|
|
21
|
+
const SvgDoorState = require('../../../assets/images/Device/door-state.svg');
|
|
22
|
+
return <SvgDoorState width={width} height={height} />;
|
|
23
|
+
}
|
|
24
|
+
if (icon === 'curent-state-1') {
|
|
25
|
+
const SvgCurrentState = require('../../../assets/images/Device/current-state.svg');
|
|
26
|
+
return <SvgCurrentState width={width} height={height} />;
|
|
27
|
+
}
|
|
28
|
+
if (icon === 'wind-strength-1') {
|
|
29
|
+
const SvgWindStrength = require('../../../assets/images/Device/wind-strength.svg');
|
|
30
|
+
return <SvgWindStrength width={width} height={height} />;
|
|
31
|
+
}
|
|
32
|
+
if (icon === 'tv') {
|
|
33
|
+
const { TV } = require('../../Images/SmartIr');
|
|
34
|
+
return <TV width={width} height={height} />;
|
|
35
|
+
}
|
|
36
|
+
if (icon === 'fan') {
|
|
37
|
+
const { Fan } = require('../../Images/SmartIr');
|
|
38
|
+
return <Fan width={width} height={height} />;
|
|
39
|
+
}
|
|
40
|
+
if (icon === 'ac') {
|
|
41
|
+
const { AC } = require('../../Images/SmartIr');
|
|
42
|
+
return <AC width={width} height={height} />;
|
|
43
|
+
}
|
|
44
|
+
if (icon === 'wm') {
|
|
45
|
+
const { WM } = require('../../Images/SmartIr');
|
|
46
|
+
return <WM width={width} height={height} />;
|
|
47
|
+
}
|
|
48
|
+
if (icon === 'fridge') {
|
|
49
|
+
const { Fridge } = require('../../Images/SmartIr');
|
|
50
|
+
return <Fridge width={width} height={height} />;
|
|
51
|
+
}
|
|
52
|
+
if (icon === 'diy') {
|
|
53
|
+
const { DIY } = require('../../Images/SmartIr');
|
|
54
|
+
return <DIY width={width} height={height} />;
|
|
55
|
+
}
|
|
56
|
+
return <></>;
|
|
57
|
+
};
|
|
@@ -240,6 +240,7 @@ export default {
|
|
|
240
240
|
ICON_CLOSE: 'ICON_CLOSE',
|
|
241
241
|
ICON_MORE: 'ICON_MORE',
|
|
242
242
|
ICON_ARROW_RIGHT: 'ICON_ARROW_RIGHT',
|
|
243
|
+
TEXT_AUTOMATE_NAME: 'TEXT_AUTOMATE_NAME',
|
|
243
244
|
|
|
244
245
|
// Parking input maunaly spot
|
|
245
246
|
PARKING_SPOT_INFO_BUTTON: 'PARKING_SPOT_INFO_BUTTON',
|
|
@@ -647,6 +648,7 @@ export default {
|
|
|
647
648
|
TOUCHABLE_ACTION_ADD_ITEM_FAVORITE: 'TOUCHABLE_ACTION_ADD_ITEM_FAVORITE',
|
|
648
649
|
TOUCHABLE_ACTION_ADD_ITEM_AUTOMATE_FAVORITE:
|
|
649
650
|
'TOUCHABLE_ACTION_ADD_ITEM_AUTOMATE_FAVORITE',
|
|
651
|
+
BUTTON_SELECT_FAVORITES: 'BUTTON_SELECT_FAVORITES',
|
|
650
652
|
|
|
651
653
|
// Smart Account
|
|
652
654
|
LOGIN_SMART_ACCOUNT: 'LOGIN_SMART_ACCOUNT',
|