Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Telemedicine_App_Development
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashini Thilakarathne
Telemedicine_App_Development
Commits
7545cdb1
Commit
7545cdb1
authored
Mar 19, 2024
by
Shashini Thilakarathne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes
parent
78a3ce6b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
27 deletions
+117
-27
StressPrediction/config.js
StressPrediction/config.js
+10
-10
StressPrediction/images/Background.png
StressPrediction/images/Background.png
+0
-0
StressPrediction/src/FetchData.js
StressPrediction/src/FetchData.js
+59
-0
StressPrediction/src/newJournalEntry.js
StressPrediction/src/newJournalEntry.js
+48
-17
No files found.
StressPrediction/config.js
View file @
7545cdb1
import
firebase
from
'
firebase/compat/app
'
;
import
{
getDatabase
}
from
'
firebase/database
'
;
import
{
getDatabase
,
ref
,
onValue
}
from
'
firebase/database
'
;
const
firebaseConfig
=
{
apiKey
:
"
AIzaSyCr8EgrdjVYrI936R0MY2xTdNvLW9d_IVc
"
,
authDomain
:
"
research-4aa0d.firebaseapp.com
"
,
databaseURL
:
"
https://research-4aa0d-default-rtdb.firebaseio.com
"
,
projectId
:
"
research-4aa0d
"
,
storageBucket
:
"
research-4aa0d.appspot.com
"
,
messagingSenderId
:
"
953444486465
"
,
appId
:
"
1:953444486465:web:68681174589c1d1c54e5c0
"
,
measurementId
:
"
G-SDEQKTS8D4
"
}
apiKey
:
"
AIzaSyCr8EgrdjVYrI936R0MY2xTdNvLW9d_IVc
"
,
authDomain
:
"
research-4aa0d.firebaseapp.com
"
,
databaseURL
:
"
https://research-4aa0d-default-rtdb.firebaseio.com
"
,
projectId
:
"
research-4aa0d
"
,
storageBucket
:
"
research-4aa0d.appspot.com
"
,
messagingSenderId
:
"
953444486465
"
,
appId
:
"
1:953444486465:web:68681174589c1d1c54e5c0
"
,
measurementId
:
"
G-SDEQKTS8D4
"
}
if
(
firebase
.
apps
.
length
===
0
){
firebase
.
initializeApp
(
firebaseConfig
);
...
...
StressPrediction/images/Background.png
0 → 100644
View file @
7545cdb1
14.2 KB
StressPrediction/src/FetchData.js
0 → 100644
View file @
7545cdb1
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Text
,
View
,
StyleSheet
}
from
'
react-native
'
;
import
{
db
}
from
'
../config
'
;
import
{
ref
,
get
}
from
'
firebase/database
'
;
const
NotificationsComponent
=
()
=>
{
const
[
notification
,
setNotification
]
=
useState
(
null
);
useEffect
(()
=>
{
const
retrieveNotification
=
async
()
=>
{
try
{
const
notificationRef
=
ref
(
db
,
'
notification
'
);
const
snapshot
=
await
get
(
notificationRef
);
if
(
snapshot
.
exists
())
{
const
notificationData
=
snapshot
.
val
();
setNotification
(
notificationData
);
}
else
{
console
.
log
(
"
No notification found.
"
);
}
}
catch
(
error
)
{
console
.
error
(
'
Error retrieving notification:
'
,
error
);
}
};
retrieveNotification
();
},
[]);
return
(
<
View
>
<
Text
style
=
{
styles
.
notificationText
}
><
/Text
>
{
notification
&&
(
<
View
>
{
notification
.
message
&&
(
<
Text
style
=
{
styles
.
notificationMessage
}
>
{
notification
.
message
===
"
Stress Level Detected
"
?
"
Your Health Level Detected: You are in Stress Level ... 🙁
"
:
"
Congratulations! You Are Healthy 🙁
"
}
<
/Text
>
)}
{
notification
.
isTrue
!==
undefined
&&
(
<
Text
>
Is
True
:
{
notification
.
isTrue
?
'
Yes
'
:
'
No
'
}
<
/Text
>
)}
<
/View
>
)}
<
/View
>
);
};
const
styles
=
StyleSheet
.
create
({
notificationMessage
:
{
color
:
'
white
'
,
fontSize
:
20
,
fontWeight
:
'
bold
'
,
},
});
export
default
NotificationsComponent
;
StressPrediction/src/newJournalEntry.js
View file @
7545cdb1
import
React
,
{
useState
}
from
'
react
'
;
import
{
View
,
Text
,
StyleSheet
,
TextInput
,
Button
,
Image
,
Modal
,
TouchableOpacity
,
ScrollView
}
from
'
react-native
'
;
import
{
db
}
from
'
../config
'
;
import
{
View
,
Text
,
StyleSheet
,
TextInput
,
Button
,
Image
,
Modal
,
TouchableOpacity
,
ScrollView
,
ImageBackground
}
from
'
react-native
'
;
import
{
db
,
onValue
,
off
}
from
'
../config
'
;
import
{
ref
,
set
}
from
'
firebase/database
'
;
import
NotificationsComponent
from
'
../src/FetchData
'
;
const
AddData
=
()
=>
{
const
[
Job_Satisfaction
,
setJobSatisfaction
]
=
useState
(
''
);
...
...
@@ -17,49 +18,53 @@ const AddData = () => {
const
jobSatisfactionValue
=
Job_Satisfaction
===
'
Yes
'
?
0
:
1
;
let
sleepHoursValue
=
parseInt
(
selectedHours
);
// Applying the logic to set sleep hours value
if
(
!
isNaN
(
sleepHoursValue
))
{
sleepHoursValue
=
sleepHoursValue
>
8
?
0
:
1
;
}
else
{
console
.
error
(
"
Invalid input for Sleep Hours. Please enter a valid number.
"
);
return
;
// Exit the function if sleep hours is invalid
return
;
}
const
postData
=
{
Job_Satisfaction
:
jobSatisfactionValue
,
Sleep_Hours
:
sleepHoursValue
,
Text
:
Additional_Text
,
isNew
:
true
// Set isNew to true initially
isNew
:
true
};
set
(
ref
(
db
,
'
live_data
'
),
postData
)
.
then
(()
=>
{
console
.
log
(
"
Data updated successfully
"
);
// After some time or event, update isNew to false
setTimeout
(()
=>
{
set
(
ref
(
db
,
'
live_data/isNew
'
),
false
);
},
5000
);
// Example: Set isNew to false after 5 seconds
},
5000
);
})
.
catch
(
error
=>
{
console
.
error
(
"
Error updating data:
"
,
error
);
});
setModalVisible
(
false
);
// Close the modal after updating data
setModalVisible
(
false
);
};
return
(
<
View
style
=
{
styles
.
container
}
>
<
Text
style
=
{
styles
.
header
}
>
STRESS
TRACKER
<
/Text
>
<
Image
source
=
{
require
(
'
../images/Background.png
'
)}
style
=
{
styles
.
backgroundImage
}
><
/Image
>
<
View
style
=
{
styles
.
notificationsContainer
}
>
<
NotificationsComponent
/>
<
/View
>
<
TouchableOpacity
onPress
=
{()
=>
setModalVisible
(
true
)}
>
<
Image
source
=
{
require
(
'
../images/Home.jpg
'
)}
style
=
{
styles
.
image
}
/
>
<
/TouchableOpacity
>
<
Button
title
=
"
Open Popup
"
<
TouchableOpacity
style
=
{
styles
.
openPopupButton
}
onPress
=
{()
=>
setModalVisible
(
true
)}
/
>
>
<
Text
style
=
{
styles
.
openPopupButtonText
}
>+<
/Text
>
<
/TouchableOpacity
>
<
Modal
animationType
=
"
slide
"
transparent
=
{
true
}
...
...
@@ -148,7 +153,26 @@ export default AddData;
const
styles
=
StyleSheet
.
create
({
container
:
{
flex
:
1
,
backgroundColor
:
'
#fff
'
,
backgroundColor
:
'
white
'
,
},
backgroundImage
:{
},
openPopupButton
:
{
position
:
'
absolute
'
,
top
:
300
,
left
:
130
,
backgroundColor
:
'
#ff2c2c
'
,
padding
:
5
,
borderRadius
:
50
,
margin
:
10
,
height
:
80
,
width
:
80
,
},
openPopupButtonText
:
{
color
:
'
#ffffff
'
,
fontSize
:
45
,
textAlign
:
'
center
'
,
},
header
:
{
fontSize
:
40
,
...
...
@@ -343,4 +367,11 @@ const styles = StyleSheet.create({
fontWeight
:
'
bold
'
,
display
:
'
none
'
,
},
notificationsContainer
:
{
position
:
'
absolute
'
,
top
:
120
,
left
:
80
,
right
:
0
,
zIndex
:
1
,
},
});
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