Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ICAT
Datahub
Commits
8662f03d
Commit
8662f03d
authored
Jun 17, 2021
by
Marjolaine Bodin
Committed by
Alejandro De Maria Antolinos
Jun 17, 2021
Browse files
Resolve Issue 504 "date filter on manager beamline calendar"
parent
a9166f60
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/containers/Calendar/InvestigationsCalendarTimeLine.js
View file @
8662f03d
...
...
@@ -10,6 +10,8 @@ import Timeline, {
import
'
react-calendar-timeline/lib/Timeline.css
'
;
import
{
Link
}
from
'
react-router-dom
'
;
import
moment
from
'
moment
'
;
import
InstrumentResource
from
'
../../resources/instrument
'
;
import
{
useQuery
}
from
'
../../helpers/hooks
'
;
const
COLOR_EMPTY_SESSION
=
'
white
'
;
const
COLOR_NON_SCHEDULED_SESSION
=
'
red
'
;
...
...
@@ -52,22 +54,28 @@ function itemRenderer(props) {
}
function
InvestigationsCalendarTimeLine
()
{
const
investigations
=
useResource
(
InvestigationResource
.
listShape
(),
{});
const
dateFormat
=
'
YYYY-MM-DD
'
;
const
query
=
useQuery
();
const
startDate
=
query
.
get
(
'
startDate
'
)
?
moment
(
query
.
get
(
'
startDate
'
),
dateFormat
)
:
moment
().
startOf
(
'
month
'
);
const
endDate
=
query
.
get
(
'
endDate
'
)
?
moment
(
query
.
get
(
'
endDate
'
),
dateFormat
)
:
moment
().
add
(
1
,
'
month
'
).
startOf
(
'
month
'
);
const
instrumentNames
=
[
...
new
Set
(
investigations
.
map
((
investigation
)
=>
{
const
{
instrument
}
=
investigation
;
return
instrument
.
name
;
})
),
].
sort
();
const
investigations
=
useResource
(
InvestigationResource
.
listShape
(),
{
startDate
:
startDate
.
format
(
dateFormat
),
endDate
:
endDate
.
format
(
dateFormat
),
});
const
instruments
=
useResource
(
InstrumentResource
.
listShape
(),
{});
let
id
=
1
;
const
groups
=
instrumentNames
.
map
((
instrumentName
)
=>
{
id
++
;
return
{
id
,
title
:
instrument
N
ame
};
const
groups
=
[];
instruments
.
forEach
((
instrument
)
=>
{
groups
.
push
({
id
:
id
++
,
title
:
instrument
.
n
ame
}
)
;
});
groups
.
push
({
id
:
id
++
,
title
:
undefined
});
const
items
=
investigations
.
map
((
investigation
)
=>
{
return
{
...
...
@@ -95,8 +103,8 @@ function InvestigationsCalendarTimeLine() {
<
Timeline
groups
=
{
groups
}
items
=
{
items
}
defaultTimeStart
=
{
moment
().
startOf
(
'
month
'
)
}
defaultTimeEnd
=
{
moment
().
add
(
1
,
'
month
'
).
startOf
(
'
month
'
)
}
defaultTimeStart
=
{
startDate
}
defaultTimeEnd
=
{
endDate
}
stackItems
itemHeightRatio
=
{
0.65
}
showCursorLine
...
...
Write
Preview
Supports
Markdown
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