Toggle navigation
Toggle navigation
This project
Loading...
Sign in
송용우
/
oss-Jaksimsamil
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
송용우
2020-06-25 01:26:22 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
803e5995a6ff558928caa139b781d1a6f08e97a6
803e5995
2 parents
309989fc
51d6adc9
Merge commit '
51d6adc9
' into feature/rest_api
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
154 additions
and
7 deletions
jaksimsamil-page/src/components/setting/GoalNumForm.js
jaksimsamil-page/src/components/setting/SettingForm.js
jaksimsamil-page/src/containers/home/HomeContainer.js
jaksimsamil-page/src/containers/setting/SettingContainer.js
jaksimsamil-page/src/modules/profile.js
jaksimsamil-server/access.log
jaksimsamil-server/src/api/profile/profile.ctrl.js
jaksimsamil-server/src/models/profile.js
jaksimsamil-page/src/components/setting/GoalNumForm.js
0 → 100644
View file @
803e599
import
React
from
'react'
;
import
{
makeStyles
}
from
'@material-ui/core/styles'
;
import
Button
from
'@material-ui/core/Button'
;
import
TextField
from
'@material-ui/core/TextField'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
'& > *'
:
{
margin
:
theme
.
spacing
(
1
),
},
},
}));
const
GoalNumForm
=
({
onChange
,
profile
,
onGoalNumSubmit
})
=>
{
const
classes
=
useStyles
();
return
(
<
div
>
<
form
onSubmit
=
{
onGoalNumSubmit
}
>
<
TextField
name
=
"goalNum"
type
=
"number"
onChange
=
{
onChange
}
value
=
{
profile
.
goalNum
}
placeholder
=
"일일 목표"
label
=
"일일 목표"
InputLabelProps
=
{{
shrink
:
true
,
}}
/
>
<
Button
variant
=
"outlined"
type
=
"submit"
>
등록
<
/Button
>
<
/form
>
<
/div
>
);
};
export
default
GoalNumForm
;
jaksimsamil-page/src/components/setting/SettingForm.js
View file @
803e599
...
...
@@ -2,9 +2,12 @@ import React from 'react';
import
palette
from
'../../lib/styles/palette'
;
import
BJIDForm
from
'./BJIDForm'
;
import
SlackForm
from
'./SlackForm'
;
import
GoalNumForm
from
'./GoalNumForm'
;
import
{
makeStyles
}
from
'@material-ui/core/styles'
;
import
Paper
from
'@material-ui/core/Paper'
;
import
Grid
from
'@material-ui/core/Grid'
;
import
CircularProgress
from
'@material-ui/core/CircularProgress'
;
import
styled
from
'styled-components'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
...
...
@@ -18,15 +21,29 @@ const useStyles = makeStyles((theme) => ({
},
}));
const
LoadingParentStyle
=
styled
.
div
`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding-top: 20px;
`
;
const
SettingForm
=
({
onChange
,
onBJIDSubmit
,
onSlackURLSubmit
,
profile
,
onSyncBJIDSubmit
,
onGoalNumSubmit
,
isLoading
,
})
=>
{
const
classes
=
useStyles
();
return
(
return
isLoading
?
(
<
LoadingParentStyle
>
<
CircularProgress
className
=
{
classes
.
loading
}
/
>
<
/LoadingParentStyle
>
)
:
(
<
div
className
=
{
classes
.
root
}
>
<
Grid
container
spacing
=
{
3
}
>
<
Grid
item
xs
=
{
12
}
>
...
...
@@ -54,6 +71,16 @@ const SettingForm = ({
/
>
<
/Paper
>
<
/Grid
>
<
Grid
container
item
xs
=
{
12
}
>
<
Paper
className
=
{
classes
.
paper
}
elevation
=
{
3
}
>
<
GoalNumForm
profile
=
{
profile
}
onChange
=
{
onChange
}
onGoalNumSubmit
=
{
onGoalNumSubmit
}
/
>
<
/Paper
>
<
/Grid
>
<
/Grid
>
<
/div
>
);
...
...
jaksimsamil-page/src/containers/home/HomeContainer.js
View file @
803e599
...
...
@@ -9,7 +9,9 @@ const HomeContainer = ({ history }) => {
user
:
user
.
user
,
profile
:
profile
,
}));
useEffect
(()
=>
{},
[
profile
.
solvedBJ
]);
useEffect
(()
=>
{
console
.
log
(
profile
);
},
[
profile
.
solvedBJ
]);
useEffect
(()
=>
{
if
(
user
)
{
let
username
=
user
.
username
;
...
...
jaksimsamil-page/src/containers/setting/SettingContainer.js
View file @
803e599
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
{
...
...
@@ -8,15 +8,20 @@ import {
syncBJID
,
initializeProfile
,
setSLACK
,
setGOALNUM
,
}
from
'../../modules/profile'
;
import
SettingForm
from
'../../components/setting/SettingForm'
;
const
SettingContainer
=
({
history
})
=>
{
const
[
isLoading
,
setLoading
]
=
useState
(
false
);
const
dispatch
=
useDispatch
();
const
{
user
,
profile
}
=
useSelector
(({
user
,
profile
})
=>
({
const
{
user
,
profile
,
loading
}
=
useSelector
(
({
user
,
profile
,
loading
})
=>
({
user
:
user
.
user
,
profile
:
profile
,
}));
loading
:
loading
,
}),
);
const
onChange
=
(
e
)
=>
{
const
{
value
,
name
}
=
e
.
target
;
...
...
@@ -33,6 +38,13 @@ const SettingContainer = ({ history }) => {
let
username
=
profile
.
username
;
dispatch
(
syncBJID
({
username
}));
};
const
onGoalNumSubmit
=
(
e
)
=>
{
e
.
preventDefault
();
let
username
=
profile
.
username
;
let
goalNum
=
profile
.
goalNum
;
dispatch
(
setGOALNUM
({
username
,
goalNum
}));
};
const
onSlackURLSubmit
=
(
e
)
=>
{
e
.
preventDefault
();
let
username
=
profile
.
username
;
...
...
@@ -60,6 +72,13 @@ const SettingContainer = ({ history }) => {
};
}
},
[
dispatch
,
user
,
history
]);
useEffect
(()
=>
{
if
(
loading
[
'profile/SYNC_BJID'
]
==
true
)
{
setLoading
(
true
);
}
else
{
setLoading
(
false
);
}
},
[
dispatch
,
loading
]);
return
(
<
SettingForm
...
...
@@ -68,7 +87,9 @@ const SettingContainer = ({ history }) => {
onBJIDSubmit
=
{
onBJIDSubmit
}
onSyncBJIDSubmit
=
{
onSyncBJIDSubmit
}
onSlackURLSubmit
=
{
onSlackURLSubmit
}
onGoalNumSubmit
=
{
onGoalNumSubmit
}
profile
=
{
profile
}
isLoading
=
{
isLoading
}
><
/SettingForm
>
);
};
...
...
jaksimsamil-page/src/modules/profile.js
View file @
803e599
...
...
@@ -17,6 +17,11 @@ const [
SET_SLACK_FAILURE
,
]
=
createRequestActionTypes
(
'/profile/SET_SLACK'
);
const
[
SET_GOALNUM
,
SET_GOALNUM_SUCCESS
,
SET_GOALNUM_FAILURE
,
]
=
createRequestActionTypes
(
'/profile/SET_GOALNUM'
);
const
[
GET_PROFILE
,
GET_PROFILE_SUCCESS
,
GET_PROFILE_FAILURE
,
...
...
@@ -31,6 +36,7 @@ export const initializeProfile = createAction(INITIALIZE);
export
const
syncBJID
=
createAction
(
SYNC_BJID
,
({
username
})
=>
({
username
,
}));
export
const
setSLACK
=
createAction
(
SET_SLACK
,
({
username
,
slackWebHookURL
})
=>
({
...
...
@@ -38,6 +44,14 @@ export const setSLACK = createAction(
slackWebHookURL
,
}),
);
export
const
setGOALNUM
=
createAction
(
SET_GOALNUM
,
({
username
,
goalNum
})
=>
({
username
,
goalNum
,
}),
);
export
const
setBJID
=
createAction
(
SET_BJID
,
({
username
,
userBJID
})
=>
({
username
,
userBJID
,
...
...
@@ -58,16 +72,21 @@ const initialState = {
friendList
:
[],
profileError
:
''
,
slackWebHookURL
:
''
,
solvedBJ_date
:
''
,
goalNum
:
''
,
};
const
getPROFILESaga
=
createRequestSaga
(
GET_PROFILE
,
profileAPI
.
getPROFILE
);
const
setBJIDSaga
=
createRequestSaga
(
SET_BJID
,
profileAPI
.
setBJID
);
const
setSLACKSaga
=
createRequestSaga
(
SET_SLACK
,
profileAPI
.
setPROFILE
);
const
setGOALNUMSaga
=
createRequestSaga
(
SET_GOALNUM
,
profileAPI
.
setPROFILE
);
const
syncBJIDSaga
=
createRequestSaga
(
SYNC_BJID
,
profileAPI
.
syncBJ
);
export
function
*
profileSaga
()
{
yield
takeLatest
(
SET_BJID
,
setBJIDSaga
);
yield
takeLatest
(
GET_PROFILE
,
getPROFILESaga
);
yield
takeLatest
(
SYNC_BJID
,
syncBJIDSaga
);
yield
takeLatest
(
SET_SLACK
,
setSLACKSaga
);
yield
takeLatest
(
SET_GOALNUM
,
setGOALNUMSaga
);
}
export
default
handleActions
(
...
...
@@ -80,7 +99,15 @@ export default handleActions(
[
GET_PROFILE_SUCCESS
]:
(
state
,
{
payload
:
{
username
,
userBJID
,
solvedBJ
,
friendList
,
slackWebHookURL
},
payload
:
{
username
,
userBJID
,
solvedBJ
,
friendList
,
slackWebHookURL
,
solvedBJ_date
,
goalNum
,
},
},
)
=>
({
...
state
,
...
...
@@ -90,6 +117,8 @@ export default handleActions(
friendList
:
friendList
,
profileError
:
null
,
slackWebHookURL
:
slackWebHookURL
,
solvedBJ_date
:
solvedBJ_date
,
goalNum
:
goalNum
,
}),
[
GET_PROFILE_FAILURE
]:
(
state
,
{
payload
:
error
})
=>
({
...
state
,
...
...
@@ -114,6 +143,14 @@ export default handleActions(
...
state
,
profileError
:
error
,
}),
[
SET_GOALNUM_SUCCESS
]:
(
state
,
{
payload
:
{
goalNum
}
})
=>
({
...
state
,
goalNum
:
goalNum
,
}),
[
SET_GOALNUM_FAILURE
]:
(
state
,
{
payload
:
error
})
=>
({
...
state
,
profileError
:
error
,
}),
[
SYNC_BJID_SUCCESS
]:
(
state
,
{
payload
:
{
solvedBJ
}
})
=>
({
...
state
,
solvedBJ
,
...
...
jaksimsamil-server/access.log
View file @
803e599
...
...
@@ -1321,3 +1321,23 @@
::1 - - [24/Jun/2020:14:15:40 +0000] "POST /api/profile/recommend HTTP/1.1" 404 9 "-" "PostmanRuntime/7.25.0"
::1 - - [24/Jun/2020:14:19:33 +0000] "POST /api/profile/recommend HTTP/1.1" 404 9 "-" "PostmanRuntime/7.25.0"
::1 - - [24/Jun/2020:14:19:36 +0000] "POST /api/profile/recommend HTTP/1.1" 404 9 "-" "PostmanRuntime/7.25.0"
::ffff:127.0.0.1 - - [24/Jun/2020:15:35:00 +0000] "POST /api/profile/setprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:35:04 +0000] "POST /api/profile/getprofile HTTP/1.1" 401 12 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:35:04 +0000] "GET /api/auth/check HTTP/1.1" 200 55 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:35:05 +0000] "POST /api/profile/getprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:37:14 +0000] "POST /api/profile/setprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:37:50 +0000] "POST /api/profile/setprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:37:54 +0000] "GET /api/auth/check HTTP/1.1" 200 55 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:37:54 +0000] "POST /api/profile/getprofile HTTP/1.1" 401 12 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:37:55 +0000] "POST /api/profile/getprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:39:50 +0000] "POST /api/profile/getprofile HTTP/1.1" 401 12 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:39:50 +0000] "GET /api/auth/check HTTP/1.1" 200 55 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:39:50 +0000] "POST /api/profile/getprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:39:54 +0000] "POST /api/profile/setprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:40:00 +0000] "GET /api/auth/check HTTP/1.1" 200 55 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:40:00 +0000] "POST /api/profile/getprofile HTTP/1.1" 401 12 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:40:00 +0000] "POST /api/profile/getprofile HTTP/1.1" 200 33281 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::1 - - [24/Jun/2020:15:40:32 +0000] "POST /api/profile/setprofile HTTP/1.1" 200 33293 "-" "PostmanRuntime/7.25.0"
::ffff:127.0.0.1 - - [24/Jun/2020:15:41:51 +0000] "GET /api/auth/check HTTP/1.1" 200 55 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:41:51 +0000] "POST /api/profile/getprofile HTTP/1.1" 401 12 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
::ffff:127.0.0.1 - - [24/Jun/2020:15:41:51 +0000] "POST /api/profile/getprofile HTTP/1.1" 200 33293 "http://localhost:3000/setting" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36 Edg/83.0.478.54"
...
...
jaksimsamil-server/src/api/profile/profile.ctrl.js
View file @
803e599
...
...
@@ -50,7 +50,7 @@ exports.setProfile = async (ctx) => {
//freindList: Joi.array().items(Joi.string()),
})
.
unknown
();
console
.
log
(
ctx
.
request
.
body
);
const
result
=
Joi
.
validate
(
ctx
.
request
.
body
,
schema
);
if
(
result
.
error
)
{
ctx
.
status
=
400
;
...
...
jaksimsamil-server/src/models/profile.js
View file @
803e599
...
...
@@ -9,6 +9,7 @@ const ProfileSchema = new Schema({
solvedBJ_date
:
Object
,
friendList
:
[
String
],
slackWebHookURL
:
String
,
goalNum
:
Number
,
});
ProfileSchema
.
statics
.
findByUsername
=
function
(
username
)
{
return
this
.
findOne
({
username
});
...
...
Please
register
or
login
to post a comment