Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
API Toucan
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Damien Armillon
API Toucan
Commits
cef6fe15
Commit
cef6fe15
authored
5 years ago
by
Damien Armillon
Browse files
Options
Downloads
Patches
Plain Diff
We can select the year
parent
bfec623c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
front/src/utils/yearSelector.js
+29
-0
29 additions, 0 deletions
front/src/utils/yearSelector.js
front/src/view/AllToucanPage/AllToucanPage.js
+47
-18
47 additions, 18 deletions
front/src/view/AllToucanPage/AllToucanPage.js
with
76 additions
and
18 deletions
front/src/utils/yearSelector.js
0 → 100644
+
29
−
0
View file @
cef6fe15
import
React
from
'
react
'
import
{
Dropdown
}
from
'
semantic-ui-react
'
function
SelectYear
(
props
)
{
const
years
=
[]
for
(
let
year
=
props
.
beginYear
;
year
>=
2018
;
year
-=
1
)
{
years
.
push
({
text
:
`
${
year
.
toString
()}
-
${(
year
+
1
).
toString
()}
`
,
value
:
year
,
key
:
year
});
}
return
(
<
Dropdown
selection
placeholder
=
"
value
"
options
=
{
years
}
defaultValue
=
{
props
.
beginYear
}
onChange
=
{(
_
,
dropdown
)
=>
props
.
updateFrame
(
dropdown
.
value
)}
/
>
)
}
export
default
SelectYear
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
front/src/view/AllToucanPage/AllToucanPage.js
+
47
−
18
View file @
cef6fe15
import
React
,
{
Component
}
from
'
react
'
import
React
,
{
Component
}
from
'
react
'
import
{
Card
,
Segment
}
from
'
semantic-ui-react
'
import
{
Card
,
Segment
}
from
'
semantic-ui-react
'
import
SelectYear
from
'
../../utils/yearSelector
'
import
ToucanCard
from
'
./ToucanCard
'
import
ToucanCard
from
'
./ToucanCard
'
import
env
from
'
../../.env
'
import
env
from
'
../../.env
'
const
date
=
new
Date
()
const
beginYear
=
1900
+
(
date
.
getMonth
()
<
8
?
date
.
getYear
()
-
1
:
date
.
getYear
());
class
AllToucan
extends
Component
{
class
AllToucan
extends
Component
{
constructor
(){
constructor
(){
super
();
super
();
this
.
state
=
{
this
.
state
=
{
toucans
:
[],
toucans
:
[],
before
:
(
new
Date
(
beginYear
+
1
,
7
,
31
)).
getTime
(),
after
:
(
new
Date
(
beginYear
,
8
,
1
)).
getTime
(),
}
}
}
}
componentDidMount
(){
updateToucan
(){
fetch
(
`
${
env
.
backURL
}
/toucan/toucans`
)
fetch
(
`
${
env
.
backURL
}
/toucan/toucans
?before=
${
this
.
state
.
before
}
&after=
${
this
.
state
.
after
}
`
)
.
then
(
result
=>
{
.
then
(
result
=>
{
return
result
.
json
()
return
result
.
json
()
})
})
...
@@ -23,9 +27,34 @@ class AllToucan extends Component {
...
@@ -23,9 +27,34 @@ class AllToucan extends Component {
})
})
.
catch
(
err
=>
console
.
log
(
err
))
.
catch
(
err
=>
console
.
log
(
err
))
}
}
updateFrame
(
value
){
var
before
=
(
new
Date
(
value
+
1
,
7
,
31
)).
getTime
()
var
after
=
(
new
Date
(
value
,
8
,
1
)).
getTime
()
this
.
setState
({
before
,
after
},()
=>
this
.
updateToucan
())
}
componentDidMount
(){
this
.
updateToucan
()
}
render
(){
render
(){
return
(
return
(
<
Segment
style
=
{{
textAlign
:
"
center
"
,
margin
:
"
3em
"
,
padding
:
"
2em
"
}}
>
<
Segment
style
=
{{
textAlign
:
"
center
"
,
margin
:
"
3em
"
,
padding
:
"
2em
"
}}
>
<
SelectYear
beginYear
=
{
beginYear
}
updateFrame
=
{
this
.
updateFrame
.
bind
(
this
)}
/
>
{
/* <Dropdown
selection
placeholder="value"
options = {years}
defaultValue = {beginYear}
onChange = {(_,props) => this.setState({
before : (new Date(props.value+1,7,31)).getTime(),
after : (new Date(props.value,8,1)).getTime()
}, () => this.updateToucan())}
/> */
}
<
Card
.
Group
centered
>
<
Card
.
Group
centered
>
{
this
.
state
.
toucans
.
map
(
toucan
=>
{
{
this
.
state
.
toucans
.
map
(
toucan
=>
{
return
<
ToucanCard
return
<
ToucanCard
...
...
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