@eohjsc/react-native-smart-city 0.6.1 → 0.6.2-rc2
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 +6 -9
- package/package.json +1 -1
- package/src/commons/Device/ItemDevice.js +30 -50
- package/src/commons/SubUnit/Favorites/index.js +0 -1
- package/src/commons/SubUnit/ShortDetail.js +0 -1
- package/src/commons/Widgets/IFrame/IFrame.js +34 -41
- package/src/commons/Widgets/IFrame/IFrameStyles.js +0 -2
- package/src/commons/Widgets/IFrame/__tests__/IFrame.test.js +3 -2
- package/src/configs/Constants.js +3 -3
- package/src/screens/Automate/AddNewAction/SetupConfigCondition.js +7 -5
- package/src/screens/Automate/ScriptDetail/utils.js +1 -1
- package/src/screens/SubUnit/Detail.js +0 -1
- package/src/screens/UnitSummary/components/RunningDevices/index.js +0 -1
package/android/build.gradle
CHANGED
|
@@ -10,18 +10,18 @@
|
|
|
10
10
|
// original location:
|
|
11
11
|
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
apply plugin: 'com.android.library'
|
|
14
|
+
apply plugin: 'maven-publish'
|
|
15
|
+
|
|
16
|
+
def DEFAULT_COMPILE_SDK_VERSION = 34
|
|
14
17
|
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
|
|
15
18
|
def DEFAULT_MIN_SDK_VERSION = 24
|
|
16
|
-
def DEFAULT_TARGET_SDK_VERSION =
|
|
19
|
+
def DEFAULT_TARGET_SDK_VERSION = 34
|
|
17
20
|
|
|
18
21
|
def safeExtGet(prop, fallback) {
|
|
19
22
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
23
|
}
|
|
21
24
|
|
|
22
|
-
apply plugin: 'com.android.library'
|
|
23
|
-
apply plugin: 'maven'
|
|
24
|
-
|
|
25
25
|
buildscript {
|
|
26
26
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
27
27
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
@@ -33,14 +33,11 @@ buildscript {
|
|
|
33
33
|
jcenter()
|
|
34
34
|
}
|
|
35
35
|
dependencies {
|
|
36
|
-
classpath 'com.android.tools.build:gradle:
|
|
36
|
+
classpath 'com.android.tools.build:gradle:7.1.2'
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
apply plugin: 'com.android.library'
|
|
42
|
-
apply plugin: 'maven'
|
|
43
|
-
|
|
44
41
|
android {
|
|
45
42
|
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
|
|
46
43
|
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
|
package/package.json
CHANGED
|
@@ -18,20 +18,19 @@ import IconComponent from '../IconComponent';
|
|
|
18
18
|
import ItemDeviceWrapper from './ItemDeviceWrapper';
|
|
19
19
|
|
|
20
20
|
const ItemDevice = memo(
|
|
21
|
-
({
|
|
21
|
+
({ description, title, sensor, unit, station, wrapStyle }) => {
|
|
22
22
|
const t = useTranslations();
|
|
23
23
|
const navigation = useNavigation();
|
|
24
|
+
const { is_managed_by_backend, device_type, icon_kit, icon } = sensor;
|
|
24
25
|
|
|
25
26
|
const {
|
|
26
27
|
isConnected: isEoHBackendConnected,
|
|
27
28
|
isFetchingStatus: isFetchingStatusFromEoHBackend,
|
|
28
29
|
} = useEoHBackendDeviceConnected(sensor);
|
|
29
|
-
|
|
30
30
|
const {
|
|
31
31
|
isConnected: isHomeAssistantConnected,
|
|
32
32
|
isConnecting: isHomeAssistantConnecting,
|
|
33
33
|
} = useHomeAssistantDeviceConnected(sensor);
|
|
34
|
-
|
|
35
34
|
const { isConnected: isBluetoothConnected } =
|
|
36
35
|
useBluetoothDeviceConnected(sensor);
|
|
37
36
|
|
|
@@ -45,64 +44,51 @@ const ItemDevice = memo(
|
|
|
45
44
|
}, [navigation, sensor, station, title, unit]);
|
|
46
45
|
|
|
47
46
|
const textConnected = useMemo(() => {
|
|
48
|
-
if (
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
if (isFetchingStatusFromEoHBackend) {
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
if (isEoHBackendConnected) {
|
|
59
|
-
return t('connected');
|
|
60
|
-
}
|
|
61
|
-
return t('disconnected');
|
|
62
|
-
}
|
|
63
|
-
// not managed by backend
|
|
64
|
-
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
65
|
-
if (isHomeAssistantConnecting) {
|
|
66
|
-
return t('connecting');
|
|
67
|
-
}
|
|
68
|
-
if (isHomeAssistantConnected) {
|
|
47
|
+
if (is_managed_by_backend) {
|
|
48
|
+
if (
|
|
49
|
+
device_type === DEVICE_TYPE.LG_THINQ ||
|
|
50
|
+
isBluetoothConnected ||
|
|
51
|
+
isEoHBackendConnected
|
|
52
|
+
) {
|
|
69
53
|
return t('connected');
|
|
70
54
|
}
|
|
55
|
+
return isFetchingStatusFromEoHBackend ? '' : t('disconnected');
|
|
56
|
+
} else if (device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
57
|
+
return isHomeAssistantConnecting
|
|
58
|
+
? t('connecting')
|
|
59
|
+
: isHomeAssistantConnected
|
|
60
|
+
? t('connected')
|
|
61
|
+
: t('disconnected');
|
|
71
62
|
}
|
|
72
63
|
return t('disconnected');
|
|
73
64
|
}, [
|
|
65
|
+
device_type,
|
|
74
66
|
isBluetoothConnected,
|
|
75
67
|
isEoHBackendConnected,
|
|
76
68
|
isFetchingStatusFromEoHBackend,
|
|
77
69
|
isHomeAssistantConnected,
|
|
78
70
|
isHomeAssistantConnecting,
|
|
79
|
-
|
|
71
|
+
is_managed_by_backend,
|
|
80
72
|
t,
|
|
81
73
|
]);
|
|
82
74
|
|
|
83
75
|
const canRenderQuickAction = useMemo(() => {
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
if (isFetchingStatusFromEoHBackend) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
// not managed by backend
|
|
97
|
-
if (sensor?.device_type === DEVICE_TYPE.GOOGLE_HOME) {
|
|
98
|
-
return isHomeAssistantConnected;
|
|
76
|
+
if (is_managed_by_backend) {
|
|
77
|
+
return (
|
|
78
|
+
device_type === DEVICE_TYPE.LG_THINQ ||
|
|
79
|
+
isBluetoothConnected ||
|
|
80
|
+
!isFetchingStatusFromEoHBackend
|
|
81
|
+
);
|
|
99
82
|
}
|
|
100
|
-
return
|
|
83
|
+
return device_type === DEVICE_TYPE.GOOGLE_HOME
|
|
84
|
+
? isHomeAssistantConnected
|
|
85
|
+
: true;
|
|
101
86
|
}, [
|
|
87
|
+
device_type,
|
|
102
88
|
isBluetoothConnected,
|
|
103
89
|
isFetchingStatusFromEoHBackend,
|
|
104
90
|
isHomeAssistantConnected,
|
|
105
|
-
|
|
91
|
+
is_managed_by_backend,
|
|
106
92
|
]);
|
|
107
93
|
|
|
108
94
|
return (
|
|
@@ -114,9 +100,9 @@ const ItemDevice = memo(
|
|
|
114
100
|
>
|
|
115
101
|
<View style={styles.boxIcon}>
|
|
116
102
|
<TouchableOpacity onPress={goToSensorDisplay}>
|
|
117
|
-
<IconComponent icon={
|
|
103
|
+
<IconComponent icon={icon_kit || icon} />
|
|
118
104
|
</TouchableOpacity>
|
|
119
|
-
{
|
|
105
|
+
{canRenderQuickAction && (
|
|
120
106
|
<ItemQuickAction
|
|
121
107
|
sensor={sensor}
|
|
122
108
|
unit={unit}
|
|
@@ -155,7 +141,6 @@ const ItemDevice = memo(
|
|
|
155
141
|
);
|
|
156
142
|
|
|
157
143
|
export default ItemDevice;
|
|
158
|
-
|
|
159
144
|
const styles = StyleSheet.create({
|
|
160
145
|
boxIcon: {
|
|
161
146
|
flexDirection: 'row',
|
|
@@ -178,11 +163,6 @@ const styles = StyleSheet.create({
|
|
|
178
163
|
lineHeight20: {
|
|
179
164
|
lineHeight: 20,
|
|
180
165
|
},
|
|
181
|
-
iconSensor: {
|
|
182
|
-
width: 40,
|
|
183
|
-
height: 40,
|
|
184
|
-
resizeMode: 'contain',
|
|
185
|
-
},
|
|
186
166
|
quickAction: {
|
|
187
167
|
width: 32,
|
|
188
168
|
height: 32,
|
|
@@ -56,7 +56,6 @@ const SubUnitFavorites = ({
|
|
|
56
56
|
<ItemDevice
|
|
57
57
|
key={`device-${sensor.id}`}
|
|
58
58
|
id={sensor.id}
|
|
59
|
-
svgMain={sensor.icon || 'sensor'}
|
|
60
59
|
statusIcon={sensor.action && sensor.action.icon}
|
|
61
60
|
statusColor={sensor.action && sensor.action.color}
|
|
62
61
|
description={sensor.value}
|
|
@@ -154,7 +154,6 @@ const ShortDetailSubUnit = ({ unit, station, isOwner }) => {
|
|
|
154
154
|
<ItemDevice
|
|
155
155
|
key={`sensor-${device.id}`}
|
|
156
156
|
id={device.id}
|
|
157
|
-
svgMain={device.icon || 'sensor'}
|
|
158
157
|
statusIcon={device.action && device.action.icon}
|
|
159
158
|
statusColor={device.action && device.action.color}
|
|
160
159
|
description={device.value}
|
|
@@ -4,51 +4,44 @@ import { styles } from './IFrameStyles';
|
|
|
4
4
|
import IconComponent from '../../IconComponent';
|
|
5
5
|
import WebView from 'react-native-webview';
|
|
6
6
|
import { TouchableOpacity, View } from 'react-native';
|
|
7
|
+
import { SCConfig } from '../../../configs';
|
|
7
8
|
|
|
8
|
-
const IFrame = memo(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const [urlWithEnv, setUrlWithEnv] = useState();
|
|
9
|
+
const IFrame = memo(({ item = {} }) => {
|
|
10
|
+
const ref = useRef();
|
|
11
|
+
const [urlWithEnv, setUrlWithEnv] = useState();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const { configuration, id, title } = item;
|
|
14
|
+
const { url } = configuration || {};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const reload = useCallback(() => {
|
|
17
|
+
ref.current.reload();
|
|
18
|
+
}, []);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
`${url}&eraOrigin=${window.location.origin}&eraWidget=${item?.id}`
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
}, [item?.id, url]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!url) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!url.includes('?')) {
|
|
25
|
+
setUrlWithEnv(`${url}?eraOrigin=${SCConfig.apiRoot}&eraWidget=${id}`);
|
|
26
|
+
} else {
|
|
27
|
+
setUrlWithEnv(`${url}&eraOrigin=${SCConfig.apiRoot}&eraWidget=${id}`);
|
|
28
|
+
}
|
|
29
|
+
}, [id, url]);
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
);
|
|
31
|
+
return (
|
|
32
|
+
<View>
|
|
33
|
+
<TouchableOpacity style={styles.reloadButton} onClick={reload}>
|
|
34
|
+
<IconComponent size={20} icon="ReloadOutlined" />
|
|
35
|
+
</TouchableOpacity>
|
|
36
|
+
<WebView
|
|
37
|
+
source={{ uri: urlWithEnv }}
|
|
38
|
+
style={styles.iframe}
|
|
39
|
+
ref={ref}
|
|
40
|
+
title={title}
|
|
41
|
+
javaScriptEnabled
|
|
42
|
+
/>
|
|
43
|
+
</View>
|
|
44
|
+
);
|
|
45
|
+
});
|
|
53
46
|
|
|
54
47
|
export default IFrame;
|
|
@@ -5,6 +5,7 @@ import IFrame from '../IFrame';
|
|
|
5
5
|
import WebView from 'react-native-webview';
|
|
6
6
|
import { TouchableOpacity } from 'react-native';
|
|
7
7
|
import { render } from '../../../../../jest/render';
|
|
8
|
+
import { SCConfig } from '../../../../configs';
|
|
8
9
|
|
|
9
10
|
describe('Test IFrame', () => {
|
|
10
11
|
let item;
|
|
@@ -24,7 +25,7 @@ describe('Test IFrame', () => {
|
|
|
24
25
|
expect(iframes).toHaveLength(1);
|
|
25
26
|
|
|
26
27
|
expect(iframes[0].props.source?.uri).toEqual(
|
|
27
|
-
|
|
28
|
+
`http://localhost:3000/?eraOrigin=${SCConfig.apiRoot}&eraWidget=1`
|
|
28
29
|
);
|
|
29
30
|
});
|
|
30
31
|
|
|
@@ -36,7 +37,7 @@ describe('Test IFrame', () => {
|
|
|
36
37
|
expect(iframes).toHaveLength(1);
|
|
37
38
|
|
|
38
39
|
expect(iframes[0].props.source?.uri).toEqual(
|
|
39
|
-
|
|
40
|
+
`http://localhost:3000/?test=1&eraOrigin=${SCConfig.apiRoot}&eraWidget=1`
|
|
40
41
|
);
|
|
41
42
|
});
|
|
42
43
|
|
package/src/configs/Constants.js
CHANGED
|
@@ -19,11 +19,13 @@ import { ToastBottomHelper } from '../../../utils/Utils';
|
|
|
19
19
|
|
|
20
20
|
const valueEvaluationToOptions = (valueEvaluation) => {
|
|
21
21
|
if (valueEvaluation.template === 'range') {
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return (
|
|
23
|
+
valueEvaluation.configuration?.ranges?.map((range, index) => ({
|
|
24
|
+
title: range.evaluate?.text,
|
|
25
|
+
condition: 'value_evaluation',
|
|
26
|
+
value: [valueEvaluation.id, index],
|
|
27
|
+
})) || []
|
|
28
|
+
);
|
|
27
29
|
}
|
|
28
30
|
if (valueEvaluation.template === 'boolean') {
|
|
29
31
|
return [
|
|
@@ -47,7 +47,7 @@ const generateAutomationConditionValueEvaluation = (
|
|
|
47
47
|
if (valueEvaluation) {
|
|
48
48
|
if (valueEvaluation.template === 'range') {
|
|
49
49
|
return `${config_name} ${t('is')} ${
|
|
50
|
-
valueEvaluation.configuration.ranges[index]?.evaluate
|
|
50
|
+
valueEvaluation.configuration.ranges[index]?.evaluate?.text
|
|
51
51
|
}`;
|
|
52
52
|
}
|
|
53
53
|
if (valueEvaluation.template === 'boolean') {
|
|
@@ -116,7 +116,6 @@ const SubUnitDetail = ({ route }) => {
|
|
|
116
116
|
<ItemDevice
|
|
117
117
|
key={`sensor-${item.id}`}
|
|
118
118
|
id={item.id}
|
|
119
|
-
svgMain={item.icon || 'door'}
|
|
120
119
|
statusIcon={item.action && item.action.icon}
|
|
121
120
|
statusColor={item.action && item.action.color}
|
|
122
121
|
title={item.name}
|
|
@@ -15,7 +15,6 @@ const RunningDevices = memo(({ unit, summaryDetail }) => {
|
|
|
15
15
|
<ItemDevice
|
|
16
16
|
key={`sensor-${item.id}`}
|
|
17
17
|
id={item.id}
|
|
18
|
-
svgMain={item.icon || 'door'}
|
|
19
18
|
statusIcon={item.action && item.action.icon}
|
|
20
19
|
statusColor={item.action && item.action.color}
|
|
21
20
|
description={item.value}
|