@eohjsc/react-native-smart-city 0.2.67 → 0.2.68
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/Popover/Dashboard/SmartAccount.svg +5 -0
- package/assets/images/scan-qr-gateway.svg +14 -0
- package/assets/images/wifi-gateway.svg +18 -0
- package/assets/images/wifi.svg +3 -0
- package/package.json +3 -1
- package/src/commons/Action/ItemQuickAction.js +4 -3
- package/src/commons/Dashboard/MyPinnedSharedUnit/__test__/MyPinnedSharedUnit.test.js +70 -0
- package/src/commons/Device/HistoryChart.js +18 -18
- package/src/commons/Device/HorizontalBarChart.js +1 -2
- package/src/commons/Device/ItemDevice.js +1 -13
- package/src/commons/Device/LinearChart.js +13 -3
- package/src/commons/UnitSummary/ConfigHistoryChart/__test__/ConfigHistoryChart.test.js +29 -0
- package/src/commons/UnitSummary/ConfigHistoryChart.js +4 -6
- package/src/configs/API.js +2 -0
- package/src/configs/BLE.js +3 -0
- package/src/iot/RemoteControl/Bluetooth.js +34 -6
- package/src/iot/RemoteControl/__test__/Bluetooth.test.js +1 -0
- package/src/iot/RemoteControl/__test__/index.mock.js +1 -0
- package/src/iot/RemoteControl/index.js +7 -2
- package/src/navigations/AddDeviceStack.js +2 -0
- package/src/navigations/AddGatewayStack.js +11 -0
- package/src/navigations/AddLGDeviceStack.js +2 -0
- package/src/navigations/AddMemberStack.js +2 -0
- package/src/navigations/AddSubUnitStack.js +2 -0
- package/src/navigations/AddUnitStack.js +2 -0
- package/src/navigations/EmergencyContactsStack.js +2 -0
- package/src/navigations/SharedStack.js +2 -0
- package/src/navigations/UnitStack.js +2 -0
- package/src/screens/AddCommon/SelectSubUnit.js +2 -0
- package/src/screens/AddNewGateway/PlugAndPlay/ConnectWifiWarning.js +190 -0
- package/src/screens/AddNewGateway/PlugAndPlay/FirstWarning.js +73 -0
- package/src/screens/AddNewGateway/PlugAndPlay/GatewayWifiList.js +154 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/FirstWarning.test.js +60 -0
- package/src/screens/AddNewGateway/PlugAndPlay/__test__/GatewayWifiList.test.js +35 -0
- package/src/screens/AddNewGateway/__test__/SetupGateway.test.js +90 -0
- package/src/screens/Device/components/SensorDisplayItem.js +4 -2
- package/src/screens/ScanChipQR/hooks/index.js +14 -5
- package/src/screens/Unit/AddMenu.js +15 -0
- package/src/screens/Unit/Detail.js +13 -2
- package/src/screens/Unit/components/__test__/MyUnitDevice.test.js +10 -6
- package/src/screens/UnitSummary/components/PowerConsumption/index.js +2 -4
- package/src/screens/UnitSummary/components/RunningDevices/__test__/index.test.js +10 -6
- package/src/utils/I18n/translations/en.json +25 -3
- package/src/utils/I18n/translations/vi.json +25 -3
- package/src/utils/Route/index.js +4 -0
- package/src/utils/Utils.js +0 -4
|
@@ -20,6 +20,7 @@ import FooterInfo from '../../../commons/Device/FooterInfo';
|
|
|
20
20
|
import MediaPlayerDetail from '../../../commons/MediaPlayerDetail';
|
|
21
21
|
import { standardizeCameraScreenSize } from '../../../utils/Utils';
|
|
22
22
|
import { Device } from '../../../configs';
|
|
23
|
+
import { useSCContextSelector } from '../../../context';
|
|
23
24
|
|
|
24
25
|
const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
|
|
25
26
|
Device.screenWidth - 32
|
|
@@ -37,11 +38,12 @@ export const SensorDisplayItem = ({
|
|
|
37
38
|
background,
|
|
38
39
|
}) => {
|
|
39
40
|
const t = useTranslations();
|
|
41
|
+
const userId = useSCContextSelector((state) => state.auth.account.user.id);
|
|
40
42
|
const doAction = useCallback(
|
|
41
43
|
(action, data) => {
|
|
42
|
-
sendRemoteCommand(sensor, action, data);
|
|
44
|
+
sendRemoteCommand(sensor, action, data, userId);
|
|
43
45
|
},
|
|
44
|
-
[sensor]
|
|
46
|
+
[sensor, userId]
|
|
45
47
|
);
|
|
46
48
|
if (item.configuration.type === 'compass') {
|
|
47
49
|
setShowWindDirection(true);
|
|
@@ -17,7 +17,7 @@ const useChipScan = (route) => {
|
|
|
17
17
|
const { success, data: new_chip } = await axiosPost(
|
|
18
18
|
API.UNIT.CHIP_SCAN(unit_id),
|
|
19
19
|
{
|
|
20
|
-
imei: imei,
|
|
20
|
+
imei: imei || body.imei,
|
|
21
21
|
qr_code: body.imei,
|
|
22
22
|
phone: phoneNumber,
|
|
23
23
|
name: chipName,
|
|
@@ -27,10 +27,19 @@ const useChipScan = (route) => {
|
|
|
27
27
|
}
|
|
28
28
|
);
|
|
29
29
|
if (success) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
if (new_chip.is_wifi) {
|
|
31
|
+
navigation.navigate(Routes.ConnectWifiWarning, {
|
|
32
|
+
wifi_ssid: new_chip.wifi_ssid,
|
|
33
|
+
wifi_pass: new_chip.wifi_pass,
|
|
34
|
+
chip_id: new_chip.id,
|
|
35
|
+
unit_id: unit_id,
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
navigation.navigate(Routes.ConnectingGateway, {
|
|
39
|
+
new_chip,
|
|
40
|
+
...route.params,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
34
43
|
} else {
|
|
35
44
|
navigation.goBack();
|
|
36
45
|
}
|
|
@@ -4,6 +4,7 @@ import { useTranslations } from '../../hooks/Common/useTranslations';
|
|
|
4
4
|
import Routes from '../../utils/Route';
|
|
5
5
|
import AddSubUnitIcon from '../../../assets/images/Popover/Dashboard/AddSubUnit.svg';
|
|
6
6
|
import AddDeviceIcon from '../../../assets/images/Popover/Dashboard/AddDevice.svg';
|
|
7
|
+
import SmartAccount from '../../../assets/images/Popover/Dashboard/SmartAccount.svg';
|
|
7
8
|
import AddMemberIcon from '../../../assets/images/Popover/Dashboard/AddMember.svg';
|
|
8
9
|
import { useNavigation } from '@react-navigation/native';
|
|
9
10
|
|
|
@@ -50,6 +51,20 @@ const AddMenu = memo(({ unit, afterItemClick, showAdd, setHideAdd }) => {
|
|
|
50
51
|
image: <AddDeviceIcon width={43} height={43} />, // TODO change icon
|
|
51
52
|
data: { screen: Routes.SetupGatewayWifi, params: { unit_id: unit.id } },
|
|
52
53
|
},
|
|
54
|
+
{
|
|
55
|
+
id: 5,
|
|
56
|
+
route: Routes.AddGatewayStack,
|
|
57
|
+
text: t('gateway') + ' Wifi',
|
|
58
|
+
image: <AddDeviceIcon width={43} height={43} />,
|
|
59
|
+
data: { screen: Routes.FirstWarning, params: { unit_id: unit.id } },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 6,
|
|
63
|
+
route: Routes.SmartAccount,
|
|
64
|
+
text: t('name_smart_account'),
|
|
65
|
+
image: <SmartAccount width={43} height={43} />, // TODO change icon
|
|
66
|
+
type: Routes.SmartAccount,
|
|
67
|
+
},
|
|
53
68
|
];
|
|
54
69
|
}, [t, unit]);
|
|
55
70
|
|
|
@@ -31,7 +31,14 @@ import { AUTOMATE_TYPE } from '../../configs/Constants';
|
|
|
31
31
|
const UnitDetail = ({ route }) => {
|
|
32
32
|
const t = useTranslations();
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const {
|
|
35
|
+
unitId,
|
|
36
|
+
unitData,
|
|
37
|
+
isOneTap,
|
|
38
|
+
routeName,
|
|
39
|
+
isAddSubUnit,
|
|
40
|
+
isSuccessfullyConnected,
|
|
41
|
+
} = route.params;
|
|
35
42
|
|
|
36
43
|
const isFocused = useIsFocused();
|
|
37
44
|
const { stateData, setAction } = useContext(SCContext);
|
|
@@ -298,6 +305,10 @@ const UnitDetail = ({ route }) => {
|
|
|
298
305
|
navigate(routeName);
|
|
299
306
|
}, [navigate, routeName]);
|
|
300
307
|
|
|
308
|
+
const Dashboard = useCallback(() => {
|
|
309
|
+
navigate(Routes.Dashboard);
|
|
310
|
+
}, [navigate]);
|
|
311
|
+
|
|
301
312
|
return (
|
|
302
313
|
<WrapParallaxScrollView
|
|
303
314
|
uriImg={unit.background}
|
|
@@ -310,7 +321,7 @@ const UnitDetail = ({ route }) => {
|
|
|
310
321
|
onAdd={setShowAdd}
|
|
311
322
|
onMore={showPopoverWithRef}
|
|
312
323
|
hideRightPlus={!isOwner}
|
|
313
|
-
onBack={routeName && onBack}
|
|
324
|
+
onBack={(isSuccessfullyConnected && Dashboard) || (routeName && onBack)}
|
|
314
325
|
>
|
|
315
326
|
<View style={styles.container}>
|
|
316
327
|
<Summaries unit={unit} />
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { act, create } from 'react-test-renderer';
|
|
4
|
+
import { SCProvider } from '../../../../context';
|
|
5
|
+
import { mockSCStore } from '../../../../context/mockStore';
|
|
4
6
|
import MyUnitDevice from '../MyUnitDevice';
|
|
5
7
|
|
|
8
|
+
const wrapComponent = (sensor) => (
|
|
9
|
+
<SCProvider initState={mockSCStore({})}>
|
|
10
|
+
<MyUnitDevice sensor={sensor} />
|
|
11
|
+
</SCProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
6
14
|
describe('Test MyUnitDevice', () => {
|
|
7
15
|
let tree;
|
|
8
16
|
|
|
9
17
|
it('Test render with status', async () => {
|
|
10
18
|
await act(() => {
|
|
11
19
|
tree = create(
|
|
12
|
-
|
|
13
|
-
sensor={{ status: 'Ok', name: 'Test', station_name: '' }}
|
|
14
|
-
/>
|
|
20
|
+
wrapComponent({ status: 'Ok', name: 'Test', station_name: '' })
|
|
15
21
|
);
|
|
16
22
|
});
|
|
17
23
|
const instance = tree.root;
|
|
@@ -21,9 +27,7 @@ describe('Test MyUnitDevice', () => {
|
|
|
21
27
|
|
|
22
28
|
it('Test render without status', async () => {
|
|
23
29
|
await act(() => {
|
|
24
|
-
tree = create(
|
|
25
|
-
<MyUnitDevice sensor={{ name: 'Test', station_name: '' }} />
|
|
26
|
-
);
|
|
30
|
+
tree = create(wrapComponent({ name: 'Test', station_name: '' }));
|
|
27
31
|
});
|
|
28
32
|
const instance = tree.root;
|
|
29
33
|
const Views = instance.findAllByType(View);
|
|
@@ -77,10 +77,8 @@ const PowerConsumption = memo(({ summaryDetail }) => {
|
|
|
77
77
|
const dataTotal = [];
|
|
78
78
|
dataTotal.push(totalPower);
|
|
79
79
|
|
|
80
|
-
const [startDate, setStartDate] = useState(
|
|
81
|
-
|
|
82
|
-
);
|
|
83
|
-
const [endDate, setEndDate] = useState(moment().valueOf());
|
|
80
|
+
const [startDate, setStartDate] = useState(moment().subtract(6, 'days'));
|
|
81
|
+
const [endDate, setEndDate] = useState(moment());
|
|
84
82
|
const [groupBy, setGroupBy] = useState('date');
|
|
85
83
|
const [getData, setData] = useState([]);
|
|
86
84
|
const [chartConfig, setChartConfig] = useState({
|
|
@@ -3,6 +3,14 @@ import { act, create } from 'react-test-renderer';
|
|
|
3
3
|
import RunningDevices from '..';
|
|
4
4
|
import { TouchableOpacity } from 'react-native';
|
|
5
5
|
import ItemDevice from '../../../../../commons/Device/ItemDevice';
|
|
6
|
+
import { mockSCStore } from '../../../../../context/mockStore';
|
|
7
|
+
import { SCProvider } from '../../../../../context';
|
|
8
|
+
|
|
9
|
+
const wrapComponent = (unit, summaryDetail) => (
|
|
10
|
+
<SCProvider initState={mockSCStore({})}>
|
|
11
|
+
<RunningDevices unit={unit} summaryDetail={summaryDetail} />
|
|
12
|
+
</SCProvider>
|
|
13
|
+
);
|
|
6
14
|
|
|
7
15
|
const mockedNavigate = jest.fn();
|
|
8
16
|
|
|
@@ -55,9 +63,7 @@ describe('test RunningDevices', () => {
|
|
|
55
63
|
};
|
|
56
64
|
|
|
57
65
|
await act(async () => {
|
|
58
|
-
tree = await create(
|
|
59
|
-
<RunningDevices unit={unit} summaryDetail={summaryDetail} />
|
|
60
|
-
);
|
|
66
|
+
tree = await create(wrapComponent(unit, summaryDetail));
|
|
61
67
|
});
|
|
62
68
|
const instance = tree.root;
|
|
63
69
|
const texts = instance.findAllByType(ItemDevice);
|
|
@@ -95,9 +101,7 @@ describe('test RunningDevices', () => {
|
|
|
95
101
|
};
|
|
96
102
|
|
|
97
103
|
await act(async () => {
|
|
98
|
-
tree = await create(
|
|
99
|
-
<RunningDevices unit={unit} summaryDetail={summaryDetail} />
|
|
100
|
-
);
|
|
104
|
+
tree = await create(wrapComponent(unit, summaryDetail));
|
|
101
105
|
});
|
|
102
106
|
const instance = tree.root;
|
|
103
107
|
const texts = instance.findAllByType(ItemDevice);
|
|
@@ -240,8 +240,10 @@
|
|
|
240
240
|
"invalid_phone_number": "Invalid phone number",
|
|
241
241
|
"Found bluetooth %{name} for remote control": "Found bluetooth %{name} for remote control",
|
|
242
242
|
"Sending command via bluetooth": "Sending command via bluetooth",
|
|
243
|
-
"
|
|
244
|
-
"
|
|
243
|
+
"command_is_sent_to_device_via_bluetooth": "Command is sent to device via bluetooth",
|
|
244
|
+
"command_is_fail_to_send_via_bluetooth": "Command is fail to send via bluetooth",
|
|
245
|
+
"control_device_via_bluetooth_successfully": "Control device via bluetooth successfully",
|
|
246
|
+
"control_device_via_bluetooth_failed": "Control device via bluetooth failed",
|
|
245
247
|
"Sending command via internet": "Sending command via internet",
|
|
246
248
|
"Command is sent to device via internet": "Command is sent to device via internet",
|
|
247
249
|
"Command is fail to send via internet": "Command is fail to send via internet",
|
|
@@ -856,6 +858,21 @@
|
|
|
856
858
|
"volume": "Volume",
|
|
857
859
|
"this_notification_will_be_updated_soon": "This notification will be updated soon",
|
|
858
860
|
"text_submit": "Submit",
|
|
861
|
+
"connecting": "Connecting",
|
|
862
|
+
"connect_device": "Connect Device",
|
|
863
|
+
"connect": "Connect",
|
|
864
|
+
"server_error": "Server Error",
|
|
865
|
+
"add_gateway_success": "Add gateway success",
|
|
866
|
+
"set_network": "Set network",
|
|
867
|
+
"select_wifi": "Select your wifi network",
|
|
868
|
+
"enter_wifi_password": "Enter wifi password",
|
|
869
|
+
"gateway_warning_content_1": "To bring you good experiences, ",
|
|
870
|
+
"gateway_warning_content_2": "your device needs a permanent wifi connection.",
|
|
871
|
+
"gateway_warning_content_3": "In the next steps, you will be instructed to connect to wifi for the device. ",
|
|
872
|
+
"gateway_warning_content_4": "To give you a good experience, you need to know the name and password of the wifi network and make sure the device is placed in a good location.",
|
|
873
|
+
"warning_beta_test_feature": "This feature is in beta test, not official yet",
|
|
874
|
+
"connecting_gateway_warning_1": "By continuing, EoH needs to connect to the device's wifi.",
|
|
875
|
+
"connecting_gateway_warning_2": "A message will appear asking you to connect.",
|
|
859
876
|
"remove_account": "Remove Account",
|
|
860
877
|
"text_sub_unit_not_have_device": "You don't have sub-unit with a device to control",
|
|
861
878
|
"tap_to_add_new_schedule": "Tap + to add new schedule",
|
|
@@ -866,5 +883,10 @@
|
|
|
866
883
|
"curtain_opens": "Curtain opens",
|
|
867
884
|
"curtain_closes": "Curtain closes",
|
|
868
885
|
"schedule_name": "Schedule name",
|
|
869
|
-
"enter_name": "Enter name"
|
|
886
|
+
"enter_name": "Enter name",
|
|
887
|
+
"name_smart_account": "Smart Account",
|
|
888
|
+
"location_permission_required_wifi_title": "Location permission is required for WiFi connections",
|
|
889
|
+
"location_permission_required_wifi_message": "This app needs location permission as this is required to scan for wifi networks.",
|
|
890
|
+
"deny": "DENY",
|
|
891
|
+
"allow": "ALLOW"
|
|
870
892
|
}
|
|
@@ -276,8 +276,10 @@
|
|
|
276
276
|
"invalid_phone_number": "Số điện thoại không hợp lệ.",
|
|
277
277
|
"Found bluetooth %{name} for remote control": "Tìm thấy thiết bị điều khiển bluetooth %{name}",
|
|
278
278
|
"Sending command via bluetooth": "Đang gởi lệnh thông qua bluetooth",
|
|
279
|
-
"
|
|
280
|
-
"
|
|
279
|
+
"command_is_sent_to_device_via_bluetooth": "Lệnh được gởi tới thiết bị thông qua bluetooth",
|
|
280
|
+
"command_is_fail_to_send_via_bluetooth": "Không thế gởi tới thiết bị thông qua bluetooth",
|
|
281
|
+
"control_device_via_bluetooth_successfully": "Điều khiển thiết bị qua bluetooth thành công",
|
|
282
|
+
"control_device_via_bluetooth_failed": "Điều khiển thiết bị qua bluetooth thất bại",
|
|
281
283
|
"Sending command via internet": "Đang gởi lệnh thông qua internet",
|
|
282
284
|
"Command is sent to device via internet": "Lệnh được gởi tới thiết bị thông qua internet",
|
|
283
285
|
"Command is fail to send via internet": "Không thế gởi tới thiết bị thông qua internet",
|
|
@@ -857,6 +859,21 @@
|
|
|
857
859
|
"volume": "Âm lượng",
|
|
858
860
|
"this_notification_will_be_updated_soon": "Thông báo này sẽ sớm được cập nhật",
|
|
859
861
|
"text_submit": "Xác nhận",
|
|
862
|
+
"connecting": "Đang kết nối",
|
|
863
|
+
"connect_device": "Kết nối thiết bị",
|
|
864
|
+
"connect": "Kết nối",
|
|
865
|
+
"server_error": "Lỗi hệ thống",
|
|
866
|
+
"set_network": "Chọn mạng",
|
|
867
|
+
"select_wifi": "Chọn mạng wifi của bạn",
|
|
868
|
+
"enter_wifi_password": "Nhập mật khẩu wifi",
|
|
869
|
+
"gateway_warning_content_1": "Để mang đến cho bạn những trải nghiệm tốt, ",
|
|
870
|
+
"gateway_warning_content_2": "thiết bị cần kết nối wifi thường trực.",
|
|
871
|
+
"gateway_warning_content_3": "Trong các bước tiếp theo, bạn sẽ được hướng dẫn kết nối wifi cho thiết bị. ",
|
|
872
|
+
"gateway_warning_content_4": "Bạn cần biết tên và mật khẩu của mạng wifi và đảm bảo thiết bị được đặt ở vị trí tốt.",
|
|
873
|
+
"warning_beta_test_feature": "Tính năng này đang ở giai đoạn beta test, chưa phải bản chính thức.",
|
|
874
|
+
"connecting_gateway_warning_1": "Bằng việc tiếp tục, EoH cần kết nối với Wifi của thiết bị.",
|
|
875
|
+
"connecting_gateway_warning_2": "Một thông báo sẽ hiện lên và yêu cầu bạn kết nối.",
|
|
876
|
+
"add_gateway_success": "Thêm gateway thành công",
|
|
860
877
|
"tap_to_add_new_schedule": "Nhấn + để thêm lịch trình mới",
|
|
861
878
|
"remove_account": "Xóa tài khoản",
|
|
862
879
|
"text_subunit_not_have_device": "Bạn không có khu vực nào có thiết bị để điều khiển",
|
|
@@ -868,5 +885,10 @@
|
|
|
868
885
|
"curtain_opens": "Rèm mở",
|
|
869
886
|
"curtain_closes": "Rèm đóng",
|
|
870
887
|
"schedule_name": "Tên lịch trình",
|
|
871
|
-
"enter_name": "Nhập tên"
|
|
888
|
+
"enter_name": "Nhập tên",
|
|
889
|
+
"name_smart_account": "Smart Account",
|
|
890
|
+
"location_permission_required_wifi_title": "Quyền vị trí là bắt buộc đối với kết nối WiFi",
|
|
891
|
+
"location_permission_required_wifi_message": "Ứng dụng này cần có quyền định vị vì ứng dụng này được yêu cầu để quét các mạng Wi-Fi.",
|
|
892
|
+
"deny": "Từ chối",
|
|
893
|
+
"allow": "Cho phép"
|
|
872
894
|
}
|
package/src/utils/Route/index.js
CHANGED
|
@@ -121,7 +121,11 @@ const Routes = {
|
|
|
121
121
|
ListDeviceSmartAccount: 'ListDeviceSmartAccount',
|
|
122
122
|
SmartAccountConnecting: 'SmartAccountConnecting',
|
|
123
123
|
EmergencySetting: 'EmergencySetting',
|
|
124
|
+
FirstWarning: 'FirstWarning',
|
|
125
|
+
ConnectWifiWarning: 'ConnectWifiWarning',
|
|
126
|
+
GatewayWifiList: 'GatewayWifiList',
|
|
124
127
|
ConfirmUnitDeletion: 'ConfirmUnitDeletion',
|
|
128
|
+
SmartAccount: 'SmartAccount',
|
|
125
129
|
};
|
|
126
130
|
|
|
127
131
|
export default Routes;
|
package/src/utils/Utils.js
CHANGED
|
@@ -120,10 +120,6 @@ export const removeFromString = (str, index) => {
|
|
|
120
120
|
return str.substr(0, index) + str.substr(index + 1);
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
-
export const arePropsEqual = (prevProps, nextProps) => {
|
|
124
|
-
return JSON.stringify(prevProps) === JSON.stringify(nextProps);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
123
|
export default {
|
|
128
124
|
validateEmail,
|
|
129
125
|
isObjectEmpty,
|