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
bad299bd
Commit
bad299bd
authored
Sep 12, 2019
by
HaOuiha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
76b8cbc9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
128 additions
and
165 deletions
+128
-165
App.js
+0
-149
reduxStore/actions/currentSelectedAction.js
+14
-14
screens/Private/SmartMeterScreen/SmartMeterScreen.js
+9
-0
screens/Public/AuthLoadingScreen.js
+105
-2
No files found.
App.js
View file @
bad299bd
...
...
@@ -12,18 +12,13 @@ import { Provider } from 'react-redux';
import
rootStore
from
'./reduxStore'
;
import
{
Root
}
from
'native-base'
;
import
{
fixTimerWarning
}
from
'./utils/fixTimerWarning'
;
import
{
YellowBox
}
from
'react-native'
;
import
{
useScreens
}
from
'react-native-screens'
;
import
{
fireStore
}
from
'./firebase'
;
console
.
disableYellowBox
=
true
;
const
Application
=
()
=>
{
useEffect
(()
=>
{
// useScreens();
fixTimerWarning
();
YellowBox
.
ignoreWarnings
([
'Warning:'
]);
// createMockData();
},
[]);
return
(
...
...
@@ -38,147 +33,3 @@ const Application = () => {
};
export
default
Application
;
const
createMockData
=
()
=>
{
// const deviceId = 'iYs6Th9Pkg1vTEDIyPa5';
// const deviceId = '8998c7d5-4476-41d9-81c6-9ef2dbac2505';
const
deviceId
=
'267a494c-a6b6-4b74-a952-82ba8d5db783'
;
const
batch
=
fireStore
.
batch
();
/*------------------------------*/
const
mainRef
=
fireStore
.
doc
(
`device/
${
deviceId
}
`
);
batch
.
set
(
mainRef
,
main
);
for
(
let
i
=
1
;
i
<=
2
;
i
++
)
{
let
mainTimerRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'Timers'
)
.
doc
();
batch
.
set
(
mainTimerRef
,
timer
);
}
/*------------------------------*/
for
(
let
i
=
1
;
i
<=
4
;
i
++
)
{
const
mcbLinks
=
{
type
:
'mcbLink'
,
name
:
`MCB Link
${
i
}
`
,
description
:
`description
${
i
}
`
,
};
let
mcbLinksRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
());
// for (let z = 1; z <= 1; z++) {
// let mcbLinkTimerRef = fireStore
// .collection('device')
// .doc(deviceId)
// .collection('mcbLinks')
// .doc(i.toString())
// .collection('Timers')
// .doc();
// batch.set(mcbLinkTimerRef, timer);
// }
batch
.
set
(
mcbLinksRef
,
mcbLinks
);
}
/*------------------------------*/
for
(
let
i
=
1
;
i
<=
4
;
i
++
)
{
for
(
let
j
=
1
;
j
<=
8
;
j
++
)
{
let
subBreakers
=
{
type
:
'subBreaker'
,
name
:
`Sub Breaker
${
j
}
`
,
description
:
`description
${
j
}
`
,
};
let
subBreakersRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
())
.
collection
(
'subBreakers'
)
.
doc
(
j
.
toString
());
for
(
let
z
=
1
;
z
<=
1
;
z
++
)
{
let
subBreakerTimerRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
())
.
collection
(
'subBreakers'
)
.
doc
(
j
.
toString
())
.
collection
(
'Timers'
)
.
doc
();
batch
.
set
(
subBreakerTimerRef
,
timer
);
}
batch
.
set
(
subBreakersRef
,
subBreakers
);
}
}
batch
.
commit
();
};
// const mcbLinkId = 1;
// const subBreakerId = 2;
const
main
=
{
type
:
'main'
,
name
:
'Main'
,
description
:
'description'
,
notification
:
true
,
rcbo
:
10
,
};
const
initTime
=
new
Date
();
initTime
.
setFullYear
(
2019
);
initTime
.
setMonth
(
0
);
initTime
.
setDate
(
0
);
initTime
.
setSeconds
(
0
);
const
timer
=
{
isActive
:
false
,
isPowerOn
:
false
,
timer
:
0
,
repeatOn
:
[
{
id
:
0
,
isRepeat
:
false
,
day
:
'Sunday'
},
{
id
:
1
,
isRepeat
:
false
,
day
:
'Monday'
},
{
id
:
2
,
isRepeat
:
false
,
day
:
'Tuesday'
},
{
id
:
3
,
isRepeat
:
false
,
day
:
'Wednesday'
},
{
id
:
4
,
isRepeat
:
false
,
day
:
'Thursday'
},
{
id
:
5
,
isRepeat
:
false
,
day
:
'Friday'
},
{
id
:
6
,
isRepeat
:
false
,
day
:
'Saturday'
},
],
};
// const mcbLinks = {
// // id: mcbLinkId,
// type: 'mcbLink',
// name: `MCB Link ${mcbLinkId}`,
// description: `description ${mcbLinkId}`,
// };
// const subBreakers = {
// // id: subBreakerId,
// type: 'subBreaker',
// name: `Sub Breaker ${subBreakerId}`,
// description: `description ${subBreakerId}`,
// };
// const timer = {
// isActive: false,
// isPowerOn: false,
// timer: 1566378008,
// repeatOn: [
// { id: 0, isRepeat: false, day: 'Sunday' },
// { id: 1, isRepeat: false, day: 'Monday' },
// { id: 2, isRepeat: false, day: 'Tuesday' },
// { id: 3, isRepeat: false, day: 'Wednesday' },
// { id: 4, isRepeat: false, day: 'Thursday' },
// { id: 5, isRepeat: false, day: 'Friday' },
// { id: 6, isRepeat: false, day: 'Saturday' },
// ],
// };
reduxStore/actions/currentSelectedAction.js
View file @
bad299bd
...
...
@@ -149,24 +149,24 @@ export const setMainStatus = value => async (dispatch, getState) => {
console
.
log
(
data
);
console
.
log
(
JSON
.
stringify
(
data
).
replace
(
/
\"
/g
,
''
));
//
const options = {
//
method: 'PUT',
// headers: { Authorization: `Token ${idToken}`, 'C
ontent-Type': 'text/plain' },
//
url: URL,
// data: JSON.stringify(data
),
//
};
const
options
=
{
method
:
'PUT'
,
headers
:
{
Authorization
:
`Token
${
idToken
}
`
,
'c
ontent-Type'
:
'text/plain'
},
url
:
URL
,
data
:
JSON
.
stringify
(
data
).
replace
(
/
\"
/g
,
''
),
};
try
{
const
res
=
await
fetch
(
URL
,
{
method
:
'PUT'
,
headers
:
{
Authorization
:
`Token
${
idToken
}
`
,
'Content-Type'
:
'text/plain'
},
body
:
JSON
.
stringify
(
data
).
replace
(
/
\"
/g
,
''
),
}).
then
(
response
=>
response
.
json
());
//
const res = await fetch(URL, {
//
method: 'PUT',
//
headers: { Authorization: `Token ${idToken}`, 'Content-Type': 'text/plain' },
//
body: JSON.stringify(data).replace(/\"/g, ''),
//
}).then(response => response.json());
console
.
log
(
res
);
//
console.log(res);
//
const response = await axios(options);
//
console.log(response);
const
response
=
await
axios
(
options
);
console
.
log
(
response
);
}
catch
(
error
)
{
console
.
log
(
error
);
}
...
...
screens/Private/SmartMeterScreen/SmartMeterScreen.js
View file @
bad299bd
...
...
@@ -38,6 +38,14 @@ class SmartMeterScreen extends PureComponent {
});
};
componentDidUpdate
=
(
prevProps
,
prevState
)
=>
{
if
(
prevProps
.
allMainDeviceInfo
!==
this
.
props
.
allMainDeviceInfo
)
{
this
.
setState
({
data
:
this
.
props
.
allMainDeviceInfo
,
});
}
};
renderItem
=
({
item
,
index
})
=>
{
return
(
<
MeterCard
...
...
@@ -104,6 +112,7 @@ class SmartMeterScreen extends PureComponent {
style
=
{[
theme
.
container
]}
contentContainerStyle
=
{[
theme
.
containerWithPadding
,
{
paddingBottom
:
isIphoneX
()
?
90
:
55
}]}
//iPhoneX BottomSpace = 34
data
=
{
data
}
extraData
=
{
this
.
props
}
keyExtractor
=
{(
item
,
index
)
=>
item
.
deviceId
}
ItemSeparatorComponent
=
{()
=>
<
View
style
=
{
theme
.
mt1
}
/>
}
ListEmptyComponent
=
{()
=>
(
...
...
screens/Public/AuthLoadingScreen.js
View file @
bad299bd
...
...
@@ -6,6 +6,7 @@ import { width } from '../../constants/Layout';
import
app
from
'../../firebase'
;
import
{
connect
}
from
'react-redux'
;
import
{
getCurrentUser
}
from
'../../reduxStore/actions/cerrentUserAction'
;
import
{
fireStore
}
from
'../../firebase'
;
class
AuthLoadingScreen
extends
Component
{
static
navigationOptions
=
{
...
...
@@ -25,7 +26,7 @@ class AuthLoadingScreen extends Component {
if
(
this
.
_isMounted
)
{
this
.
setState
({
isShowImg
:
false
});
}
},
8
00
);
// 1200
},
9
00
);
// 1200
};
_bootstrapAsync
=
async
()
=>
{
...
...
@@ -43,7 +44,7 @@ class AuthLoadingScreen extends Component {
// console.log(idToken);
await
this
.
props
.
getCurrentUser
(
user
);
this
.
props
.
navigation
.
navigate
(
RememberedLogin
===
'true'
?
'Main'
:
'Login'
);
//
this.props.navigation.navigate(false ? 'Main' : 'Login'
);
//
createMockData(
);
}
else
{
this
.
props
.
navigation
.
navigate
(
alreadyLaunched
===
'true'
?
'Login'
:
'Onboarding'
);
}
...
...
@@ -89,3 +90,105 @@ export default connect(
null
,
mapDispatchToProps
)(
AuthLoadingScreen
);
const
createMockData
=
()
=>
{
console
.
log
(
'writting data'
);
// const deviceId = 'iYs6Th9Pkg1vTEDIyPa5';
// const deviceId = '8998c7d5-4476-41d9-81c6-9ef2dbac2505';
const
deviceId
=
'267a494c-a6b6-4b74-a952-82ba8d5db783'
;
const
batch
=
fireStore
.
batch
();
/*------------------------------*/
const
mainRef
=
fireStore
.
doc
(
`device/
${
deviceId
}
`
);
batch
.
set
(
mainRef
,
main
);
for
(
let
i
=
1
;
i
<=
2
;
i
++
)
{
let
mainTimerRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'Timers'
)
.
doc
();
batch
.
set
(
mainTimerRef
,
timer
);
}
/*------------------------------*/
for
(
let
i
=
1
;
i
<=
4
;
i
++
)
{
const
mcbLinks
=
{
type
:
'mcbLink'
,
name
:
`MCB Link
${
i
}
`
,
description
:
`description
${
i
}
`
,
};
let
mcbLinksRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
());
batch
.
set
(
mcbLinksRef
,
mcbLinks
);
}
/*------------------------------*/
for
(
let
i
=
1
;
i
<=
4
;
i
++
)
{
for
(
let
j
=
1
;
j
<=
8
;
j
++
)
{
let
subBreakers
=
{
type
:
'subBreaker'
,
name
:
`Sub Breaker
${
j
}
`
,
description
:
`description
${
j
}
`
,
};
let
subBreakersRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
())
.
collection
(
'subBreakers'
)
.
doc
(
j
.
toString
());
for
(
let
z
=
1
;
z
<=
1
;
z
++
)
{
let
subBreakerTimerRef
=
fireStore
.
collection
(
'device'
)
.
doc
(
deviceId
)
.
collection
(
'mcbLinks'
)
.
doc
(
i
.
toString
())
.
collection
(
'subBreakers'
)
.
doc
(
j
.
toString
())
.
collection
(
'Timers'
)
.
doc
();
batch
.
set
(
subBreakerTimerRef
,
timer
);
}
batch
.
set
(
subBreakersRef
,
subBreakers
);
}
}
batch
.
commit
();
};
const
main
=
{
type
:
'main'
,
name
:
'Main'
,
description
:
'description'
,
notification
:
true
,
rcbo
:
10
,
};
const
initTime
=
new
Date
();
initTime
.
setFullYear
(
2019
);
initTime
.
setMonth
(
0
);
initTime
.
setDate
(
0
);
initTime
.
setSeconds
(
0
);
const
timer
=
{
isActive
:
false
,
isPowerOn
:
false
,
timer
:
0
,
repeatOn
:
[
{
id
:
0
,
isRepeat
:
false
,
day
:
'Sunday'
},
{
id
:
1
,
isRepeat
:
false
,
day
:
'Monday'
},
{
id
:
2
,
isRepeat
:
false
,
day
:
'Tuesday'
},
{
id
:
3
,
isRepeat
:
false
,
day
:
'Wednesday'
},
{
id
:
4
,
isRepeat
:
false
,
day
:
'Thursday'
},
{
id
:
5
,
isRepeat
:
false
,
day
:
'Friday'
},
{
id
:
6
,
isRepeat
:
false
,
day
:
'Saturday'
},
],
};
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