Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
safetcut-app
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
atichat
safetcut-app
Commits
b4f5ca9a
Commit
b4f5ca9a
authored
Sep 13, 2019
by
HaOuiha
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/ejectedExpo' into ejectedExpo
parents
8d120271
8181b820
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
11 deletions
+77
-11
components/MeterCard.js
+7
-2
reduxStore/actions/currentSelectedAction.js
+43
-7
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
+27
-2
No files found.
components/MeterCard.js
View file @
b4f5ca9a
...
...
@@ -22,10 +22,10 @@ class MeterCard extends Component {
this
.
getShadow
();
}
if
(
prevProps
.
shadow
!==
this
.
props
.
shadow
)
{
await
this
.
setInitState
();
this
.
setInitState
();
}
};
setInitState
=
async
()
=>
{
setInitState
=
()
=>
{
const
{
shadow
}
=
this
.
props
;
this
.
setState
({
isPowerOn
:
shadow
.
SM1
.
BK_S
,
...
...
@@ -75,6 +75,11 @@ class MeterCard extends Component {
<
/View
>
<
/Row
>
<
/View
>
<
View
style
=
{[
theme
.
rowContainer
,
{
position
:
'absolute'
,
top
:
10
,
right
:
5
}]}
>
<
Icon
name
=
"wifi"
type
=
"FontAwesome"
style
=
{
styles
.
iconStyle
}
/
>
<
Icon
name
=
{
item
.
isSharing
?
'users'
:
'user'
}
type
=
"FontAwesome"
style
=
{
styles
.
iconStyle
}
/
>
<
View
style
=
{[
styles
.
online
,
{
backgroundColor
:
item
.
isOnline
?
'#10ca88'
:
color
.
primary
}]}
/
>
<
/View
>
<
/BaseButton
>
)
:
(
<
TouchableOpacity
onPress
=
{
this
.
props
.
onPressEachCard
}
style
=
{
styles
.
cardContainer
}
>
...
...
reduxStore/actions/currentSelectedAction.js
View file @
b4f5ca9a
...
...
@@ -125,13 +125,6 @@ export const setMainStatus = value => async (dispatch, getState) => {
};
const
data
=
{
data
:
{
CMD_MSG
:
{
MSG1
:
command
()
}
}
};
// console.log('value', value, 'command', command(), 'qs', qs.stringify({ data: { CMD_MSG: { MSG1: command() } } }));
// console.log('selectedDeviceId', selectedDeviceId);
// console.log(idToken);
// console.log(URL);
// console.log(data);
// console.log(JSON.stringify(data).replace(/\"/g, ''));
const
options
=
{
method
:
'PUT'
,
headers
:
{
Authorization
:
`Token
${
idToken
}
`
,
'content-Type'
:
'text/plain'
},
...
...
@@ -158,6 +151,49 @@ export const setMainStatus = value => async (dispatch, getState) => {
}
};
export
const
setSubBreakerStatus
=
(
value
,
MainIndex
,
SubIndex
)
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
}
=
getState
();
const
{
currentSelectedData
,
shadow
}
=
currentSelectedDeviceReducer
;
const
selectedDeviceId
=
currentSelectedData
.
deviceId
;
const
URL
=
`
${
baseURL
}
/shadow/
${
selectedDeviceId
}
`
;
const
idToken
=
await
app
.
auth
().
currentUser
.
getIdToken
(
true
);
const
command
=
()
=>
{
switch
(
value
)
{
case
true
:
return
`L
${
MainIndex
+
1
}
B
${
SubIndex
+
1
}
_ON`
;
case
false
:
return
`L
${
MainIndex
+
1
}
B
${
SubIndex
+
1
}
_OFF`
;
}
};
const
data
=
{
data
:
{
CMD_MSG
:
{
MSG1
:
command
()
}
}
};
const
options
=
{
method
:
'PUT'
,
headers
:
{
Authorization
:
`Token
${
idToken
}
`
,
'content-Type'
:
'text/plain'
},
url
:
URL
,
data
:
JSON
.
stringify
(
data
).
replace
(
/
\"
/g
,
''
),
};
try
{
const
{
data
:
{
writeShadow
:
{
value
:
{
CMD_MSG
},
},
},
}
=
await
axios
(
options
);
// console.log(value);
// console.log('ori', shadow);
// const newShadow = { ...shadow, CMD_MSG, SM1: { ...shadow.SM1, BK_S: value ? 1 : 0 } };
// console.log('new', newShadow);
// dispatch(getCurrentSelectedShadowAction(newShadow));
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
// export const getCurrentSelectedData = (deviceId, mcbLinkId, subBreakerId) => (dispatch, getState) => {
// const { currentSelectedDeviceReducer } = getState();
// const { selectedDeviceId } = currentSelectedDeviceReducer;
...
...
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
View file @
b4f5ca9a
...
...
@@ -9,6 +9,7 @@ import {
getCurrentSelectedShadow
,
loadingAction
,
setMainStatus
,
setSubBreakerStatus
,
}
from
'../../../reduxStore/actions/currentSelectedAction'
;
import
{
getTimers
,
loadingTimersAction
,
errorTimersAction
}
from
'../../../reduxStore/actions/timersAction'
;
import
{
isIphoneX
}
from
'../../../utils/isPhoneX'
;
...
...
@@ -219,12 +220,32 @@ class SmartMeterDetailScreen extends Component {
this
.
setState
(
prevState
=>
(
mcbLink
.
isExpand
=
!
prevState
.
mcbLinksInfo
[
indexMcbLinks
].
isExpand
));
const
renderSubBreaker
=
(
subBreaker
,
indexSubBreakers
)
=>
{
const
handleOnPressSubBreakerSwitch
=
()
=>
const
handleOnPressSubBreakerSwitch
=
async
value
=>
{
this
.
setState
(
prevState
=>
(
subBreaker
.
isPowerOn
=
!
prevState
.
subBreakersInfo
[
indexMcbLinks
][
indexSubBreakers
].
isPowerOn
)
);
const
deviceId
=
this
.
props
.
navigation
.
getParam
(
'deviceId'
);
await
this
.
props
.
setSubBreakerStatus
(
value
,
indexMcbLinks
,
indexSubBreakers
);
let
test
=
setInterval
(()
=>
{
this
.
props
.
getCurrentSelectedShadow
(
deviceId
);
console
.
log
(
'getShadow'
);
},
2000
);
if
(
this
.
state
.
prevShadow
!==
props
.
shadow
)
{
clearInterval
(
test
);
return
{
isWaiting
:
false
};
}
else
{
setTimeout
(()
=>
{
clearInterval
(
test
);
},
6000
);
}
};
const
isSubOn
=
this
.
props
.
shadow
[
`ML
${
indexMcbLinks
+
1
}
`
][
`L
${
indexMcbLinks
+
1
}
B
${
indexSubBreakers
+
1
}
`
];
return
(
<
View
style
=
{{
...
...
@@ -250,7 +271,11 @@ class SmartMeterDetailScreen extends Component {
<
/View
>
<
/Left
>
<
Right
>
<
Switch
value
=
{
subBreaker
.
isPowerOn
}
onChange
=
{
handleOnPressSubBreakerSwitch
}
/
>
<
Switch
disabled
=
{
this
.
props
.
shadow
.
SM1
.
BK_S
===
0
?
true
:
false
}
value
=
{
isSubOn
===
1
?
true
:
false
}
onValueChange
=
{
value
=>
handleOnPressSubBreakerSwitch
(
value
)}
/
>
<
/Right
>
<
/Row
>
<
/View
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment