@eohjsc/react-native-smart-city 0.4.99 → 0.5.1

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.
Files changed (35) hide show
  1. package/package.json +2 -2
  2. package/src/commons/ActionGroup/OnOffTemplate/OnOffButtonTemplateStyle.js +0 -1
  3. package/src/commons/ActionGroup/OnOffTemplate/SwitchButtonTemplate.js +60 -48
  4. package/src/commons/ActionGroup/OnOffTemplate/index.js +4 -32
  5. package/src/commons/ActionGroup/SliderRangeTemplate.js +53 -64
  6. package/src/commons/ActionGroup/SliderRangeTemplateStyles.js +2 -4
  7. package/src/commons/ActionGroup/TerminalBoxTemplate.js +11 -11
  8. package/src/commons/ActionGroup/TerminalBoxTemplateStyle.js +3 -0
  9. package/src/commons/ActionGroup/TextBoxTemplate.js +24 -22
  10. package/src/commons/ActionGroup/TextBoxTemplateStyle.js +3 -0
  11. package/src/commons/ActionGroup/__test__/SliderRangeTemplate.test.js +69 -17
  12. package/src/commons/ActionGroup/__test__/SwitchButtonTemplate.test.js +33 -25
  13. package/src/commons/ActionGroup/__test__/TextBoxTemplate.test.js +19 -0
  14. package/src/commons/Device/PMSensor/PMSensorIndicator.js +3 -5
  15. package/src/commons/Device/RainningSensor/CurrentRainSensor.js +50 -45
  16. package/src/commons/Form/TextInput.js +2 -0
  17. package/src/commons/Header/Styles/HeaderCustomStyles.js +1 -1
  18. package/src/commons/HeaderAni/index.js +2 -2
  19. package/src/commons/Sharing/WrapHeaderScrollable.js +1 -2
  20. package/src/commons/SubUnit/__test__/ShortDetail.test.js +2 -0
  21. package/src/hooks/IoT/__test__/useWatchConfigs.test.js +1 -0
  22. package/src/hooks/IoT/useWatchConfigs.js +3 -1
  23. package/src/iot/mqtt.js +23 -9
  24. package/src/screens/Automate/AddNewAction/SetupScriptDelay.js +1 -1
  25. package/src/screens/Automate/Components/InputName.js +8 -2
  26. package/src/screens/Automate/EditActionsList/index.js +5 -5
  27. package/src/screens/Automate/OneTap/__test__/AddNewOneTap.test.js +17 -3
  28. package/src/screens/Device/__test__/mqttDetail.test.js +33 -20
  29. package/src/screens/Device/components/SensorDisplayItem.js +7 -3
  30. package/src/screens/Device/detail.js +3 -2
  31. package/src/screens/Device/hooks/useDeviceWatchConfigControl.js +4 -10
  32. package/src/screens/Unit/ManageUnitStyles.js +1 -1
  33. package/src/utils/I18n/translations/en.js +2 -0
  34. package/src/utils/I18n/translations/vi.js +2 -0
  35. package/src/commons/ActionGroup/OnOffTemplate/styles.js +0 -7
@@ -38,6 +38,7 @@ describe('test OneTap', () => {
38
38
  unit: { id: 1 },
39
39
  isMultiUnits: false,
40
40
  isAutomateTab: false,
41
+ closeScreen: Routes.ScriptDetail,
41
42
  },
42
43
  };
43
44
 
@@ -66,15 +67,28 @@ describe('test OneTap', () => {
66
67
  await inputName[0].props.onChangeText('Tap to up');
67
68
  });
68
69
 
69
- const item = instance.findAll(
70
+ const item = instance.find(
70
71
  (el) =>
71
72
  el.props.accessibilityLabel === AccessibilityLabel.BOTTOM_VIEW_MAIN &&
72
73
  el.type === TouchableOpacity
73
74
  );
74
75
 
75
- expect(item).toHaveLength(1);
76
76
  await act(async () => {
77
- await item[0].props.onPress();
77
+ await item.props.onPress();
78
+ });
79
+
80
+ expect(mockedNavigate).toHaveBeenCalledWith({
81
+ merge: true,
82
+ name: Routes.ScriptDetail,
83
+ params: {
84
+ newAutomate: {
85
+ id: 1,
86
+ script: { id: 1, name: 'William Miller' },
87
+ type: 'one_tap',
88
+ unit: 1,
89
+ weekday_repeat: [],
90
+ },
91
+ },
78
92
  });
79
93
  });
80
94
 
@@ -318,8 +318,8 @@ describe('test DeviceDetail', () => {
318
318
  data: '00012',
319
319
  }
320
320
  );
321
- expect(valueBoxs[0].props.value).toEqual('0.1');
322
- expect(valueBoxs[1].props.value).toEqual('0.2');
321
+ expect(valueBoxs[0].props.value).toEqual(0.1);
322
+ expect(valueBoxs[1].props.value).toEqual(0.2);
323
323
  });
324
324
 
325
325
  it('should render device detail, modbus call updateGlobalValue, int_all exceed 32767', async () => {
@@ -330,8 +330,8 @@ describe('test DeviceDetail', () => {
330
330
  data: '0001F000',
331
331
  }
332
332
  );
333
- expect(valueBoxs[0].props.value).toEqual('0.1');
334
- expect(valueBoxs[1].props.value).toEqual('-409.6');
333
+ expect(valueBoxs[0].props.value).toEqual(0.1);
334
+ expect(valueBoxs[1].props.value).toEqual(-409.6);
335
335
  });
336
336
 
337
337
  it('should render device detail, modbus call updateGlobalValue, uint_32', async () => {
@@ -346,8 +346,8 @@ describe('test DeviceDetail', () => {
346
346
  data: '0001CCDDBBAA',
347
347
  }
348
348
  );
349
- expect(valueBoxs[0].props.value).toEqual('0.1');
350
- expect(valueBoxs[1].props.value).toEqual('343708356.1');
349
+ expect(valueBoxs[0].props.value).toEqual(0.1);
350
+ expect(valueBoxs[1].props.value).toEqual(343708356.1);
351
351
  });
352
352
 
353
353
  it('should render device detail, modbus call updateGlobalValue, float_cdba', async () => {
@@ -363,8 +363,8 @@ describe('test DeviceDetail', () => {
363
363
  }
364
364
  );
365
365
 
366
- expect(valueBoxs[0].props.value).toEqual('0.1');
367
- expect(valueBoxs[1].props.value).toEqual('369.6');
366
+ expect(valueBoxs[0].props.value).toEqual(0.1);
367
+ expect(valueBoxs[1].props.value).toEqual(369.6);
368
368
  });
369
369
 
370
370
  it('should render device detail, modbus call updateGlobalValue, float_cdba, data not hex format', async () => {
@@ -380,7 +380,7 @@ describe('test DeviceDetail', () => {
380
380
  }
381
381
  );
382
382
 
383
- expect(valueBoxs[0].props.value).toEqual('0.1');
383
+ expect(valueBoxs[0].props.value).toEqual(0.1);
384
384
  expect(valueBoxs[1].props.value).toEqual('--');
385
385
  });
386
386
 
@@ -396,7 +396,7 @@ describe('test DeviceDetail', () => {
396
396
  data: '0001P5670123', // reverse for simple
397
397
  }
398
398
  );
399
- expect(valueBoxs[0].props.value).toEqual('0.1');
399
+ expect(valueBoxs[0].props.value).toEqual(0.1);
400
400
  expect(valueBoxs[1].props.value).toEqual('--');
401
401
  });
402
402
 
@@ -412,8 +412,8 @@ describe('test DeviceDetail', () => {
412
412
  data: '0001CCDDBBAA',
413
413
  }
414
414
  );
415
- expect(valueBoxs[0].props.value).toEqual('0.1');
416
- expect(valueBoxs[1].props.value).toEqual('5244.5');
415
+ expect(valueBoxs[0].props.value).toEqual(0.1);
416
+ expect(valueBoxs[1].props.value).toEqual(5244.5);
417
417
  });
418
418
 
419
419
  test('should render device detail, modbus call updateGlobalValue, int_last4', async () => {
@@ -429,8 +429,8 @@ describe('test DeviceDetail', () => {
429
429
  }
430
430
  );
431
431
 
432
- expect(valueBoxs[0].props.value).toEqual('0.1');
433
- expect(valueBoxs[1].props.value).toEqual('4804.2');
432
+ expect(valueBoxs[0].props.value).toEqual(0.1);
433
+ expect(valueBoxs[1].props.value).toEqual(4804.2);
434
434
  });
435
435
 
436
436
  it('should render device detail, modbus call updateGlobalValue, convert_ai', async () => {
@@ -448,8 +448,8 @@ describe('test DeviceDetail', () => {
448
448
  }
449
449
  );
450
450
 
451
- expect(valueBoxs[0].props.value).toEqual('0.1');
452
- expect(valueBoxs[1].props.value).toEqual('10');
451
+ expect(valueBoxs[0].props.value).toEqual(0.1);
452
+ expect(valueBoxs[1].props.value).toEqual(10);
453
453
  });
454
454
 
455
455
  it('should render device detail, modbus call updateGlobalValue, convert_ai min_raw same max_raw', async () => {
@@ -467,7 +467,7 @@ describe('test DeviceDetail', () => {
467
467
  }
468
468
  );
469
469
 
470
- expect(valueBoxs[0].props.value).toEqual('0.1');
470
+ expect(valueBoxs[0].props.value).toEqual(0.1);
471
471
  expect(valueBoxs[1].props.value).toEqual('--');
472
472
  });
473
473
 
@@ -482,7 +482,7 @@ describe('test DeviceDetail', () => {
482
482
  }
483
483
  );
484
484
 
485
- expect(valueBoxs[0].props.value).toEqual('0.1');
485
+ expect(valueBoxs[0].props.value).toEqual(0.1);
486
486
  expect(valueBoxs[1].props.value).toEqual('--');
487
487
  });
488
488
 
@@ -496,7 +496,20 @@ describe('test DeviceDetail', () => {
496
496
  }
497
497
  );
498
498
 
499
- expect(valueBoxs[0].props.value).toEqual('10');
499
+ expect(valueBoxs[0].props.value).toEqual(10);
500
+ expect(valueBoxs[1].props.value).toEqual('--');
501
+ });
502
+
503
+ it('arduino pin submit data type string updateGlobalValue', async () => {
504
+ const valueBoxs = await _receiveDataOnDeviceDetail(
505
+ [{ id: 128282 }, { id: 128324 }],
506
+ 'config/128282/value/',
507
+ {
508
+ v: 'on',
509
+ }
510
+ );
511
+
512
+ expect(valueBoxs[0].props.value).toEqual('on');
500
513
  expect(valueBoxs[1].props.value).toEqual('--');
501
514
  });
502
515
 
@@ -538,7 +551,7 @@ describe('test DeviceDetail', () => {
538
551
  }
539
552
  );
540
553
 
541
- expect(valueBoxs[0].props.value).toEqual('36');
554
+ expect(valueBoxs[0].props.value).toEqual(36);
542
555
  expect(valueBoxs[1].props.value).toEqual('--');
543
556
  });
544
557
 
@@ -22,7 +22,11 @@ import { useEvaluateValue } from '../hooks/useEvaluateValue';
22
22
  import styles from '../styles';
23
23
  import { DetailHistoryChart } from './DetailHistoryChart';
24
24
  import VisualChart from './VisualChart';
25
-
25
+ import { standardizeCameraScreenSize } from '../../../utils/Utils';
26
+ import { Device } from '../../../configs';
27
+ const { standardizeWidth, standardizeHeight } = standardizeCameraScreenSize(
28
+ Device.screenWidth - 32
29
+ );
26
30
  export const SensorDisplayItem = ({
27
31
  item = {},
28
32
  sensor,
@@ -147,8 +151,8 @@ export const SensorDisplayItem = ({
147
151
  }}
148
152
  key={`camera-device-${id}`}
149
153
  cameraName={name}
150
- width="100%"
151
- height="100%"
154
+ width={standardizeWidth}
155
+ height={standardizeHeight}
152
156
  />
153
157
  </View>
154
158
  );
@@ -512,7 +512,7 @@ const DeviceDetail = ({ route }) => {
512
512
  const { configs, options, config, from_config, to_config } =
513
513
  configuration;
514
514
 
515
- configs?.forEach((config) => configIdsSet.add(config.id));
515
+ configs?.forEach((object) => configIdsSet.add(object.id));
516
516
  options?.forEach((option) => configIdsSet.add(option.config));
517
517
 
518
518
  if (config) {
@@ -615,7 +615,7 @@ const DeviceDetail = ({ route }) => {
615
615
  }, [display.items, isNetworkConnected, sensor, mqttConfigs])
616
616
  );
617
617
 
618
- useWatchConfigs(configIdsTemp.current);
618
+ useWatchConfigs(chipFiltered.length ? [] : configIdsTemp.current);
619
619
 
620
620
  const isShowEmergencyResolve =
621
621
  display.items.filter(
@@ -751,6 +751,7 @@ const DeviceDetail = ({ route }) => {
751
751
  }
752
752
  showWindDirection={showWindDirection}
753
753
  isDeviceHasBle={isDeviceHasBle}
754
+ key={`sensor${sensor.id}`}
754
755
  >
755
756
  {display.items.map((item, index) => {
756
757
  return (
@@ -8,12 +8,11 @@ export const useDeviceWatchConfigControl = (
8
8
  display,
9
9
  mqttConfigs = {}
10
10
  ) => {
11
+ const { is_managed_by_backend, device_type } = device;
11
12
  const configsNeedWatching = useMemo(() => {
12
13
  if (
13
- !device?.is_managed_by_backend ||
14
- [DEVICE_TYPE.GOOGLE_HOME, DEVICE_TYPE.LG_THINQ].includes(
15
- device?.device_type
16
- )
14
+ !is_managed_by_backend ||
15
+ [DEVICE_TYPE.GOOGLE_HOME, DEVICE_TYPE.LG_THINQ].includes(device_type)
17
16
  ) {
18
17
  return [];
19
18
  }
@@ -24,11 +23,6 @@ export const useDeviceWatchConfigControl = (
24
23
  );
25
24
  }
26
25
  return configsControl;
27
- }, [
28
- mqttConfigs,
29
- device?.device_type,
30
- device?.is_managed_by_backend,
31
- display,
32
- ]);
26
+ }, [is_managed_by_backend, device_type, display, mqttConfigs]);
33
27
  useWatchConfigs(configsNeedWatching);
34
28
  };
@@ -18,7 +18,7 @@ export default StyleSheet.create({
18
18
  bottom: 0,
19
19
  borderWidth: 0,
20
20
  alignSelf: 'center',
21
- paddingBottom: 16 + getBottomSpace(),
21
+ paddingBottom: 20 + getBottomSpace(),
22
22
  },
23
23
  boxImage: {
24
24
  flexDirection: 'row',
@@ -1464,6 +1464,8 @@ export default {
1464
1464
  end_devices_added: 'end devices added',
1465
1465
  bellow_widget_is_not_configured: 'Bellow widget is not configured',
1466
1466
  bellow_widget_is_wrongly_configured: 'Bellow widget is wrongly configured',
1467
+ widget_have_not_been_shared:
1468
+ '{widget} widget have not been shared. Please contact the owner',
1467
1469
  'customize...': 'Customize...',
1468
1470
  uri_invalid: 'URI invalid',
1469
1471
  when_value_is: 'When value is',
@@ -1474,6 +1474,8 @@ export default {
1474
1474
  end_devices_added: 'thiết bị được thêm vào',
1475
1475
  bellow_widget_is_not_configured: 'Tiện ích bên dưới chưa được cấu hình',
1476
1476
  bellow_widget_is_wrongly_configured: 'Tiện ích bên dưới được cấu hình sai',
1477
+ widget_have_not_been_shared:
1478
+ 'Tiện ích {widget} chưa được chia sẽ. Vui lòng liên hệ với chủ sở hữu',
1477
1479
  'customize...': 'Tùy chỉnh...',
1478
1480
  uri_invalid: 'URI không hợp lệ',
1479
1481
  when_value_is: 'Khi giá trị là',
@@ -1,7 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
-
3
- export default StyleSheet.create({
4
- wrap: {
5
- marginBottom: 16,
6
- },
7
- });