Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ehasa-mobile
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WIMMA Lab 2019
Overflow
ehasa-mobile
Commits
ddac8d34
Commit
ddac8d34
authored
5 years ago
by
Taneli Riihimäki
Browse files
Options
Downloads
Patches
Plain Diff
Basic functionalities almost working, some little bugs
parent
15439f53
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.env
+1
-1
1 addition, 1 deletion
.env
App.js
+1
-1
1 addition, 1 deletion
App.js
components/Login.js
+6
-6
6 additions, 6 deletions
components/Login.js
components/LoginForm.js
+1
-1
1 addition, 1 deletion
components/LoginForm.js
components/RegisterForm.js
+11
-6
11 additions, 6 deletions
components/RegisterForm.js
with
20 additions
and
15 deletions
.env
+
1
−
1
View file @
ddac8d34
REACT_APP_URL = "http://localhost:5000"
REACT_APP_URL = "http://172.20.2.110:5000"
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
App.js
+
1
−
1
View file @
ddac8d34
import
React
,
{
Component
}
from
"
react
"
;
import
React
,
{
Component
}
from
"
react
"
;
import
{
StyleSheet
,
Text
,
View
,
Button
}
from
"
react-native
"
;
import
{
StyleSheet
,
Text
,
View
,
Button
,
AsyncStorage
}
from
"
react-native
"
;
import
FetchLocation
from
"
./components/FetchLocation
"
;
import
FetchLocation
from
"
./components/FetchLocation
"
;
import
Login
from
"
./components/Login
"
;
import
Login
from
"
./components/Login
"
;
...
...
This diff is collapsed.
Click to expand it.
components/Login.js
+
6
−
6
View file @
ddac8d34
...
@@ -80,9 +80,9 @@ class Login extends Component {
...
@@ -80,9 +80,9 @@ class Login extends Component {
/>
/>
)}
)}
{
this
.
state
.
username
&&
(
{
this
.
state
.
username
&&
(
<
b
utton
<
B
utton
id
=
"
logoutButton
"
id
=
"
logoutButton
"
onPress
=
{
this
.
handleLogout
}
onPress
=
{
this
.
handleLogout
.
bind
(
this
)
}
title
=
"
Logout
"
title
=
"
Logout
"
/>
/>
)}
)}
...
@@ -90,15 +90,15 @@ class Login extends Component {
...
@@ -90,15 +90,15 @@ class Login extends Component {
{
this
.
state
.
form
===
"
register
"
&&
(
{
this
.
state
.
form
===
"
register
"
&&
(
<
RegisterForm
<
RegisterForm
view
=
""
view
=
""
handleState
=
{
this
.
handleState
}
handleState
=
{
this
.
handleState
.
bind
(
this
)
}
toggleView
=
{
this
.
toggleView
}
toggleView
=
{
this
.
toggleView
.
bind
(
this
)
}
/
>
/
>
)}
)}
{
this
.
state
.
form
===
"
login
"
&&
(
{
this
.
state
.
form
===
"
login
"
&&
(
<
LoginForm
<
LoginForm
view
=
""
view
=
""
handleState
=
{
this
.
handleState
}
handleState
=
{
this
.
handleState
.
bind
(
this
)
}
toggleView
=
{
this
.
toggleView
}
toggleView
=
{
this
.
toggleView
.
bind
(
this
)
}
/
>
/
>
)}
)}
<
/View
>
<
/View
>
...
...
This diff is collapsed.
Click to expand it.
components/LoginForm.js
+
1
−
1
View file @
ddac8d34
...
@@ -34,7 +34,7 @@ export class LoginForm extends React.Component {
...
@@ -34,7 +34,7 @@ export class LoginForm extends React.Component {
e
.
preventDefault
();
e
.
preventDefault
();
// Send login info to the server
// Send login info to the server
fetch
(
`
${
process
.
env
.
REACT_APP_URL
}
/user/login`
,
{
fetch
(
`
http://172.20.2.110:5000
/user/login`
,
{
method
:
"
POST
"
,
method
:
"
POST
"
,
headers
:
{
headers
:
{
Accept
:
"
application/json
"
,
Accept
:
"
application/json
"
,
...
...
This diff is collapsed.
Click to expand it.
components/RegisterForm.js
+
11
−
6
View file @
ddac8d34
...
@@ -9,8 +9,11 @@ export class RegisterForm extends React.Component {
...
@@ -9,8 +9,11 @@ export class RegisterForm extends React.Component {
errorMsg
:
""
,
errorMsg
:
""
,
username
:
""
,
username
:
""
,
password
:
""
,
password
:
""
,
password2
:
""
password2
:
""
,
registered
:
false
};
};
//this.handleRegister = this.handleRegister.bind(this);
}
}
// shows error messages associated with registering
// shows error messages associated with registering
...
@@ -32,13 +35,14 @@ export class RegisterForm extends React.Component {
...
@@ -32,13 +35,14 @@ export class RegisterForm extends React.Component {
handleRegister
=
e
=>
{
handleRegister
=
e
=>
{
const
name
=
this
.
state
.
username
;
const
name
=
this
.
state
.
username
;
const
password
=
this
.
state
.
password
;
const
password
=
this
.
state
.
password
;
e
.
preventDefault
();
console
.
log
(
"
PÄÄSTII TÄNNE
"
);
this
.
setState
({
registered
:
true
});
console
.
log
(
"
Registered:
"
+
this
.
state
.
registered
);
if
(
this
.
state
.
password
!==
this
.
state
.
password2
)
{
if
(
this
.
state
.
password
!==
this
.
state
.
password2
)
{
this
.
handleError
(
"
Passwords do not match
"
);
this
.
handleError
(
"
Passwords do not match
"
);
}
else
{
}
else
{
// Send register info to the server
// Send register info to the server
fetch
(
"
http://
localhost
:5000/user/register
"
,
{
fetch
(
`
http://
172.20.2.110
:5000/user/register
`
,
{
method
:
"
POST
"
,
method
:
"
POST
"
,
headers
:
{
headers
:
{
Accept
:
"
application/json
"
,
Accept
:
"
application/json
"
,
...
@@ -56,7 +60,7 @@ export class RegisterForm extends React.Component {
...
@@ -56,7 +60,7 @@ export class RegisterForm extends React.Component {
this
.
props
.
handleState
(
result
);
this
.
props
.
handleState
(
result
);
this
.
handleView
();
this
.
handleView
();
}
else
{
}
else
{
this
.
handleError
(
result
.
errorResponse
.
message
);
this
.
handleError
(
result
.
message
);
}
}
},
},
// Note: it's important to handle errors here
// Note: it's important to handle errors here
...
@@ -73,6 +77,7 @@ export class RegisterForm extends React.Component {
...
@@ -73,6 +77,7 @@ export class RegisterForm extends React.Component {
return
(
return
(
<
View
className
=
"
fade-main
"
>
<
View
className
=
"
fade-main
"
>
<
View
className
=
"
sticky
"
>
<
View
className
=
"
sticky
"
>
{
this
.
state
.
registered
&&
<
Text
>
REKISTERÖIDÄÄN
<
/Text>
}
<
Text
className
=
"
close
"
onPress
=
{
this
.
handleView
}
>
<
Text
className
=
"
close
"
onPress
=
{
this
.
handleView
}
>
×
×
<
/Text
>
<
/Text
>
...
@@ -100,7 +105,7 @@ export class RegisterForm extends React.Component {
...
@@ -100,7 +105,7 @@ export class RegisterForm extends React.Component {
onChangeText
=
{
password2
=>
this
.
setState
({
password2
})}
onChangeText
=
{
password2
=>
this
.
setState
({
password2
})}
required
required
/>
/>
<
Button
type
=
"
submit
"
title
=
"
Submit
"
onPress
=
{
this
.
handleRegister
}
/
>
<
Button
title
=
"
Submit
"
onPress
=
{
this
.
handleRegister
}
/
>
<
Text
>
{
this
.
state
.
errorMsg
}
<
/Text
>
<
Text
>
{
this
.
state
.
errorMsg
}
<
/Text
>
<
/View
>
<
/View
>
<
/View
>
<
/View
>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment