@eohjsc/react-native-smart-city 0.4.41 → 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/package.json +3 -3
- package/src/commons/ActionGroup/NumberUpDownActionTemplate.js +4 -7
- package/src/commons/ActionGroup/__test__/NumberUpDownTemplate.test.js +4 -1
- package/src/commons/Dashboard/MyUnit/index.js +8 -6
- package/src/commons/Modal/ModalCustom.js +2 -2
- package/src/commons/SubUnit/OneTap/ItemOneTap.js +1 -0
- package/src/configs/AccessibilityLabel.js +1 -0
- package/src/screens/Device/__test__/detail.test.js +61 -1
- package/src/screens/Device/detail.js +18 -24
- package/src/screens/Sharing/InfoMemberUnit.js +3 -1
- package/src/screens/Sharing/__test__/InfoMemberUnit.test.js +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eohjsc/react-native-smart-city",
|
|
3
3
|
"title": "React Native Smart Home",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.43",
|
|
5
5
|
"description": "TODO",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"files": [
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"dependencies": {
|
|
103
103
|
"@ant-design/icons-react-native": "^2.2.1",
|
|
104
104
|
"@ant-design/react-native": "^4.0.5",
|
|
105
|
-
"@react-native-picker/picker": "^1.16.7",
|
|
106
105
|
"@babel/helper-environment-visitor": "^7.16.7",
|
|
107
106
|
"@eohjsc/react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
108
107
|
"@formatjs/intl-getcanonicallocales": "^1.4.5",
|
|
@@ -121,6 +120,7 @@
|
|
|
121
120
|
"@react-native-community/netinfo": "^9.3.4",
|
|
122
121
|
"@react-native-community/segmented-control": "^2.1.1",
|
|
123
122
|
"@react-native-community/slider": "^3.0.3",
|
|
123
|
+
"@react-native-picker/picker": "^1.16.7",
|
|
124
124
|
"@react-navigation/bottom-tabs": "^5.8.0",
|
|
125
125
|
"@react-navigation/drawer": "^5.9.0",
|
|
126
126
|
"@react-navigation/native": "^5.7.0",
|
|
@@ -211,8 +211,8 @@
|
|
|
211
211
|
"string-format": "^2.0.0",
|
|
212
212
|
"sync-directory": "^5.1.7",
|
|
213
213
|
"timezone-mock": "^1.1.3",
|
|
214
|
+
"uuid": "^9.0.0",
|
|
214
215
|
"uuid-by-string": "^3.0.2",
|
|
215
|
-
"uuidv4": "^6.2.13",
|
|
216
216
|
"validator": "^13.1.1",
|
|
217
217
|
"victory-native": "^35.0.1"
|
|
218
218
|
},
|
|
@@ -49,13 +49,10 @@ const NumberUpDownActionTemplate = ({
|
|
|
49
49
|
|
|
50
50
|
const doActionAndWatchConfig = useCallback(
|
|
51
51
|
async (actionData, actionValue) => {
|
|
52
|
-
let data = actionValue;
|
|
53
|
-
if (
|
|
54
|
-
data =
|
|
55
|
-
|
|
56
|
-
data.config_id = config;
|
|
57
|
-
data.config_value = actionValue;
|
|
58
|
-
}
|
|
52
|
+
let data = { value: actionValue, temperature: actionValue };
|
|
53
|
+
if (allow_config_store_value && config) {
|
|
54
|
+
data.config_id = config;
|
|
55
|
+
data.config_value = actionValue;
|
|
59
56
|
}
|
|
60
57
|
await doAction(actionData, data);
|
|
61
58
|
if (!is_managed_by_backend) {
|
|
@@ -189,13 +189,15 @@ const MyUnit = ({ refreshing }) => {
|
|
|
189
189
|
|
|
190
190
|
useEffect(() => {
|
|
191
191
|
if (isDeleteUnitSuccessFully || previousMyUnits?.length > myUnits?.length) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
setAction(Action.RESET_DELETE_UNIT_ACTION);
|
|
195
|
-
}, 60);
|
|
196
|
-
return () => clearTimeout(to);
|
|
192
|
+
carouselRef?.current?.snapToItem(0, true);
|
|
193
|
+
setAction(Action.RESET_DELETE_UNIT_ACTION);
|
|
197
194
|
}
|
|
198
|
-
}, [
|
|
195
|
+
}, [
|
|
196
|
+
isDeleteUnitSuccessFully,
|
|
197
|
+
setAction,
|
|
198
|
+
previousMyUnits?.length,
|
|
199
|
+
myUnits?.length,
|
|
200
|
+
]);
|
|
199
201
|
|
|
200
202
|
return (
|
|
201
203
|
<>
|
|
@@ -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}
|
|
@@ -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',
|
|
@@ -194,6 +194,7 @@ describe('test DeviceDetail', () => {
|
|
|
194
194
|
useLayoutEffectSpy.mockImplementation(() => setState);
|
|
195
195
|
mock.reset();
|
|
196
196
|
mockedNavigate.mockClear();
|
|
197
|
+
watchMultiConfigs.mockReset();
|
|
197
198
|
});
|
|
198
199
|
|
|
199
200
|
it('render DeviceDetail render SensorDisplayItem', async () => {
|
|
@@ -813,6 +814,65 @@ describe('test DeviceDetail', () => {
|
|
|
813
814
|
el.props.accessibilityLabel === AccessibilityLabel.SENSOR_DISPLAY_ITEM
|
|
814
815
|
);
|
|
815
816
|
expect(sensorDisplayItem.length).toEqual(1);
|
|
816
|
-
expect(watchMultiConfigs).
|
|
817
|
+
expect(watchMultiConfigs).toHaveBeenCalledWith([1]);
|
|
818
|
+
});
|
|
819
|
+
|
|
820
|
+
it('watch action config', async () => {
|
|
821
|
+
mock.onGet(API.CHIP.JSON_CONFIGURATION).reply(200, []);
|
|
822
|
+
const responseDisplay = {
|
|
823
|
+
items: [
|
|
824
|
+
{
|
|
825
|
+
id: 1,
|
|
826
|
+
order: 0,
|
|
827
|
+
template: 'on_off_button_action_template',
|
|
828
|
+
type: 'on_off_button_action_template',
|
|
829
|
+
configuration: {
|
|
830
|
+
config: 2,
|
|
831
|
+
},
|
|
832
|
+
},
|
|
833
|
+
],
|
|
834
|
+
};
|
|
835
|
+
const responseDisplayValueV2 = {
|
|
836
|
+
configs: [{ id: 2 }],
|
|
837
|
+
is_connected: true,
|
|
838
|
+
last_updated: '2021-01-24T12:00:00.000Z',
|
|
839
|
+
};
|
|
840
|
+
mockAxios(responseDisplay, responseDisplayValueV2);
|
|
841
|
+
await act(async () => {
|
|
842
|
+
tree = await create(wrapComponent(store, account, route));
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
expect(watchMultiConfigs).toHaveBeenCalledWith([2]);
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
it('watch stages grid action config', async () => {
|
|
849
|
+
mock.onGet(API.CHIP.JSON_CONFIGURATION).reply(200, []);
|
|
850
|
+
const responseDisplay = {
|
|
851
|
+
items: [
|
|
852
|
+
{
|
|
853
|
+
id: 1,
|
|
854
|
+
order: 0,
|
|
855
|
+
template: 'StatesGridActionTemplate',
|
|
856
|
+
configuration: {
|
|
857
|
+
options: [
|
|
858
|
+
{
|
|
859
|
+
config: 3,
|
|
860
|
+
},
|
|
861
|
+
],
|
|
862
|
+
},
|
|
863
|
+
},
|
|
864
|
+
],
|
|
865
|
+
};
|
|
866
|
+
const responseDisplayValueV2 = {
|
|
867
|
+
configs: [{ id: 2 }],
|
|
868
|
+
is_connected: true,
|
|
869
|
+
last_updated: '2021-01-24T12:00:00.000Z',
|
|
870
|
+
};
|
|
871
|
+
mockAxios(responseDisplay, responseDisplayValueV2);
|
|
872
|
+
await act(async () => {
|
|
873
|
+
tree = await create(wrapComponent(store, account, route));
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
expect(watchMultiConfigs).toHaveBeenCalledWith([3]);
|
|
817
877
|
});
|
|
818
878
|
});
|
|
@@ -59,7 +59,7 @@ import { useReceiveNotifications } from '../../hooks';
|
|
|
59
59
|
import useChipJsonConfiguration, {
|
|
60
60
|
useConnectChipMqtt,
|
|
61
61
|
} from '../../hooks/useMqtt';
|
|
62
|
-
import {
|
|
62
|
+
import { watchMultiConfigs } from '../../iot/Monitor';
|
|
63
63
|
|
|
64
64
|
const DeviceDetail = ({ route }) => {
|
|
65
65
|
const configIdsTemp = useRef([]);
|
|
@@ -136,8 +136,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
return action.some((item) => {
|
|
139
|
-
|
|
140
|
-
return JSON.stringify(configuration).includes(
|
|
139
|
+
return JSON.stringify(item?.configuration)?.includes(
|
|
141
140
|
'"command_prefer_over_bluetooth":true'
|
|
142
141
|
);
|
|
143
142
|
});
|
|
@@ -500,35 +499,30 @@ const DeviceDetail = ({ route }) => {
|
|
|
500
499
|
let params = new URLSearchParams();
|
|
501
500
|
const configIds = [];
|
|
502
501
|
|
|
502
|
+
// todo Bang refactor widgets like dashboard
|
|
503
503
|
display.items.map((item) => {
|
|
504
|
-
const type = item?.template || item?.type;
|
|
505
504
|
if (!item.configuration) {
|
|
506
505
|
return;
|
|
507
506
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
if (type === 'action') {
|
|
512
|
-
if (
|
|
513
|
-
[
|
|
514
|
-
'on_off_button_action_template',
|
|
515
|
-
'one_button_action_template',
|
|
516
|
-
].includes(item.configuration.template)
|
|
517
|
-
) {
|
|
518
|
-
!configIds.includes(item.configuration.configuration.config) &&
|
|
519
|
-
configIds.push(item.configuration.configuration.config);
|
|
507
|
+
item.configuration.configs?.map((config) => {
|
|
508
|
+
if (!configIds.includes(config.id)) {
|
|
509
|
+
configIds.push(config.id);
|
|
520
510
|
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
511
|
+
});
|
|
512
|
+
item.configuration.options?.map((option) => {
|
|
513
|
+
if (!configIds.includes(option.config)) {
|
|
514
|
+
configIds.push(option.config);
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
if (item.configuration.config) {
|
|
518
|
+
!configIds.includes(item.configuration.config) &&
|
|
519
|
+
configIds.push(item.configuration.config);
|
|
528
520
|
}
|
|
529
521
|
});
|
|
530
522
|
configIdsTemp.current = configIds.filter(Boolean);
|
|
531
523
|
|
|
524
|
+
watchMultiConfigs(configIdsTemp.current);
|
|
525
|
+
|
|
532
526
|
configIds.map((id) => {
|
|
533
527
|
params.append('config', id);
|
|
534
528
|
});
|
|
@@ -725,7 +719,7 @@ const DeviceDetail = ({ route }) => {
|
|
|
725
719
|
}, [sensor]);
|
|
726
720
|
|
|
727
721
|
useEffect(() => {
|
|
728
|
-
appState === 'active' &&
|
|
722
|
+
appState === 'active' && watchMultiConfigs(configIdsTemp.current);
|
|
729
723
|
}, [appState]);
|
|
730
724
|
|
|
731
725
|
const shouldRender =
|
|
@@ -58,7 +58,9 @@ const InfoMemberUnit = memo(({ route }) => {
|
|
|
58
58
|
if (stateAlertAction?.is_change) {
|
|
59
59
|
hideAlertAction();
|
|
60
60
|
if (itemSelected?.role?.is_owner) {
|
|
61
|
-
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
setIsShowWarning(true);
|
|
63
|
+
}, 500);
|
|
62
64
|
}
|
|
63
65
|
} else {
|
|
64
66
|
removeMember(
|
|
@@ -131,6 +131,7 @@ describe('Test InfoMemberUnit', () => {
|
|
|
131
131
|
});
|
|
132
132
|
|
|
133
133
|
it('test change owner', async () => {
|
|
134
|
+
jest.useFakeTimers();
|
|
134
135
|
mock.onGet(API.SHARE.UNIT_MEMBER_INFO(1, 1)).reply(200, {
|
|
135
136
|
id: 2,
|
|
136
137
|
identity: 'owner',
|
|
@@ -163,6 +164,7 @@ describe('Test InfoMemberUnit', () => {
|
|
|
163
164
|
await act(async () => {
|
|
164
165
|
await alertAction.props.rightButtonClick();
|
|
165
166
|
});
|
|
167
|
+
jest.runAllTimers();
|
|
166
168
|
expect(alertAction.props.visible).toEqual(false);
|
|
167
169
|
expect(modalPopupCT.props.isVisible).toEqual(true);
|
|
168
170
|
|