@eohjsc/react-native-smart-city 0.4.52 → 0.4.54
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/README.md +23 -0
- package/package.json +1 -1
- package/src/commons/Action/ItemQuickAction.js +42 -16
- package/src/configs/SCConfig.js +5 -6
- package/src/iot/Monitor.js +1 -1
- package/src/utils/Apis/axios.js +0 -2
package/README.md
CHANGED
|
@@ -35,12 +35,35 @@ import {
|
|
|
35
35
|
AutomateStack,
|
|
36
36
|
NotificationStack,
|
|
37
37
|
} from '@eohjsc/react-native-smart-city';
|
|
38
|
+
import Config from 'react-native-config';
|
|
38
39
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
39
40
|
|
|
40
41
|
// TODO: What to do with the module?
|
|
41
42
|
const Stack = createStackNavigator();
|
|
42
43
|
|
|
43
44
|
const YourStack = () => {
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const config = {
|
|
49
|
+
apiRoot: Config.API_ROOT,
|
|
50
|
+
GOOGLE_MAP_API_KEY: Config.GOOGLE_MAP_API_KEY,
|
|
51
|
+
LG_CLIENT_ID: Config.LG_CLIENT_ID,
|
|
52
|
+
LG_REDIRECT_URI_APP: Config.LG_REDIRECT_URI_APP,
|
|
53
|
+
LG_URL: Config.LG_URL,
|
|
54
|
+
VCONNEX_CLIENT_ID: Config.VCONNEX_CLIENT_ID,
|
|
55
|
+
VCONNEX_REDIRECT_URI_APP: Config.VCONNEX_REDIRECT_URI,
|
|
56
|
+
pusherAppKey: Config.PUSHER_APP_KEY,
|
|
57
|
+
pusherAppCluster: Config.PUSHER_APP_CLUSTER,
|
|
58
|
+
language,
|
|
59
|
+
setCurrentSensorDisplay,
|
|
60
|
+
appName: Config.APP_NAME,
|
|
61
|
+
packageName: Config.APP_PACKAGE_NAME, // Your package name is required
|
|
62
|
+
versionCode: Config.APP_VERSION_CODE, // Your app version is required
|
|
63
|
+
};
|
|
64
|
+
initSCConfig(config);
|
|
65
|
+
}, [language, setCurrentSensorDisplay]);
|
|
66
|
+
|
|
44
67
|
// Declare yourAuthObject and params
|
|
45
68
|
return (
|
|
46
69
|
<Stack.Navigator>
|
package/package.json
CHANGED
|
@@ -8,6 +8,16 @@ import IconComponent from '../IconComponent';
|
|
|
8
8
|
|
|
9
9
|
const ItemQuickAction = memo(
|
|
10
10
|
({ sensor, wrapperStyle, setStatus, iconSize = 30 }) => {
|
|
11
|
+
const { quick_action } = sensor || {};
|
|
12
|
+
const {
|
|
13
|
+
config_id,
|
|
14
|
+
off_action,
|
|
15
|
+
on_status,
|
|
16
|
+
on_action,
|
|
17
|
+
off_status,
|
|
18
|
+
interval,
|
|
19
|
+
will_auto_update_status,
|
|
20
|
+
} = quick_action || {};
|
|
11
21
|
const [action, setAction] = useState(sensor.action);
|
|
12
22
|
// eslint-disable-next-line no-unused-vars
|
|
13
23
|
const [configValues, _] = useConfigGlobalState('configValues');
|
|
@@ -17,26 +27,34 @@ const ItemQuickAction = memo(
|
|
|
17
27
|
const [processing, setProcessing] = useState(false);
|
|
18
28
|
|
|
19
29
|
useEffect(() => {
|
|
20
|
-
if (!(
|
|
30
|
+
if (!(config_id in configValues)) {
|
|
21
31
|
return;
|
|
22
32
|
}
|
|
23
|
-
const configValue = configValues[
|
|
33
|
+
const configValue = configValues[config_id];
|
|
24
34
|
setIsOn(configValue?.value);
|
|
25
|
-
}, [
|
|
35
|
+
}, [configValues, config_id]);
|
|
26
36
|
|
|
27
37
|
useEffect(() => {
|
|
28
|
-
if (!
|
|
38
|
+
if (!quick_action) {
|
|
29
39
|
return;
|
|
30
40
|
}
|
|
31
41
|
|
|
32
42
|
if (isOn) {
|
|
33
|
-
setAction(
|
|
34
|
-
setStatus && setStatus(
|
|
43
|
+
setAction(off_action);
|
|
44
|
+
setStatus && setStatus(on_status);
|
|
35
45
|
} else {
|
|
36
|
-
setAction(
|
|
37
|
-
setStatus && setStatus(
|
|
46
|
+
setAction(on_action);
|
|
47
|
+
setStatus && setStatus(off_status);
|
|
38
48
|
}
|
|
39
|
-
}, [
|
|
49
|
+
}, [
|
|
50
|
+
isOn,
|
|
51
|
+
setStatus,
|
|
52
|
+
quick_action,
|
|
53
|
+
off_action,
|
|
54
|
+
on_status,
|
|
55
|
+
on_action,
|
|
56
|
+
off_status,
|
|
57
|
+
]);
|
|
40
58
|
|
|
41
59
|
const userId = useSCContextSelector((state) => state?.auth.account.user.id);
|
|
42
60
|
const onActionPress = useCallback(async () => {
|
|
@@ -46,9 +64,7 @@ const ItemQuickAction = memo(
|
|
|
46
64
|
}
|
|
47
65
|
setProcessing(true);
|
|
48
66
|
let data = null;
|
|
49
|
-
if (
|
|
50
|
-
action?.allow_config_store_value_id === sensor?.quick_action?.config_id
|
|
51
|
-
) {
|
|
67
|
+
if (action?.allow_config_store_value_id === config_id) {
|
|
52
68
|
if (action?.name?.toLowerCase().includes('off')) {
|
|
53
69
|
data = {
|
|
54
70
|
config_id: action?.allow_config_store_value_id,
|
|
@@ -64,13 +80,23 @@ const ItemQuickAction = memo(
|
|
|
64
80
|
}
|
|
65
81
|
await sendRemoteCommand(sensor, action, data, userId);
|
|
66
82
|
|
|
67
|
-
if (!
|
|
83
|
+
if (!will_auto_update_status) {
|
|
68
84
|
setTimeout(() => {
|
|
69
|
-
setIsOn(action.id ===
|
|
70
|
-
},
|
|
85
|
+
setIsOn(action.id === on_action.id);
|
|
86
|
+
}, interval);
|
|
71
87
|
}
|
|
72
88
|
setProcessing(false);
|
|
73
|
-
}, [
|
|
89
|
+
}, [
|
|
90
|
+
processing,
|
|
91
|
+
action,
|
|
92
|
+
config_id,
|
|
93
|
+
sendRemoteCommand,
|
|
94
|
+
sensor,
|
|
95
|
+
userId,
|
|
96
|
+
will_auto_update_status,
|
|
97
|
+
interval,
|
|
98
|
+
on_action?.id,
|
|
99
|
+
]);
|
|
74
100
|
|
|
75
101
|
if (!action) {
|
|
76
102
|
return <View />;
|
package/src/configs/SCConfig.js
CHANGED
|
@@ -100,8 +100,6 @@ const SCDefaultConfig = {
|
|
|
100
100
|
intervalWatchConfigTime: 30000,
|
|
101
101
|
setCurrentSensorDisplay: () => {},
|
|
102
102
|
appName: 'E-Ra',
|
|
103
|
-
packageName: 'com.eohjsc.eohmobile.staging',
|
|
104
|
-
versionCode: 1
|
|
105
103
|
};
|
|
106
104
|
|
|
107
105
|
export class SCConfig {
|
|
@@ -119,12 +117,15 @@ export class SCConfig {
|
|
|
119
117
|
static intervalWatchConfigTime = SCDefaultConfig.intervalWatchConfigTime;
|
|
120
118
|
static setCurrentSensorDisplay = SCDefaultConfig.setCurrentSensorDisplay;
|
|
121
119
|
static appName = SCDefaultConfig.appName;
|
|
122
|
-
static packageName = SCDefaultConfig.packageName;
|
|
123
|
-
static versionCode = SCDefaultConfig.versionCode;
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
export const initSCConfig = (config) => {
|
|
127
123
|
api.setBaseURL(config.apiRoot ?? SCDefaultConfig.apiRoot);
|
|
124
|
+
api.setHeaders({
|
|
125
|
+
'Content-Type': 'application/json',
|
|
126
|
+
'App-Version-Code': config.versionCode,
|
|
127
|
+
'App-Package-Name': config.packageName,
|
|
128
|
+
});
|
|
128
129
|
LocaleConfig.defaultLocale = config.language ?? SCConfig.language;
|
|
129
130
|
SCConfig.ENV = config.ENV ?? SCConfig.ENV;
|
|
130
131
|
SCConfig.language = config.language ?? SCConfig.language;
|
|
@@ -147,6 +148,4 @@ export const initSCConfig = (config) => {
|
|
|
147
148
|
SCConfig.setCurrentSensorDisplay =
|
|
148
149
|
config.setCurrentSensorDisplay ?? SCDefaultConfig.setCurrentSensorDisplay;
|
|
149
150
|
SCConfig.appName = config.appName ?? SCDefaultConfig.appName;
|
|
150
|
-
SCConfig.packageName = config.packageName ?? SCConfig.packageName;
|
|
151
|
-
SCConfig.versionCode = config.version ?? SCConfig.versionCode;
|
|
152
151
|
};
|
package/src/iot/Monitor.js
CHANGED
|
@@ -37,7 +37,7 @@ const watchingConfigs = {};
|
|
|
37
37
|
|
|
38
38
|
export const updateGlobalValue = (configId, value) => {
|
|
39
39
|
const configValues = getConfigGlobalState('configValues');
|
|
40
|
-
|
|
40
|
+
let newConfigValues = { ...configValues };
|
|
41
41
|
newConfigValues[configId] = value;
|
|
42
42
|
setConfigGlobalState('configValues', newConfigValues);
|
|
43
43
|
};
|
package/src/utils/Apis/axios.js
CHANGED