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-08-28 21:21:53 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
05582aae0cd21f825c893c30a4df318ea2d5f2d2
05582aae
2 parents
ae933b07
7a39581f
Merge commit '
7a39581f
' into feature/rest_api
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
127 additions
and
53 deletions
jaksimsamil-page/package.json
jaksimsamil-page/src/components/home/HeatMap.js
jaksimsamil-page/src/components/home/HomeForm.js
jaksimsamil-page/src/containers/home/HomeContainer.js
jaksimsamil-page/yarn.lock
jaksimsamil-server/src/models/challenge.js
jaksimsamil-server/src/models/session.js
jaksimsamil-page/package.json
View file @
05582aa
...
...
@@ -13,6 +13,7 @@
"moment"
:
"^2.27.0"
,
"open-color"
:
"^1.7.0"
,
"react"
:
"^16.13.1"
,
"react-calendar-heatmap"
:
"^1.8.1"
,
"react-dom"
:
"^16.13.1"
,
"react-redux"
:
"^7.2.0"
,
"react-router-dom"
:
"^5.2.0"
,
...
...
jaksimsamil-page/src/components/home/HeatMap.js
0 → 100644
View file @
05582aa
import
React
,
{
use
}
from
'react'
;
import
CalendarHeatmap
from
'react-calendar-heatmap'
;
import
'react-calendar-heatmap/dist/styles.css'
;
/*
TODO: 날짜 범위 지정, 날짜별 검색 추가
*/
/*
solvedBJbyDATE:
solvedBJbyDATE:{
20190304 : [Object]
...
}
*/
const
HeatMap
=
(
HMArr
)
=>
{
return
(
<
div
>
<
CalendarHeatmap
onClick
=
{()
=>
{
console
.
log
(
HMArr
);
}}
startDate
=
{
new
Date
(
'2020-01-01'
)}
endDate
=
{
new
Date
(
'2020-12-01'
)}
values
=
{
HMArr
.
HMArr
}
classForValue
=
{(
value
)
=>
{
if
(
!
value
)
{
return
'color-empty'
;
}
return
`color-github-
${
value
.
count
}
`
;
}}
tooltipDataAttrs
=
{(
value
)
=>
{
return
{
'data-tooltip'
:
`
${
value
.
date
}
has count:
${
value
.
count
}
`
,
};
}}
showWeekdayLabels
=
{
true
}
/
>
<
/div
>
);
};
export
default
HeatMap
;
jaksimsamil-page/src/components/home/HomeForm.js
View file @
05582aa
...
...
@@ -3,7 +3,7 @@ import { makeStyles } from '@material-ui/core/styles';
import
Paper
from
'@material-ui/core/Paper'
;
import
Grid
from
'@material-ui/core/Grid'
;
import
palette
from
'../../lib/styles/palette'
;
import
AuthForm
from
'../auth/AuthForm
'
;
import
HeatMap
from
'./HeatMap
'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
flexGrow
:
1
,
...
...
@@ -17,7 +17,7 @@ const useStyles = makeStyles((theme) => ({
color
:
theme
.
palette
.
text
.
secondary
,
},
}));
const
HomeForm
=
({
PSdata
,
goalNum
})
=>
{
const
HomeForm
=
({
PSdata
,
HMArr
,
goalNum
})
=>
{
const
classes
=
useStyles
();
return
PSdata
?
(
<
div
className
=
{
classes
.
root
}
>
...
...
@@ -48,7 +48,11 @@ const HomeForm = ({ PSdata, goalNum }) => {
<
h3
>
마지막으로
푼
문제
<
/h3
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
12
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
HeatMap
HMArr
=
{
HMArr
}
/
>
<
/Paper
>
<
/Grid
>
<
Grid
item
xs
=
{
4
}
>
<
Paper
className
=
{
classes
.
paper
}
>
<
h1
>
{
PSdata
.
weekNum
}
<
/h1
>
...
...
jaksimsamil-page/src/containers/home/HomeContainer.js
View file @
05582aa
import
React
,
{
useEffect
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
HomeForm
from
'../../components/home/HomeForm'
;
import
{
getPROFILE
,
initializeProfile
}
from
'../../modules/profile'
;
const
HomeContainer
=
({
history
})
=>
{
const
dispatch
=
useDispatch
();
const
[
HMArr
,
setHMArr
]
=
useState
([]);
const
{
user
,
profile
}
=
useSelector
(({
user
,
profile
})
=>
({
user
:
user
.
user
,
profile
:
profile
,
}));
const
makeHeatmapValues
=
(
PSdata
)
=>
{
let
obj_keys
=
Object
.
keys
(
PSdata
);
let
result
=
[];
for
(
let
i
=
0
;
i
<
obj_keys
.
length
;
i
++
)
{
result
.
push
({
date
:
//2019-10-15
obj_keys
[
i
].
slice
(
0
,
4
)
+
'-'
+
obj_keys
[
i
].
slice
(
4
,
6
)
+
'-'
+
obj_keys
[
i
].
slice
(
6
,
8
),
count
:
PSdata
[
obj_keys
[
i
]].
length
,
});
}
return
result
;
};
useEffect
(()
=>
{
if
(
!
user
)
{
alert
(
'로그인이 필요합니다 '
);
...
...
@@ -23,7 +42,9 @@ const HomeContainer = ({ history }) => {
}
},
[
dispatch
,
user
,
history
]);
useEffect
(()
=>
{
console
.
log
(
profile
);
if
(
profile
.
solvedBJ_date
)
{
setHMArr
(
makeHeatmapValues
(
profile
.
solvedBJ_date
.
solvedBJbyDATE
));
}
},
[
profile
]);
useEffect
(()
=>
{
if
(
user
)
{
...
...
@@ -31,6 +52,12 @@ const HomeContainer = ({ history }) => {
dispatch
(
getPROFILE
({
username
}));
}
},
[
dispatch
,
user
]);
return
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
goalNum
=
{
profile
.
goalNum
}
/>
;
return
(
<
HomeForm
PSdata
=
{
profile
.
solvedBJ_date
}
HMArr
=
{
HMArr
}
goalNum
=
{
profile
.
goalNum
}
/
>
);
};
export
default
withRouter
(
HomeContainer
);
...
...
jaksimsamil-page/yarn.lock
View file @
05582aa
This diff is collapsed. Click to expand it.
jaksimsamil-server/src/models/challenge.js
View file @
05582aa
...
...
@@ -2,47 +2,48 @@ const mongoose = require("mongoose");
const
{
Schema
}
=
mongoose
;
const
ChallengeSchema
=
new
Schema
(
{
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
isOpen
:
{
type
:
Boolean
},
},
{
collection
:
"challenge"
,
}
);
ChallengeSchema
.
statics
.
findByChallengeName
=
function
(
challengeName
)
{
return
this
.
findOne
({
challengeName
:
challengeName
});
};
ChallengeSchema
.
methods
.
getChallengeName
=
function
()
{
return
this
.
challengeName
;
};
ChallengeSchema
.
methods
.
getStartDate
=
function
()
{
return
this
.
startDate
;
};
ChallengeSchema
.
methods
.
getEndDate
=
function
()
{
return
this
.
endDate
;
};
ChallengeSchema
.
methods
.
getDurationPerSession
=
function
()
{
return
this
.
durationPerSession
;
};
ChallengeSchema
.
methods
.
getGoalPerSession
=
function
()
{
return
this
.
goalPerSession
;
};
ChallengeSchema
.
methods
.
serialize
=
function
()
{
return
this
.
toJSON
();
};
const
Challenge
=
mongoose
.
model
(
"Challenge"
,
ChallengeSchema
);
module
.
exports
=
Challenge
;
const
ChallengeSchema
=
new
Schema
({
challengeName
:
{
type
:
String
,
required
:
true
},
startDate
:
{
type
:
Object
,
required
:
true
},
endDate
:
{
type
:
Object
,
required
:
true
},
durationPerSession
:
{
type
:
String
,
required
:
true
},
// '1d' means one day per session, '2w' means 2 weeks per session, '3m' means 3 months per session.
goalPerSession
:
{
type
:
Number
,
required
:
true
},
// number of problems for one session
status
:
{
type
:
String
}
},{
collection
:
'challenge'
});
ChallengeSchema
.
statics
.
findByChallengeName
=
function
(
challengeName
){
return
this
.
findOne
({
challengeName
:
challengeName
});
}
ChallengeSchema
.
methods
.
getChallengeName
=
function
(){
return
this
.
challengeName
;
}
ChallengeSchema
.
methods
.
getStartDate
=
function
(){
return
this
.
startDate
;
}
ChallengeSchema
.
methods
.
getEndDate
=
function
(){
return
this
.
endDate
;
}
ChallengeSchema
.
method
.
getDurationPerSession
=
function
(){
return
this
.
durationPerSession
;
}
ChallengeSchema
.
methods
.
getGoalPerSession
=
function
(){
return
this
.
goalPerSession
;
}
ChallengeSchema
.
methods
.
getStatus
=
function
(){
return
this
.
status
;
}
ChallengeSchema
.
methods
.
serialize
=
function
(){
return
this
.
toJSON
();
}
const
Challenge
=
mongoose
.
model
(
'Challenge'
,
ChallengeSchema
);
module
.
exports
=
Challenge
;
\ No newline at end of file
...
...
jaksimsamil-server/src/models/session.js
View file @
05582aa
...
...
@@ -6,7 +6,7 @@ const SessionSchema = new Schema({
challengeId
:
{
type
:
Schema
.
Types
.
ObjectId
,
ref
:
'Challenge'
},
sessionStartDate
:
{
type
:
Object
},
sessionEndDate
:
{
type
:
Object
},
isOpen
:
{
type
:
Boolean
}
status
:
{
type
:
String
}
},{
collection
:
'session'
});
...
...
@@ -23,8 +23,8 @@ SessionSchema.methods.getSessionEndDate=function(){
return
this
.
sessionEndDate
;
}
SessionSchema
.
methods
.
get
IsOpen
=
function
(){
return
this
.
isOpen
;
SessionSchema
.
methods
.
get
Status
=
function
(){
return
this
.
status
;
}
SessionSchema
.
methods
.
serialize
=
function
(){
...
...
Please
register
or
login
to post a comment