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
8ff86ee3
Commit
8ff86ee3
authored
Sep 19, 2019
by
Tonk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add delete connected device function, update get connected device
parent
897d2eda
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
26 deletions
+75
-26
components/Form/Input.js
+2
-2
components/InputField.js
+1
-1
components/MeterCard.js
+4
-4
constants/Styles.js
+0
-5
reduxStore/actions/currentSelectedAction.js
+61
-0
reduxStore/actions/timersAction.js
+2
-0
screens/Private/NotificationScreen/NotificationScreen.js
+3
-3
screens/Private/SmartMeterScreen/McbLinkScreen.js
+0
-0
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
+2
-11
No files found.
components/Form/Input.js
View file @
8ff86ee3
...
...
@@ -63,10 +63,10 @@ class Input extends Component {
<
/View
>
{
touched
&&
((
error
&&
(
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
textDanger
,
styles
.
errPosition
]}
>
{
error
}
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
theme
.
textDanger
,
styles
.
errPosition
]}
>
{
error
}
<
/Text
>
))
||
(
warning
&&
(
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
textWarning
,
styles
.
errPosition
]}
>
{
warning
}
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
theme
.
textWarning
,
styles
.
errPosition
]}
>
{
warning
}
<
/Text
>
)))}
<
/View
>
);
...
...
components/InputField.js
View file @
8ff86ee3
...
...
@@ -63,7 +63,7 @@ const InputField = ({
item
.
field
===
name
&&
item
.
error
?
(
<
Text
key
=
{
`
${
index
}
`
}
style
=
{[
theme
.
smD
escription
,
theme
.
textDanger
,
{
bottom
:
-
15
,
position
:
'absolute'
}]}
style
=
{[
theme
.
d
escription
,
theme
.
textDanger
,
{
bottom
:
-
15
,
position
:
'absolute'
}]}
>
{
item
.
error
}
<
/Text
>
...
...
components/MeterCard.js
View file @
8ff86ee3
...
...
@@ -43,7 +43,7 @@ class MeterCard extends Component {
{
backgroundColor
:
isPowerOn
===
1
?
'rgba(65, 204, 0, 0.59)'
:
'rgba(223, 0, 0, 0.59)'
},
]}
>
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
textWhite
]}
>
{
isPowerOn
===
1
?
'ON'
:
'OFF'
}
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
theme
.
textWhite
]}
>
{
isPowerOn
===
1
?
'ON'
:
'OFF'
}
<
/Text
>
<
/View
>
<
View
style
=
{[
theme
.
centerContainer
]}
>
{
item
.
img
?
(
...
...
@@ -63,7 +63,7 @@ class MeterCard extends Component {
<
Row
style
=
{{
alignItems
:
'center'
}}
>
<
Text
style
=
{[
theme
.
smallTitle
,
{
marginRight
:
15
}]}
>
{
item
.
name
||
'Untitled'
}
<
/Text
>
<
/Row
>
<
Text
style
=
{[
theme
.
smD
escription
]}
numberOfLines
=
{
2
}
>
<
Text
style
=
{[
theme
.
d
escription
]}
numberOfLines
=
{
2
}
>
{
item
.
description
}
<
/Text
>
<
Row
style
=
{{
marginTop
:
10
}}
>
...
...
@@ -89,7 +89,7 @@ class MeterCard extends Component {
{
backgroundColor
:
isPowerOn
===
1
?
'rgba(65, 204, 0, 0.59)'
:
'rgba(223, 0, 0, 0.59)'
},
]}
>
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
textWhite
]}
>
{
isPowerOn
===
1
?
'ON'
:
'OFF'
}
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
theme
.
textWhite
]}
>
{
isPowerOn
===
1
?
'ON'
:
'OFF'
}
<
/Text
>
<
/View
>
<
View
style
=
{[
theme
.
centerContainer
]}
>
{
item
.
img
?
(
...
...
@@ -109,7 +109,7 @@ class MeterCard extends Component {
<
Row
style
=
{{
alignItems
:
'center'
}}
>
<
Text
style
=
{[
theme
.
smallTitle
,
{
marginRight
:
15
}]}
>
{
item
.
name
}
<
/Text
>
<
/Row
>
<
Text
style
=
{[
theme
.
smD
escription
]}
numberOfLines
=
{
2
}
>
<
Text
style
=
{[
theme
.
d
escription
]}
numberOfLines
=
{
2
}
>
{
item
.
description
}
<
/Text
>
<
Row
style
=
{{
marginTop
:
10
}}
>
...
...
constants/Styles.js
View file @
8ff86ee3
...
...
@@ -74,11 +74,6 @@ export const theme = StyleSheet.create({
fontFamily
:
'Avenir-Roman'
,
color
:
color
.
grey
,
},
smDescription
:
{
fontSize
:
12
,
fontFamily
:
'Avenir-Roman'
,
color
:
color
.
grey
,
},
input
:
{
fontSize
:
16
,
paddingTop
:
20
,
...
...
reduxStore/actions/currentSelectedAction.js
View file @
8ff86ee3
import
app
,
{
fireStore
}
from
'../../firebase'
;
import
axios
from
'axios'
;
import
_
from
'lodash'
;
import
{
getExistedConnectedDeviceAction
}
from
'./timersAction'
;
const
baseURL
=
'https://us-central1-safetcut-20cdf.cloudfunctions.net'
;
...
...
@@ -240,6 +241,66 @@ export const setSubBreakerStatus = (value, MainIndex, SubIndex) => async (dispat
console
.
log
(
error
);
}
};
export
const
addConnectedDevice
=
(
mcbLinkId
,
subBreakerId
,
deviceData
)
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
,
timersReducer
}
=
getState
();
const
{
currentSelectedData
}
=
currentSelectedDeviceReducer
;
const
{
existedConnectedDevice
}
=
timersReducer
;
const
selectedDeviceId
=
currentSelectedData
.
deviceId
;
const
getDocRef
=
()
=>
{
const
docRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
selectedDeviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
mcbLinkId
)
.
collection
(
'subBreakers'
)
.
doc
(
subBreakerId
);
return
docRef
;
};
const
newConnectedDevice
=
existedConnectedDevice
.
map
(
x
=>
x
.
index
+
1
===
subBreakerId
&&
[...
x
[
index
],
deviceData
]
);
try
{
const
docRef
=
getDocRef
();
await
docRef
.
add
(
deviceData
);
dispatch
(
getExistedConnectedDeviceAction
(
newConnectedDevice
));
}
catch
(
error
)
{}
};
export
const
deleteConnectedDevice
=
data
=>
async
(
dispatch
,
getState
)
=>
{
const
{
currentSelectedDeviceReducer
,
timersReducer
}
=
getState
();
const
{
currentSelectedData
}
=
currentSelectedDeviceReducer
;
const
{
existedConnectedDevice
}
=
timersReducer
;
const
selectedDeviceId
=
currentSelectedData
.
deviceId
;
const
{
mcbLinkId
,
subBreakerId
,
connectedDeviceId
}
=
data
;
console
.
log
(
'action connected device'
,
existedConnectedDevice
);
const
getDocRef
=
()
=>
{
const
docRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
selectedDeviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
mcbLinkId
)
.
collection
(
'subBreakers'
)
.
doc
(
subBreakerId
)
.
collection
(
'electronicDevices'
)
.
doc
(
connectedDeviceId
);
return
docRef
;
};
const
newConnectedDevice
=
existedConnectedDevice
.
map
(
x
=>
x
.
filter
(
device
=>
device
.
connectedDeviceId
!==
connectedDeviceId
)
);
try
{
dispatch
(
getExistedConnectedDeviceAction
(
newConnectedDevice
));
const
docRef
=
getDocRef
();
await
docRef
.
delete
();
}
catch
(
error
)
{
console
.
log
(
error
);
}
};
// export const getCurrentSelectedData = (deviceId, mcbLinkId, subBreakerId) => (dispatch, getState) => {
// const { currentSelectedDeviceReducer } = getState();
...
...
reduxStore/actions/timersAction.js
View file @
8ff86ee3
...
...
@@ -151,6 +151,8 @@ export const getTimers = () => async (dispatch, getState) => {
existedConnectedDevice
.
push
(
connectedDevices
.
docs
.
map
(
connectedDevice
=>
Object
.
assign
(
connectedDevice
.
data
(),
{
mcbLinkId
:
mcbLink
.
id
,
subBreakerId
:
subBreaker
.
id
,
connectedDeviceId
:
connectedDevice
.
id
,
})
)
...
...
screens/Private/NotificationScreen/NotificationScreen.js
View file @
8ff86ee3
...
...
@@ -192,7 +192,7 @@ class NotificationScreen extends React.Component {
)}
<
View
style
=
{{
display
:
'flex'
,
flexDirection
:
'column'
,
flex
:
1
}}
>
<
View
style
=
{[
theme
.
rowContainer
,
{
justifyContent
:
'space-between'
,
marginBottom
:
10
}]}
>
<
Text
style
=
{[
theme
.
smD
escription
,
{
color
:
'#b9babc'
}]}
>
{
data
.
user
||
'unknown'
}
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
{
color
:
'#b9babc'
}]}
>
{
data
.
user
||
'unknown'
}
<
/Text
>
{
!
data
.
read
&&
(
<
View
...
...
@@ -207,7 +207,7 @@ class NotificationScreen extends React.Component {
},
]}
>
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
textWhite
]}
>
New
<
/Text
>
<
Text
style
=
{[
theme
.
d
escription
,
theme
.
textWhite
]}
>
New
<
/Text
>
<
/View
>
)}
<
/View
>
...
...
@@ -215,7 +215,7 @@ class NotificationScreen extends React.Component {
<
Text
style
=
{[
theme
.
normalText
,
theme
.
textDark
]}
>
{
data
.
action
}
{
data
.
device
}
<
/Text
>
<
Text
style
=
{[
theme
.
smD
escription
,
{
color
:
'#b9babc'
}]}
>
<
Text
style
=
{[
theme
.
d
escription
,
{
color
:
'#b9babc'
}]}
>
{
format
(
data
.
time
*
1000
,
'hh:mm A'
)}
<
/Text
>
<
/View
>
...
...
screens/Private/SmartMeterScreen/McbLinkScreen.js
View file @
8ff86ee3
This diff is collapsed.
Click to expand it.
screens/Private/SmartMeterScreen/SmartMeterDetailScreen.js
View file @
8ff86ee3
...
...
@@ -82,8 +82,6 @@ class SmartMeterDetailScreen extends Component {
)
{
this
.
setSubBreakersState
();
}
console
.
log
(
'S'
,
this
.
state
);
console
.
log
(
'PROPS'
,
this
.
props
);
};
handleToggle
=
async
value
=>
{
this
.
setState
({
isWaiting
:
true
});
...
...
@@ -92,12 +90,9 @@ class SmartMeterDetailScreen extends Component {
await
this
.
props
.
setMainStatus
(
value
);
const
getShadowInterval
=
setInterval
(
async
()
=>
{
console
.
log
(
'getShadow'
);
this
.
setState
(()
=>
{
const
{
currentSelectedData
,
breakerStatus
}
=
this
.
props
;
if
(
this
.
props
.
desiredBreakerStatus
===
this
.
props
.
breakerStatus
)
{
console
.
log
(
'Interval Handletoggle'
);
clearInterval
(
getShadowInterval
);
return
{
...
...
@@ -226,7 +221,7 @@ class SmartMeterDetailScreen extends Component {
index
%
3
===
0
?
{
marginRight
:
0
}
:
{
marginLeft
:
10
},
]}
>
<
Text
style
=
{[
theme
.
smD
escription
,
{
color
:
item
.
value
>
item
.
limit
?
color
.
white
:
color
.
grey
}]}
>
<
Text
style
=
{[
theme
.
d
escription
,
{
color
:
item
.
value
>
item
.
limit
?
color
.
white
:
color
.
grey
}]}
>
{
item
.
name
}
<
/Text
>
<
Text
...
...
@@ -245,7 +240,7 @@ class SmartMeterDetailScreen extends Component {
<
Text
style
=
{[
theme
.
smD
escription
,
theme
.
d
escription
,
theme
.
textDark
,
{
color
:
item
.
value
>
item
.
limit
?
color
.
white
:
color
.
darkGrey
,
...
...
@@ -296,11 +291,8 @@ class SmartMeterDetailScreen extends Component {
await
this
.
props
.
getCurrentSelectedShadow
();
const
getShadowInterval
=
setInterval
(
async
()
=>
{
console
.
log
(
'getShadow'
);
this
.
setState
(()
=>
{
if
(
this
.
props
.
desiredBreakerStatus
===
this
.
props
.
breakerStatus
)
{
console
.
log
(
'Interval HandletoggleSubBreaker'
);
clearInterval
(
getShadowInterval
);
return
{
isWaiting
:
false
};
}
else
{
...
...
@@ -314,7 +306,6 @@ class SmartMeterDetailScreen extends Component {
return
{
isWaiting
:
false
};
}
});
console
.
log
(
'checkedTimes'
,
checkedTimes
);
++
checkedTimes
;
await
this
.
props
.
getCurrentSelectedShadow
();
this
.
setSubBreakersState
();
...
...
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